Recipes
Short Tinyping examples for a new sign-up, a payment, an error spike, a failed backup and a finished deploy.
Each recipe assumes TINYPING_TOKEN is set. Every JavaScript recipe uses this notify helper. See Sending events for all the fields.
export async function notify(event) {
try {
const response = await fetch('https://api.tinyping.app/v1/events', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.TINYPING_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(event),
signal: AbortSignal.timeout(5000),
});
return response.ok;
} catch {
return false;
}
}New sign-up
Send an alert from the code that creates the account.
await notify({ title: 'New sign-up', body: user.email, kind: 'signup' });Payment received
Send a short summary, not the full payload. Verify your payment provider signature before this step.
await notify({
title: 'Payment received',
body: `${customer.email} paid ${amount}`,
kind: 'payment',
url: invoiceUrl,
});Error spike
Use high priority so the event stands out in your inbox.
await notify({
title: 'Error spike',
body: `${count} errors in the last 5 minutes`,
kind: 'error',
priority: 'high',
tags: ['api'],
});Failed backup
The || runs curl only when the backup command fails.
./backup.sh || curl https://api.tinyping.app/v1/events \
-H "Authorization: Bearer $TINYPING_TOKEN" \
-d title="Backup failed" \
-d kind=backup \
-d priority=highDeploy finished
Use low priority for good news you only need to see later.
import json, os, urllib.request
event = {"title": "Deploy finished", "body": "main is live", "kind": "deploy", "priority": "low"}
request = urllib.request.Request(
"https://api.tinyping.app/v1/events",
data=json.dumps(event).encode(),
headers={
"Authorization": f"Bearer {os.environ['TINYPING_TOKEN']}",
"Content-Type": "application/json",
},
)
urllib.request.urlopen(request, timeout=5).close()Tip
Use the kind field for the type of event. You can then search for it in your inbox.
