@sentry/bundler-plugins 11.12.0 → 11.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  2. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  3. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  4. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  5. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  6. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  7. package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
  8. package/build/cjs/babel-plugin/component-annotation.js +14 -32
  9. package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
  10. package/build/cjs/babel-plugin/constants.js +140 -122
  11. package/build/cjs/babel-plugin/constants.js.map +1 -1
  12. package/build/cjs/babel-plugin/experimental.js +204 -307
  13. package/build/cjs/babel-plugin/experimental.js.map +1 -1
  14. package/build/cjs/babel-plugin/index.js +315 -437
  15. package/build/cjs/babel-plugin/index.js.map +1 -1
  16. package/build/cjs/bun/index.js +81 -117
  17. package/build/cjs/bun/index.js.map +1 -1
  18. package/build/cjs/core/build-plugin-manager.js +626 -702
  19. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  20. package/build/cjs/core/cli.js +134 -129
  21. package/build/cjs/core/cli.js.map +1 -1
  22. package/build/cjs/core/component-annotate-hooks.js +16 -27
  23. package/build/cjs/core/component-annotate-hooks.js.map +1 -1
  24. package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
  25. package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
  26. package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
  27. package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
  28. package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
  29. package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
  30. package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
  31. package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
  32. package/build/cjs/core/component-annotation-oxc.js +68 -103
  33. package/build/cjs/core/component-annotation-oxc.js.map +1 -1
  34. package/build/cjs/core/debug-id-upload.js +223 -234
  35. package/build/cjs/core/debug-id-upload.js.map +1 -1
  36. package/build/cjs/core/get-code-injection-position.js +59 -74
  37. package/build/cjs/core/get-code-injection-position.js.map +1 -1
  38. package/build/cjs/core/glob.js +9 -7
  39. package/build/cjs/core/glob.js.map +1 -1
  40. package/build/cjs/core/index.js +77 -61
  41. package/build/cjs/core/index.js.map +1 -1
  42. package/build/cjs/core/logger.js +17 -26
  43. package/build/cjs/core/logger.js.map +1 -1
  44. package/build/cjs/core/options-mapping.js +95 -117
  45. package/build/cjs/core/options-mapping.js.map +1 -1
  46. package/build/cjs/core/sentry/telemetry.js +90 -105
  47. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  48. package/build/cjs/core/sentry/transports.js +92 -99
  49. package/build/cjs/core/sentry/transports.js.map +1 -1
  50. package/build/cjs/core/sourcemap-settings.js +98 -61
  51. package/build/cjs/core/sourcemap-settings.js.map +1 -1
  52. package/build/cjs/core/upload-filter.js +41 -46
  53. package/build/cjs/core/upload-filter.js.map +1 -1
  54. package/build/cjs/core/utils.js +228 -219
  55. package/build/cjs/core/utils.js.map +1 -1
  56. package/build/cjs/core/version.js +4 -5
  57. package/build/cjs/core/version.js.map +1 -1
  58. package/build/cjs/esbuild/index.js +180 -211
  59. package/build/cjs/esbuild/index.js.map +1 -1
  60. package/build/cjs/loader-utils/index.js +5 -10
  61. package/build/cjs/rollup/debug-id-injection.js +22 -38
  62. package/build/cjs/rollup/debug-id-injection.js.map +1 -1
  63. package/build/cjs/rollup/debug-id-stamping.js +14 -24
  64. package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
  65. package/build/cjs/rollup/index.js +192 -246
  66. package/build/cjs/rollup/index.js.map +1 -1
  67. package/build/cjs/rollup/source-map-handling.js +151 -175
  68. package/build/cjs/rollup/source-map-handling.js.map +1 -1
  69. package/build/cjs/vite/index.js +19 -21
  70. package/build/cjs/vite/index.js.map +1 -1
  71. package/build/cjs/vite/source-map-hooks.js +112 -89
  72. package/build/cjs/vite/source-map-hooks.js.map +1 -1
  73. package/build/cjs/webpack/component-annotation-transform.js +20 -26
  74. package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
  75. package/build/cjs/webpack/index.js +271 -340
  76. package/build/cjs/webpack/index.js.map +1 -1
  77. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  78. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  79. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  80. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  81. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  82. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  83. package/build/esm/_virtual/_rolldown/runtime.js +2 -0
  84. package/build/esm/babel-plugin/component-annotation.js +13 -29
  85. package/build/esm/babel-plugin/component-annotation.js.map +1 -1
  86. package/build/esm/babel-plugin/constants.js +140 -120
  87. package/build/esm/babel-plugin/constants.js.map +1 -1
  88. package/build/esm/babel-plugin/experimental.js +204 -305
  89. package/build/esm/babel-plugin/experimental.js.map +1 -1
  90. package/build/esm/babel-plugin/index.js +311 -434
  91. package/build/esm/babel-plugin/index.js.map +1 -1
  92. package/build/esm/bun/index.js +76 -101
  93. package/build/esm/bun/index.js.map +1 -1
  94. package/build/esm/core/build-plugin-manager.js +621 -683
  95. package/build/esm/core/build-plugin-manager.js.map +1 -1
  96. package/build/esm/core/cli.js +134 -127
  97. package/build/esm/core/cli.js.map +1 -1
  98. package/build/esm/core/component-annotate-hooks.js +16 -25
  99. package/build/esm/core/component-annotate-hooks.js.map +1 -1
  100. package/build/esm/core/component-annotation-oxc-ast.js +9 -19
  101. package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
  102. package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
  103. package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
  104. package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
  105. package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
  106. package/build/esm/core/component-annotation-oxc-walk.js +61 -121
  107. package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
  108. package/build/esm/core/component-annotation-oxc.js +65 -96
  109. package/build/esm/core/component-annotation-oxc.js.map +1 -1
  110. package/build/esm/core/debug-id-upload.js +218 -213
  111. package/build/esm/core/debug-id-upload.js.map +1 -1
  112. package/build/esm/core/get-code-injection-position.js +59 -72
  113. package/build/esm/core/get-code-injection-position.js.map +1 -1
  114. package/build/esm/core/glob.js +9 -5
  115. package/build/esm/core/glob.js.map +1 -1
  116. package/build/esm/core/index.js +62 -47
  117. package/build/esm/core/index.js.map +1 -1
  118. package/build/esm/core/logger.js +17 -24
  119. package/build/esm/core/logger.js.map +1 -1
  120. package/build/esm/core/options-mapping.js +95 -115
  121. package/build/esm/core/options-mapping.js.map +1 -1
  122. package/build/esm/core/sentry/telemetry.js +89 -102
  123. package/build/esm/core/sentry/telemetry.js.map +1 -1
  124. package/build/esm/core/sentry/transports.js +90 -83
  125. package/build/esm/core/sentry/transports.js.map +1 -1
  126. package/build/esm/core/sourcemap-settings.js +96 -59
  127. package/build/esm/core/sourcemap-settings.js.map +1 -1
  128. package/build/esm/core/upload-filter.js +39 -30
  129. package/build/esm/core/upload-filter.js.map +1 -1
  130. package/build/esm/core/utils.js +221 -209
  131. package/build/esm/core/utils.js.map +1 -1
  132. package/build/esm/core/version.js +4 -3
  133. package/build/esm/core/version.js.map +1 -1
  134. package/build/esm/esbuild/index.js +176 -195
  135. package/build/esm/esbuild/index.js.map +1 -1
  136. package/build/esm/loader-utils/index.js +4 -3
  137. package/build/esm/package.json +1 -1
  138. package/build/esm/rollup/debug-id-injection.js +22 -36
  139. package/build/esm/rollup/debug-id-injection.js.map +1 -1
  140. package/build/esm/rollup/debug-id-stamping.js +14 -22
  141. package/build/esm/rollup/debug-id-stamping.js.map +1 -1
  142. package/build/esm/rollup/index.js +189 -226
  143. package/build/esm/rollup/index.js.map +1 -1
  144. package/build/esm/rollup/source-map-handling.js +149 -159
  145. package/build/esm/rollup/source-map-handling.js.map +1 -1
  146. package/build/esm/vite/index.js +19 -18
  147. package/build/esm/vite/index.js.map +1 -1
  148. package/build/esm/vite/source-map-hooks.js +109 -72
  149. package/build/esm/vite/source-map-hooks.js.map +1 -1
  150. package/build/esm/webpack/component-annotation-transform.js +17 -24
  151. package/build/esm/webpack/component-annotation-transform.js.map +1 -1
  152. package/build/esm/webpack/index.js +268 -322
  153. package/build/esm/webpack/index.js.map +1 -1
  154. package/build/types/core/build-plugin-manager.d.ts +16 -5
  155. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  156. package/build/types/core/cli.d.ts +6 -1
  157. package/build/types/core/cli.d.ts.map +1 -1
  158. package/build/types/core/debug-id-upload.d.ts +7 -4
  159. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  160. package/build/types/core/index.d.ts +3 -3
  161. package/build/types/core/index.d.ts.map +1 -1
  162. package/build/types/core/options-mapping.d.ts +4 -3
  163. package/build/types/core/options-mapping.d.ts.map +1 -1
  164. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  165. package/build/types/core/sourcemap-settings.d.ts +10 -1
  166. package/build/types/core/sourcemap-settings.d.ts.map +1 -1
  167. package/build/types/core/types.d.ts +25 -1
  168. package/build/types/core/types.d.ts.map +1 -1
  169. package/build/types/core/utils.d.ts +4 -0
  170. package/build/types/core/utils.d.ts.map +1 -1
  171. package/build/types/core/version.d.ts +1 -1
  172. package/build/types/esbuild/index.d.ts +2 -2
  173. package/build/types/esbuild/index.d.ts.map +1 -1
  174. package/build/types/rollup/index.d.ts +2 -2
  175. package/build/types/rollup/index.d.ts.map +1 -1
  176. package/build/types/rollup/source-map-handling.d.ts.map +1 -1
  177. package/build/types/vite/index.d.ts +3 -3
  178. package/build/types/vite/index.d.ts.map +1 -1
  179. package/build/types/vite/source-map-hooks.d.ts.map +1 -1
  180. package/build/types/webpack/index.d.ts +7 -3
  181. package/build/types/webpack/index.d.ts.map +1 -1
  182. package/package.json +8 -15
  183. package/build/cjs/loader-utils/index.js.map +0 -1
  184. package/build/esm/loader-utils/index.js.map +0 -1
