Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,33 @@ Because the integration owns error capture, `setupFastifyErrorHandler` no longer
-});
```

### `sourcemaps.disable`, `deleteSourcemapsAfterUpload` and `filesToDeleteAfterUpload` are deprecated

Affected SDKs: the bundler plugins and all SDKs with build-time options.

Three source map build options are deprecated. They still work, log a warning at build time, and will be removed in v12:

| Deprecated option | Replacement |
| ---------------------------------------------------- | ---------------------------------------------------------- |
| `sourcemaps: { disable: 'disable-upload' }` | `sourcemaps: { upload: false }` |
| `sourcemaps: { disable: true }` | `sourcemaps: { upload: false, injectDebugIds: false }` |
| `sourcemaps.deleteSourcemapsAfterUpload` | `sourcemaps.delete` |
| `sourcemaps.filesToDeleteAfterUpload` | `sourcemaps.delete`, or a script that runs after the build |
| `deleteSourcemapsAfterUpload` (Gatsby plugin option) | `sourcemaps.delete` |

`deleteSourcemapsAfterUpload: false` becomes `delete: false`. `delete: true` removes more than `deleteSourcemapsAfterUpload: true`: for source maps you turned on yourself, the old option only removed the maps of the chunks that were uploaded. `delete: true` removes every source map of the build, also CSS source maps and the maps of chunks that the upload leaves out, and it does so also when nothing is uploaded. In `@sentry/nextjs`, both options only apply to the client source maps.

When `sourcemaps.delete` is unset, Sentry already removes the source maps it turned on itself, and `delete: true` removes all of them. If you used `filesToDeleteAfterUpload` to delete other files, delete them with a script after the build.

Some SDKs turned on source maps for `disable: 'disable-upload'`, so that you could upload them yourself. With `upload: false`, they only do so when you also set `delete: false`.

In `@sentry/astro`, `@sentry/nuxt` and `@sentry/solidstart`, `sourcemaps.disable: true` also leaves out the Sentry plugin, so no release is injected or created. In `@sentry/nitro`, it skips the release creation. The new options keep these release steps. To turn them off too, set:

```js
sourcemaps: { upload: false, injectDebugIds: false },
release: { inject: false, create: false, finalize: false, setCommits: false, deploy: false },
```

### `@sentry/nextjs`

**Tracing removed from generated templates:** Tracing was removed from the generated Pages Router API handler, Edge API handler, and Middleware wrapper templates. Route handlers and middleware are still instrumented automatically, so no action is required for most users.
Expand Down Expand Up @@ -1482,7 +1509,7 @@ Affected SDKs: `@sentry/remix`.

The plugin now also applies the build-time instrumentation transform. If you added `sentryOrchestrionPlugin()` from `@sentry/server-utils/orchestrion/vite` to your Vite config manually, remove it. Opt out with `sentryRemixVitePlugin({ buildTimeInstrumentation: false })`.

It also injects debug IDs and uploads source maps once you pass `org`, `project` and `authToken` — opt out with `sentryRemixVitePlugin({ sourcemaps: { disable: true } })`.
It also injects debug IDs and uploads source maps once you pass `org`, `project` and `authToken` — opt out with `sentryRemixVitePlugin({ sourcemaps: { upload: false, injectDebugIds: false } })`.

### React: Simpler React Router setup via `@sentry/react/react-router`

Expand Down Expand Up @@ -1815,7 +1842,7 @@ tracing loaders and actions.
instead of wrapping them individually.
- The deprecated `sentryHandleRequest` export was removed. Use `wrapSentryHandleRequest` instead.

The deprecated `sourceMapsUploadOptions` option was removed from `sentryReactRouter()`. Move its fields to the root level of the `sentryConfig` passed to `sentryReactRouter()`. Note that `enabled` was replaced by `sourcemaps.disable` (inverted: `enabled: false` becomes `sourcemaps: { disable: true }`).
The deprecated `sourceMapsUploadOptions` option was removed from `sentryReactRouter()`. Move its fields to the root level of the `sentryConfig` passed to `sentryReactRouter()`. Note that `enabled: false` becomes `sourcemaps: { upload: false, injectDebugIds: false }`.

### Browser and Node profiling

Expand Down Expand Up @@ -1922,7 +1949,7 @@ remains available on the React-based SDKs (`@sentry/nextjs`, `@sentry/react-rout

The following bundler plugin options have no first-class equivalent and are no longer reachable:
`release.uploadLegacySourcemaps`, `_experiments`, and the whole-plugin `disable` flag (use
`sourcemaps.disable` instead).
`sourcemaps: { upload: false, injectDebugIds: false }` instead).

