Streaks
Track consecutive user engagement with configurable streak mechanics, grace periods, and freezes.
Streaks track consecutive user engagement over time. Define a qualifying event (like app_open or workout_completed), and Amba automatically tracks current count, longest count, and streak status.
How it works
- Admin defines a streak definition with a qualifying event and period
- When a user tracks the qualifying event, their streak is automatically updated
- If the user misses a period, the streak resets (unless a grace period or freeze is configured)
- Streak evaluation also runs daily in the background to catch broken streaks
SDK usage
Get user's streaks
Each streak includes:
Qualify a streak manually
Automatic qualification
When you track an event that matches a streak's qualifying_event, the streak is automatically qualified:
Streak mechanics
Period
daily— user must qualify once per calendar dayweekly— user must qualify once per calendar week
Grace period
Set grace_period_hours to give users extra time before their streak breaks. For example, a 6-hour grace period means the user has until 6 AM the next day.
Streak freezes
When freeze_enabled is true, users can freeze their streak to prevent it from breaking. max_freezes controls how many freezes are allowed per period.
Admin API reference
| Method | Path | Description |
|---|---|---|
POST | /admin/streaks | Create streak definition |
GET | /admin/streaks | List streak definitions |
Client API reference
| Method | Path | Description |
|---|---|---|
GET | /client/streaks | Get user's streak states |
POST | /client/streaks/:id/qualify | Record qualifying event |
POST /client/streaks/:id/qualify
Records a qualifying event for a streak. Handles:
- Already qualified today (returns current state, no-op)
- Consecutive day (increments count)
- Broken streak (resets to 1)
Response:
MCP tools
| Tool | Description |
|---|---|
amba_create_streak | Create a streak definition with qualifying event, period, grace, and freeze settings |
Example
Reading streaks in Expo
Database tables
| Table | Purpose |
|---|---|
streak_definitions | Definitions with qualifying event, period, grace, freeze settings |
user_streaks | Per-user streak state (current count, longest, status) |
streak_events | Event log (increment, reset, freeze) |