@@ -1,478 +1,355 @@
1
- import { NATIVE_COMPONENT_NAME, NATIVE_ELEMENT_NAME, NATIVE_SOURCE_FILE_NAME, WEB_COMPONENT_NAME, WEB_ELEMENT_NAME, WEB_SOURCE_FILE_NAME, getComponentAnnotationAttributes } from './component-annotation.js';
2
- import { KNOWN_INCOMPATIBLE_PLUGINS } from './constants.js';
3
- export { experimentalComponentNameAnnotatePlugin } from './experimental.js';
4
-
1
+ import "../_virtual/_rolldown/runtime.js";
2
+ import { NATIVE_COMPONENT_NAME, NATIVE_ELEMENT_NAME, NATIVE_SOURCE_FILE_NAME, WEB_COMPONENT_NAME, WEB_ELEMENT_NAME, WEB_SOURCE_FILE_NAME, getComponentAnnotationAttributes } from "./component-annotation.js";
3
+ import { KNOWN_INCOMPATIBLE_PLUGINS } from "./constants.js";
4
+ import { experimentalComponentNameAnnotatePlugin } from "./experimental.js";
5
+ // src/babel-plugin/index.ts
5
6
  const SENTRY_LABEL_ATTRIBUTE = "sentry-label";
6
7
  const MAX_LABEL_LENGTH = 64;
7
8
  const DEFAULT_TEXT_COMPONENT_NAMES = ["Text", "text"];
8
9
  const MAX_TEXT_SEARCH_DEPTH = 3;
9
10
  function componentNameAnnotatePlugin(babel) {
10
- return createPlugin(babel);
11
+ return createPlugin(babel);
11
12
  }
