Skip to content

Commit e8c28e7

Browse files
authored
ensure proper sentry silencing (#2934)
* ensure proper sentry silencing * add comments
1 parent b4bc6d9 commit e8c28e7

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

web/next.config.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const env_version = process.env.DANSWER_VERSION; // version from env variable
44
// Use env version if set & valid, otherwise default to package version
55
const version = env_version || package_version;
66

7+
// Always require withSentryConfig
8+
const { withSentryConfig } = require("@sentry/nextjs");
9+
710
/** @type {import('next').NextConfig} */
811
const nextConfig = {
912
output: "standalone",
@@ -13,17 +16,29 @@ const nextConfig = {
1316
},
1417
};
1518

16-
const { withSentryConfig } = require("@sentry/nextjs");
17-
1819
// Sentry configuration for error monitoring:
1920
// - Without SENTRY_AUTH_TOKEN and NEXT_PUBLIC_SENTRY_DSN: Sentry is completely disabled
2021
// - 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 = {
2230
org: process.env.SENTRY_ORG || "danswer",
2331
project: process.env.SENTRY_PROJECT || "data-plane-web",
2432
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
2635
sourceMaps: {
27-
skipUpload: !process.env.SENTRY_AUTH_TOKEN,
36+
include: ["./.next"],
37+
validate: false,
38+
urlPrefix: "~/_next",
39+
skip: !sentryEnabled,
2840
},
29-
});
41+
};
42+
43+
// Export the module with conditional Sentry configuration
44+
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);

0 commit comments

Comments
 (0)