Cloudflare Analytics Engine only retains data for 90 days. For a week-long food event that’s fine during the event, but the stats dashboard would go dark three months later. The snapshot workflow queries the Worker’s analytics API daily and commits JSON files directly to the repo, preserving your event stats indefinitely.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/samgutentag/sbburgerweek/llms.txt
Use this file to discover all available pages before exploring further.
What gets snapshotted
Two kinds of snapshot files are produced: Daily aggregate snapshots —snapshots/tracking-YYYY-MM-DD.json — created automatically by the snapshot-tracking.yml GitHub Action while it’s running. Each file contains the per-restaurant action breakdown for that calendar day. The stats page merges these files when loading historical data.
Hourly snapshot files — snapshots/hourly-events.json and snapshots/hourly-labels.json — created once at wind-down time by running snapshot-hourly.sh. These capture the full hourly breakdown for the event period and are used by the stats page charts after the event concludes, replacing live Worker queries.
Setup
Deploy the tracking Worker
The snapshot workflow queries your Worker’s analytics endpoints. Make sure the Worker from Click Tracking is deployed and receiving events before enabling snapshots.
Add GitHub repo secrets
Go to your repo on GitHub → Settings → Secrets and variables → Actions → New repository secret. Add both of the following:
| Secret name | Value |
|---|---|
CF_ACCOUNT_ID | Your Cloudflare Account ID |
CF_API_TOKEN | Your Cloudflare API token (same one used by the Worker) |
Configure the workflow
Edit
.github/workflows/snapshot-tracking.yml:-
Uncomment the schedule block and adjust the cron to cover your event dates:
-
Update the SQL timestamp filters in the inline Python script (appears in two places):
-
Update the dataset name in the SQL queries if you changed it from the default:
Snapshot format
Each daily snapshot file (snapshots/tracking-YYYY-MM-DD.json) contains a per-restaurant action breakdown for that day:
Hourly snapshots for concluded event stats
snapshot-hourly.sh is run once at wind-down time, before you disable trackUrl. It invokes snapshot-hourly.py, which queries the Worker’s ?hourly=true and ?hourly=true&label=X endpoints, scoped to your event’s eventStartDate and eventEndDate from config.js, and saves the results to two files:
snapshots/hourly-events.json— total action counts broken down by hoursnapshots/hourly-labels.json— per-label hourly counts