diff --git a/instrumentation.ts b/instrumentation.ts index 41a4d932d..bfbc30551 100644 --- a/instrumentation.ts +++ b/instrumentation.ts @@ -1,5 +1,5 @@ export async function register() { - if (process.env.NEXT_RUNTIME === 'nodejs') { + if (process.env.NEXT_RUNTIME === 'nodejs' && process.env.NEXT_PUBLIC_SENTRY_DSN) { await import('./sentry.server.config.js') } } diff --git a/next.config.mjs b/next.config.mjs index fcaddd3b3..3d865ff7f 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -42,12 +42,21 @@ const config = withBundleAnalyzer( '.mjs': ['.mts', '.mjs'], } + // Ignore sentry warnings when not wrapped with withSentryConfig + webpackConfig.ignoreWarnings = [ + ...(webpackConfig.ignoreWarnings ?? []), + { file: /esm\/platform\/node\/instrumentation.js/ }, + { module: /esm\/platform\/node\/instrumentation.js/ }, + ] + return webpackConfig }, }), ) -export default withSentryConfig(config, { - telemetry: false, - tunnelRoute: '/monitoring-tunnel', -}) +export default process.env.NEXT_PUBLIC_SENTRY_DSN + ? withSentryConfig(config, { + telemetry: false, + tunnelRoute: '/monitoring-tunnel', + }) + : config