Skip to content

Commit 7c9bc1d

Browse files
cursoragentLms24
andcommitted
Refactor error mechanism types across Sentry integrations
Co-authored-by: lukas.stracke <[email protected]>
1 parent 21b8e54 commit 7c9bc1d

File tree

8 files changed

+11
-7
lines changed

8 files changed

+11
-7
lines changed

packages/core/src/client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,10 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
11591159
}
11601160

11611161
this.captureException(reason, {
1162+
mechanism: {
1163+
handled: false,
1164+
type: 'internal',
1165+
},
11621166
data: {
11631167
__sentry__: true,
11641168
},

packages/nextjs/src/common/pages-router-instrumentation/_error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function captureUnderscoreErrorException(contextOrProps: ContextOrP
4545
// is what passing a string to `captureException` will wind up doing)
4646
captureException(err || `_error.js called with falsy error (${err})`, {
4747
mechanism: {
48-
type: 'instrument',
48+
type: 'nextjs.error',
4949
handled: false,
5050
data: {
5151
function: '_error.getInitialProps',

packages/nextjs/src/common/pages-router-instrumentation/wrapApiHandlerWithSentry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function wrapApiHandlerWithSentry(apiHandler: NextApiHandler, parameteriz
110110

111111
captureException(objectifiedErr, {
112112
mechanism: {
113-
type: 'instrument',
113+
type: 'nextjs.api',
114114
handled: false,
115115
data: {
116116
wrapped_handler: wrappingTarget.name,

packages/nextjs/src/common/wrapMiddlewareWithSentry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function wrapMiddlewareWithSentry<H extends EdgeRouteHandler>(
102102
error => {
103103
captureException(error, {
104104
mechanism: {
105-
type: 'instrument',
105+
type: 'nextjs.middleware',
106106
handled: false,
107107
},
108108
});

packages/nextjs/src/edge/wrapApiHandlerWithSentry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function wrapApiHandlerWithSentry<H extends EdgeRouteHandler>(
8282
error => {
8383
captureException(error, {
8484
mechanism: {
85-
type: 'instrument',
85+
type: 'nextjs.edge',
8686
handled: false,
8787
},
8888
});

packages/node-core/src/integrations/childProcess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function captureWorkerThreadEvents(worker: Worker, options: Options): void {
9999
.on('error', error => {
100100
if (options.captureWorkerErrors !== false) {
101101
captureException(error, {
102-
mechanism: { type: 'instrument', handled: false, data: { threadId: String(threadId) } },
102+
mechanism: { type: 'worker_thread', handled: false, data: { threadId: String(threadId) } },
103103
});
104104
} else {
105105
addBreadcrumb({

packages/react/src/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function reactErrorHandler(
9595
): (error: any, errorInfo: ErrorInfo) => void {
9696
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9797
return (error: any, errorInfo: ErrorInfo) => {
98-
const eventId = captureReactException(error, errorInfo);
98+
const eventId = captureReactException(error, errorInfo, { mechanism: { handled: false, type: 'react' } });
9999
if (callback) {
100100
callback(error, errorInfo, eventId);
101101
}

packages/react/src/errorboundary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
123123
}
124124

125125
const handled = this.props.handled != null ? this.props.handled : !!this.props.fallback;
126-
const eventId = captureReactException(error, errorInfo, { mechanism: { handled } });
126+
const eventId = captureReactException(error, errorInfo, { mechanism: { handled, type: 'react' } });
127127

128128
if (onError) {
129129
onError(error, componentStack, eventId);

0 commit comments

Comments
 (0)