From cd24067f171700ab300db6ec86a9295ded05abb1 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Fri, 22 Nov 2024 12:19:52 -0300 Subject: [PATCH] chore: Add ability to disable Sentry source maps (#17699) * chore: Remove Sentry source maps * Using .env to control Sentry source maps * Trying with sourcemaps property * Turned silent off for testing * Completely turned off devtool --- .env.example | 4 +++- apps/web/next.config.js | 10 +++++++++- turbo.json | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 83764f27a8..84472e5fe8 100644 --- a/.env.example +++ b/.env.example @@ -147,6 +147,8 @@ NEXT_PUBLIC_SENDGRID_SENDER_NAME= # Used for capturing exceptions and logging messages NEXT_PUBLIC_SENTRY_DSN= SENTRY_DEBUG= +SENTRY_DISABLE_CLIENT_SOURCE_MAPS= +SENTRY_DISABLE_SERVER_SOURCE_MAPS= SENTRY_MAX_SPANS= SENTRY_TRACES_SAMPLE_RATE= @@ -414,4 +416,4 @@ NEXT_PUBLIC_WEBSITE_TERMS_URL= NEXT_PUBLIC_LOGGER_LEVEL= # Used to use Replexica SDK, a tool for real-time AI-powered localization -REPLEXICA_API_KEY= \ No newline at end of file +REPLEXICA_API_KEY= diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 94529ec1f5..095dad461d 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -186,7 +186,7 @@ const nextConfig = { locales: ["en"], localeDetection: false, }, - productionBrowserSourceMaps: false, + productionBrowserSourceMaps: process.env.SENTRY_DISABLE_CLIENT_SOURCE_MAPS === "0", /* We already do type check on GH actions */ typescript: { ignoreBuildErrors: !!process.env.CI, @@ -223,6 +223,10 @@ const nextConfig = { }, webpack: (config, { webpack, buildId, isServer }) => { if (isServer) { + if (process.env.SENTRY_DISABLE_SERVER_SOURCE_MAPS === "1") { + config.devtool = false; + } + // Module not found fix @see https://github.com/boxyhq/jackson/issues/1535#issuecomment-1704381612 config.plugins.push( new webpack.IgnorePlugin({ @@ -667,6 +671,10 @@ if (!!process.env.NEXT_PUBLIC_SENTRY_DSN) { hideSourceMaps: true, // disable source map generation for the server code disableServerWebpackPlugin: !!process.env.SENTRY_DISABLE_SERVER_WEBPACK_PLUGIN, + silent: false, + sourcemaps: { + disable: process.env.SENTRY_DISABLE_SERVER_SOURCE_MAPS === "1", + }, }) ); } diff --git a/turbo.json b/turbo.json index 90eef88a9a..4ed07ff993 100644 --- a/turbo.json +++ b/turbo.json @@ -400,6 +400,8 @@ "SENDGRID_API_KEY", "SENDGRID_EMAIL", "SENDGRID_SYNC_API_KEY", + "SENTRY_DISABLE_CLIENT_SOURCE_MAPS", + "SENTRY_DISABLE_SERVER_SOURCE_MAPS", "SENTRY_DISABLE_SERVER_WEBPACK_PLUGIN", "SLACK_CLIENT_ID", "SLACK_CLIENT_SECRET",