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(nextjs): added webpack treeshaking flags as config (#18359)
This PR updates the Sentry Next.js integration to improve tree-shaking
configuration and add new options for finer control over what SDK code
is included in the final bundle.
The most significant changes are:
- Added several new tree-shaking flags for better user DX.
Closes#18417
---------
Co-authored-by: Copilot <[email protected]>
Copy file name to clipboardExpand all lines: packages/nextjs/src/config/types.ts
+35-5Lines changed: 35 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -112,6 +112,36 @@ export type SentryBuildWebpackOptions = {
112
112
* Removes Sentry SDK logger statements from the bundle. Note that this doesn't affect Sentry Logs.
113
113
*/
114
114
removeDebugLogging?: boolean;
115
+
116
+
/**
117
+
* Setting this to true will treeshake any SDK code that is related to tracing and performance monitoring.
118
+
*/
119
+
removeTracing?: boolean;
120
+
121
+
/**
122
+
* Setting this flag to `true` will tree shake any SDK code related to capturing iframe content with Session Replay.
123
+
* It's only relevant when using Session Replay. Enable this flag if you don't want to record any iframes.
124
+
* This has no effect if you did not add `replayIntegration`.
125
+
*/
126
+
excludeReplayIframe?: boolean;
127
+
128
+
/**
129
+
* Setting this flag to `true` will tree shake any SDK code related to capturing shadow dom elements with Session Replay.
130
+
* It's only relevant when using Session Replay.
131
+
* Enable this flag if you don't want to record any shadow DOM elements.
132
+
* This has no effect if you did not add `replayIntegration`.
133
+
*/
134
+
excludeReplayShadowDOM?: boolean;
135
+
136
+
/**
137
+
* Setting this flag to `true` will tree shake any SDK code that is related to the included compression web worker for Session Replay.
138
+
* It's only relevant when using Session Replay.
139
+
* Enable this flag if you want to host a compression worker yourself.
140
+
* See Using a Custom Compression Worker for details.
141
+
* We don't recommend enabling this flag unless you provide a custom worker URL.
142
+
* This has no effect if you did not add `replayIntegration`.
143
+
*/
144
+
excludeReplayCompressionWorker?: boolean;
115
145
};
116
146
117
147
/**
@@ -403,38 +433,38 @@ export type SentryBuildOptions = {
403
433
*/
404
434
bundleSizeOptimizations?: {
405
435
/**
406
-
* If set to `true`, the Sentry SDK will attempt to tree-shake (remove) any debugging code within itself during the build.
436
+
* If set to `true`, the Sentry SDK will attempt to treeshake (remove) any debugging code within itself during the build.
407
437
* Note that the success of this depends on tree shaking being enabled in your build tooling.
408
438
*
409
439
* Setting this option to `true` will disable features like the SDK's `debug` option.
410
440
*/
411
441
excludeDebugStatements?: boolean;
412
442
413
443
/**
414
-
* If set to `true`, the Sentry SDK will attempt to tree-shake (remove) code within itself that is related to tracing and performance monitoring.
444
+
* If set to `true`, the Sentry SDK will attempt to treeshake (remove) code within itself that is related to tracing and performance monitoring.
415
445
* Note that the success of this depends on tree shaking being enabled in your build tooling.
416
446
* **Notice:** Do not enable this when you're using any performance monitoring-related SDK features (e.g. `Sentry.startTransaction()`).
417
447
*/
418
448
excludeTracing?: boolean;
419
449
420
450
/**
421
-
* If set to `true`, the Sentry SDK will attempt to tree-shake (remove) code related to the SDK's Session Replay Shadow DOM recording functionality.
451
+
* If set to `true`, the Sentry SDK will attempt to treeshake (remove) code related to the SDK's Session Replay Shadow DOM recording functionality.
422
452
* Note that the success of this depends on tree shaking being enabled in your build tooling.
423
453
*
424
454
* This option is safe to be used when you do not want to capture any Shadow DOM activity via Sentry Session Replay.
425
455
*/
426
456
excludeReplayShadowDom?: boolean;
427
457
428
458
/**
429
-
* If set to `true`, the Sentry SDK will attempt to tree-shake (remove) code related to the SDK's Session Replay `iframe` recording functionality.
459
+
* If set to `true`, the Sentry SDK will attempt to treeshake (remove) code related to the SDK's Session Replay `iframe` recording functionality.
430
460
* Note that the success of this depends on tree shaking being enabled in your build tooling.
431
461
*
432
462
* You can safely do this when you do not want to capture any `iframe` activity via Sentry Session Replay.
433
463
*/
434
464
excludeReplayIframe?: boolean;
435
465
436
466
/**
437
-
* If set to `true`, the Sentry SDK will attempt to tree-shake (remove) code related to the SDK's Session Replay's Compression Web Worker.
467
+
* If set to `true`, the Sentry SDK will attempt to treeshake (remove) code related to the SDK's Session Replay's Compression Web Worker.
438
468
* Note that the success of this depends on tree shaking being enabled in your build tooling.
439
469
*
440
470
* **Notice:** You should only use this option if you manually host a compression worker and configure it in your Sentry Session Replay integration config via the `workerUrl` option.
0 commit comments