-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentry.server.config.ts
More file actions
51 lines (41 loc) · 1.63 KB
/
sentry.server.config.ts
File metadata and controls
51 lines (41 loc) · 1.63 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
42
43
44
45
46
47
48
49
50
51
// This file configures the initialization of Sentry on the server.
// The config you add here will be used whenever the server handles a request.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from '@sentry/nextjs'
/**
* Determines if Sentry should be enabled.
* Only enables in production environment, NOT in:
* - localhost development (NODE_ENV === 'development')
* - E2E tests (APP_ENV === 'test')
* - Vercel preview/development deployments
*
* @returns {boolean} Whether Sentry should be enabled
*/
const isSentryEnabled = (): boolean => {
// Vercel provides VERCEL_ENV: 'production' | 'preview' | 'development'
if (process.env.VERCEL_ENV) {
return process.env.VERCEL_ENV === 'production'
}
// Local development or E2E tests
if (process.env.NODE_ENV === 'development') {
return false
}
// E2E test environment (APP_ENV=test with production build)
if (process.env.APP_ENV === 'test') {
return false
}
// Fallback: only enable if NODE_ENV is production
return process.env.NODE_ENV === 'production'
}
Sentry.init({
dsn: 'https://06b1775946774ab1527986b339ea85ed@o1245861.ingest.us.sentry.io/4510597804261376',
// Only enable Sentry in production environment
enabled: isSentryEnabled(),
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 1,
// Enable logs to be sent to Sentry
enableLogs: true,
// Enable sending user PII (Personally Identifiable Information)
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
sendDefaultPii: true,
})