### `@sentry/nuxt`

Expand All @@ -1938,7 +1965,7 @@ sentry.server.config.ts

After the rename, the SDK bundles the file into the Nitro server build and initializes itself at server startup. See ["the server config is bundled"](#sentrynuxt-the-server-config-is-bundled---import-is-no-longer-needed) above: the `--import` preload is no longer needed.

The deprecated `sourceMapsUploadOptions` module option was removed. Move its fields to the root level of the `sentry` module options. Note that `url` was renamed to `sentryUrl`, and `enabled` was replaced by `sourcemaps.disable` (inverted: `enabled: false` becomes `sourcemaps: { disable: true }`).
The deprecated `sourceMapsUploadOptions` module option was removed. Move its fields to the root level of the `sentry` module options. Note that `url` was renamed to `sentryUrl`, and `enabled: false` becomes `sourcemaps: { upload: false, injectDebugIds: false }`. To also turn off the release steps, as `enabled: false` did, see [the deprecated source map options](#sourcemapsdisable-deletesourcemapsafterupload-and-filestodeleteafterupload-are-deprecated).

```ts
// nuxt.config.ts
Expand Down Expand Up @@ -2011,7 +2038,7 @@ export default defineConfig({

### `@sentry/astro`

The deprecated `sourceMapsUploadOptions` option was removed from `sentryAstro()`. Move its fields to the top level of the `sentryAstro()` options. Note that `assets` and `filesToDeleteAfterUpload` moved into `sourcemaps`, and `enabled` was replaced by `sourcemaps.disable` (inverted: `enabled: false` becomes `sourcemaps: { disable: true }`).
The deprecated `sourceMapsUploadOptions` option was removed from `sentryAstro()`. Move its fields to the top level of the `sentryAstro()` options. Note that `assets` moved into `sourcemaps`, `filesToDeleteAfterUpload` is replaced by `sourcemaps.delete`, and `enabled: false` becomes `sourcemaps: { upload: false, injectDebugIds: false }`. To also turn off the release steps, as `enabled: false` did, see [the deprecated source map options](#sourcemapsdisable-deletesourcemapsafterupload-and-filestodeleteafterupload-are-deprecated).

```js
// astro.config.mjs
Expand Down Expand Up @@ -2091,8 +2118,9 @@ Sentry.init({
### `@sentry/solidstart`

The `sourceMapsUploadOptions` build option was removed. Move its fields to the top level, matching every
other meta-framework SDK. Note that `enabled` was replaced by `sourcemaps.disable` (inverted:
`enabled: false` becomes `sourcemaps: { disable: true }`).
other meta-framework SDK. Note that `enabled: false` becomes `sourcemaps: { upload: false, injectDebugIds: false }`,
and `filesToDeleteAfterUpload` is replaced by `sourcemaps.delete`. To also turn off the release steps, as
`enabled: false` did, see [the deprecated source map options](#sourcemapsdisable-deletesourcemapsafterupload-and-filestodeleteafterupload-are-deprecated).

This only affects SolidStart 1 setups using `withSentry()` / `sentrySolidStartVite()`. SolidStart 2's
`sentrySolidStart()` already took its options at the top level.
Expand All @@ -2113,8 +2141,7 @@ export default defineConfig(
// after
telemetry: false,
sourcemaps: {
disable: false,
filesToDeleteAfterUpload: ['./dist/**/*.map'],
delete: true,
},
},
),
Expand Down
5 changes: 4 additions & 1 deletion packages/astro/src/integration/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sentryVitePlugin } from '@sentry/bundler-plugins/vite';
import { resolveSourceMapsFeatures, warnOnRemovedBuildOptions } from '@sentry/core';
import { resolveSourceMapsFeatures, warnOnConflictingSourceMapOptions, warnOnRemovedBuildOptions } from '@sentry/core';
import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite';
import type { AstroConfig, AstroIntegration } from 'astro';
import * as fs from 'fs';
Expand Down Expand Up @@ -59,6 +59,8 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
warnOnRemovedBuildOptions(options, ['unstable_sentryVitePluginOptions', 'sourceMapsUploadOptions'], message =>
logger.warn(message),
);
// The Sentry plugin is not added with `sourcemaps.disable: true`.
warnOnConflictingSourceMapOptions(sourcemaps, message => logger.warn(message));

const sdkEnabled = {
client: typeof enabled === 'boolean' ? enabled : (enabled?.client ?? true),
Expand All @@ -81,6 +83,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
// A user's own glob replaces the SDK's deletion. Maps in a Cloudflare `_worker.js` folder
// stay, so that wrangler can read them for `upload_source_maps`.
const sdkDeleteSourceMaps =
// oxlint-disable-next-line typescript/no-deprecated
sourcemaps?.delete === undefined && sourcemaps?.filesToDeleteAfterUpload === undefined
? (environment?: string) =>
sdkEnabledSourceMaps(environment) && !buildState.writesCloudflareWorker ? true : undefined
Expand Down
40 changes: 14 additions & 26 deletions packages/bundler-plugins/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export interface Options {

// TODO(v12): Remove `disable`. `upload` and `injectDebugIds` replace it.
/**
* @deprecated Use `sourcemaps.upload` and `sourcemaps.injectDebugIds` instead. `upload: false` replaces
* `"disable-upload"`, and `upload: false, injectDebugIds: false` replaces `true`.
*
* Disables all functionality related to sourcemaps if set to `true`.
*
* If set to `"disable-upload"`, the plugin will not upload sourcemaps to Sentry, but will still inject debug IDs
Expand Down Expand Up @@ -223,39 +226,24 @@ export interface Options {
*/
resolveSourceMap?: ResolveSourceMapHook;

// TODO(v12): Remove.
/**
* A glob or an 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).
* @deprecated Use `sourcemaps.delete` instead. When it is unset, Sentry already removes the source maps it
* turned on, and `delete: true` removes all of them. To delete other files, run a script after the build.
*
* The globbing patterns must follow the implementation of the `glob` package: https://www.npmjs.com/package/glob#glob-primer
*
* Use the `debug` option to print information about which files end up being deleted.
* A glob or an array of globs, or a promise of them, that specifies the build artifacts to delete after the
* upload to Sentry. The globbing patterns must follow the implementation of the `glob` package.
*/
filesToDeleteAfterUpload?: string | string[] | Promise<string | string[] | undefined>;

// TODO(v12): Remove.
/**
* Whether source maps are removed from the build output after they are uploaded to Sentry.
*
* When unset, the plugin removes only the source maps it turned on itself, that is, when the bundler's source map
* setting was not set. `true` also removes source maps you enabled yourself. `false` never removes them; the plugin
* still turns on hidden source maps when the setting is not set, so they can be uploaded.
* @deprecated Use `sourcemaps.delete` instead. For source maps you turned on, `delete: true` removes every
* source map of the build, also those of chunks that were not uploaded, and also when nothing is uploaded.
*
* When the plugin turned source maps on, none of them reach the build output, not even those of chunks that
* `sourcemaps.assets` or `sourcemaps.ignore` keep out of the upload. Source maps you enabled yourself are only
* removed for the JavaScript chunks that were uploaded; excluded chunks keep theirs.
*
* `true` removes source maps you enabled yourself even when no upload runs, for example without an auth token.
* With `sourcemaps.disable` set, the plugin keeps them for a manual upload and warns. The plugin does not turn
* source maps on when it cannot upload them.
*
* With webpack's array form of `devtool`, `true` replaces the array with one hidden source map setting for
* all asset types, because webpack hides the array from plugins.
*
* With Rollup, Vite and webpack the removed source maps are never written to the output directory. With esbuild
* they are deleted after the upload.
* Whether source maps are removed from the build output after they are uploaded to Sentry. When unset, the
* plugin removes only the source maps it turned on itself. `true` also removes the source maps you turned on
* for the JavaScript chunks that were uploaded. `false` never removes them.
*/
deleteSourcemapsAfterUpload?: boolean;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/bundler-plugins/test/core/option-mappings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,12 @@ describe('validateOptions', () => {
});

it.each([undefined, 'disable-upload'] as const)(
'does not warn when `deleteSourcemapsAfterUpload` is set and `sourcemaps.disable` is `%s`',
'does not warn about a conflict when `deleteSourcemapsAfterUpload` is set and `sourcemaps.disable` is `%s`',
disable => {
const options = normalizeUserOptions({ sourcemaps: { disable, deleteSourcemapsAfterUpload: true } });

expect(validateOptions(options, mockedLogger)).toBe(true);
expect(mockedLogger.warn).not.toHaveBeenCalled();
expect(mockedLogger.warn).not.toHaveBeenCalledWith(expect.stringMatching(/ is ignored | still | is set, but /));
},
);

Expand Down
31 changes: 14 additions & 17 deletions packages/core/src/build-time-plugins/buildTimeOptionsBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ interface SourceMapsOptions {

// TODO(v12): Remove `disable`. `upload` and `injectDebugIds` replace it.
/**
* @deprecated Use `sourcemaps.upload` and `sourcemaps.injectDebugIds` instead. `upload: false` replaces
* `"disable-upload"`, and `upload: false, injectDebugIds: false` replaces `true`.
*
* If this flag is `true`, any functionality related to source maps will be disabled. This includes the automatic upload of source maps.
*
* By default (`false`), the plugin automatically uploads source maps during a production build if a Sentry auth token is detected.
Expand Down Expand Up @@ -280,31 +283,25 @@ interface SourceMapsOptions {
*/
ignore?: string | string[];

// TODO(v12): Remove.
/**
* A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
* upload to Sentry has been completed.
* @deprecated Use `sourcemaps.delete` instead. When it is unset, Sentry already removes the source maps it
* turned on, and `delete: true` removes all of them. To delete other files, run a script after the build.
*
* A glob or an array of globs that specifies the build artifacts to delete after the upload to Sentry.
*
* The globbing patterns must follow the implementation of the `glob` package: https://www.npmjs.com/package/glob#glob-primer
*/
filesToDeleteAfterUpload?: string | Array<string>;

// TODO(v12): Remove.
/**
* Whether source maps are removed from the build output after they are uploaded to Sentry.
*
* When unset, the plugin removes only the source maps it turned on itself, that is, when the bundler's source map
* setting was not set. `true` also removes source maps you enabled yourself. `false` never removes them; the plugin
* still turns on hidden source maps when the setting is not set, so they can be uploaded.
*
* When the plugin turned source maps on, none of them reach the build output, not even those of chunks that
* `sourcemaps.assets` or `sourcemaps.ignore` keep out of the upload. Source maps you enabled yourself are only
* removed for the JavaScript chunks that were uploaded; excluded chunks keep theirs.
*
* `true` removes source maps you enabled yourself even when no upload runs, for example without an auth token.
* With `sourcemaps.disable` set, the plugin keeps them for a manual upload and warns. The plugin does not turn
* source maps on when it cannot upload them.
* @deprecated Use `sourcemaps.delete` instead. For source maps you turned on, `delete: true` removes every
* source map of the build, also those of chunks that were not uploaded, and also when nothing is uploaded.
*
* With webpack's array form of `devtool`, `true` replaces the array with one hidden source map setting for
* all asset types, because webpack hides the array from plugins.
* Whether source maps are removed from the build output after they are uploaded to Sentry. When unset, Sentry
* removes only the source maps it turned on itself. `true` also removes the source maps you turned on for the
* JavaScript chunks that were uploaded. `false` never removes them.
*/
deleteSourcemapsAfterUpload?: boolean;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { consoleSandbox } from '../utils/debug-logger';

/** The source map options that can conflict with each other. */
/** The source map options that can conflict with each other or are deprecated. */
export interface ConflictingSourceMapOptions {
disable?: boolean | 'disable-upload';
upload?: boolean;
Expand All @@ -14,8 +14,8 @@ export interface ConflictingSourceMapOptions {
const loggedWarnings = new Set<string>();

/**
* Warns about `sourcemaps` options that conflict with each other. It logs
* each warning once per process.
* Warns about deprecated `sourcemaps` options and about options that conflict with each other. It
* logs each warning once per process.
*
* The bundler plugin calls this for the options it gets. SDKs that apply some of the options
* themselves call it with the user's options, because the plugin does not see them all.
Expand Down Expand Up @@ -46,6 +46,23 @@ export function warnOnConflictingSourceMapOptions(
}
};

// TODO(v12): Remove along with the deprecated options.
if (sourcemaps.disable !== undefined) {
warn(
"`sourcemaps.disable` is deprecated and will be removed in the next major version. Use `sourcemaps.upload: false` instead of `'disable-upload'`, and `sourcemaps: { upload: false, injectDebugIds: false }` instead of `true`.",
);
}
if (sourcemaps.deleteSourcemapsAfterUpload !== undefined) {
warn(
'`sourcemaps.deleteSourcemapsAfterUpload` is deprecated and will be removed in the next major version. Use `sourcemaps.delete` instead.',
);
}
if (sourcemaps.filesToDeleteAfterUpload !== undefined) {
warn(
'`sourcemaps.filesToDeleteAfterUpload` is deprecated and will be removed in the next major version. Use `sourcemaps.delete` instead. To delete other files, run a script after the build.',
);
}

const usesFeatureOptions = sourcemaps.upload !== undefined || sourcemaps.injectDebugIds !== undefined;
// TODO(v12): Remove along with `sourcemaps.disable`.
if (usesFeatureOptions && sourcemaps.disable !== undefined) {
Expand Down
Loading
Loading