Track user actions, award points, create achievements. That's the whole recipe.
Sign up and create a project. Get your API token.
Create events in the dashboard with point values.
Send POST requests to /track. Points brew automatically.
All API requests require a Bearer token in the Authorization header. Get your token from the API Keys section in your project dashboard.
Authorization: Bearer your_api_token_here
KEEP IT SECURE: Never expose your API token in client-side code. Use it only on your server.
https://api.brewale.dev/trackTrack a user event. The event name should match an event you've created in your dashboard. Points are awarded automatically based on the event's point value.
{
"event": "PURCHASE",
"userId": "user123"
}{
"success": true
}NOTE: Events are processed asynchronously. The API returns immediately, and points are awarded within seconds. Check your dashboard to see users and their points.
async function trackEvent(event, userId) {
const response = await fetch('https://api.brewale.dev/track', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_api_token_here'
},
body: JSON.stringify({
event: event,
userId: userId
})
})
if (!response.ok) {
throw new Error(`Failed to track event: ${response.statusText}`)
}
return await response.json()
}
// Usage
await trackEvent('PURCHASE', 'user123')
await trackEvent('SIGNUP', 'user456')Once you're tracking events, the dashboard shows you everything you need: