diff --git a/docs/platforms/javascript/common/best-practices/micro-frontends.mdx b/docs/platforms/javascript/common/best-practices/micro-frontends.mdx index 36a8eecc493df..0766ba74d11a4 100644 --- a/docs/platforms/javascript/common/best-practices/micro-frontends.mdx +++ b/docs/platforms/javascript/common/best-practices/micro-frontends.mdx @@ -83,7 +83,6 @@ below is for Webpack, but this is also supported in Vite, Rollup, and esbuild. const { sentryWebpackPlugin } = require("@sentry/bundler-plugins/webpack"); module.exports = { - devtool: "hidden-source-map", // Source map generation must be turned on ("hidden-source-map", "source-map", etc.) plugins: [ sentryWebpackPlugin({ moduleMetadata: ({ release }) => ({ dsn: "__MODULE_DSN__", release }), diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/angular-nx.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/angular-nx.mdx index 3b190aed99d08..9836abd748b42 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/angular-nx.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/angular-nx.mdx @@ -90,29 +90,23 @@ const { sentryWebpackPlugin } = require("@sentry/bundler-plugins/webpack"); module.exports = { // ... other config above ... - devtool: "hidden-source-map", // Source map generation must be turned on ("hidden-source-map", "source-map", etc.) plugins: [ sentryWebpackPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } + delete: true, + }, }), ], }; ``` - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Webpack Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. + +Angular turns on the source maps, so the plugin keeps them in the build output by default. `sourcemaps.delete: true` removes them after the upload, so your users can't download them. + Learn more about configuring the plugin in our Sentry webpack plugin documentation. @@ -147,7 +141,10 @@ Then, follow the [official Nx documentation](https://nx.dev/nx-api/angular/execu "options": { "org": "___ORG_SLUG___", "project": "___PROJECT_SLUG___", - "authToken": "___SENTRY_AUTH_TOKEN___" + "authToken": "___SENTRY_AUTH_TOKEN___", + "sourcemaps": { + "delete": true + } } } ] @@ -158,11 +155,9 @@ Then, follow the [official Nx documentation](https://nx.dev/nx-api/angular/execu ``` - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Esbuild Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. + +Angular turns on the source maps, so the plugin keeps them in the build output by default. `sourcemaps.delete: true` removes them after the upload, so your users can't download them. + ## 3. Upload diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/angular-webpack.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/angular-webpack.mdx index 0d748d55e5439..d76e657f2cd10 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/angular-webpack.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/angular-webpack.mdx @@ -102,18 +102,14 @@ const { sentryWebpackPlugin } = require("@sentry/bundler-plugins/webpack"); module.exports = { // ... other config above ... - devtool: "hidden-source-map", // Source map generation must be turned on ("hidden-source-map", "source-map", etc.) plugins: [ sentryWebpackPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } + delete: true, + }, }), ], }; @@ -137,9 +133,7 @@ We recommend running a production build to test your implementation. - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Webpack Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. + +Angular turns on the source maps, so the plugin keeps them in the build output by default. `sourcemaps.delete: true` removes them after the upload, so your users can't download them. + diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/bundler-plugin-options.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/bundler-plugin-options.mdx index 631e695c64f60..5d8eb45194b3d 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/bundler-plugin-options.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/bundler-plugin-options.mdx @@ -48,9 +48,6 @@ sentryVitePlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - sourcemaps: { - filesToDeleteAfterUpload: ["./dist/**/*.map"], - }, }); ``` @@ -157,6 +154,62 @@ Completely disables all functionality of the plugin. Options related to source maps upload and processing. +When your bundler's source map setting isn't set, the plugin turns on hidden source maps, uploads them, and removes them from the build output. It does this only when it can upload, that is, when it has an auth token, an organization, and a project. Source maps that you turn on yourself are uploaded and stay in the build output. + + + +Whether the plugin uploads source maps to Sentry. + +With `false`, the plugin uploads nothing, but it still injects debug IDs: the bundles get the debug ID snippet and a `//# debugId=` comment, and the emitted source maps get the matching `debug_id` field. This happens inside the bundler's build pipeline, so hashes computed by later build steps (for example, for subresource integrity) include the debug IDs. + +Use this to upload the source maps yourself later, for example with `sentry-cli sourcemaps upload`. The files already have their debug IDs, so you don't need an `inject` step. + +With `false`, the plugin turns on source maps only when `sourcemaps.delete` is `false`. + +```javascript +sentryVitePlugin({ + sourcemaps: { + // Upload only in CI + upload: process.env.CI === "true", + }, +}); +``` + + + + + +Whether the plugin injects debug IDs into the bundles and their source maps. + +With `false`, the plugin adds no debug IDs and uploads no source maps, because the upload matches files by debug ID. Use this when another tool injects the debug IDs and uploads the source maps, for example the Sentry CLI. + + + + + +Whether the plugin removes source maps from the build output. + +- Not set: the plugin removes the source maps it turned on itself, that is, when your bundler's source map setting wasn't set. Source maps that you turned on stay. +- `true`: the plugin removes all source maps of the build, also the ones you turned on, and also the ones of files that `sourcemaps.assets` or `sourcemaps.ignore` keep out of the upload. The plugin switches visible source maps to hidden ones, so that no `sourceMappingURL` comment points to a removed file. +- `false`: the plugin removes no source maps. When your bundler's source map setting isn't set, the plugin turns on hidden source maps, and they stay in the build output. + +`true` and `false` don't depend on an upload. They also apply when the upload is turned off, when it can't run (for example, without an auth token), and when it fails. + +With Rollup, Vite, and webpack, the plugin never writes the removed source maps to the output directory. With esbuild, it deletes them after the build. + +To keep the source maps for a manual upload later, set `upload: false` and `delete: false`: + +```javascript +sentryVitePlugin({ + sourcemaps: { + upload: false, + delete: false, + }, +}); +``` + + + A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry. @@ -203,25 +256,20 @@ Use the `debug` option to print information about source map resolution. - - -A glob, an array of globs or a promise resolving a glob or array of globs that specifies the build artifacts that should be deleted after the artifact upload to Sentry has been completed. - -Note: If you pass in a Promise that resolves to a string or array, the plugin will await the Promise and use the resolved value globs. This is useful if you need to dynamically determine the files to delete. Some higher-level Sentry SDKs or options use this feature (e.g., SvelteKit). - -The globbing patterns must follow the implementation of the [`glob`](https://www.npmjs.com/package/glob#glob-primer) package. + -Use the `debug` option to print information about which files end up being deleted. +Use [`sourcemaps.upload`](#sourcemaps.upload) and [`sourcemaps.injectDebugIds`](#sourcemaps.injectDebugIds) instead: - +| `sourcemaps.disable` | Replacement | +| -------------------- | ---------------------------------- | +| `"disable-upload"` | `sourcemaps.upload: false` | +| `true` | `sourcemaps.injectDebugIds: false` | - +When you set `upload` or `injectDebugIds`, the plugin ignores `disable`. If this flag is `true`, any functionality related to source maps will be disabled. -If set to `"disable-upload"`, the plugin will not upload source maps to Sentry, but will still inject debug IDs into the build artifacts: the bundles receive the runtime debug ID snippet and a `//# debugId=` comment, and the emitted source maps receive the matching `debug_id` field. This happens inside the bundler's build pipeline, so hashes computed by later build steps (for example, for subresource integrity) include the debug IDs. - -This is useful if you want to manually upload source maps to Sentry at a later point in time, for example with `sentry-cli sourcemaps upload`. The artifacts already carry their debug IDs, so no `inject` step is needed. +If set to `"disable-upload"`, the plugin will not upload source maps to Sentry, but will still inject debug IDs into the build artifacts, like `sourcemaps.upload: false`. diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/esbuild.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/esbuild.mdx index b6595835f4cd4..9bc3bf18ec092 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/esbuild.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/esbuild.mdx @@ -92,19 +92,12 @@ Example: const { sentryEsbuildPlugin } = require("@sentry/bundler-plugins/esbuild"); require("esbuild").build({ - sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.) plugins: [ // Put the Sentry esbuild plugin after all other plugins sentryEsbuildPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }); @@ -118,19 +111,12 @@ require("esbuild").build({ const { sentryEsbuildPlugin } = require("___SDK_PACKAGE___/esbuild"); require("esbuild").build({ - sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.) plugins: [ // Put the Sentry esbuild plugin after all other plugins sentryEsbuildPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }); @@ -138,13 +124,7 @@ require("esbuild").build({ - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Esbuild Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. - + diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/rollup.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/rollup.mdx index 06aa5f958ffef..fe72a764beb04 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/rollup.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/rollup.mdx @@ -72,20 +72,12 @@ Example: import { sentryRollupPlugin } from "@sentry/bundler-plugins/rollup"; export default { - output: { - sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.) - }, plugins: [ // Put the Sentry rollup plugin after all other plugins sentryRollupPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }; @@ -99,20 +91,12 @@ export default { import { sentryRollupPlugin } from "@sentry/node/rollup"; export default { - output: { - sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.) - }, plugins: [ // Put the Sentry rollup plugin after all other plugins sentryRollupPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }; @@ -120,10 +104,4 @@ export default { - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Rollup Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. - + diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/vite.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/vite.mdx index f80aaf701c107..9b16eecf494a6 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/vite.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/vite.mdx @@ -81,21 +81,12 @@ import { defineConfig } from "vite"; import { sentryVitePlugin } from "@sentry/bundler-plugins/vite"; export default defineConfig({ - build: { - sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.) - }, plugins: [ // Put the Sentry Vite plugin after all other plugins sentryVitePlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }); @@ -110,21 +101,12 @@ import { defineConfig } from "vite"; import { sentryVitePlugin } from "@sentry/node/vite"; export default defineConfig({ - build: { - sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.) - }, plugins: [ // Put the Sentry Vite plugin after all other plugins sentryVitePlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }); @@ -132,13 +114,7 @@ export default defineConfig({ - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Vite Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. - + diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/webpack.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/webpack.mdx index 3ecc5dc434c6e..416a759ada7c3 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/webpack.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/webpack.mdx @@ -22,7 +22,7 @@ If you'd rather configure source map uploading with webpack manually, follow the ## Manual Setup - + Install the Sentry webpack plugin: @@ -40,7 +40,7 @@ pnpm add @sentry/bundler-plugins --save-dev - + The Sentry webpack plugin is part of your Sentry SDK package. You don't need to install another package. @@ -75,18 +75,11 @@ const { sentryWebpackPlugin } = require("@sentry/bundler-plugins/webpack"); module.exports = { // ... other config above ... - devtool: "hidden-source-map", // Source map generation must be turned on ("hidden-source-map", "source-map", etc.) plugins: [ sentryWebpackPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }; @@ -102,18 +95,11 @@ const { sentryWebpackPlugin } = require("___SDK_PACKAGE___/webpack"); module.exports = { // ... other config above ... - devtool: "hidden-source-map", // Source map generation must be turned on ("hidden-source-map", "source-map", etc.) plugins: [ sentryWebpackPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }; @@ -125,39 +111,36 @@ module.exports = { -Add the following to your `gatsby-node.js` file: +`@sentry/gatsby` adds the Sentry webpack plugin to production builds, so you don't need to add it yourself. The SDK passes no organization, project, or auth token to the plugin. Set them with the `SENTRY_ORG`, `SENTRY_PROJECT`, and `SENTRY_AUTH_TOKEN` environment variables, or in the `.env.sentry-build-plugin` file. -```javascript {filename:gatsby-node.js} -const { sentryWebpackPlugin } = require("@sentry/bundler-plugins/webpack"); + -exports.onCreateWebpackConfig = ({ actions }) => { - actions.setWebpackConfig({ - plugins: [ - sentryWebpackPlugin({ - org: "___ORG_SLUG___", - project: "___PROJECT_SLUG___", - authToken: process.env.SENTRY_AUTH_TOKEN, +Gatsby sets `devtool: "source-map"` for production builds, so the SDK uploads these source maps but keeps them in the build output by default. To remove the browser source maps after the upload, set `sourcemaps.delete` in the plugin options: +```javascript {filename:gatsby-config.js} +module.exports = { + plugins: [ + { + resolve: "@sentry/gatsby", + options: { sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } - }), - ], - }); + delete: true, + }, + }, + }, + ], }; ``` + + - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using Sentry Webpack Plugin's - `sourcemaps.filesToDeleteAfterUpload` - option to delete source maps after they've been uploaded to Sentry. - + + + + + diff --git a/docs/platforms/javascript/common/troubleshooting/index.mdx b/docs/platforms/javascript/common/troubleshooting/index.mdx index 546fddfd90cd8..b0c2786dea02e 100644 --- a/docs/platforms/javascript/common/troubleshooting/index.mdx +++ b/docs/platforms/javascript/common/troubleshooting/index.mdx @@ -499,7 +499,7 @@ Learn more about fixing these caching issues in the - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using [Sentry Esbuild Plugin's - `sourcemaps.filesToDeleteAfterUpload`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.filesToDeleteAfterUpload) - option to delete source maps after they've been uploaded to Sentry. - + diff --git a/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/rollup.mdx b/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/rollup.mdx index c2f8ffb6e6b6d..827faf75f50c4 100644 --- a/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/rollup.mdx +++ b/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/rollup.mdx @@ -60,29 +60,15 @@ Example: import { sentryRollupPlugin } from "@sentry/bundler-plugins/rollup"; export default { - output: { - sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.) - }, plugins: [ // Put the Sentry rollup plugin after all other plugins sentryRollupPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }; ``` - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using [Sentry Rollup Plugin's - `sourcemaps.filesToDeleteAfterUpload`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.filesToDeleteAfterUpload) - option to delete source maps after they've been uploaded to Sentry. - + diff --git a/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/vite.mdx b/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/vite.mdx index dc338d99470c8..b55e78a0ec682 100644 --- a/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/vite.mdx +++ b/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/vite.mdx @@ -69,33 +69,18 @@ import { defineConfig } from "vite"; import { sentryVitePlugin } from "@sentry/bundler-plugins/vite"; export default defineConfig({ - build: { - sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.) - }, plugins: [ // Put the Sentry Vite plugin after all other plugins sentryVitePlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }); ``` - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using [Sentry Vite Plugin's - `sourcemaps.filesToDeleteAfterUpload`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.filesToDeleteAfterUpload) - option to delete source maps after they've been uploaded to Sentry. - + diff --git a/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/webpack.mdx b/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/webpack.mdx index a2f2839024e8e..728d2a31ae25f 100644 --- a/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/webpack.mdx +++ b/docs/platforms/javascript/guides/cordova/sourcemaps/uploading/webpack.mdx @@ -61,30 +61,17 @@ const { sentryWebpackPlugin } = require("@sentry/bundler-plugins/webpack"); module.exports = { // ... other config above ... - devtool: "hidden-source-map", // Source map generation must be turned on ("hidden-source-map", "source-map", etc.) plugins: [ sentryWebpackPlugin({ org: "___ORG_SLUG___", project: "___PROJECT_SLUG___", authToken: process.env.SENTRY_AUTH_TOKEN, - - sourcemaps: { - // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry. - // Set the appropriate glob pattern for your output folder - some glob examples below: - filesToDeleteAfterUpload: ["./**/*.map", ".*/**/public/**/*.map", "./dist/**/client/**/*.map"] - } }), ], }; ``` - - Generating source maps **may expose them to the public**, potentially causing your - source code to be leaked. You can prevent this by configuring your server to - deny access to `.js.map` files, or by using [Sentry Webpack Plugin's - `sourcemaps.filesToDeleteAfterUpload`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.filesToDeleteAfterUpload) - option to delete source maps after they've been uploaded to Sentry. - + diff --git a/docs/platforms/javascript/guides/nextjs/capturing-errors/index.mdx b/docs/platforms/javascript/guides/nextjs/capturing-errors/index.mdx index 22c75d1cf790c..00ccd307bfef2 100644 --- a/docs/platforms/javascript/guides/nextjs/capturing-errors/index.mdx +++ b/docs/platforms/javascript/guides/nextjs/capturing-errors/index.mdx @@ -202,7 +202,7 @@ If you see the same error twice, you're likely capturing in multiple places. Che ### Missing Stack Traces -Server errors may show minified traces in production. Enable source maps for readable traces. +Server errors may show minified traces in production when Sentry has no source maps for them. Check that your build uploads source maps. The `digest` property on server errors is a hash you can search for in logs. diff --git a/docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx b/docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx index 26f1c59202ffa..3fe951fcdbea9 100644 --- a/docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx +++ b/docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx @@ -94,53 +94,81 @@ withSentryConfig(nextConfig, { ## Source Maps Options - +You don't need to turn source maps on. When you run `next build`, the SDK turns on source maps if you haven't set them, uploads them, and removes the client-side source maps from the build output. Server-side source maps stay. -Disable any functionality related to source maps. +- Webpack: when `devtool` isn't set, the SDK uses `hidden-source-map` for the client build and `source-map` for the server builds. It removes all client-side source maps, also the ones you turned on yourself. +- Turbopack: when `productionBrowserSourceMaps` isn't set, the SDK sets it to `true` and removes the client-side source maps after the upload. When you set `productionBrowserSourceMaps` yourself, the client-side source maps stay. - +To change this, use [`sourcemaps.upload`](#sourcemaps.upload), [`sourcemaps.injectDebugIds`](#sourcemaps.injectDebugIds), and [`sourcemaps.delete`](#sourcemaps.delete). - + -A glob or an array of globs that specifies the build artifacts that should be uploaded to Sentry. If not specified, the plugin will try to upload all JavaScript files and source map files created during build. +Whether the SDK uploads source maps to Sentry. -The globbing patterns follow the implementation of the `glob` package. +With `false`, the SDK uploads nothing, but it still injects debug IDs into the bundles and their source maps. Use this to upload the source maps yourself later, for example with `sentry-cli sourcemaps upload`. The files already have their debug IDs, so you don't need an `inject` step. + +With `false`, the SDK turns on source maps only when `sourcemaps.delete` is `false`. - + -A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry. +Whether the SDK injects debug IDs into the bundles and their source maps. + +With `false`, the SDK adds no debug IDs, uploads no source maps, and turns on no source maps, because the upload matches files by debug ID. Use this when another tool injects the debug IDs and uploads the source maps, for example the Sentry CLI. - + -Toggle whether generated **client-side** source maps within your Next.js build folder will be automatically deleted after being uploaded to Sentry. When enabled, source maps in `.next/static/` are deleted but **server-side source maps** (in `.next/server/`) are intentionally kept because: +Whether the SDK removes the **client-side** source maps (in `.next/static/`) from the build output. The SDK never removes the **server-side** source maps (in `.next/server/`), because: - They are required for server-side error reporting at runtime. - They are not a security concern since they are not publicly accessible to users. -To customize which files are deleted after upload (for example, to include additional paths), use the `sourcemaps.filesToDeleteAfterUpload` option instead. - - +The values: - +- Not set: with Webpack, the SDK removes all client-side source maps. With Turbopack, it removes them only when it turned them on itself, that is, when `productionBrowserSourceMaps` isn't set. When you turn off the upload, the SDK removes nothing. +- `true`: the SDK removes all client-side source maps, also the ones you turned on (for example with `productionBrowserSourceMaps`) and the ones that weren't uploaded. +- `false`: the SDK removes no source maps. When you haven't set the source map setting, the SDK still turns source maps on, and they stay in the build output. With Turbopack, these files have `sourceMappingURL` comments, so browsers can find them. -An array of glob patterns that specifies which source map files will be deleted after being uploaded to Sentry. When set, this overrides the default deletion behavior of `deleteSourcemapsAfterUpload`. +`true` and `false` don't depend on an upload. They also apply when you turn off the upload, and when the upload fails. -Use this option when you need fine-grained control over which source maps are deleted. Make sure to also enable [hidden source maps](https://webpack.js.org/configuration/devtool/) for any files you plan to delete, otherwise your build output will contain broken `sourceMappingURL` references. +To keep the source maps for a manual upload later, set `upload: false` and `delete: false`: ```javascript withSentryConfig(nextConfig, { sourcemaps: { - filesToDeleteAfterUpload: [".next/static/**/*.map"], + upload: false, + delete: false, }, }); ``` + + +Use [`sourcemaps.upload`](#sourcemaps.upload) and [`sourcemaps.injectDebugIds`](#sourcemaps.injectDebugIds) instead. `"disable-upload"` is the same as `upload: false`, and `true` is the same as `injectDebugIds: false`. When you set `upload` or `injectDebugIds`, the SDK ignores `disable`. + +Disable any functionality related to source maps. + + + + + +A glob or an array of globs that specifies the build artifacts that should be uploaded to Sentry. If not specified, the plugin will try to upload all JavaScript files and source map files created during build. + +The globbing patterns follow the implementation of the `glob` package. + + + + + +A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry. + + + ## Release Options @@ -193,10 +221,12 @@ Include Next.js-internal code and code from dependencies when uploading source m If you find that there are some frames in your client-side stack traces that aren't getting source-mapped even when most others are, the issue might be that those frames are from files in `static/chunks/` rather than - `static/chunks/pages/`. By default, such files aren't uploaded because the - majority of the files in `static/chunks/` only contain Next.js or third-party - code. To upload all of the files and source maps, including ones from - third-party packages, set the `widenClientFileUpload` option to `true`. + `static/chunks/pages/`. With Webpack, such files aren't uploaded by default + because the majority of the files in `static/chunks/` only contain Next.js or + third-party code. To upload all of the files and source maps, including ones + from third-party packages, set the `widenClientFileUpload` option to `true`. + With Turbopack, the SDK uploads `static/chunks/` by default, and this option + adds only the `main-*` chunks. Note: Enabling this option can lead to longer build times. diff --git a/docs/platforms/javascript/guides/nextjs/manual-setup/webpack-setup.mdx b/docs/platforms/javascript/guides/nextjs/manual-setup/webpack-setup.mdx index 02e70ca785262..2df3a5d21a76f 100644 --- a/docs/platforms/javascript/guides/nextjs/manual-setup/webpack-setup.mdx +++ b/docs/platforms/javascript/guides/nextjs/manual-setup/webpack-setup.mdx @@ -89,6 +89,8 @@ export default withSentryConfig(nextConfig, { By default, Webpack uploads source maps **during the build process** using the Sentry Webpack Plugin. This happens separately for each build (client, server, edge), which can increase build time. +You don't need to turn source maps on. When `devtool` isn't set, the SDK uses `hidden-source-map` for the client build and `source-map` for the server builds. It removes all client-side source maps from the build output and keeps the server-side source maps. To change this, see [`sourcemaps.delete`](/platforms/javascript/guides/nextjs/configuration/build/#sourcemaps.delete). + For faster builds, you can use the post-build upload mode (available in Next.js 15.4.1+), which uploads all source maps in a single operation after all builds complete. ### Default: Upload During Build diff --git a/docs/platforms/javascript/guides/react-router/hydrogen.mdx b/docs/platforms/javascript/guides/react-router/hydrogen.mdx index 7c36175596822..668cdc036251e 100644 --- a/docs/platforms/javascript/guides/react-router/hydrogen.mdx +++ b/docs/platforms/javascript/guides/react-router/hydrogen.mdx @@ -270,6 +270,8 @@ sentry-cli sourcemaps inject /path/to/build/dir sentry-cli sourcemaps upload /path/to/build/dir ``` +When you don't set `build.sourcemap` in your Vite config, the `sentryReactRouter` plugin turns on hidden source maps. Without the `buildEnd` hook, the SDK doesn't remove them, so delete the `.map` files from your build output after the upload. + ### Control the Data You Send to Sentry +When you don't set `build.sourcemap` in your Vite config, the SDK turns on hidden source maps for the client and server builds. After the adapter ran, the SDK uploads the source maps to Sentry and removes them from the build output. When you turn on source maps yourself, the SDK uploads them and they stay. + + Disable automatic source maps upload by setting `autoUploadSourceMaps` to `false`. +With `false`, the SDK also doesn't turn on source maps or inject debug IDs. To upload the source maps yourself later, set [`sourcemaps.upload`](#sourcemaps.upload) to `false` instead. + + + + + +Whether the SDK uploads source maps to Sentry. + +With `false`, the SDK uploads nothing, but it still injects debug IDs into the bundles and their source maps. Use this to upload the source maps yourself later, for example with `sentry-cli sourcemaps upload`. The files already have their debug IDs, so you don't need an `inject` step. + +With `false`, the SDK turns on source maps only when [`sourcemaps.delete`](#sourcemaps.delete) is `false`. + + + + + +Whether the SDK injects debug IDs into the bundles and their source maps. + +With `false`, the SDK adds no debug IDs and uploads no source maps, because the upload matches files by debug ID. Use this when another tool injects the debug IDs and uploads the source maps, for example the Sentry CLI. + + + + + +Whether the SDK removes source maps from the build output. + +- Not set: the SDK removes the source maps it turned on itself, that is, when `build.sourcemap` isn't set in your Vite config. Source maps that you turned on stay. +- `true`: the SDK removes all source maps of the build, also the ones you turned on. The SDK switches `build.sourcemap: true` to `"hidden"`, so that no `sourceMappingURL` comment points to a removed file. +- `false`: the SDK removes no source maps. When `build.sourcemap` isn't set, the SDK turns on hidden source maps, and they stay in the build output. + +`true` and `false` don't depend on an upload. They also apply when the upload is turned off, when it can't run (for example, without an auth token), and when it fails. + +The SDK removes the `.map` files after the adapter ran, from the adapter output folder and from hidden folders such as `.svelte-kit` and `.vercel`. + +To keep the source maps for a manual upload later, set `upload: false` and `delete: false`: + +```javascript {filename:vite.config.(js|ts)} {7-10} +import { sveltekit } from "@sveltejs/kit/vite"; +import { sentrySvelteKit } from "@sentry/sveltekit/vite"; + +export default { + plugins: [ + sentrySvelteKit({ + sourcemaps: { + upload: false, + delete: false, + }, + }), + sveltekit(), + ], + // ... rest of your Vite config +}; +``` + ## Auto-Instrumentation Options diff --git a/docs/platforms/javascript/guides/tanstackstart-react/features/sentryTanstackStart.mdx b/docs/platforms/javascript/guides/tanstackstart-react/features/sentryTanstackStart.mdx index e5aa905dd8e98..4f0adbb48e98f 100644 --- a/docs/platforms/javascript/guides/tanstackstart-react/features/sentryTanstackStart.mdx +++ b/docs/platforms/javascript/guides/tanstackstart-react/features/sentryTanstackStart.mdx @@ -11,7 +11,7 @@ The plugin also loads your `instrument.server` file in production builds that us ## Usage -To automatically upload source maps, you need to provide your Sentry auth token, organization, and project slugs in your Vite configuration. The plugin then, by default, automatically enables hidden source maps and deletes `.map` files after upload. +To automatically upload source maps, you need to provide your Sentry auth token, organization, and project slugs in your Vite configuration. When you don't set `build.sourcemap` in your Vite config, the plugin turns on hidden source maps, uploads them, and removes them from the build output. Source maps that you turn on yourself are uploaded and stay in the build output. diff --git a/docs/product/sentry-basics/getting-started-tutorial/enable-readable-stack-traces.mdx b/docs/product/sentry-basics/getting-started-tutorial/enable-readable-stack-traces.mdx index e2c22d765a748..0605e2f54732a 100644 --- a/docs/product/sentry-basics/getting-started-tutorial/enable-readable-stack-traces.mdx +++ b/docs/product/sentry-basics/getting-started-tutorial/enable-readable-stack-traces.mdx @@ -75,9 +75,6 @@ import react from "@vitejs/plugin-react"; import { sentryVitePlugin } from "@sentry/bundler-plugins/vite"; export default defineConfig({ - build: { - sourcemap: true, - }, plugins: [ react(), sentryVitePlugin({ @@ -97,7 +94,7 @@ Your `org` and `project` here must point to the **same frontend project** as the -By default, the plugin deletes the source map files from your build output after uploading them, so they're not served to your users in production. +The plugin turns on source maps for the production build, uploads them, and then removes them from your build output, so they're not served to your users in production. ## 4. Trigger the Error Again diff --git a/includes/bundler-plugin-source-maps/esbuild.mdx b/includes/bundler-plugin-source-maps/esbuild.mdx new file mode 100644 index 0000000000000..07ef66ef48396 --- /dev/null +++ b/includes/bundler-plugin-source-maps/esbuild.mdx @@ -0,0 +1,7 @@ +You don't need to turn on source maps. When `sourcemap` isn't set, the plugin sets it to `"external"`, uploads the source maps to Sentry, and deletes them from the build output after the upload. It does this only when it can upload, that is, when it has an auth token, an organization, and a project. + + + +If you set `sourcemap` yourself, the plugin uploads these source maps and keeps them in the build output, where they can be public. To delete them after the upload, set [`sourcemaps.delete: true`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.delete). + + diff --git a/includes/bundler-plugin-source-maps/rollup.mdx b/includes/bundler-plugin-source-maps/rollup.mdx new file mode 100644 index 0000000000000..e5b57b8fb6c51 --- /dev/null +++ b/includes/bundler-plugin-source-maps/rollup.mdx @@ -0,0 +1,7 @@ +You don't need to turn on source maps. When `output.sourcemap` isn't set, the plugin turns on hidden source maps, uploads them to Sentry, and removes them from the build output. It does this only when it can upload, that is, when it has an auth token, an organization, and a project. + + + +If you set `output.sourcemap` yourself, the plugin uploads these source maps and keeps them in the build output, where they can be public. To remove them after the upload, set [`sourcemaps.delete: true`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.delete). + + diff --git a/includes/bundler-plugin-source-maps/vite.mdx b/includes/bundler-plugin-source-maps/vite.mdx new file mode 100644 index 0000000000000..431421677595a --- /dev/null +++ b/includes/bundler-plugin-source-maps/vite.mdx @@ -0,0 +1,7 @@ +You don't need to turn on source maps. When `build.sourcemap` isn't set, the plugin turns on hidden source maps, uploads them to Sentry, and removes them from the build output. It does this only when it can upload, that is, when it has an auth token, an organization, and a project. + + + +If you set `build.sourcemap` yourself, the plugin uploads these source maps and keeps them in the build output, where they can be public. To remove them after the upload, set [`sourcemaps.delete: true`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.delete). + + diff --git a/includes/bundler-plugin-source-maps/webpack.mdx b/includes/bundler-plugin-source-maps/webpack.mdx new file mode 100644 index 0000000000000..85fb36a5e535a --- /dev/null +++ b/includes/bundler-plugin-source-maps/webpack.mdx @@ -0,0 +1,7 @@ +You don't need to turn on source maps. When `devtool` isn't set, the plugin sets it to `"hidden-source-map"`, uploads the source maps to Sentry, and removes them from the build output. It does this only when it can upload, that is, when it has an auth token, an organization, and a project. + + + +If you set `devtool` yourself, the plugin uploads these source maps and keeps them in the build output, where they can be public. To remove them after the upload, set [`sourcemaps.delete: true`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.delete). + + diff --git a/includes/react-router/source-maps-upload.mdx b/includes/react-router/source-maps-upload.mdx index 78537cc821dc9..34249229b4681 100644 --- a/includes/react-router/source-maps-upload.mdx +++ b/includes/react-router/source-maps-upload.mdx @@ -23,3 +23,17 @@ export default { + }, } satisfies Config; ``` + +When you don't set `build.sourcemap` in your Vite config, the SDK turns on hidden source maps for the client and server builds. After the upload, `sentryOnBuildEnd` removes the `.map` files from your build directory. When you turn on source maps yourself, the SDK uploads them and they stay. + +To change this, set the [`sourcemaps.upload`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.upload), [`sourcemaps.injectDebugIds`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.injectDebugIds), and [`sourcemaps.delete`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.delete) options in your Sentry config. For example, to keep the source maps for a manual upload later: + +```typescript {filename: vite.config.ts} +const sentryConfig: SentryReactRouterBuildOptions = { + // ... + sourcemaps: { + upload: false, + delete: false, + }, +}; +``` diff --git a/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx b/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx index d625c13e19cca..e973e3ead80b2 100644 --- a/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx +++ b/platform-includes/getting-started-cloudflare/javascript.nuxt.mdx @@ -180,6 +180,10 @@ export default defineNuxtConfig({ }); ``` +Sentry uploads these source maps and keeps them in the build output, where they can be public. + +To remove all source maps from the build output, set [`sourcemaps.delete: true`](/platforms/javascript/sourcemaps/uploading/bundler-plugin-options/#sourcemaps.delete) in the `sentry` options. + ### Control the Data You Send to Sentry