12
13
  function createPlugin({ types: t }) {
13
- return {
14
- visitor: {
15
- Program: {
16
- enter(path, state) {
17
- const fragmentContext = collectFragmentContext(path);
18
- state.sentryFragmentContext = fragmentContext;
19
- }
20
- },
21
- FunctionDeclaration(path, state) {
22
- if (!path.node.id?.name) {
23
- return;
24
- }
25
- if (isKnownIncompatiblePluginFromState(state)) {
26
- return;
27
- }
28
- const context = createJSXProcessingContext(state, t, path.node.id.name);
29
- functionBodyPushAttributes(context, path);
30
- },
31
- ArrowFunctionExpression(path, state) {
32
- const parent = path.parent;
33
- if (!parent || !("id" in parent) || !parent.id || !("name" in parent.id) || !parent.id.name) {
34
- return;
35
- }
36
- if (isKnownIncompatiblePluginFromState(state)) {
37
- return;
38
- }
39
- const context = createJSXProcessingContext(state, t, parent.id.name);
40
- functionBodyPushAttributes(context, path);
41
- },
42
- ClassDeclaration(path, state) {
43
- const name = path.get("id");
44
- const properties = path.get("body").get("body");
45
- const render = properties.find((prop) => {
46
- return prop.isClassMethod() && prop.get("key").isIdentifier({ name: "render" });
47
- });
48
- if (!render?.traverse || isKnownIncompatiblePluginFromState(state)) {
49
- return;
50
- }
51
- const context = createJSXProcessingContext(state, t, name.node?.name || "");
52
- render.traverse({
53
- ReturnStatement(returnStatement) {
54
- const arg = returnStatement.get("argument");
55
- if (!arg.isJSXElement() && !arg.isJSXFragment()) {
56
- return;
57
- }
58
- processJSX(context, arg);
59
- }
60
- });
61
- }
62
- }
63
- };
14
+ return { visitor: {
15
+ Program: { enter(path, state) {
16
+ state.sentryFragmentContext = collectFragmentContext(path);
17
+ } },
18
+ FunctionDeclaration(path, state) {
19
+ if (!path.node.id?.name) return;
20
+ if (isKnownIncompatiblePluginFromState(state)) return;
21
+ functionBodyPushAttributes(createJSXProcessingContext(state, t, path.node.id.name), path);
22
+ },
23
+ ArrowFunctionExpression(path, state) {
24
+ const parent = path.parent;
25
+ if (!parent || !("id" in parent) || !parent.id || !("name" in parent.id) || !parent.id.name) return;
26
+ if (isKnownIncompatiblePluginFromState(state)) return;
27
+ functionBodyPushAttributes(createJSXProcessingContext(state, t, parent.id.name), path);
28
+ },
29
+ ClassDeclaration(path, state) {
30
+ const name = path.get("id");
31
+ const render = path.get("body").get("body").find((prop) => {
32
+ return prop.isClassMethod() && prop.get("key").isIdentifier({ name: "render" });
33
+ });
34
+ if (!render?.traverse || isKnownIncompatiblePluginFromState(state)) return;
35
+ const context = createJSXProcessingContext(state, t, name.node?.name || "");
36
+ render.traverse({ ReturnStatement(returnStatement) {
37
+ const arg = returnStatement.get("argument");
38
+ if (!arg.isJSXElement() && !arg.isJSXFragment()) return;
39
+ processJSX(context, arg);
40
+ } });
41
+ }
42
+ } };
64
43
  }
44
+ /**
45
+ * Creates a JSX processing context from the plugin state
46
+ */
65
47
  function createJSXProcessingContext(state, t, componentName) {
66
- return {
67
- annotateFragments: state.opts["annotate-fragments"] === true,
68
- t,
69
- componentName,
70
- sourceFileName: sourceFileNameFromState(state),
71
- attributeNames: attributeNamesFromState(state),
72
- ignoredComponents: state.opts.ignoredComponents ?? [],
73
- fragmentContext: state.sentryFragmentContext,
74
- autoInjectSentryLabel: !!state.opts.autoInjectSentryLabel,
75
- textComponentNames: (state.opts.autoInjectSentryLabel && typeof state.opts.autoInjectSentryLabel === "object" ? state.opts.autoInjectSentryLabel.textComponentNames : void 0) ?? DEFAULT_TEXT_COMPONENT_NAMES
76
- };
48
+ return {
49
+ annotateFragments: state.opts["annotate-fragments"] === true,
50
+ t,
51
+ componentName,
52
+ sourceFileName: sourceFileNameFromState(state),
53
+ attributeNames: attributeNamesFromState(state),
54
+ ignoredComponents: state.opts.ignoredComponents ?? [],
55
+ fragmentContext: state.sentryFragmentContext,
56
+ autoInjectSentryLabel: !!state.opts.autoInjectSentryLabel,
57
+ textComponentNames: (state.opts.autoInjectSentryLabel && typeof state.opts.autoInjectSentryLabel === "object" ? state.opts.autoInjectSentryLabel.textComponentNames : void 0) ?? DEFAULT_TEXT_COMPONENT_NAMES
58
+ };
77
59
  }
