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