11import { Carrier , getHubFromCarrier , getMainCarrier } from '@sentry/hub' ;
22import { RewriteFrames } from '@sentry/integrations' ;
33import { configureScope , getCurrentHub , init as nodeInit , Integrations } from '@sentry/node' ;
4+ import { Event } from '@sentry/types' ;
45import { escapeStringForRegex , logger } from '@sentry/utils' ;
56import * as domainModule from 'domain' ;
67import * as path from 'path' ;
@@ -56,6 +57,8 @@ export function init(options: NextjsOptions): void {
5657 if ( process . env . VERCEL ) {
5758 scope . setTag ( 'vercel' , true ) ;
5859 }
60+
61+ scope . addEventProcessor ( filterTransactions ) ;
5962 } ) ;
6063
6164 if ( activeDomain ) {
@@ -65,6 +68,8 @@ export function init(options: NextjsOptions): void {
6568 // apply the changes made by `nodeInit` to the domain's hub also
6669 domainHub . bindClient ( globalHub . getClient ( ) ) ;
6770 domainHub . getScope ( ) ?. update ( globalHub . getScope ( ) ) ;
71+ // `scope.update()` doesn’t copy over event processors, so we have to add it manually
72+ domainHub . getScope ( ) ?. addEventProcessor ( filterTransactions ) ;
6873
6974 // restore the domain hub as the current one
7075 domain . active = activeDomain ;
@@ -107,6 +112,10 @@ function addServerIntegrations(options: NextjsOptions): void {
107112 }
108113}
109114
115+ function filterTransactions ( event : Event ) : Event | null {
116+ return event . type === 'transaction' && event . transaction === '/404' ? null : event ;
117+ }
118+
110119export { withSentryConfig } from './config' ;
111120export { withSentry } from './utils/withSentry' ;
112121
0 commit comments