Dokumentation
Monitoring (Sentry)
Sentry-Fehlerüberwachung — Setup, Performance-Traces, Source Maps und Produktions-Debugging.
Motoko Base nutzt Sentry für Fehlerüberwachung in Produktion. Es gibt kein Monitoring-Dashboard in der App — nutze die Sentry-Web-UI.
Official docs: Sentry Next.js documentation
Setup
- Erstelle ein Sentry-Projekt (Plattform: Next.js)
- Kopiere den DSN aus Project Settings → Client Keys
- Für Source Maps (Produktions-Builds) erstelle ein Auth-Token mit Release-Upload-Berechtigung
- Setze Env-Vars:
| Variable | Scope | Purpose |
|---|---|---|
NEXT_PUBLIC_SENTRY_DSN | Public | Enables Sentry when set |
SENTRY_AUTH_TOKEN | CI / build | Source map upload |
SENTRY_ORG | CI / build | Organization slug |
SENTRY_PROJECT | CI / build | Project slug |
Lass den DSN unset, um Monitoring vollständig zu deaktivieren.
Development vs production
Sentry ist während next dev aus (auch mit gesetztem DSN), um Webpack-Listener-Rauschen zu vermeiden. Zum lokalen Testen:
pnpm build && pnpm startPerformance-Sampling: 10% in Produktion, sonst 0%. Session Replay und User Feedback sind standardmäßig aus.
Errors & performance
- Unbehandelte Exceptions werden automatisch erfasst (Client + Server)
- App-Router-Fehler:
src/app/global-error.tsx,src/app/dashboard/error.tsx - Manuelles Capture für abgefangene Fehler:
import { captureException } from "@/lib/monitoring";
try {
// ...
} catch (error) {
captureException(error); // fail-open — never throws
}Melde keine erwarteten Ergebnisse (Validierungsfehler, signed-out, not-found, fehlende Config).
Die authentifizierte User-ID wird beim Sign-in angehängt (Sentry.setUser({ id })) und beim Sign-out gelöscht.
Source maps
next.config.ts umschließt den Build mit withSentryConfig. Wenn SENTRY_AUTH_TOKEN, SENTRY_ORG und SENTRY_PROJECT in CI gesetzt sind:
- Source Maps werden während
next buildhochgeladen - Client-Maps werden nach dem Upload gelöscht
- Stack Traces lösen in Sentry Issues zu TypeScript auf
Builds gelingen ohne Upload-Credentials — du erhältst nur keine lesbaren Stacks.
Browser-Events können über /sentry-tunnel getunnelt werden (hilft bei Adblockern).
Production debugging
- Öffne Sentry → Issues
- Filtere nach
environment: production - Klicke ein Issue → Stack Trace, Breadcrumbs, User-ID
- Reproduziere mit
pnpm build && pnpm startlokal gegen ein Nicht-Produktions-Sentry-Projekt
Sensible Daten werden bereinigt (src/lib/monitoring/scrub.ts) — keine Passwörter, Tokens, API-Keys oder KI-Prompts.
Where to change this
| What | Where |
|---|---|
| Enable rules & sampling | src/lib/monitoring/config.ts |
| Scrubbing | src/lib/monitoring/scrub.ts |
| Shared init options | src/lib/monitoring/options.ts |
captureException, user context | src/lib/monitoring/index.ts |
| Client init | src/instrumentation-client.ts |
| Server/edge init | src/instrumentation.ts, sentry.server.config.ts, sentry.edge.config.ts |
| Build / source maps | next.config.ts |
Environment Variables — alle Sentry-Env-Vars.