Ga naar hoofdinhoud

Sentry Error Tracking

Configure Sentry for error monitoring and performance tracking.

Setup​

1. Create Sentry Project​

  1. Go to sentry.io
  2. Create a new project for Node.js
  3. Copy the DSN

2. Configure​

SENTRY_DSN=https://xxx@sentry.io/12345
SENTRY_TRACES_SAMPLE_RATE=0.1
SENTRY_ENVIRONMENT=production

3. Integration​

Sentry is automatically configured in the API when SENTRY_DSN is set. It captures:

  • Unhandled exceptions
  • HTTP 5xx responses
  • Slow database queries
  • Performance traces

Features​

FeatureDescription
Error groupingSimilar errors grouped
Stack tracesFull stack traces with context
BreadcrumbsEvents leading to error
PerformanceTransaction tracing
Release trackingErrors by release version
AlertsEmail/Slack notifications

Custom Error Context​

import * as Sentry from "@sentry/node";

Sentry.setUser({ id: userId, email: userEmail });
Sentry.setTag("tenant", tenantId);
Sentry.captureMessage("Custom event");

Source Maps​

Upload source maps for readable stack traces:

sentry-cli releases files $VERSION upload-sourcemaps ./dist