mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-08-08 14:02:09 +02:00
ensure proper sentry silencing (#2934)
* ensure proper sentry silencing * add comments
This commit is contained in:
@@ -4,6 +4,9 @@ const env_version = process.env.DANSWER_VERSION; // version from env variable
|
|||||||
// Use env version if set & valid, otherwise default to package version
|
// Use env version if set & valid, otherwise default to package version
|
||||||
const version = env_version || package_version;
|
const version = env_version || package_version;
|
||||||
|
|
||||||
|
// Always require withSentryConfig
|
||||||
|
const { withSentryConfig } = require("@sentry/nextjs");
|
||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
@@ -13,17 +16,29 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const { withSentryConfig } = require("@sentry/nextjs");
|
|
||||||
|
|
||||||
// Sentry configuration for error monitoring:
|
// Sentry configuration for error monitoring:
|
||||||
// - Without SENTRY_AUTH_TOKEN and NEXT_PUBLIC_SENTRY_DSN: Sentry is completely disabled
|
// - Without SENTRY_AUTH_TOKEN and NEXT_PUBLIC_SENTRY_DSN: Sentry is completely disabled
|
||||||
// - With both configured: Only unhandled errors are captured (no performance/session tracking)
|
// - With both configured: Only unhandled errors are captured (no performance/session tracking)
|
||||||
module.exports = withSentryConfig(nextConfig, {
|
|
||||||
|
// Determine if Sentry should be enabled
|
||||||
|
const sentryEnabled = Boolean(
|
||||||
|
process.env.SENTRY_AUTH_TOKEN && process.env.NEXT_PUBLIC_SENTRY_DSN
|
||||||
|
);
|
||||||
|
|
||||||
|
// Sentry webpack plugin options
|
||||||
|
const sentryWebpackPluginOptions = {
|
||||||
org: process.env.SENTRY_ORG || "danswer",
|
org: process.env.SENTRY_ORG || "danswer",
|
||||||
project: process.env.SENTRY_PROJECT || "data-plane-web",
|
project: process.env.SENTRY_PROJECT || "data-plane-web",
|
||||||
authToken: process.env.SENTRY_AUTH_TOKEN,
|
authToken: process.env.SENTRY_AUTH_TOKEN,
|
||||||
silent: false,
|
silent: !sentryEnabled, // Silence output when Sentry is disabled
|
||||||
|
dryRun: !sentryEnabled, // Don't upload source maps when Sentry is disabled
|
||||||
sourceMaps: {
|
sourceMaps: {
|
||||||
skipUpload: !process.env.SENTRY_AUTH_TOKEN,
|
include: ["./.next"],
|
||||||
|
validate: false,
|
||||||
|
urlPrefix: "~/_next",
|
||||||
|
skip: !sentryEnabled,
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// Export the module with conditional Sentry configuration
|
||||||
|
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);
|
||||||
|
Reference in New Issue
Block a user