|
1 | | -// This file configures the initialization of Sentry on the server. |
2 | | -// The config you add here will be used whenever the server handles a request. |
3 | | -// https://docs.sentry.io/platforms/javascript/guides/nextjs/ |
4 | | - |
| 1 | +import { |
| 2 | + beforeSend, |
| 3 | + beforeSendTransaction, |
| 4 | +} from '@events-helsinki/components/sentry/utils'; |
5 | 5 | import * as Sentry from '@sentry/nextjs'; |
6 | 6 |
|
7 | | -Sentry.init({ |
8 | | - dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, |
9 | | - environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT, |
10 | | - // Adjust this value in production, or use tracesSampler for greater control |
11 | | - // @see https://develop.sentry.dev/sdk/performance/ |
12 | | - // To turn it off, remove the line |
13 | | - // @see https://github.com/getsentry/sentry-javascript/discussions/4503#discussioncomment-2143116 |
14 | | - tracesSampleRate: parseFloat( |
15 | | - process.env.NEXT_PUBLIC_SENTRY_TRACE_SAMPLE_RATE ?? '0.1' |
16 | | - ), |
17 | | - // ... |
18 | | - // Note: if you want to override the automatic release value, do not set a |
19 | | - // `release` value here - use the environment variable `SENTRY_RELEASE`, so |
20 | | - // that it will also get attached to your source maps |
21 | | - beforeSend: async (event, hint) => { |
22 | | - if (process.env.NODE_ENV === 'development') { |
23 | | - // eslint-disable-next-line no-console |
24 | | - console.log('Sentry event', event); |
25 | | - // eslint-disable-next-line no-console |
26 | | - console.log('Sentry hint', hint); |
27 | | - } |
28 | | - return event; |
29 | | - }, |
30 | | -}); |
| 7 | +if (process.env.NEXT_PUBLIC_SENTRY_DSN) { |
| 8 | + Sentry.init({ |
| 9 | + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, |
| 10 | + environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT, |
| 11 | + release: process.env.NEXT_PUBLIC_SENTRY_RELEASE, |
| 12 | + // Adjust this value in production, or use tracesSampler for greater control |
| 13 | + // @see https://develop.sentry.dev/sdk/performance/ |
| 14 | + // To turn it off, remove the line |
| 15 | + // @see https://github.com/getsentry/sentry-javascript/discussions/4503#discussioncomment-2143116 |
| 16 | + tracesSampleRate: Number.parseFloat( |
| 17 | + process.env.NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE || '0' |
| 18 | + ), |
| 19 | + normalizeDepth: 3, |
| 20 | + integrations: [Sentry.extraErrorDataIntegration({ depth: 3 })], |
| 21 | + beforeSend, |
| 22 | + beforeSendTransaction, |
| 23 | + // Setting this option to true will print useful information to the console while you're setting up Sentry. |
| 24 | + debug: false, |
| 25 | + }); |
| 26 | +} |
0 commit comments