60
+ /**
61
+ * Processes the body of a function to add Sentry tracking attributes to JSX elements.
62
+ * Handles various function body structures including direct JSX returns, conditional expressions,
63
+ * and nested JSX elements.
64
+ */
78
65
  function functionBodyPushAttributes(context, path) {
79
- let jsxNode;
80
- const functionBody = path.get("body").get("body");
81
- if (!("length" in functionBody) && functionBody.parent && (functionBody.parent.type === "JSXElement" || functionBody.parent.type === "JSXFragment")) {
82
- const maybeJsxNode = functionBody.find((c) => {
83
- return c.type === "JSXElement" || c.type === "JSXFragment";
84
- });
85
- if (!maybeJsxNode) {
86
- return;
87
- }
88
- jsxNode = maybeJsxNode;
89
- } else {
90
- const returnStatement = functionBody.find((c) => {
91
- return c.type === "ReturnStatement";
92
- });
93
- if (!returnStatement) {
94
- return;
95
- }
96
- const arg = returnStatement.get("argument");
97
- if (!arg) {
98
- return;
99
- }
100
- if (Array.isArray(arg)) {
101
- return;
102
- }
103
- if (arg.isConditionalExpression()) {
104
- const consequent = arg.get("consequent");
105
- if (consequent.isJSXFragment() || consequent.isJSXElement()) {
106
- processJSX(context, consequent);
107
- }
108
- const alternate = arg.get("alternate");
109
- if (alternate.isJSXFragment() || alternate.isJSXElement()) {
110
- processJSX(context, alternate);
111
- }
112
- return;
113
- }
114
- if (!arg.isJSXFragment() && !arg.isJSXElement()) {
115
- return;
116
- }
117
- jsxNode = arg;
118
- }
119
- if (!jsxNode) {
120
- return;
121
- }
122
- processJSX(context, jsxNode);
66
+ let jsxNode;
67
+ const functionBody = path.get("body").get("body");
68
+ if (!("length" in functionBody) && functionBody.parent && (functionBody.parent.type === "JSXElement" || functionBody.parent.type === "JSXFragment")) {
69
+ const maybeJsxNode = functionBody.find((c) => {
70
+ return c.type === "JSXElement" || c.type === "JSXFragment";
71
+ });
72
+ if (!maybeJsxNode) return;
73
+ jsxNode = maybeJsxNode;
74
+ } else {
75
+ const returnStatement = functionBody.find((c) => {
76
+ return c.type === "ReturnStatement";
77
+ });
78
+ if (!returnStatement) return;
79
+ const arg = returnStatement.get("argument");
80
+ if (!arg) return;
81
+ if (Array.isArray(arg)) return;
82
+ if (arg.isConditionalExpression()) {
83
+ const consequent = arg.get("consequent");
84
+ if (consequent.isJSXFragment() || consequent.isJSXElement()) processJSX(context, consequent);
85
+ const alternate = arg.get("alternate");
86
+ if (alternate.isJSXFragment() || alternate.isJSXElement()) processJSX(context, alternate);
87
+ return;
88
+ }
89
+ if (!arg.isJSXFragment() && !arg.isJSXElement()) return;
90
+ jsxNode = arg;
91
+ }
92
+ if (!jsxNode) return;
93
+ processJSX(context, jsxNode);
123
94
  }
95
+ /**
96
+ * Recursively processes JSX elements to add Sentry tracking attributes.
97
+ * Handles both JSX elements and fragments, applying appropriate attributes
98
+ * based on configuration and component context.
99
+ */
124
100
  function processJSX(context, jsxNode, componentName) {
125
- if (!jsxNode) {
126
- return;
127
- }
128
- const currentComponentName = componentName ?? context.componentName;
129
- const isRootElement = componentName === void 0;
130
- const paths = jsxNode.get("openingElement");
131
- const openingElements = Array.isArray(paths) ? paths : [paths];
132
- openingElements.forEach((openingElement) => {
133
- applyAttributes(context, openingElement, currentComponentName);
134
- });
135
- let children = jsxNode.get("children");
136
- if (children && !("length" in children)) {
137
- children = [children];
138
- }
139
- let shouldSetComponentName = context.annotateFragments;
140
- children.forEach((child) => {
141
- if (!child.node) {
142
- return;
143
- }
144
- const openingElement = child.get("openingElement");
145
- if (Array.isArray(openingElement)) {
146
- return;
147
- }
148
- if (shouldSetComponentName && openingElement?.node) {
149
- shouldSetComponentName = false;
150
- processJSX(context, child, currentComponentName);
151
- } else {
152
- processJSX(context, child, "");
153
- }
154
- });
155
- if (isRootElement && context.autoInjectSentryLabel) {
156
- maybeInjectSentryLabel(context, jsxNode);
157
- }
101
+ if (!jsxNode) return;
102
+ const currentComponentName = componentName ?? context.componentName;
103
+ const isRootElement = componentName === void 0;
104
+ const paths = jsxNode.get("openingElement");
105
+ (Array.isArray(paths) ? paths : [paths]).forEach((openingElement) => {
106
+ applyAttributes(context, openingElement, currentComponentName);
107
+ });
108
+ let children = jsxNode.get("children");
109
+ if (children && !("length" in children)) children = [children];
110
+ let shouldSetComponentName = context.annotateFragments;
111
+ children.forEach((child) => {
112
+ if (!child.node) return;
113
+ const openingElement = child.get("openingElement");
114
+ if (Array.isArray(openingElement)) return;
115
+ if (shouldSetComponentName && openingElement?.node) {
116
+ shouldSetComponentName = false;
117
+ processJSX(context, child, currentComponentName);
118
+ } else processJSX(context, child, "");
119
+ });
120
+ if (isRootElement && context.autoInjectSentryLabel) maybeInjectSentryLabel(context, jsxNode);
158
121
  }
122
+ /**
123
+ * Applies Sentry tracking attributes to a JSX opening element.
124
+ * Adds component name, element name, and source file attributes while
125
+ * respecting ignore lists and fragment detection.
126
+ */
159
127
  function applyAttributes(context, openingElement, componentName) {
160
- const { t, attributeNames, ignoredComponents, fragmentContext, sourceFileName } = context;
161
- if (!openingElement.node) {
162
- return;
163
- }
164
- if (!openingElement.node.attributes) openingElement.node.attributes = [];
165
- const elementName = getPathName(t, openingElement);
166
- for (const [name, value] of getComponentAnnotationAttributes({
167
- attributeNames,
168
- componentName,
169
- elementName,
170
- existingAttributes: getExistingAttributeNames(openingElement),
171
- ignoredComponents,
172
- isFragment: isReactFragment(t, openingElement, fragmentContext),
173
- sourceFileName
174
- })) {
175
- openingElement.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(name), t.stringLiteral(value)));
176
- }
128
+ const { t, attributeNames, ignoredComponents, fragmentContext, sourceFileName } = context;
129
+ if (!openingElement.node) return;
130
+ if (!openingElement.node.attributes) openingElement.node.attributes = [];
131
+ const elementName = getPathName(t, openingElement);
132
+ for (const [name, value] of getComponentAnnotationAttributes({
133
+ attributeNames,
134
+ componentName,
135
+ elementName,
136
+ existingAttributes: getExistingAttributeNames(openingElement),
137
+ ignoredComponents,
138
+ isFragment: isReactFragment(t, openingElement, fragmentContext),
139
+ sourceFileName
140
+ })) openingElement.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(name), t.stringLiteral(value)));
177
141
  }
