# Error reporting to a self-hosted tracker, off until a DSN is set

packages/error-reporting sends scrubbed errors from the Worker, the browser and the Expo app to a Sentry-compatible tracker; deploy/error-tracker runs Rustrak in Docker behind a Cloudflare Tunnel.

- **One package for every runtime.** `packages/error-reporting` configures Sentry's SDKs for the Worker (`withErrorReporting` around `fetch` and `scheduled`), the browser and the Expo app, each off until its DSN is set (`ERROR_REPORTING_DSN`, `VITE_ERROR_REPORTING_DSN`, `EXPO_PUBLIC_ERROR_REPORTING_DSN`). Every event passes one scrubber: e-mails, credentials, `td_`/`mr_`/`sk_`/`pk_` tokens and CPFs are redacted, URLs lose their query, only a short header list stays, the user is just an id, and a project's health keys go at any depth. Sentry v11's permissive defaults are replaced by a restricted `dataCollection`, and `pnpm lint` fails on an `@sentry/*` import anywhere else. `/api/rpc` reports unexpected failures with their request ID, and a browser error after a failed API call carries that call's `x-request-id`. See [error reporting](/docs/architecture/observability#error-reporting). ([0269751](https://github.com/CarlosZiegler/template-cloudflare/commit/02697516a0349f88ba4e856d2b4b44d595f3c1b2))
- **Nothing before the first paint.** The browser SDK (33 KB gzip) loads after hydration; until then a few hundred bytes keep uncaught errors. The Worker imports its SDK on the first request only when reporting is on. With no DSN the startup chunks grow by 808 bytes gzip, and the build fails if a startup chunk ever contains the SDK. Browser reports go through `POST /api/errors/tunnel` on the site's own origin, limited to 30 a minute per person in the database. Production deploys upload hidden source maps to the tracker and delete them before deploy, and skip that without a token. ([0269751](https://github.com/CarlosZiegler/template-cloudflare/commit/02697516a0349f88ba4e856d2b4b44d595f3c1b2), [measurement](https://github.com/CarlosZiegler/template-cloudflare/blob/main/docs/measurements/2026-11-27-error-reporting.md))
- **The tracker.** `deploy/error-tracker` runs Rustrak (server and dashboard, telemetry off, SQLite or PostgreSQL) for a VPS, published through a Cloudflare Tunnel with the dashboard behind Cloudflare Access. A local run received a Worker error, browser errors and a Hermes frame, scrubbed and symbolicated. ([12f2043](https://github.com/CarlosZiegler/template-cloudflare/commit/12f20432dd03d461a2ff4ec310075c0784e723c4))
