Setting up Sentry
Configure the built-in Sentry monitoring provider.
Sentry is the only built-in monitoring provider in this repo.
Repo Structure
The integration is split across packages:
packages/monitoring/apiselects and loads the active providerpackages/monitoring/sentrycontains the Sentry service and the browser/serverinitconfigsapps/web/instrumentation.tsruns serverregister()+onRequestErrorapps/web/instrumentation-client.tsruns the client instrumentation
This repo does not configure Sentry by wrapping apps/web/next.config.ts with withSentryConfig().
Initialization Flow
Init is owned by the monitoring instrumentation entries, not by SentryMonitoringService:
- Client —
apps/web/instrumentation-client.ts→registerClientMonitoringInstrumentation()installswindow.onerror/unhandledrejectionhandlers and lazy-importsinitializeSentryBrowserClient. Errors fired before the Sentry chunk loads are buffered and replayed. - Server —
apps/web/instrumentation.ts→registerMonitoringInstrumentation()callsinitializeSentryServerClient.onRequestErrorforwards to Sentry'scaptureRequestError, which records the route, method, and headers.
Sentry's GlobalHandlers integration is filtered out of initializeSentryBrowserClient so the monitoring layer owns global error handling — keeping both would double-report.
Required Environment Variables
NEXT_PUBLIC_MONITORING_PROVIDER=sentryNEXT_PUBLIC_SENTRY_DSN=https://your-dsn@sentry.io/project-idOptional:
NEXT_PUBLIC_SENTRY_ENVIRONMENT=productionSENTRY_RELEASE=1.0.0Key Files
apps/web/instrumentation.tsapps/web/instrumentation-client.tspackages/monitoring/api/src/instrumentation.tspackages/monitoring/api/src/instrumentation-client.tspackages/monitoring/api/src/components/provider.tsxpackages/monitoring/api/src/server.tspackages/monitoring/sentry/src/sentry.client.config.tspackages/monitoring/sentry/src/sentry.server.config.tspackages/monitoring/sentry/src/services/sentry-monitoring.service.ts
Runtime Behavior
- client code gets a Sentry-backed monitoring context through
MonitoringProvider - server code gets a Sentry-backed service through
getServerMonitoringService() - global
window.onerror/unhandledrejectionevents flow through the monitoring instrumentation, not Sentry'sGlobalHandlers - server request errors flow through
onRequestError→ SentrycaptureRequestErrorwith full route context - client
error.tsxskips reporting whenerror.digestis set, since the error already fired server-side viaonRequestError - if no provider is configured, monitoring falls back to the console service