Skip to content

Commit adad4bd

Browse files
cursoragentchargome
andcommitted
Add React component annotation configuration option to Sentry Next.js SDK
Co-authored-by: charly.gomez <[email protected]>
1 parent 5b3f314 commit adad4bd

File tree

1 file changed

+24
-0
lines changed
  • docs/platforms/javascript/guides/nextjs/configuration/build

1 file changed

+24
-0
lines changed

docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,30 @@ The route manifest is a build-time generated mapping of your Next.js App Router
268268

269269
</SdkOption>
270270

271+
<SdkOption name="reactComponentAnnotation" type="object | undefined">
272+
273+
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.
274+
275+
This option accepts an object with the following property:
276+
277+
- `enabled` (boolean): Whether to enable React component annotation. Defaults to `false`.
278+
279+
```javascript
280+
withSentryConfig(nextConfig, {
281+
reactComponentAnnotation: {
282+
enabled: true,
283+
},
284+
});
285+
```
286+
287+
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.
288+
289+
<Alert level="info">
290+
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.
291+
</Alert>
292+
293+
</SdkOption>
294+
271295
<SdkOption
272296
name="unstable_sentryWebpackPluginOptions"
273297
type="SentryWebpackPluginOptions"

0 commit comments

Comments
 (0)