-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentry.client.config.js
32 lines (29 loc) · 1.18 KB
/
sentry.client.config.js
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
// This file configures the initialization of Sentry on the browser.
// The config you add here will be used whenever a page is visited.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from "@sentry/nextjs";
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
const TRACES_SAMPLE_RATE = process.env.NEXT_PUBLIC_SENTRY_TRACE_SAMPLE_RATE;
const SENTRY_ENVIRONMENRT = process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT;
if (process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT) {
if (!SENTRY_DSN) {
throw new Error("SENTRY_DSN env variable missing");
}
if (!TRACES_SAMPLE_RATE) {
throw new Error("TRACES_SAMPLE_RATE env variable missing");
}
if (!SENTRY_ENVIRONMENRT) {
throw new Error("SENTRY_ENVIRONMENRT env variable missing");
}
Sentry.init({
dsn: SENTRY_DSN,
tracesSampleRate: TRACES_SAMPLE_RATE ? parseFloat(TRACES_SAMPLE_RATE) : 0,
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
environment: SENTRY_ENVIRONMENRT,
});
} else {
// eslint-disable-next-line no-console
console.log(
"Sentry environment missing. Add NEXT_PUBLIC_SENTRY_ENVIRONMENT env variables if you want to enabled Sentry"
);
}