-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentry.edge.config.ts
More file actions
52 lines (42 loc) · 1.79 KB
/
sentry.edge.config.ts
File metadata and controls
52 lines (42 loc) · 1.79 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
52
// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
// The config you add here will be used whenever one of the edge features is loaded.
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
// 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://[email protected]/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,
})