178
142
  function sourceFileNameFromState(state) {
179
- const name = fullSourceFileNameFromState(state);
180
- if (!name) {
181
- return void 0;
182
- }
183
- if (name.indexOf("/") !== -1) {
184
- return name.split("/").pop();
185
- } else if (name.indexOf("\\") !== -1) {
186
- return name.split("\\").pop();
187
- } else {
188
- return name;
189
- }
143
+ const name = fullSourceFileNameFromState(state);
144
+ if (!name) return;
145
+ if (name.indexOf("/") !== -1) return name.split("/").pop();
146
+ else if (name.indexOf("\\") !== -1) return name.split("\\").pop();
147
+ else return name;
190
148
  }
191
149
  function fullSourceFileNameFromState(state) {
192
- const name = state.file.opts.parserOpts?.sourceFileName;
193
- if (typeof name === "string") {
194
- return name;
195
- }
196
- return null;
150
+ const name = state.file.opts.parserOpts?.sourceFileName;
151
+ if (typeof name === "string") return name;
152
+ return null;
197
153
  }
198
154
  function isKnownIncompatiblePluginFromState(state) {
199
- const fullSourceFileName = fullSourceFileNameFromState(state);
200
- if (!fullSourceFileName) {
201
- return false;
202
- }
203
- return KNOWN_INCOMPATIBLE_PLUGINS.some((pluginName) => {
204
- if (fullSourceFileName.includes(`/node_modules/${pluginName}/`) || fullSourceFileName.includes(`\\node_modules\\${pluginName}\\`)) {
205
- return true;
206
- }
207
- return false;
208
- });
155
+ const fullSourceFileName = fullSourceFileNameFromState(state);
156
+ if (!fullSourceFileName) return false;
157
+ return KNOWN_INCOMPATIBLE_PLUGINS.some((pluginName) => {
158
+ if (fullSourceFileName.includes(`/node_modules/${pluginName}/`) || fullSourceFileName.includes(`\\node_modules\\${pluginName}\\`)) return true;
159
+ return false;
160
+ });
209
161
  }
210
162
  function attributeNamesFromState(state) {
211
- if (state.opts.native) {
212
- return [NATIVE_COMPONENT_NAME, NATIVE_ELEMENT_NAME, NATIVE_SOURCE_FILE_NAME];
213
- }
214
- return [WEB_COMPONENT_NAME, WEB_ELEMENT_NAME, WEB_SOURCE_FILE_NAME];
163
+ if (state.opts.native) return [
164
+ NATIVE_COMPONENT_NAME,
165
+ NATIVE_ELEMENT_NAME,
166
+ NATIVE_SOURCE_FILE_NAME
167
+ ];
168
+ return [
169
+ WEB_COMPONENT_NAME,
170
+ WEB_ELEMENT_NAME,
171
+ WEB_SOURCE_FILE_NAME
172
+ ];
215
173
  }
216
174
  function collectFragmentContext(programPath) {
217
- const fragmentAliases = /* @__PURE__ */ new Set();
218
- const reactNamespaceAliases = /* @__PURE__ */ new Set(["React"]);
219
- programPath.traverse({
220
- ImportDeclaration(importPath) {
221
- const source = importPath.node.source.value;
222
- if (source === "react" || source === "React") {
223
- importPath.node.specifiers.forEach((spec) => {
224
- if (spec.type === "ImportSpecifier" && spec.imported.type === "Identifier") {
225
- if (spec.imported.name === "Fragment") {
226
- fragmentAliases.add(spec.local.name);
227
- }
228
- } else if (spec.type === "ImportDefaultSpecifier" || spec.type === "ImportNamespaceSpecifier") {
229
- reactNamespaceAliases.add(spec.local.name);
230
- }
231
- });
232
- }
233
- },
234
- // Handle simple variable assignments only (avoid complex cases)
235
- VariableDeclarator(varPath) {
236
- if (varPath.node.init) {
237
- const init = varPath.node.init;
238
- if (varPath.node.id.type === "Identifier") {
239
- if (init.type === "Identifier" && fragmentAliases.has(init.name)) {
240
- fragmentAliases.add(varPath.node.id.name);
241
- }
242
- if (init.type === "MemberExpression" && init.object.type === "Identifier" && init.property.type === "Identifier" && init.property.name === "Fragment" && reactNamespaceAliases.has(init.object.name)) {
243
- fragmentAliases.add(varPath.node.id.name);
244
- }
245
- }
246
- if (varPath.node.id.type === "ObjectPattern") {
247
- if (init.type === "Identifier" && reactNamespaceAliases.has(init.name)) {
248
- const properties = varPath.node.id.properties;
249
- for (const prop of properties) {
250
- if (prop.type === "ObjectProperty" && prop.key?.type === "Identifier" && prop.value?.type === "Identifier" && prop.key.name === "Fragment") {
251
- fragmentAliases.add(prop.value.name);
252
- }
253
- }
254
- }
255
- }
256
- }
257
- }
258
- });
259
- return { fragmentAliases, reactNamespaceAliases };
175
+ const fragmentAliases = /* @__PURE__ */ new Set();
176
+ const reactNamespaceAliases = /* @__PURE__ */ new Set(["React"]);
177
+ programPath.traverse({
178
+ ImportDeclaration(importPath) {
179
+ const source = importPath.node.source.value;
180
+ if (source === "react" || source === "React") importPath.node.specifiers.forEach((spec) => {
181
+ if (spec.type === "ImportSpecifier" && spec.imported.type === "Identifier") {
182
+ if (spec.imported.name === "Fragment") fragmentAliases.add(spec.local.name);
183
+ } else if (spec.type === "ImportDefaultSpecifier" || spec.type === "ImportNamespaceSpecifier") reactNamespaceAliases.add(spec.local.name);
184
+ });
185
+ },
186
+ VariableDeclarator(varPath) {
187
+ if (varPath.node.init) {
188
+ const init = varPath.node.init;
189
+ if (varPath.node.id.type === "Identifier") {
190
+ if (init.type === "Identifier" && fragmentAliases.has(init.name)) fragmentAliases.add(varPath.node.id.name);
191
+ if (init.type === "MemberExpression" && init.object.type === "Identifier" && init.property.type === "Identifier" && init.property.name === "Fragment" && reactNamespaceAliases.has(init.object.name)) fragmentAliases.add(varPath.node.id.name);
192
+ }
193
+ if (varPath.node.id.type === "ObjectPattern") {
194
+ if (init.type === "Identifier" && reactNamespaceAliases.has(init.name)) {
195
+ const properties = varPath.node.id.properties;
196
+ for (const prop of properties) if (prop.type === "ObjectProperty" && prop.key?.type === "Identifier" && prop.value?.type === "Identifier" && prop.key.name === "Fragment") fragmentAliases.add(prop.value.name);
197
+ }
198
+ }
199
+ }
200
+ }
201
+ });
202
+ return {
203
+ fragmentAliases,
204
+ reactNamespaceAliases
205
+ };
260
206
  }
