From e3a794e1fd15c9b777bfc4a71401498238b4e086 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Thu, 11 Jul 2024 07:13:28 +0000 Subject: [PATCH] docs(nextjs): Clarify which API wrappers are intended for which router ref https://github.com/getsentry/sentry-javascript/issues/12865 --- packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts | 4 +++- packages/nextjs/src/index.types.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts b/packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts index e55eedd9802e..bf0d475603f2 100644 --- a/packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts +++ b/packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts @@ -22,7 +22,9 @@ import { import { vercelWaitUntil } from './utils/vercelWaitUntil'; /** - * Wraps a Next.js route handler with performance and error instrumentation. + * Wraps a Next.js App Router Route handler with Sentry error and performance instrumentation. + * + * NOTICE: This wrapper is for App Router API routes. If you are looking to wrap Pages Router API routes use `wrapApiHandlerWithSentry` instead. */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export function wrapRouteHandlerWithSentry any>( diff --git a/packages/nextjs/src/index.types.ts b/packages/nextjs/src/index.types.ts index 629560b96312..afff0bd98a19 100644 --- a/packages/nextjs/src/index.types.ts +++ b/packages/nextjs/src/index.types.ts @@ -41,7 +41,9 @@ export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metric export { withSentryConfig } from './config'; /** - * Wraps a Next.js API handler with Sentry error and performance instrumentation. + * Wraps a Next.js Pages Router API route with Sentry error and performance instrumentation. + * + * NOTICE: This wrapper is for Pages Router API routes. If you are looking to wrap App Router API routes use `wrapRouteHandlerWithSentry` instead. * * @param handler The handler exported from the API route file. * @param parameterizedRoute The page's parameterized route.