1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37// Server-side Sentry configuration for API and SSR error monitoring
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from '@sentry/nextjs';
// Only initialize Sentry in production
if (process.env.NODE_ENV === 'production') {
Sentry.init({
dsn: process.env.SENTRY_DSN,
// Lower sampling for server-side performance monitoring
tracesSampleRate: 0.05,
// Enhanced error filtering for server
beforeSend(event, hint) {
// Skip if no DSN configured
if (!process.env.SENTRY_DSN) {
return null;
}
return event;
},
// Server-specific context
initialScope: {
tags: {
component: 'server',
site: '3blue1brown',
},
},
// Capture additional server context
integrations: [
// Avoid BrowserTracing on server to prevent conflicts
],
});
}