-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsentry.server.config.ts
More file actions
41 lines (33 loc) · 1.04 KB
/
sentry.server.config.ts
File metadata and controls
41 lines (33 loc) · 1.04 KB
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
38
39
40
41
/**
* Sentry Server Configuration
*
* This file configures Sentry error tracking for the server side (API routes, SSR).
* Server errors, unhandled exceptions, and performance data are reported.
*/
import * as Sentry from "@sentry/nextjs";
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
// Only initialize if DSN is configured
if (SENTRY_DSN) {
Sentry.init({
dsn: SENTRY_DSN,
// Performance monitoring - lower rate on server for cost efficiency
tracesSampleRate: process.env.NODE_ENV === "production" ? 0.05 : 1.0,
// Environment tracking
environment: process.env.NODE_ENV,
// Filter out non-actionable errors
ignoreErrors: [
// Expected validation errors
"ZodError",
// Database connection errors during startup
"ECONNREFUSED",
],
// Don't send PII
sendDefaultPii: false,
// Capture unhandled promise rejections
integrations: [
Sentry.captureConsoleIntegration({
levels: ["error"],
}),
],
});
}