@@ -113,60 +113,65 @@ export function init(options: NodeOptions): void {
113
113
114
114
nodeInit ( opts ) ;
115
115
116
- const filterLowQualityTransactions : EventProcessor = event => {
117
- if ( event . type === 'transaction' ) {
118
- // Filter out transactions for static assets
119
- // This regex matches the default path to the static assets (`_next/static`) and could potentially filter out too many transactions.
120
- // We match `/_next/static/` anywhere in the transaction name because its location may change with the basePath setting.
121
- if ( event . transaction ?. match ( / ^ G E T ( \/ .* ) ? \/ _ n e x t \/ s t a t i c \/ / ) ) {
122
- return null ;
123
- }
124
-
125
- // Filter out transactions for requests to the tunnel route
126
- if (
127
- globalWithInjectedValues . __sentryRewritesTunnelPath__ &&
128
- event . transaction === `POST ${ globalWithInjectedValues . __sentryRewritesTunnelPath__ } `
129
- ) {
130
- return null ;
131
- }
132
-
133
- // Filter out requests to resolve source maps for stack frames in dev mode
134
- 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 / ) ) {
135
- return null ;
136
- }
137
-
138
- return event ;
139
- } else {
140
- return event ;
141
- }
142
- } ;
143
- filterLowQualityTransactions . id = 'NextLowQualityTransactionsFilter' ;
144
- addEventProcessor ( filterLowQualityTransactions ) ;
145
-
146
- const filterSentrySpans : EventProcessor = event => {
147
- if ( event . type === 'transaction' ) {
148
- event . spans = event . spans ?. filter ( span => {
149
- // Filter out spans for Sentry event sends
150
- const httpTargetAttribute : unknown = span . data ?. [ 'http.target' ] ;
151
- if ( typeof httpTargetAttribute === 'string' ) {
152
- // TODO: Find a more robust matching logic
153
- return ! httpTargetAttribute . includes ( 'sentry_client' ) && ! httpTargetAttribute . includes ( 'sentry_key' ) ;
116
+ addEventProcessor (
117
+ Object . assign (
118
+ ( event => {
119
+ if ( event . type === 'transaction' ) {
120
+ // Filter out transactions for static assets
121
+ // This regex matches the default path to the static assets (`_next/static`) and could potentially filter out too many transactions.
122
+ // We match `/_next/static/` anywhere in the transaction name because its location may change with the basePath setting.
123
+ if ( event . transaction ?. match ( / ^ G E T ( \/ .* ) ? \/ _ n e x t \/ s t a t i c \/ / ) ) {
124
+ return null ;
125
+ }
126
+
127
+ // Filter out transactions for requests to the tunnel route
128
+ if (
129
+ globalWithInjectedValues . __sentryRewritesTunnelPath__ &&
130
+ event . transaction === `POST ${ globalWithInjectedValues . __sentryRewritesTunnelPath__ } `
131
+ ) {
132
+ return null ;
133
+ }
134
+
135
+ // Filter out requests to resolve source maps for stack frames in dev mode
136
+ 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 / ) ) {
137
+ return null ;
138
+ }
139
+
140
+ // Filter out /404 transactions for pages-router which seem to be created excessively
141
+ if ( event . transaction === '/404' ) {
142
+ return null ;
143
+ }
144
+
145
+ return event ;
146
+ } else {
147
+ return event ;
154
148
}
155
-
156
- // Filter out requests to resolve source maps for stack frames in dev mode
157
- const httpUrlAttribute : unknown = span . data ?. [ 'http.url' ] ;
158
- if ( typeof httpUrlAttribute === 'string' ) {
159
- return ! httpUrlAttribute . includes ( '__nextjs_original-stack-frame' ) ;
149
+ } ) satisfies EventProcessor ,
150
+ { id : 'NextLowQualityTransactionsFilter' } ,
151
+ ) ,
152
+ ) ;
153
+
154
+ addEventProcessor (
155
+ Object . assign (
156
+ ( event => {
157
+ if ( event . type === 'transaction' ) {
158
+ event . spans = event . spans ?. filter ( span => {
159
+ // Filter out spans for Sentry event sends
160
+ const httpTargetAttribute : unknown = span . data ?. [ 'http.target' ] ;
161
+ if ( typeof httpTargetAttribute === 'string' ) {
162
+ // TODO: Find a more robust matching logic - We likely want to use the OTEL SDK's `suppressTracing` in our transport, if we end up using it, we can delete this filtering logic here.
163
+ return ! httpTargetAttribute . includes ( 'sentry_client' ) && ! httpTargetAttribute . includes ( 'sentry_key' ) ;
164
+ }
165
+
166
+ return true ;
167
+ } ) ;
160
168
}
161
169
162
- return true ;
163
- } ) ;
164
- }
165
-
166
- return event ;
167
- } ;
168
- filterSentrySpans . id = 'NextFilterSentrySpans' ;
169
- addEventProcessor ( filterSentrySpans ) ;
170
+ return event ;
171
+ } ) satisfies EventProcessor ,
172
+ { id : 'NextFilterSentrySpans' } ,
173
+ ) ,
174
+ ) ;
170
175
171
176
// TODO(v8): Remove these tags
172
177
setTag ( 'runtime' , 'node' ) ;
0 commit comments