Skip to main content

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.

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.

What gets snapshotted

Two kinds of snapshot files are produced: Daily aggregate snapshotssnapshots/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 filessnapshots/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

1

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.
2

Add GitHub repo secrets

Go to your repo on GitHub → SettingsSecrets and variablesActionsNew repository secret. Add both of the following:
Secret nameValue
CF_ACCOUNT_IDYour Cloudflare Account ID
CF_API_TOKENYour Cloudflare API token (same one used by the Worker)
3

Configure the workflow

Edit .github/workflows/snapshot-tracking.yml:
  1. Uncomment the schedule block and adjust the cron to cover your event dates:
    schedule:
      # Hourly during event week — adjust date range for next event
      - cron: "0 * 5-14 3 *"   # Mar 5–14, hourly
    
  2. Update the SQL timestamp filters in the inline Python script (appears in two places):
    WHERE timestamp >= toDateTime('2026-03-05 09:00:00')
    
  3. Update the dataset name in the SQL queries if you changed it from the default:
    FROM sbburritoweek
    
Commit and push the updated workflow file.
4

Trigger manually if needed

The workflow also supports manual dispatch. Go to your repo → Actions tab → Snapshot Tracking DataRun workflow. This is useful for a one-off snapshot or for testing before your event starts.

Snapshot format

Each daily snapshot file (snapshots/tracking-YYYY-MM-DD.json) contains a per-restaurant action breakdown for that day:
{
  "date": "2026-03-07",
  "data": [
    {
      "label": "El Taco Loco",
      "view": 142,
      "directions-google": 38,
      "directions-apple": 21,
      "share": 14,
      "upvote": 27,
      "website": 19
    },
    {
      "label": "Mesa Burger",
      "view": 98,
      "directions-google": 22,
      "share": 9,
      "upvote": 15
    }
  ]
}
The stats page reads all available snapshot files and merges them with live Worker data when building the leaderboard.

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 hour
  • snapshots/hourly-labels.json — per-label hourly counts
After the event concludes, the stats page detects these files and loads them directly, eliminating the need for live Worker queries to render the hourly charts.
./snapshot-hourly.sh
git add snapshots/hourly-events.json snapshots/hourly-labels.json
git commit -m "Snapshot hourly data for concluded event"
git push
Hourly snapshots must be captured before you set trackUrl: null and disable the Worker. Once the Worker stops recording new events, the Analytics Engine dataset is the only source of historical data — and once that 90-day window closes, it’s gone. Run snapshot-hourly.sh as the first step of your wind-down checklist.

Build docs developers (and LLMs) love