You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(nuxt): Base decision on source maps upload only on Nuxt source map settings (#15859)
There is a total of 6 settings in Nuxt where you can disable/enable your
source maps. This is not only difficult to understand when writing and
maintaining the logic for this. It may also be hard to debug stuff for
users.

There is this discussion around Nuxt source maps:
#15028
And this issue:
#15160
A problem with the current setup was not only the difficulty to
understand all of this but also it sometimes just overwrote stuff you
didn't want it to. Like in the default case of Nuxt, `sourcemap.server`
is `true`, but as `nitro.rollupConfig.output.sourcemap` is always
undefined, Sentry would overwrite this setting to `'hidden'`, even
though the source maps were enabled already.
---
The only two relevant options in Nuxt are the [root-level sourcemap
options](https://nuxt.com/docs/guide/going-further/debugging#sourcemaps).
Those settings will propagate to nitro, vite and rollup.
As we overwrite the source maps setting if the setting is undefined,
only the basic Nuxt source map settings (linked above) are taken into
account for that from now on.
console.log(`[Sentry] Adding Sentry Vite plugin to the ${runtime} runtime.`);
82
+
}
83
+
});
84
+
}
30
85
31
-
// Add Sentry plugin
86
+
// Add Sentry plugin
87
+
// Vite plugin is added on the client and server side (hook runs twice)
88
+
// Nuxt client source map is 'false' by default. Warning about this will be shown already in an earlier step, and it's also documented that `nuxt.sourcemap.client` needs to be enabled.
'[Sentry] Setting `sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [".*/**/public/**/*.map"]` to delete generated source maps after they were uploaded to Sentry.',
/* There are 3 ways to set up source maps (https://github.com/getsentry/sentry-javascript/issues/13993)
203
+
/* There are multiple ways to set up source maps (https://github.com/getsentry/sentry-javascript/issues/13993 and https://github.com/getsentry/sentry-javascript/pull/15859)
127
204
1. User explicitly disabled source maps
128
205
- keep this setting (emit a warning that errors won't be unminified in Sentry)
129
206
- We will not upload anything
@@ -133,11 +210,24 @@ export function getPluginOptions(
133
210
- we enable 'hidden' source maps generation
134
211
- configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)
135
212
136
-
Nuxt has 3 places to set source maps: vite options, rollup options, nuxt itself
137
-
Ideally, all 3 are enabled to get all source maps.
213
+
Users only have to explicitly enable client source maps. Sentry only overwrites the base Nuxt source map settings as they propagate.
'[Sentry] Disabled source map setting in the Nuxt config: `nitro.rollupConfig.output.sourcemapExcludeSources`. Source maps will include the actual code to be able to un-minify code snippets in Sentry.',
263
-
);
264
-
});
333
+
if(isDebug){
334
+
consoleSandbox(()=>{
335
+
// eslint-disable-next-line no-console
336
+
console.log(
337
+
'[Sentry] Set `sourcemapExcludeSources: false` in the Nuxt config (`nitro.rollupConfig.output`). Source maps will now include the actual code to be able to un-minify code snippets in Sentry.',
338
+
);
339
+
});
340
+
}
341
+
}
265
342
266
-
returnpreviousUserSourceMapSetting;
343
+
functionvalidateDifferentSourceMapSettings({
344
+
nuxtSettingKey,
345
+
nuxtSettingValue,
346
+
otherSettingKey,
347
+
otherSettingValue,
348
+
}: {
349
+
nuxtSettingKey: string;
350
+
nuxtSettingValue?: SourceMapSetting;
351
+
otherSettingKey: string;
352
+
otherSettingValue?: SourceMapSetting;
353
+
}): void{
354
+
if(nuxtSettingValue!==otherSettingValue){
355
+
consoleSandbox(()=>{
356
+
// eslint-disable-next-line no-console
357
+
console.warn(
358
+
`[Sentry] Source map generation settings are conflicting. Sentry uses \`${nuxtSettingKey}: ${nuxtSettingValue}\`. However, a conflicting setting was discovered (\`${otherSettingKey}: ${otherSettingValue}\`). This setting was probably explicitly set in your configuration. Sentry won't override this setting but it may affect source maps generation and upload. Without source maps, code snippets on the Sentry Issues page will remain minified.`,
359
+
);
360
+
});
361
+
}
267
362
}
268
363
269
-
functionlogKeepSourceMapSetting(
364
+
functionlogKeepEnabledSourceMapSetting(
270
365
sentryNuxtModuleOptions: SentryNuxtModuleOptions,
271
366
settingKey: string,
272
367
settingValue: string,
@@ -275,24 +370,24 @@ function logKeepSourceMapSetting(
275
370
consoleSandbox(()=>{
276
371
// eslint-disable-next-line no-console
277
372
console.log(
278
-
`[Sentry] We discovered \`${settingKey}\` is set to \`${settingValue}\`. Sentry will keep this source map setting. This will un-minify the code snippet on the Sentry Issue page.`,
373
+
`[Sentry] \`${settingKey}\` is enabled with \`${settingValue}\`. This will correctly un-minify the code snippet on the Sentry Issue Details page.`,
`[Sentry] Parts of source map generation are currently disabled in your Nuxt configuration (\`${settingKey}: false\`). This setting is either a default setting or was explicitly set in your configuration. Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified. To show unminified code, enable source maps in \`${settingKey}\` (e.g. by setting them to \`hidden\`).`,
383
+
`[Sentry] We discovered \`${settingKey}\` is set to \`false\`. This setting is either a default setting or was explicitly set in your configuration. Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified. To show unminified code, enable source maps in \`${settingKey}\` (e.g. by setting them to \`'hidden'\`).`,
0 commit comments