Skip to content

Commit ca3a024

Browse files
author
Luca Forstner
committed
filtering logic
1 parent 6dceb58 commit ca3a024

File tree

2 files changed

+56
-7
lines changed

2 files changed

+56
-7
lines changed

dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ const DEPENDENTS: Dependent[] = [
6868
// Next.js doesn't require explicit exports, so we can just merge top level and `default` exports:
6969
// @ts-expect-error: `default` is not in the type definition but it's defined
7070
exports: Object.keys({ ...SentryNextJs, ...SentryNextJs.default }),
71+
ignoreExports: [
72+
// legacy, to be removed...
73+
'Handlers',
74+
// legacy, to be removed...
75+
'Integrations',
76+
// legacy, to be removed...
77+
'addGlobalEventProcessor',
78+
// legacy, to be removed...
79+
'autoDiscoverNodePerformanceMonitoringIntegrations',
80+
// legacy, to be removed...
81+
'getActiveTransaction',
82+
// legacy, to be removed...
83+
'hapiErrorPlugin',
84+
// legacy, to be removed...
85+
'makeMain',
86+
],
7187
},
7288
{
7389
package: '@sentry/remix',

packages/nextjs/src/server/index.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export { onUncaughtExceptionIntegration } from './onUncaughtExceptionIntegration
1818

1919
const 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(/GET \/.*\/static\/.*.js/)) {
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(/\/__nextjs_original-stack-frame/)) {
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

Comments
 (0)