From adad4bdc4adede8ea1ad3ee844c1b6eb562abd73 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 5 Aug 2025 15:05:56 +0000 Subject: [PATCH] Add React component annotation configuration option to Sentry Next.js SDK Co-authored-by: charly.gomez --- .../nextjs/configuration/build/index.mdx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx b/docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx index 68a8f35337172..4ea93272b9850 100644 --- a/docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx +++ b/docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx @@ -268,6 +268,30 @@ The route manifest is a build-time generated mapping of your Next.js App Router + + +Enables React component name tracking. When enabled, it annotates React components with data attributes that allow Sentry to track which components users interacted with in features like Session Replay and breadcrumbs. + +This option accepts an object with the following property: + +- `enabled` (boolean): Whether to enable React component annotation. Defaults to `false`. + +```javascript +withSentryConfig(nextConfig, { + reactComponentAnnotation: { + enabled: true, + }, +}); +``` + +When enabled, the Sentry Metro plugin applies `@sentry/babel-plugin-component-annotate`, which parses your application's JSX source code at build time and adds `data-sentry-component` and `data-sentry-source-file` attributes to your components. This helps identify exactly which React component was interacted with, removing ambiguity from generic element names. + + + This feature requires components to be in `.jsx` or `.tsx` file formats. Only components in your project (outside of `node_modules`) are annotated by default. + + + +