diff --git a/packages/nextjs/src/client/index.ts b/packages/nextjs/src/client/index.ts index 10e1d94566af..5d8c6c46b911 100644 --- a/packages/nextjs/src/client/index.ts +++ b/packages/nextjs/src/client/index.ts @@ -6,6 +6,7 @@ import type { Client, EventProcessor, Integration } from '@sentry/types'; import { devErrorSymbolicationEventProcessor } from '../common/devErrorSymbolicationEventProcessor'; import { getVercelEnv } from '../common/getVercelEnv'; +import { isRedirectNavigationError } from '../common/nextNavigationErrorUtils'; import { browserTracingIntegration } from './browserTracingIntegration'; import { nextjsClientStackFrameNormalizationIntegration } from './clientNormalizationIntegration'; import { INCOMPLETE_APP_ROUTER_INSTRUMENTATION_TRANSACTION_NAME } from './routing/appRouterRoutingInstrumentation'; @@ -47,6 +48,11 @@ export function init(options: BrowserOptions): Client | undefined { filterIncompleteNavigationTransactions.id = 'IncompleteTransactionFilter'; addEventProcessor(filterIncompleteNavigationTransactions); + const filterNextRedirectError: EventProcessor = (event, hint) => + isRedirectNavigationError(hint?.originalException) ? null : event; + filterNextRedirectError.id = 'NextRedirectErrorFilter'; + addEventProcessor(filterNextRedirectError); + if (process.env.NODE_ENV === 'development') { addEventProcessor(devErrorSymbolicationEventProcessor); }