Skip to content

Commit 48b4129

Browse files
authored
feat(nextjs): Add flag for suppressing router transition warning (#16823)
1 parent e4cf7e8 commit 48b4129

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/nextjs/src/config/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,11 @@ export type SentryBuildOptions = {
462462
*/
463463
errorHandler?: (err: Error) => void;
464464

465+
/**
466+
* Suppress the warning about the `onRouterTransitionStart` hook.
467+
*/
468+
suppressOnRouterTransitionStartWarning?: boolean;
469+
465470
/**
466471
* Contains a set of experimental flags that might change in future releases. These flags enable
467472
* features that are still in development and may be modified, renamed, or removed without notice.

packages/nextjs/src/config/withSentryConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ function getFinalConfigObject(
236236
const instrumentationClientFileContents = getInstrumentationClientFileContents();
237237
if (
238238
instrumentationClientFileContents !== undefined &&
239-
!instrumentationClientFileContents.includes('onRouterTransitionStart')
239+
!instrumentationClientFileContents.includes('onRouterTransitionStart') &&
240+
!userSentryOptions.suppressOnRouterTransitionStartWarning
240241
) {
241242
// eslint-disable-next-line no-console
242243
console.warn(

0 commit comments

Comments
 (0)