Creating a Custom Monitoring Provider
Extend the monitoring abstraction with your own provider.
If you need a provider other than Sentry, add it through the monitoring abstraction.
Steps
- Implement
MonitoringService - Register the provider in
packages/monitoring/api/src/get-monitoring-provider.ts - Register the client provider in
packages/monitoring/api/src/components/provider.tsx - Register the server service in
packages/monitoring/api/src/services/get-server-monitoring-service.ts - Register a server instrumentation entry in
packages/monitoring/api/src/instrumentation.ts— must export bothregister()andonRequestError.onRequestErroris required so clienterror.tsxcan safely dedup server-origin errors viaerror.digest. - Register a client instrumentation entry in
packages/monitoring/api/src/instrumentation-client.ts— must exportinit()and acaptureException(error, mechanism)used by the package-ownedwindow.onerror/unhandledrejection/ boundary handlers.
Core Types
Use these files as the source of truth:
packages/monitoring/core/src/monitoring.service.tspackages/monitoring/core/src/monitoring.context.tspackages/monitoring/api/src/get-monitoring-provider.tspackages/monitoring/api/src/instrumentation.tspackages/monitoring/api/src/instrumentation-client.ts
Important Constraint
The provider name must be added to the MONITORING_PROVIDERS enum. Without that change, NEXT_PUBLIC_MONITORING_PROVIDER will be treated as invalid and the app will fall back to the console service.