@@ -18,6 +18,7 @@ export { onUncaughtExceptionIntegration } from './onUncaughtExceptionIntegration
1818
1919const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
2020 __rewriteFramesDistDir__ ?: string ;
21+ __sentryRewritesTunnelPath__ ?: string ;
2122} ;
2223
2324/**
@@ -73,7 +74,9 @@ export function init(options: NodeOptions): void {
7374 }
7475
7576 const customDefaultIntegrations = [
76- ...getDefaultIntegrations ( options ) . filter ( integration => integration . name !== 'OnUncaughtException' ) ,
77+ ...getDefaultIntegrations ( options ) . filter (
78+ integration => integration . name !== 'OnUncaughtException' && integration . name !== 'NodeFetch' ,
79+ ) ,
7780 onUncaughtExceptionIntegration ( ) ,
7881 ] ;
7982
@@ -107,19 +110,49 @@ export function init(options: NodeOptions): void {
107110
108111 nodeInit ( opts ) ;
109112
110- const filterTransactions : EventProcessor = event => {
111- return event . type === 'transaction' && event . transaction === '/404' ? null : event ;
113+ const filterLowQualityTransactions : EventProcessor = event => {
114+ if ( event . type === 'transaction' ) {
115+ if ( event . transaction ?. match ( / G E T \/ .* \/ s t a t i c \/ .* .j s / ) ) {
116+ // TODO: Make this based on basePath and assetPrefix
117+ return null ;
118+ } else if (
119+ globalWithInjectedValues . __sentryRewritesTunnelPath__ &&
120+ event . transaction === `POST ${ globalWithInjectedValues . __sentryRewritesTunnelPath__ } `
121+ ) {
122+ return null ;
123+ } else if ( event . transaction ?. match ( / \/ _ _ n e x t j s _ o r i g i n a l - s t a c k - f r a m e / ) ) {
124+ return null ;
125+ } else if ( event . transaction === '/404' ) {
126+ return null ;
127+ }
128+
129+ return event ;
130+ } else {
131+ return event ;
132+ }
112133 } ;
113-
114- filterTransactions . id = 'NextServer404TransactionFilter' ;
134+ filterLowQualityTransactions . id = 'NextLowQualityTransactionsFilter' ;
135+ addEventProcessor ( filterLowQualityTransactions ) ;
136+
137+ const filterSentrySpans : EventProcessor = event => {
138+ if ( event . type === 'transaction' ) {
139+ event . spans = event . spans ?. filter (
140+ span =>
141+ ! span . data ?. [ 'http.target' ] ?. includes ( 'sentry_client' ) && ! span . data ?. [ 'http.target' ] ?. includes ( 'sentry_key' ) ,
142+ ) ;
143+ event . spans = event . spans ?. filter ( span => ! span . data ?. [ 'http.url' ] ?. includes ( '__nextjs_original-stack-frame' ) ) ;
144+ }
145+
146+ return event ;
147+ } ;
148+ filterSentrySpans . id = 'NextFilterSentrySpans' ;
149+ addEventProcessor ( filterSentrySpans ) ;
115150
116151 setTag ( 'runtime' , 'node' ) ;
117152 if ( IS_VERCEL ) {
118153 setTag ( 'vercel' , true ) ;
119154 }
120155
121- addEventProcessor ( filterTransactions ) ;
122-
123156 if ( process . env . NODE_ENV === 'development' ) {
124157 addEventProcessor ( devErrorSymbolicationEventProcessor ) ;
125158 }
0 commit comments