Skip to content

Commit 076c4df

Browse files
committed
conditionally capture
1 parent 805e1af commit 076c4df

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/nextjs/src/common/wrapServerComponentWithSentry.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,31 @@ export function wrapServerComponentWithSentry<F extends (...args: any[]) => any>
4242
const isolationScope = getIsolationScope();
4343
const span = getActiveSpan();
4444
const { componentRoute, componentType } = context;
45+
let shouldCapture = false;
4546
isolationScope.setTransactionName(`${componentType} Server Component (${componentRoute})`);
4647

4748
if (span) {
4849
if (isNotFoundNavigationError(error)) {
50+
shouldCapture = false;
4951
// We don't want to report "not-found"s
5052
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' });
5153
} else if (isRedirectNavigationError(error)) {
54+
shouldCapture = false;
5255
// We don't want to report redirects
5356
span.setStatus({ code: SPAN_STATUS_OK });
5457
} else {
5558
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
5659
}
5760
}
5861

59-
captureException(error, {
60-
mechanism: {
61-
handled: false,
62-
type: 'auto.function.nextjs.server_component',
63-
},
64-
});
62+
if (shouldCapture) {
63+
captureException(error, {
64+
mechanism: {
65+
handled: false,
66+
type: 'auto.function.nextjs.server_component',
67+
},
68+
});
69+
}
6570
},
6671
() => {
6772
waitUntil(flushSafelyWithTimeout());

0 commit comments

Comments
 (0)