Sentry

Error tracking and performance monitoring for both frontend and backend. Captures unhandled exceptions, performance traces, and session replays to aid debugging in production.

Architecture

ComponentPathPurpose
Backend setupbackend/src/lib/sentry.tsSDK init, sensitive data scrubbing
Backend capturebackend/src/middleware/errorHandler.tsException capture in middleware
Frontend setupfrontend/src/main.tsxSDK init, session replay

Configuration

SecretPurpose
SENTRY_DSN_BACKENDBackend error reporting endpoint
Frontend DSNConfigured in main.tsx (public, not secret)

Backend DSN stored as GitHub Environment Secret, synced to Fly.io. See Deployment Pipeline.

Backend Integration

The error handler middleware (backend/src/middleware/errorHandler.ts) is the last middleware in the Backend Middleware pipeline. It:

  1. Catches all unhandled exceptions from routes and services
  2. Scrubs sensitive data (tokens, passwords, cookies, authorization headers)
  3. Attaches request context (URL, method, user ID)
  4. Reports to Sentry
  5. Returns a structured JSON error response to the client

See Error Handling Pattern for the error response format.

Sensitive Data Scrubbing

Before sending events to Sentry, the following are stripped:

Data TypeFields Scrubbed
Authauthorization, cookie, set-cookie headers
Credentialspassword, token, secret, apiKey body fields
PIIConfigurable via beforeSend hook

This prevents credentials and PII from appearing in the Sentry dashboard.

Frontend Integration

Frontend Sentry integration in frontend/src/main.tsx includes:

FeaturePurpose
Error boundaryCatches React render errors
Session replayRecords user sessions for debugging
Performance tracingMeasures page load and navigation timing
BreadcrumbsLogs user actions leading to errors

Environment Awareness

Sentry events are tagged with:

  • environment: development, staging, or production (maps to APP_ENV)
  • release: Git commit SHA for source map matching

Only staging and production environments send events to Sentry. Development errors are logged locally.