Cloudflare Worker that receives error reports from the four G2 apps
(eyefit-g2, hunter-g2, speechcoach-g2, breakmate-g2) for remote
debugging. Reports are stored in Workers KV with a 7-day TTL.
POST /report— accepts a JSON error report. CORS-enabled.{ "app": "eyefit", "version": "0.6.0", "message": "TypeError: ...", "stack": "...", "context": { "source": "main.ts" }, "timestamp": 1712800000000, "userAgent": "..." }GET /reports?app={name}— list up to 100 recent reports. Requiresx-admin-tokenheader matching theADMIN_TOKENsecret.GET /health— healthcheck.
Rate limited to 30 requests per minute per IP (in-memory, per isolate).
npm install
npx wrangler kv:namespace create TELEMETRY_KV
# copy the returned id into wrangler.toml (kv_namespaces[0].id)
npx wrangler secret put ADMIN_TOKENnpx wrangler dev
# in another terminal:
curl http://127.0.0.1:8787/health
curl -X POST http://127.0.0.1:8787/report \
-H "Content-Type: application/json" \
-d '{"app":"eyefit","version":"0.6.0","message":"test","timestamp":1712800000000}'npx wrangler deployAfter deploying, note the worker URL (e.g.
https://g2-telemetry.<subdomain>.workers.dev) and put it in each G2
app's src/telemetry.ts TELEMETRY_URL.
curl https://g2-telemetry.<subdomain>.workers.dev/reports?app=eyefit \
-H "x-admin-token: $ADMIN_TOKEN"