261
207
  function isReactFragment(t, openingElement, context) {
262
- if (openingElement.isJSXFragment()) {
263
- return true;
264
- }
265
- const elementName = getPathName(t, openingElement);
266
- if (elementName === "Fragment" || elementName === "React.Fragment") {
267
- return true;
268
- }
269
- if (context && elementName && context.fragmentAliases.has(elementName)) {
270
- return true;
271
- }
272
- if (openingElement.node && "name" in openingElement.node && openingElement.node.name && typeof openingElement.node.name === "object" && "type" in openingElement.node.name && openingElement.node.name.type === "JSXMemberExpression") {
273
- const nodeName = openingElement.node.name;
274
- if (typeof nodeName !== "object" || !nodeName) {
275
- return false;
276
- }
277
- if ("object" in nodeName && "property" in nodeName) {
278
- const nodeNameObject = nodeName.object;
279
- const nodeNameProperty = nodeName.property;
280
- if (typeof nodeNameObject !== "object" || typeof nodeNameProperty !== "object") {
281
- return false;
282
- }
283
- if (!nodeNameObject || !nodeNameProperty) {
284
- return false;
285
- }
286
- const objectName = "name" in nodeNameObject && nodeNameObject.name;
287
- const propertyName = "name" in nodeNameProperty && nodeNameProperty.name;
288
- if (objectName === "React" && propertyName === "Fragment") {
289
- return true;
290
- }
291
- if (context) {
292
- if (context.reactNamespaceAliases.has(objectName) && propertyName === "Fragment") {
293
- return true;
294
- }
295
- if (context.fragmentAliases.has(objectName) && propertyName === "Fragment") {
296
- return true;
297
- }
298
- }
299
- }
300
- }
301
- return false;
208
+ if (openingElement.isJSXFragment()) return true;
209
+ const elementName = getPathName(t, openingElement);
210
+ if (elementName === "Fragment" || elementName === "React.Fragment") return true;
211
+ if (context && elementName && context.fragmentAliases.has(elementName)) return true;
212
+ if (openingElement.node && "name" in openingElement.node && openingElement.node.name && typeof openingElement.node.name === "object" && "type" in openingElement.node.name && openingElement.node.name.type === "JSXMemberExpression") {
213
+ const nodeName = openingElement.node.name;
214
+ if (typeof nodeName !== "object" || !nodeName) return false;
215
+ if ("object" in nodeName && "property" in nodeName) {
216
+ const nodeNameObject = nodeName.object;
217
+ const nodeNameProperty = nodeName.property;
218
+ if (typeof nodeNameObject !== "object" || typeof nodeNameProperty !== "object") return false;
219
+ if (!nodeNameObject || !nodeNameProperty) return false;
220
+ const objectName = "name" in nodeNameObject && nodeNameObject.name;
221
+ const propertyName = "name" in nodeNameProperty && nodeNameProperty.name;
222
+ if (objectName === "React" && propertyName === "Fragment") return true;
223
+ if (context) {
224
+ if (context.reactNamespaceAliases.has(objectName) && propertyName === "Fragment") return true;
225
+ if (context.fragmentAliases.has(objectName) && propertyName === "Fragment") return true;
226
+ }
227
+ }
228
+ }
229
+ return false;
302
230
  }
303
231
  function getExistingAttributeNames(openingElement) {
304
- const names = /* @__PURE__ */ new Set();
305
- openingElement.node.attributes.forEach((node) => {
306
- if (node.type === "JSXAttribute" && typeof node.name.name === "string") {
307
- names.add(node.name.name);
308
- }
309
- });
310
- return names;
232
+ const names = /* @__PURE__ */ new Set();
233
+ openingElement.node.attributes.forEach((node) => {
234
+ if (node.type === "JSXAttribute" && typeof node.name.name === "string") names.add(node.name.name);
235
+ });
236
+ return names;
311
237
  }
