One line. No boilerplate. No setup.
The track
package gives you instant, persistent tracking for streaks, counters, histories, and records — across sessions, isolates, and app restarts.
Define once, track forever.
Table of Contents
StreakTracker — track streaks that reset when a period is missed (e.g. daily habits)
HistoryTracker — maintain a rolling list of recent items with max length and deduplication
PeriodicCounter — count events within aligned time periods (e.g. daily tasks, hourly goals)
RolloverCounter — track counts over a sliding window that resets after inactivity
ActivityCounter — capture detailed activity stats over hours, days, months, and years
BestRecord — track the best (max or min) performance over time, with history and fallback
BasicCounter — simple persistent counter with no expiration or alignment
Why Use track
?
Working with streaks, counters, and history usually means:
- Manually managing resets
- Writing timestamp logic and period alignment
- Saving counters and records yourself
- Cleaning up old or expired data
track removes all that:
you just define, call, and trust it.
Lets you define, track, and forget — the system handles everything in the background
One-line setup, no manual timers or storage
Persisted across app restarts and isolates
Async-safe and cache-friendly
Perfect for streaks, habits, counters, leaderboards, activity stats, and more
Choosing the Right Tool
Each service is tailored for a specific pattern of time-based control.
Goal | Use |
---|---|
“Track a streak of daily activity” | StreakTracker |
“Keep a list of recent values” | HistoryTracker<T> |
“Count per hour / day / week” | PeriodicCounter |
“Reset X minutes after last use” | RolloverCounter |
“Track activity history over time” | ActivityCounter |
“Track the best result or score” | BestRecord |
“Simple always-on counter” | BasicCounter |
“Maintain a daily learning streak”
→ Aligned periods (daily
,weekly
, etc.)
→ Resets if user misses a full period
→ Ideal for habit chains, gamified streaks
→ Tracks best streak ever (with BestRecord)
“Track recent searches, actions, or viewed items”
→ FIFO list stored inPrf<List<T>>
→ Supports deduplication, max length, and type-safe adapters
→ Perfect for autocomplete history, usage trails, or navigation stacks
“How many times today?”
→ Auto-reset at the start of each period (e.g. midnight)
→ Clean for tracking daily usage, hourly limits
“Max 5 actions per 10 minutes (sliding)”
→ Resets after duration from last activity
→ Perfect for soft rate caps, retry attempt tracking
“Track usage over time by hour, day, month, year”
→ Persistent time-series counter
→ Supports summaries, totals, active dates, and trimming
→ Ideal for activity heatmaps, usage analytics, or historical stats
“Record your highest score or fastest time”
→ Tracks best (max/min) values with full history and fallback
→ Great for highscores, fastest runs, or top performance
“Count total taps, visits, or actions”
→ Simple always-on counter without reset logic
→ Now with synchronizedclearValueOnly()
for safe updates