Skip to content

Commit 15fcfea

Browse files
authored
feat(nextjs): Stabilize captureRequestError (#13550)
1 parent b4112b0 commit 15fcfea

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

dev-packages/e2e-tests/test-applications/nextjs-13/instrumentation.ts

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ export function register() {
1515
});
1616
}
1717
}
18+
19+
export const onRequestError = Sentry.captureRequestError;

dev-packages/e2e-tests/test-applications/nextjs-14/instrumentation.ts

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ export function register() {
1919
});
2020
}
2121
}
22+
23+
export const onRequestError = Sentry.captureRequestError;

dev-packages/e2e-tests/test-applications/nextjs-15/instrumentation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ export async function register() {
1010
}
1111
}
1212

13-
export const onRequestError = Sentry.experimental_captureRequestError;
13+
export const onRequestError = Sentry.captureRequestError;

dev-packages/e2e-tests/test-applications/nextjs-app-dir/instrumentation.ts

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ export function register() {
1515
});
1616
}
1717
}
18+
19+
export const onRequestError = Sentry.captureRequestError;

packages/nextjs/src/common/captureRequestError.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,9 @@ type ErrorContext = {
1313
};
1414

1515
/**
16-
* Reports errors for the Next.js `onRequestError` instrumentation hook.
17-
*
18-
* Notice: This function is experimental and not intended for production use. Breaking changes may be done to this funtion in any release.
19-
*
20-
* @experimental
16+
* Reports errors passed to the the Next.js `onRequestError` instrumentation hook.
2117
*/
22-
export function experimental_captureRequestError(
23-
error: unknown,
24-
request: RequestInfo,
25-
errorContext: ErrorContext,
26-
): void {
18+
export function captureRequestError(error: unknown, request: RequestInfo, errorContext: ErrorContext): void {
2719
withScope(scope => {
2820
scope.setSDKProcessingMetadata({
2921
request: {
@@ -48,3 +40,11 @@ export function experimental_captureRequestError(
4840
});
4941
});
5042
}
43+
44+
/**
45+
* Reports errors passed to the the Next.js `onRequestError` instrumentation hook.
46+
*
47+
* @deprecated Use `captureRequestError` instead.
48+
*/
49+
// TODO(v9): Remove this export
50+
export const experimental_captureRequestError = captureRequestError;

packages/nextjs/src/common/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ export { wrapMiddlewareWithSentry } from './wrapMiddlewareWithSentry';
1111
export { wrapPageComponentWithSentry } from './wrapPageComponentWithSentry';
1212
export { wrapGenerationFunctionWithSentry } from './wrapGenerationFunctionWithSentry';
1313
export { withServerActionInstrumentation } from './withServerActionInstrumentation';
14-
export { experimental_captureRequestError } from './captureRequestError';
14+
// eslint-disable-next-line deprecation/deprecation
15+
export { experimental_captureRequestError, captureRequestError } from './captureRequestError';

packages/nextjs/src/index.types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,5 @@ export declare function wrapApiHandlerWithSentryVercelCrons<F extends (...args:
141141
*/
142142
export declare function wrapPageComponentWithSentry<C>(WrappingTarget: C): C;
143143

144-
export { experimental_captureRequestError } from './common/captureRequestError';
144+
// eslint-disable-next-line deprecation/deprecation
145+
export { experimental_captureRequestError, captureRequestError } from './common/captureRequestError';

0 commit comments

Comments
 (0)