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
| Component | Path | Purpose |
|---|---|---|
| Backend setup | backend/src/lib/sentry.ts | SDK init, sensitive data scrubbing |
| Backend capture | backend/src/middleware/errorHandler.ts | Exception capture in middleware |
| Frontend setup | frontend/src/main.tsx | SDK init, session replay |
Configuration
| Secret | Purpose |
|---|---|
SENTRY_DSN_BACKEND | Backend error reporting endpoint |
| Frontend DSN | Configured 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:
- Catches all unhandled exceptions from routes and services
- Scrubs sensitive data (tokens, passwords, cookies, authorization headers)
- Attaches request context (URL, method, user ID)
- Reports to Sentry
- 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 Type | Fields Scrubbed |
|---|---|
| Auth | authorization, cookie, set-cookie headers |
| Credentials | password, token, secret, apiKey body fields |
| PII | Configurable 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:
| Feature | Purpose |
|---|---|
| Error boundary | Catches React render errors |
| Session replay | Records user sessions for debugging |
| Performance tracing | Measures page load and navigation timing |
| Breadcrumbs | Logs user actions leading to errors |
Environment Awareness
Sentry events are tagged with:
environment:development,staging, orproduction(maps toAPP_ENV)release: Git commit SHA for source map matching
Only staging and production environments send events to Sentry. Development errors are logged locally.
Related
- Error Handling Pattern — Structured error responses
- Backend Middleware — Error handler middleware position
- External Integrations — All third-party integrations
- Frontend Architecture — Frontend Sentry setup
- CI-CD Workflows — Source map upload on deploy
- Security Scanning — Complementary security monitoring