312
238
  function getPathName(t, path) {
313
- if (!path.node) return UNKNOWN_ELEMENT_NAME;
314
- if (!("name" in path.node)) {
315
- return UNKNOWN_ELEMENT_NAME;
316
- }
317
- const name = path.node.name;
318
- if (typeof name === "string") {
319
- return name;
320
- }
321
- if (t.isIdentifier(name) || t.isJSXIdentifier(name)) {
322
- return name.name;
323
- }
324
- if (t.isJSXNamespacedName(name)) {
325
- return name.name.name;
326
- }
327
- if (t.isJSXMemberExpression(name)) {
328
- const objectName = getJSXMemberExpressionObjectName(t, name.object);
329
- const propertyName = name.property.name;
330
- return `${objectName}.${propertyName}`;
331
- }
332
- return UNKNOWN_ELEMENT_NAME;
239
+ if (!path.node) return UNKNOWN_ELEMENT_NAME;
240
+ if (!("name" in path.node)) return UNKNOWN_ELEMENT_NAME;
241
+ const name = path.node.name;
242
+ if (typeof name === "string") return name;
243
+ if (t.isIdentifier(name) || t.isJSXIdentifier(name)) return name.name;
244
+ if (t.isJSXNamespacedName(name)) return name.name.name;
245
+ if (t.isJSXMemberExpression(name)) return `${getJSXMemberExpressionObjectName(t, name.object)}.${name.property.name}`;
246
+ return UNKNOWN_ELEMENT_NAME;
333
247
  }
334
248
  function getJSXMemberExpressionObjectName(t, object) {
335
- if (t.isJSXIdentifier(object)) {
336
- return object.name;
337
- }
338
- if (t.isJSXMemberExpression(object)) {
339
- const objectName = getJSXMemberExpressionObjectName(t, object.object);
340
- return `${objectName}.${object.property.name}`;
341
- }
342
- return UNKNOWN_ELEMENT_NAME;
249
+ if (t.isJSXIdentifier(object)) return object.name;
250
+ if (t.isJSXMemberExpression(object)) return `${getJSXMemberExpressionObjectName(t, object.object)}.${object.property.name}`;
251
+ return UNKNOWN_ELEMENT_NAME;
343
252
  }
253
+ /**
254
+ * Extracts static text content from JSX children, searching up to a depth limit.
255
+ * Collects text from JSXText nodes of the root element and from recognized
256
+ * text components (e.g. <Text>). Non-text custom components are traversed
257
+ * but their own JSXText is not collected.
258
+ *
259
+ * Returns null when dynamic content is found anywhere in the subtree,
260
+ * signaling that the entire label should be skipped.
261
+ */
344
262
  function extractStaticTextFromChildren(t, node, textComponentNames, depth, isRoot) {
345
- if (depth <= 0) {
346
- return [];
347
- }
348
- const texts = [];
349
- for (const child of node.children) {
350
- if (t.isJSXText(child)) {
351
- if (isRoot) {
352
- const trimmed = child.value.replace(/\s+/g, " ").trim();
353
- if (trimmed) {
354
- texts.push(trimmed);
355
- }
356
- }
357
- } else if (t.isJSXElement(child)) {
358
- const childName = getElementName(t, child.openingElement);
359
- if (textComponentNames.includes(childName)) {
360
- const innerTexts = extractTextFromTextComponent(t, child, textComponentNames);
361
- if (innerTexts === null) {
362
- return null;
363
- }
364
- texts.push(...innerTexts);
365
- } else {
366
- const result = extractStaticTextFromChildren(t, child, textComponentNames, depth - 1, false);
367
- if (result === null) {
368
- return null;
369
- }
370
- texts.push(...result);
371
- }
372
- } else if (t.isJSXFragment(child)) {
373
- const result = extractStaticTextFromChildren(t, child, textComponentNames, depth, isRoot);
374
- if (result === null) {
375
- return null;
376
- }
377
- texts.push(...result);
378
- } else if (t.isJSXExpressionContainer(child)) {
379
- if (!t.isJSXEmptyExpression(child.expression)) {
380
- return null;
381
- }
382
- } else if (t.isJSXSpreadChild(child)) {
383
- return null;
384
- }
385
- }
386
- return texts;
263
+ if (depth <= 0) return [];
264
+ const texts = [];
265
+ for (const child of node.children) if (t.isJSXText(child)) {
266
+ if (isRoot) {
267
+ const trimmed = child.value.replace(/\s+/g, " ").trim();
268
+ if (trimmed) texts.push(trimmed);
269
+ }
270
+ } else if (t.isJSXElement(child)) {
271
+ const childName = getElementName(t, child.openingElement);
272
+ if (textComponentNames.includes(childName)) {
273
+ const innerTexts = extractTextFromTextComponent(t, child, textComponentNames);
274
+ if (innerTexts === null) return null;
275
+ texts.push(...innerTexts);
276
+ } else {
277
+ const result = extractStaticTextFromChildren(t, child, textComponentNames, depth - 1, false);
278
+ if (result === null) return null;
279
+ texts.push(...result);
280
+ }
281
+ } else if (t.isJSXFragment(child)) {
282
+ const result = extractStaticTextFromChildren(t, child, textComponentNames, depth, isRoot);
283
+ if (result === null) return null;
284
+ texts.push(...result);
285
+ } else if (t.isJSXExpressionContainer(child)) {
286
+ if (!t.isJSXEmptyExpression(child.expression)) return null;
287
+ } else if (t.isJSXSpreadChild(child)) return null;
288
+ return texts;
387
289
  }
