Skip to content

Commit 32dd9d8

Browse files
chargomeclaude
andauthored
feat(nextjs)!: Remove deprecated build-time config options (#23221)
Removes the deprecated top-level `withSentryConfig` options marked with `TODO(v11)`. All have replacements documented as an old→new table in `docs/migration/v11-end-state.md`. Also removes top-level `excludeServerRoutes`, which was deprecated in the same PR as the others (#18343) but never got a `TODO(v11)` marker. closes #22245 --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 2e15d04 commit 32dd9d8

18 files changed

Lines changed: 76 additions & 504 deletions

File tree

dev-packages/e2e-tests/test-applications/nextjs-15-t3/next.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ const config = {};
66
import { withSentryConfig } from '@sentry/nextjs';
77

88
export default withSentryConfig(config, {
9-
disableLogger: true,
9+
webpack: {
10+
treeshake: {
11+
removeDebugLogging: true,
12+
},
13+
},
1014
silent: true,
1115
});

dev-packages/e2e-tests/test-applications/nextjs-16-bun/next.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ const nextConfig: NextConfig = {};
55

66
export default withSentryConfig(nextConfig, {
77
silent: true,
8-
_experimental: {
9-
turbopackApplicationKey: 'nextjs-16-bun-e2e',
10-
},
8+
applicationKey: 'nextjs-16-bun-e2e',
119
});

dev-packages/e2e-tests/test-applications/nextjs-16-streaming/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const nextConfig: NextConfig = {};
88

99
export default withSentryConfig(nextConfig, {
1010
silent: true,
11+
applicationKey: 'nextjs-16-streaming-e2e',
1112
_experimental: {
1213
vercelCronsMonitoring: true,
13-
turbopackApplicationKey: 'nextjs-16-streaming-e2e',
1414
turbopackReactComponentAnnotation: {
1515
enabled: true,
1616
},

dev-packages/e2e-tests/test-applications/nextjs-16/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ const nextConfig: NextConfig = {
1414

1515
export default withSentryConfig(nextConfig, {
1616
silent: true,
17+
applicationKey: 'nextjs-16-e2e',
1718
_experimental: {
1819
vercelCronsMonitoring: true,
19-
turbopackApplicationKey: 'nextjs-16-e2e',
2020
turbopackReactComponentAnnotation: {
2121
enabled: true,
2222
},

dev-packages/e2e-tests/test-applications/nextjs-orpc/next.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ const config = {};
44
import { withSentryConfig } from '@sentry/nextjs';
55

66
export default withSentryConfig(config, {
7-
disableLogger: true,
7+
webpack: {
8+
treeshake: {
9+
removeDebugLogging: true,
10+
},
11+
},
812
});

dev-packages/e2e-tests/test-applications/supabase-nextjs/next.config.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,27 @@ module.exports = withSentryConfig(module.exports, {
2525
// Upload a larger set of source maps for prettier stack traces (increases build time)
2626
widenClientFileUpload: true,
2727

28-
// Automatically annotate React components to show their full name in breadcrumbs and session replay
29-
reactComponentAnnotation: {
30-
enabled: true,
31-
},
32-
3328
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
3429
// This can increase your server load as well as your hosting bill.
3530
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
3631
// side errors will fail.
3732
tunnelRoute: '/monitoring',
3833

39-
// Automatically tree-shake Sentry logger statements to reduce bundle size
40-
disableLogger: false,
41-
42-
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
43-
// See the following for more information:
44-
// https://docs.sentry.io/product/crons/
45-
// https://vercel.com/docs/cron-jobs
46-
automaticVercelMonitors: true,
34+
webpack: {
35+
// Automatically annotate React components to show their full name in breadcrumbs and session replay
36+
reactComponentAnnotation: {
37+
enabled: true,
38+
},
39+
40+
// Automatically tree-shake Sentry logger statements to reduce bundle size
41+
treeshake: {
42+
removeDebugLogging: false,
43+
},
44+
45+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
46+
// See the following for more information:
47+
// https://docs.sentry.io/product/crons/
48+
// https://vercel.com/docs/cron-jobs
49+
automaticVercelMonitors: true,
50+
},
4751
});

docs/migration/v11-end-state.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -865,19 +865,22 @@ Sentry.init({
865865
866866
### `@sentry/nextjs`
867867
868-
The following long-deprecated options in `withSentryConfig` / the `sentry` config were removed:
869-
870-
- `unstable_sentryWebpackPluginOptions`
871-
- `autoInstrumentServerFunctions`
872-
- `autoInstrumentMiddleware`
873-
- `autoInstrumentAppDirectory`
874-
- `disableLogger`
875-
- `automaticVercelMonitors`
876-
- `disableManifestInjection`
877-
- `disableSentryWebpackConfig`
878-
- `turbopackApplicationKey`
879-
880-
Remove these options from your `next.config.js` / `next.config.ts`.
868+
The following long-deprecated top-level options in `withSentryConfig` / the `sentry` config were removed. Most of them
869+
moved under the `webpack` option in v10; use the replacement listed below instead:
870+
871+
| Removed option | Replacement |
872+
| --------------------------------------- | -------------------------------------------------------------- |
873+
| `autoInstrumentServerFunctions` | `webpack.autoInstrumentServerFunctions` |
874+
| `autoInstrumentMiddleware` | `webpack.autoInstrumentMiddleware` |
875+
| `autoInstrumentAppDirectory` | `webpack.autoInstrumentAppDirectory` |
876+
| `automaticVercelMonitors` | `webpack.automaticVercelMonitors` |
877+
| `excludeServerRoutes` | `webpack.excludeServerRoutes` |
878+
| `reactComponentAnnotation` | `webpack.reactComponentAnnotation` |
879+
| `unstable_sentryWebpackPluginOptions` | `webpack.unstable_sentryWebpackPluginOptions` |
880+
| `disableSentryWebpackConfig` | `webpack.disableSentryConfig` |
881+
| `disableLogger` | `webpack.treeshake.removeDebugLogging` |
882+
| `disableManifestInjection` | `routeManifestInjection: false` |
883+
| `_experimental.turbopackApplicationKey` | `applicationKey` (works for both webpack and Turbopack builds) |
881884
882885
### Meta-framework build options
883886

packages/nextjs/src/client/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function init(options: BrowserOptions): Client | undefined {
5353
consoleSandbox(() => {
5454
// eslint-disable-next-line no-console
5555
console.warn(
56-
'[@sentry/nextjs] You have enabled `debug: true`, but Sentry debug logging was removed from your bundle (likely via `withSentryConfig({ disableLogger: true })` / `webpack.treeshake.removeDebugLogging: true`). Set that option to `false` to see Sentry debug output.',
56+
'[@sentry/nextjs] You have enabled `debug: true`, but Sentry debug logging was removed from your bundle (likely via `webpack.treeshake.removeDebugLogging: true`). Set that option to `false` to see Sentry debug output.',
5757
);
5858
});
5959
}

packages/nextjs/src/config/turbopack/constructTurbopackConfig.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ export function constructTurbopackConfig({
7878
// so it is safe even for node_modules with strict initialization order.
7979
// We only exclude Next.js build polyfills which contain non-standard syntax that causes
8080
// parse errors when any code is prepended (Turbopack re-parses the loader output).
81-
// eslint-disable-next-line typescript/no-deprecated
82-
const applicationKey = userSentryOptions?.applicationKey ?? userSentryOptions?._experimental?.turbopackApplicationKey;
81+
const applicationKey = userSentryOptions?.applicationKey;
8382
if (applicationKey && nextJsVersion && supportsTurbopackRuleCondition(nextJsVersion)) {
8483
newConfig.rules = safelyAddTurbopackRule(newConfig.rules, {
8584
matcher: '*.{ts,tsx,js,jsx,mjs,cjs}',

packages/nextjs/src/config/types.ts

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -531,36 +531,6 @@ export type SentryBuildOptions = {
531531
excludeReplayWorker?: boolean;
532532
};
533533

534-
/**
535-
* Options related to react component name annotations.
536-
* Disabled by default, unless a value is set for this option.
537-
* When enabled, your app's DOM will automatically be annotated during build-time with their respective component names.
538-
* This will unlock the capability to search for Replays in Sentry by component name, as well as see component names in breadcrumbs and performance monitoring.
539-
* Please note that this feature is not currently supported by the esbuild bundler plugins, and will only annotate React components
540-
*
541-
* @deprecated Use `webpack.reactComponentAnnotation` instead.
542-
*/
543-
reactComponentAnnotation?: {
544-
/**
545-
* Whether the component name annotate plugin should be enabled or not.
546-
*/
547-
enabled?: boolean;
548-
549-
/**
550-
* A list of strings representing the names of components to ignore. The plugin will not apply `data-sentry` annotations on the DOM element for these components.
551-
*/
552-
ignoredComponents?: string[];
553-
}; // TODO(v11): remove this option
554-
555-
/**
556-
* Options to be passed directly to the Sentry Webpack Plugin (`@sentry/bundler-plugins/webpack`) that ships with the Sentry Next.js SDK.
557-
* You can use this option to override any options the SDK passes to the webpack plugin.
558-
*
559-
* Please note that this option is unstable and may change in a breaking way in any release.
560-
* @deprecated Use `webpack.unstable_sentryWebpackPluginOptions` instead.
561-
*/
562-
unstable_sentryWebpackPluginOptions?: SentryWebpackPluginOptions; // TODO(v11): remove this option
563-
564534
/**
565535
* Include Next.js-internal code and code from dependencies when uploading source maps.
566536
*
@@ -576,40 +546,6 @@ export type SentryBuildOptions = {
576546
// TODO: Add an alias to this function called "uploadSourceMapsForDependencies"
577547
widenClientFileUpload?: boolean;
578548

579-
/**
580-
* Automatically instrument Next.js data fetching methods and Next.js API routes with error and performance monitoring.
581-
* Defaults to `true`.
582-
* @deprecated Use `webpack.autoInstrumentServerFunctions` instead.
583-
*/
584-
autoInstrumentServerFunctions?: boolean; // TODO(v11): remove this option
585-
586-
/**
587-
* Automatically instrument Next.js middleware with error and performance monitoring. Defaults to `true`.
588-
* @deprecated Use `webpack.autoInstrumentMiddleware` instead.
589-
*/
590-
autoInstrumentMiddleware?: boolean; // TODO(v11): remove this option
591-
592-
/**
593-
* Automatically instrument components in the `app` directory with error monitoring. Defaults to `true`.
594-
* @deprecated Use `webpack.autoInstrumentAppDirectory` instead.
595-
*/
596-
autoInstrumentAppDirectory?: boolean; // TODO(v11): remove this option
597-
598-
/**
599-
* Exclude certain serverside API routes or pages from being instrumented with Sentry during build-time. This option
600-
* takes an array of strings or regular expressions. This options also affects pages in the `app` directory.
601-
*
602-
* NOTE: Pages should be specified as routes (`/animals` or `/api/animals/[animalType]/habitat`), not filepaths
603-
* (`pages/animals/index.js` or `.\src\pages\api\animals\[animalType]\habitat.tsx`), and strings must be be a full,
604-
* exact match.
605-
*
606-
* Notice: If you build Next.js with turbopack, the Sentry SDK will no longer apply build-time instrumentation and
607-
* purely rely on Next.js telemetry features, meaning that this option will effectively no-op.
608-
*
609-
* @deprecated Use `webpack.excludeServerRoutes` instead.
610-
*/
611-
excludeServerRoutes?: Array<RegExp | string>;
612-
613549
/**
614550
* Tunnel Sentry requests through this route on the Next.js server, to circumvent ad-blockers blocking Sentry events
615551
* from being sent. This option should be a path (for example: '/error-monitoring').
@@ -621,22 +557,6 @@ export type SentryBuildOptions = {
621557
*/
622558
tunnelRoute?: string | boolean;
623559

624-
/**
625-
* Tree shakes Sentry SDK logger statements from the bundle.
626-
*
627-
* @deprecated Use `webpack.treeshake.removeDebugLogging` instead.
628-
*/
629-
disableLogger?: boolean; // TODO(v11): remove this option
630-
631-
/**
632-
* Automatically create cron monitors in Sentry for your Vercel Cron Jobs if configured via `vercel.json`.
633-
*
634-
* Defaults to `false`.
635-
*
636-
* @deprecated Use `webpack.automaticVercelMonitors` instead.
637-
*/
638-
automaticVercelMonitors?: boolean; // TODO(v11): remove this option
639-
640560
/**
641561
* When an error occurs during release creation or sourcemaps upload, the plugin will call this function.
642562
*
@@ -659,15 +579,6 @@ export type SentryBuildOptions = {
659579
*/
660580
suppressOnRouterTransitionStartWarning?: boolean;
661581

662-
/**
663-
* Disables automatic injection of the route manifest into the client bundle.
664-
*
665-
* @deprecated Use `routeManifestInjection: false` instead.
666-
*
667-
* @default false
668-
*/
669-
disableManifestInjection?: boolean; // TODO(v11): remove this option
670-
671582
/**
672583
* Options for the route manifest injection feature.
673584
*
@@ -716,20 +627,6 @@ export type SentryBuildOptions = {
716627
exclude?: Array<string | RegExp> | ((route: string) => boolean);
717628
};
718629

719-
/**
720-
* Disables automatic injection of Sentry's Webpack configuration.
721-
*
722-
* By default, the Sentry Next.js SDK injects its own Webpack configuration to enable features such as
723-
* source map upload and automatic instrumentation. Set this option to `true` if you want to prevent
724-
* the SDK from modifying your Webpack config (for example, if you want to handle Sentry integration manually
725-
* or if you are on an older version of Next.js while using Turbopack).
726-
*
727-
* @deprecated Use `webpack.disableSentryConfig` instead.
728-
*
729-
* @default false
730-
*/
731-
disableSentryWebpackConfig?: boolean; // TODO(v11): remove this option
732-
733630
/**
734631
* When true (and Next.js >= 15), use the runAfterProductionCompile hook to consolidate sourcemap uploads
735632
* into a single operation after builds complete, reducing build time.
@@ -753,19 +650,6 @@ export type SentryBuildOptions = {
753650
* Requires cron jobs to be configured in `vercel.json`.
754651
*/
755652
vercelCronsMonitoring?: boolean;
756-
/**
757-
* Application key used by `thirdPartyErrorFilterIntegration` to distinguish
758-
* first-party code from third-party code in Turbopack builds.
759-
*
760-
* When set, a Turbopack loader injects `_sentryModuleMetadata` into every
761-
* first-party module, mirroring what `@sentry/bundler-plugins/webpack` does for
762-
* webpack builds via its `moduleMetadata` / `applicationKey` option.
763-
*
764-
* Requires Next.js 16+
765-
*
766-
* @deprecated Use the top-level `applicationKey` option instead, which works for both webpack and Turbopack builds.
767-
*/
768-
turbopackApplicationKey?: string; // TODO(v11): remove this option
769653
/**
770654
* Options for React component name annotation in Turbopack builds.
771655
* When enabled, JSX elements are annotated with `data-sentry-component`,

0 commit comments

Comments
 (0)