diff --git a/babel.config.ts b/babel.config.ts index f7cebd18e6a222..b7ba2975e6f28a 100644 --- a/babel.config.ts +++ b/babel.config.ts @@ -44,12 +44,14 @@ const config: TransformOptions = { }, ], ['babel-plugin-add-react-displayname'], + '@sentry/babel-plugin-component-annotate', ], }, development: { plugins: [ '@emotion/babel-plugin', '@babel/plugin-transform-react-jsx-source', + '@sentry/babel-plugin-component-annotate', ...(process.env.SENTRY_UI_HOT_RELOAD ? ['react-refresh/babel'] : []), ], }, diff --git a/package.json b/package.json index 37a1e7367bfcb6..3e770de06be568 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "@sentry-internal/rrweb": "2.9.0", "@sentry-internal/rrweb-player": "2.9.0", "@sentry-internal/rrweb-snapshot": "2.9.0", + "@sentry/babel-plugin-component-annotate": "^2.14.0", "@sentry/core": "^7.99.0", "@sentry/integrations": "^7.99.0", "@sentry/node": "^7.99.0", diff --git a/static/app/utils/performanceForSentry/index.tsx b/static/app/utils/performanceForSentry/index.tsx index d66a0e794fc846..a4935334af9c86 100644 --- a/static/app/utils/performanceForSentry/index.tsx +++ b/static/app/utils/performanceForSentry/index.tsx @@ -604,7 +604,9 @@ function getNearestElementName(node: HTMLElement | undefined | null): string | u let current: HTMLElement | null = node; while (current && current !== document.body) { const elementName = - current.dataset?.testId ?? current.dataset?.component ?? current.dataset?.element; + current.dataset?.testId ?? + current.dataset?.sentryComponent ?? + current.dataset?.element; if (elementName) { return elementName; diff --git a/yarn.lock b/yarn.lock index ace868ee7d4397..2db61ec20bca7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2858,6 +2858,11 @@ "@sentry/types" "7.99.0" "@sentry/utils" "7.99.0" +"@sentry/babel-plugin-component-annotate@^2.14.0": + version "2.14.0" + resolved "https://registry.yarnpkg.com/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-2.14.0.tgz#e62f448dd3c922a6d32e9f1c0a5ae85fa6ec22c2" + integrity sha512-FWU4+Lx6fgxjAkwmc3S9j1Q/6pqKZyZzfi52B+8WMNw7a5QjGXgxc5ucBazZYgrcsJKCFBp4QG3PPxNAieFimQ== + "@sentry/browser@7.99.0": version "7.99.0" resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.99.0.tgz#3e78beb490d141c988038ea902689a1e9171c6cf"