290
+ /**
291
+ * Recursively extracts static text from within a recognized text component.
292
+ * Handles nested text components (e.g. <Text>Hello <Text style={bold}>world</Text></Text>)
293
+ * which is the standard React Native pattern for inline styling.
294
+ *
295
+ * Returns null when any dynamic content is found, signaling bail-out.
296
+ */
388
297
  function extractTextFromTextComponent(t, node, textComponentNames) {
389
- const texts = [];
390
- for (const child of node.children) {
391
- if (t.isJSXText(child)) {
392
- const trimmed = child.value.replace(/\s+/g, " ").trim();
393
- if (trimmed) {
394
- texts.push(trimmed);
395
- }
396
- } else if (t.isJSXExpressionContainer(child)) {
397
- if (!t.isJSXEmptyExpression(child.expression)) {
398
- return null;
399
- }
400
- } else if (t.isJSXElement(child)) {
401
- const childName = getElementName(t, child.openingElement);
402
- if (textComponentNames.includes(childName)) {
403
- const innerTexts = extractTextFromTextComponent(t, child, textComponentNames);
404
- if (innerTexts === null) {
405
- return null;
406
- }
407
- texts.push(...innerTexts);
408
- } else {
409
- const innerTexts = extractTextFromTextComponent(t, child, textComponentNames);
410
- if (innerTexts === null) {
411
- return null;
412
- }
413
- }
414
- } else if (t.isJSXFragment(child)) {
415
- const innerTexts = extractTextFromTextComponent(t, child, textComponentNames);
416
- if (innerTexts === null) {
417
- return null;
418
- }
419
- texts.push(...innerTexts);
420
- } else if (t.isJSXSpreadChild(child)) {
421
- return null;
422
- }
423
- }
424
- return texts;
298
+ const texts = [];
299
+ for (const child of node.children) if (t.isJSXText(child)) {
300
+ const trimmed = child.value.replace(/\s+/g, " ").trim();
301
+ if (trimmed) texts.push(trimmed);
302
+ } else if (t.isJSXExpressionContainer(child)) {
303
+ if (!t.isJSXEmptyExpression(child.expression)) return null;
304
+ } else if (t.isJSXElement(child)) {
305
+ const childName = getElementName(t, child.openingElement);
306
+ if (textComponentNames.includes(childName)) {
307
+ const innerTexts = extractTextFromTextComponent(t, child, textComponentNames);
308
+ if (innerTexts === null) return null;
309
+ texts.push(...innerTexts);
310
+ } else if (extractTextFromTextComponent(t, child, textComponentNames) === null) return null;
311
+ } else if (t.isJSXFragment(child)) {
312
+ const innerTexts = extractTextFromTextComponent(t, child, textComponentNames);
313
+ if (innerTexts === null) return null;
314
+ texts.push(...innerTexts);
315
+ } else if (t.isJSXSpreadChild(child)) return null;
316
+ return texts;
425
317
  }
426
318
  function getElementName(t, openingElement) {
427
- const name = openingElement.name;
428
- if (t.isJSXIdentifier(name)) {
429
- return name.name;
430
- }
431
- if (t.isJSXMemberExpression(name)) {
432
- return `${getJSXMemberExpressionObjectName(t, name.object)}.${name.property.name}`;
433
- }
434
- return "";
319
+ const name = openingElement.name;
320
+ if (t.isJSXIdentifier(name)) return name.name;
321
+ if (t.isJSXMemberExpression(name)) return `${getJSXMemberExpressionObjectName(t, name.object)}.${name.property.name}`;
322
+ return "";
435
323
  }
324
+ /**
325
+ * Injects a sentry-label attribute on the root JSX element of a component if
326
+ * static text content can be extracted from its children.
327
+ *
328
+ * When the root is a JSX fragment, the first JSXElement child is used as the
329
+ * target for both text extraction and attribute injection (since fragments
330
+ * cannot carry attributes).
331
+ */
436
332
  function maybeInjectSentryLabel(context, jsxNode) {
437
- const { t, textComponentNames, ignoredComponents, componentName } = context;
438
- const node = jsxNode.node;
439
- let targetElement;
440
- if (t.isJSXElement(node)) {
441
- targetElement = node;
442
- } else if (t.isJSXFragment(node)) {
443
- const firstChild = node.children.find((c) => t.isJSXElement(c));
444
- if (!firstChild) {
445
- return;
446
- }
447
- targetElement = firstChild;
448
- } else {
449
- return;
450
- }
451
- const targetElementName = getElementName(t, targetElement.openingElement);
452
- if (ignoredComponents.some((ignored) => ignored === componentName || ignored === targetElementName)) {
453
- return;
454
- }
455
- if (targetElement.openingElement.attributes.some(
456
- (attr) => t.isJSXAttribute(attr) && attr.name.name === SENTRY_LABEL_ATTRIBUTE
457
- )) {
458
- return;
459
- }
460
- const texts = extractStaticTextFromChildren(t, targetElement, textComponentNames, MAX_TEXT_SEARCH_DEPTH, true);
461
- if (texts === null) {
462
- return;
463
- }
464
- let label = texts.join(" ").replace(/\s+/g, " ").trim();
465
- if (!label) {
466
- return;
467
- }
468
- if (label.length > MAX_LABEL_LENGTH) {
469
- label = `${label.substring(0, MAX_LABEL_LENGTH - 3)}...`;
470
- }
471
- targetElement.openingElement.attributes.push(
472
- t.jSXAttribute(t.jSXIdentifier(SENTRY_LABEL_ATTRIBUTE), t.stringLiteral(label))
473
- );
333
+ const { t, textComponentNames, ignoredComponents, componentName } = context;
334
+ const node = jsxNode.node;
335
+ let targetElement;
336
+ if (t.isJSXElement(node)) targetElement = node;
337
+ else if (t.isJSXFragment(node)) {
338
+ const firstChild = node.children.find((c) => t.isJSXElement(c));
339
+ if (!firstChild) return;
340
+ targetElement = firstChild;
341
+ } else return;
342
+ const targetElementName = getElementName(t, targetElement.openingElement);
343
+ if (ignoredComponents.some((ignored) => ignored === componentName || ignored === targetElementName)) return;
344
+ if (targetElement.openingElement.attributes.some((attr) => t.isJSXAttribute(attr) && attr.name.name === SENTRY_LABEL_ATTRIBUTE)) return;
345
+ const texts = extractStaticTextFromChildren(t, targetElement, textComponentNames, MAX_TEXT_SEARCH_DEPTH, true);
346
+ if (texts === null) return;
347
+ let label = texts.join(" ").replace(/\s+/g, " ").trim();
348
+ if (!label) return;
349
+ if (label.length > MAX_LABEL_LENGTH) label = `${label.substring(0, 61)}...`;
350
+ targetElement.openingElement.attributes.push(t.jSXAttribute(t.jSXIdentifier(SENTRY_LABEL_ATTRIBUTE), t.stringLiteral(label)));
474
351
  }
475
352
  const UNKNOWN_ELEMENT_NAME = "unknown";
353
+ export { componentNameAnnotatePlugin as default, experimentalComponentNameAnnotatePlugin };
476
354
 
477
- export { componentNameAnnotatePlugin as default };
478
- //# sourceMappingURL=index.js.map
355
+ //# sourceMappingURL=index.js.map