diff --git a/dev-packages/e2e-tests/test-applications/nextjs-13/instrumentation.ts b/dev-packages/e2e-tests/test-applications/nextjs-13/instrumentation.ts index 1f889238427c..180685d41b4a 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-13/instrumentation.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-13/instrumentation.ts @@ -15,3 +15,5 @@ export function register() { }); } } + +export const onRequestError = Sentry.captureRequestError; diff --git a/dev-packages/e2e-tests/test-applications/nextjs-14/instrumentation.ts b/dev-packages/e2e-tests/test-applications/nextjs-14/instrumentation.ts index 0999fdd8e089..2dd920dfcc73 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-14/instrumentation.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-14/instrumentation.ts @@ -19,3 +19,5 @@ export function register() { }); } } + +export const onRequestError = Sentry.captureRequestError; diff --git a/dev-packages/e2e-tests/test-applications/nextjs-15/instrumentation.ts b/dev-packages/e2e-tests/test-applications/nextjs-15/instrumentation.ts index ca4a213e58ba..964f937c439a 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-15/instrumentation.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-15/instrumentation.ts @@ -10,4 +10,4 @@ export async function register() { } } -export const onRequestError = Sentry.experimental_captureRequestError; +export const onRequestError = Sentry.captureRequestError; diff --git a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/instrumentation.ts b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/instrumentation.ts index cd269ab160e7..a95bb9ee95ee 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/instrumentation.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/instrumentation.ts @@ -15,3 +15,5 @@ export function register() { }); } } + +export const onRequestError = Sentry.captureRequestError; diff --git a/packages/nextjs/src/common/captureRequestError.ts b/packages/nextjs/src/common/captureRequestError.ts index 8350a0f2e593..1556076619a0 100644 --- a/packages/nextjs/src/common/captureRequestError.ts +++ b/packages/nextjs/src/common/captureRequestError.ts @@ -13,17 +13,9 @@ type ErrorContext = { }; /** - * Reports errors for the Next.js `onRequestError` instrumentation hook. - * - * Notice: This function is experimental and not intended for production use. Breaking changes may be done to this funtion in any release. - * - * @experimental + * Reports errors passed to the the Next.js `onRequestError` instrumentation hook. */ -export function experimental_captureRequestError( - error: unknown, - request: RequestInfo, - errorContext: ErrorContext, -): void { +export function captureRequestError(error: unknown, request: RequestInfo, errorContext: ErrorContext): void { withScope(scope => { scope.setSDKProcessingMetadata({ request: { @@ -48,3 +40,11 @@ export function experimental_captureRequestError( }); }); } + +/** + * Reports errors passed to the the Next.js `onRequestError` instrumentation hook. + * + * @deprecated Use `captureRequestError` instead. + */ +// TODO(v9): Remove this export +export const experimental_captureRequestError = captureRequestError; diff --git a/packages/nextjs/src/common/index.ts b/packages/nextjs/src/common/index.ts index 23ddfa383772..354113637a30 100644 --- a/packages/nextjs/src/common/index.ts +++ b/packages/nextjs/src/common/index.ts @@ -11,4 +11,5 @@ export { wrapMiddlewareWithSentry } from './wrapMiddlewareWithSentry'; export { wrapPageComponentWithSentry } from './wrapPageComponentWithSentry'; export { wrapGenerationFunctionWithSentry } from './wrapGenerationFunctionWithSentry'; export { withServerActionInstrumentation } from './withServerActionInstrumentation'; -export { experimental_captureRequestError } from './captureRequestError'; +// eslint-disable-next-line deprecation/deprecation +export { experimental_captureRequestError, captureRequestError } from './captureRequestError'; diff --git a/packages/nextjs/src/index.types.ts b/packages/nextjs/src/index.types.ts index b093968bdebe..a272990162b3 100644 --- a/packages/nextjs/src/index.types.ts +++ b/packages/nextjs/src/index.types.ts @@ -141,4 +141,5 @@ export declare function wrapApiHandlerWithSentryVercelCrons(WrappingTarget: C): C; -export { experimental_captureRequestError } from './common/captureRequestError'; +// eslint-disable-next-line deprecation/deprecation +export { experimental_captureRequestError, captureRequestError } from './common/captureRequestError';