Monitoring Overview
Current monitoring behavior in the Next.js Drizzle SaaS Kit.
The monitoring layer in this repo is extensible, but the checked-in runtime currently supports one built-in provider: Sentry.
Current State
@kit/monitoring-coreprovides the base service types and console fallback@kit/monitoringprovides provider selection, hooks, and server helpers@kit/sentryis the only registered concrete provider in the repo- If
NEXT_PUBLIC_MONITORING_PROVIDERis unset, the app falls back to console logging
Supported Provider Values
Current runtime support:
sentry- empty / unset value for console fallback
Other provider names are not registered by default in this repository.
Quick Start
apps/web/.env.local
NEXT_PUBLIC_MONITORING_PROVIDER=sentryNEXT_PUBLIC_SENTRY_DSN=https://xxxxx@xxxxx.ingest.sentry.io/xxxxxManual Capture
Client-side:
import { useMonitoring } from '@kit/monitoring/hooks';function MyComponent() { const monitoring = useMonitoring(); async function onSubmit() { try { await submitForm(); } catch (error) { monitoring.captureException(error as Error, { context: 'form_submission', }); } }}Server-side:
import { getServerMonitoringService } from '@kit/monitoring/server';export async function processPayment() { const monitoring = await getServerMonitoringService(); try { // ... } catch (error) { await monitoring.captureException(error as Error); throw error; }}Extending Monitoring
You can add more providers, but they are not prewired in this repo. To do that:
- implement a monitoring service
- add the provider name to
packages/monitoring/api/src/get-monitoring-provider.ts - register the provider in the client and server registries
See Custom Monitoring Provider for the pattern.