@@ -4,6 +4,9 @@ const env_version = process.env.DANSWER_VERSION; // version from env variable
4
4
// Use env version if set & valid, otherwise default to package version
5
5
const version = env_version || package_version ;
6
6
7
+ // Always require withSentryConfig
8
+ const { withSentryConfig } = require ( "@sentry/nextjs" ) ;
9
+
7
10
/** @type {import('next').NextConfig } */
8
11
const nextConfig = {
9
12
output : "standalone" ,
@@ -13,17 +16,29 @@ const nextConfig = {
13
16
} ,
14
17
} ;
15
18
16
- const { withSentryConfig } = require ( "@sentry/nextjs" ) ;
17
-
18
19
// Sentry configuration for error monitoring:
19
20
// - Without SENTRY_AUTH_TOKEN and NEXT_PUBLIC_SENTRY_DSN: Sentry is completely disabled
20
21
// - With both configured: Only unhandled errors are captured (no performance/session tracking)
21
- module . exports = withSentryConfig ( nextConfig , {
22
+
23
+ // Determine if Sentry should be enabled
24
+ const sentryEnabled = Boolean (
25
+ process . env . SENTRY_AUTH_TOKEN && process . env . NEXT_PUBLIC_SENTRY_DSN
26
+ ) ;
27
+
28
+ // Sentry webpack plugin options
29
+ const sentryWebpackPluginOptions = {
22
30
org : process . env . SENTRY_ORG || "danswer" ,
23
31
project : process . env . SENTRY_PROJECT || "data-plane-web" ,
24
32
authToken : process . env . SENTRY_AUTH_TOKEN ,
25
- silent : false ,
33
+ silent : ! sentryEnabled , // Silence output when Sentry is disabled
34
+ dryRun : ! sentryEnabled , // Don't upload source maps when Sentry is disabled
26
35
sourceMaps : {
27
- skipUpload : ! process . env . SENTRY_AUTH_TOKEN ,
36
+ include : [ "./.next" ] ,
37
+ validate : false ,
38
+ urlPrefix : "~/_next" ,
39
+ skip : ! sentryEnabled ,
28
40
} ,
29
- } ) ;
41
+ } ;
42
+
43
+ // Export the module with conditional Sentry configuration
44
+ module . exports = withSentryConfig ( nextConfig , sentryWebpackPluginOptions ) ;
0 commit comments