-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentry.server.config.ts
More file actions
43 lines (37 loc) · 1.23 KB
/
sentry.server.config.ts
File metadata and controls
43 lines (37 loc) · 1.23 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
// 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';
import packageJson from './package.json';
// Helper to safely parse Sentry sample rates from environment variables
const parseSampleRate = (
value: string | undefined,
defaultValue: number,
): number => {
const parsed = parseFloat(value ?? String(defaultValue));
if (isNaN(parsed) || parsed < 0 || parsed > 1) {
return defaultValue;
}
return parsed;
};
const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN ?? '';
const environment =
process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID ??
process.env.NODE_ENV ??
'mobility-feeds-dev';
const release = packageJson.version;
const tracesSampleRate = parseSampleRate(
process.env.NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE,
0.05,
);
if (dsn.length > 0) {
Sentry.init({
dsn,
environment,
release,
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
});
}