Skip to content

aleapc/g2-telemetry-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

g2-telemetry-worker

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.

Endpoints

  • 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. Requires x-admin-token header matching the ADMIN_TOKEN secret.
  • GET /health — healthcheck.

Rate limited to 30 requests per minute per IP (in-memory, per isolate).

Setup

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_TOKEN

Local dev

npx 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}'

Deploy

npx wrangler deploy

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

Listing reports

curl https://g2-telemetry.<subdomain>.workers.dev/reports?app=eyefit \
  -H "x-admin-token: $ADMIN_TOKEN"

About

Cloudflare Worker for error telemetry from Even Realities G2 apps

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors