Skip to content

Migrate from Better Stack to Sentry (Cloudflare Workers module) for error logging #59

Description

@baronunread

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions