Context
Today alertBetterStack() in src/worker/alerts.ts is the only external logging/alerting integration. It's called from just two dead-letter-queue consumers (clicks.ts, storage.ts). Everything else (global error handler in index.ts, domain CF-API failures, rate-limit warnings, batch-insert failures) only goes to console.error/console.warn, i.e. Cloudflare's default log stream, with no alerting or aggregation.
Goal
Replace Better Stack with Sentry using the official @sentry/cloudflare Workers module, and use the migration as a chance to widen coverage so errors that are currently only console.errord get captured too.
Proposed work
- Add
@sentry/cloudflare, wrap the Worker fetch handler with withSentry() (per Cloudflare's supported integration), add SENTRY_DSN (and org/project ids if needed) to Env, wrangler.jsonc vars, .dev.vars.example, and prod.secrets.env.example.
- Replace
alertBetterStack() call sites (clicks.ts, storage.ts dead-letter consumers) with Sentry.captureException/captureMessage.
- Wire the global error handler (
index.ts:46) and other console.error call sites (domains CF-API failures, rate-limit warnings, batch-insert failures) into Sentry so they're actually visible/alertable instead of silent log-stream noise.
- Remove
alerts.ts, BETTERSTACK_SOURCE_TOKEN/BETTERSTACK_INGEST_URL from Env, wrangler.jsonc, and secrets docs; keep the playwright env's no-op-in-tests behavior equivalent for Sentry (disable/no-op in e2e).
- Update
AGENTS.md/CLAUDE.md Config section to reference Sentry instead of Better Stack.
Out of scope
Source maps / release tracking can be a fast-follow, not required for v1.
Context
Today
alertBetterStack()insrc/worker/alerts.tsis the only external logging/alerting integration. It's called from just two dead-letter-queue consumers (clicks.ts,storage.ts). Everything else (global error handler inindex.ts, domain CF-API failures, rate-limit warnings, batch-insert failures) only goes toconsole.error/console.warn, i.e. Cloudflare's default log stream, with no alerting or aggregation.Goal
Replace Better Stack with Sentry using the official
@sentry/cloudflareWorkers module, and use the migration as a chance to widen coverage so errors that are currently onlyconsole.errord get captured too.Proposed work
@sentry/cloudflare, wrap the Worker fetch handler withwithSentry()(per Cloudflare's supported integration), addSENTRY_DSN(and org/project ids if needed) toEnv,wrangler.jsoncvars,.dev.vars.example, andprod.secrets.env.example.alertBetterStack()call sites (clicks.ts,storage.tsdead-letter consumers) withSentry.captureException/captureMessage.index.ts:46) and otherconsole.errorcall sites (domains CF-API failures, rate-limit warnings, batch-insert failures) into Sentry so they're actually visible/alertable instead of silent log-stream noise.alerts.ts,BETTERSTACK_SOURCE_TOKEN/BETTERSTACK_INGEST_URLfromEnv,wrangler.jsonc, and secrets docs; keep theplaywrightenv's no-op-in-tests behavior equivalent for Sentry (disable/no-op in e2e).AGENTS.md/CLAUDE.mdConfig section to reference Sentry instead of Better Stack.Out of scope
Source maps / release tracking can be a fast-follow, not required for v1.