Skip to content

Commit

Permalink
Avoid trying to launch sentry for instances without Sentry DSN key
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrucs committed Nov 29, 2024
1 parent 626a9eb commit 5f2ea2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as Sentry from '@sentry/nextjs';

export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
await import('./sentry.server.config');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ const sentryOptions = {
maxBreadcrumbs: 50,
attachStacktrace: true,
integrations: [Sentry.replayIntegration()],
};
} as Sentry.BrowserOptions;

// Development & tests setup
if (process.env.NODE_ENV !== 'production') {
// Don't actually send the errors to Sentry
sentryOptions.beforeSend = () => null;
}

Sentry.init(sentryOptions);
if (SENTRY_DSN) {
Sentry.init(sentryOptions);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ const sentryOptions = {
environment: process.env.ENVIRONMENT,
maxBreadcrumbs: 50,
attachStacktrace: true,
};
} as Sentry.NodeOptions;

// Development & tests setup
if (process.env.NODE_ENV !== 'production') {
// Don't actually send the errors to Sentry
sentryOptions.beforeSend = () => null;
}

Sentry.init(sentryOptions);
if (SENTRY_DSN) {
Sentry.init(sentryOptions);
}

0 comments on commit 5f2ea2b

Please sign in to comment.