A Babel plugin that automatically annotates your output DOM with their respective frontend component names.
This will unlock the capability to search for Replays in Sentry by component name, as well as see component names in breadcrumbs and performance monitoring.
Please note that your Sentry JavaScript SDK version must be at least 7.91.0
to take advantage of these features.
Currently, this plugin only works with React, and will exclusively parse .jsx
and .tsx
files.
This plugin comes included in Sentry's bundler plugins, alongside many other features to improve your Sentry workflow. It can be downloaded individually, but it is recommended that you install the bundler plugins for your respective bundler, and enable this feature through the config object.
Check out the supported bundler plugin packages for installation instructions:
Using npm:
npm install @sentry/babel-plugin-component-annotate --save-dev
Using yarn:
yarn add @sentry/babel-plugin-component-annotate --dev
Using pnpm:
pnpm add @sentry/babel-plugin-component-annotate --save-dev
Type: string[]
A list of strings representing the names of components to ignore. The plugin will not apply data-sentry
annotations on the DOM element for these components.
// babel.config.js
{
// ... other config above ...
plugins: [
// Put this plugin before any other plugins you have that transform JSX code
// The options are set by providing an object as the second element in the array, but not required
['@sentry/babel-plugin-component-annotate', {ignoredComponents: ['Foo', 'Bar']}]
],
}
Or alternatively, configure the plugin by directly importing it:
// babel.config.js
import componentNameAnnotatePlugin from '@sentry/babel-plugin-component-annotate';
{
// ... other config above ...
plugins: [
// Put this plugin before any other plugins you have that transform JSX code
[componentNameAnnotatePlugin]
],
}