@sentry/babel-plugin-component-annotate 2.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.
- package/LICENSE +29 -0
- package/README.md +88 -0
- package/dist/cjs/index.js +386 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.mjs +382 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/constants.d.ts +26 -0
- package/dist/types/index.d.ts +46 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Sentry
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
- Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
- Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
- Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
|
|
3
|
+
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# Sentry Babel Component Annotate Plugin (Beta)
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/@sentry/babel-plugin-component-annotate)
|
|
10
|
+
[](https://www.npmjs.com/package/@sentry/babel-plugin-component-annotate)
|
|
11
|
+
[](https://www.npmjs.com/package/@babel-plugin-component-annotate)
|
|
12
|
+
|
|
13
|
+
This plugin is currently in beta. Please help us improve by [reporting any issues or giving us feedback](https://github.com/getsentry/sentry-javascript-bundler-plugins/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).
|
|
14
|
+
|
|
15
|
+
A Babel plugin that automatically annotates your output DOM with their respective frontend component names.
|
|
16
|
+
This will unlock the capability to search for Replays in Sentry by component name, as well as see component names in breadcrumbs and performance monitoring.
|
|
17
|
+
Please note that your Sentry JavaScript SDK version must be at least `7.91.0` to take advantage of these features.
|
|
18
|
+
Currently, this plugin only works with React, and will exclusively parse `.jsx` and `.tsx` files.
|
|
19
|
+
|
|
20
|
+
### Note
|
|
21
|
+
|
|
22
|
+
This plugin comes included in Sentry's bundler plugins, alongside many other features to improve your Sentry workflow.
|
|
23
|
+
It can be downloaded individually, but it is recommended that you install the bundler plugins for your respective bundler, and enable this feature through the config object.
|
|
24
|
+
|
|
25
|
+
Check out the supported bundler plugin packages for installation instructions:
|
|
26
|
+
|
|
27
|
+
- [Rollup](https://www.npmjs.com/package/@sentry/rollup-plugin)
|
|
28
|
+
- [Vite](https://www.npmjs.com/package/@sentry/vite-plugin)
|
|
29
|
+
- [Webpack](https://www.npmjs.com/package/@sentry/webpack-plugin)
|
|
30
|
+
- esbuild: Not currently supported
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Using npm:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @sentry/babel-plugin-component-annotate --save-dev
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Using yarn:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
yarn add @sentry/babel-plugin-component-annotate --dev
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Using pnpm:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pnpm install @sentry/babel-plugin-component-annotate --dev
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Example
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
// babel.config.js
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
// ... other config above ...
|
|
59
|
+
|
|
60
|
+
plugins: [
|
|
61
|
+
// Put this plugin before any other plugins you have that transform JSX code
|
|
62
|
+
['@sentry/babel-plugin-component-annotate']
|
|
63
|
+
],
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Or alternatively, configure the plugin by directly importing it:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
// babel.config.js
|
|
71
|
+
|
|
72
|
+
import {componentNameAnnotatePlugin} from '@sentry/babel-plugin-component-annotate';
|
|
73
|
+
|
|
74
|
+
{
|
|
75
|
+
// ... other config above ...
|
|
76
|
+
|
|
77
|
+
plugins: [
|
|
78
|
+
// Put this plugin before any other plugins you have that transform JSX code
|
|
79
|
+
[componentNameAnnotatePlugin]
|
|
80
|
+
],
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## More information
|
|
85
|
+
|
|
86
|
+
- [Sentry Documentation](https://docs.sentry.io/quickstart/)
|
|
87
|
+
- [Sentry Discord](https://discord.gg/Ww9hbqr)
|
|
88
|
+
- [Sentry Stackoverflow](http://stackoverflow.com/questions/tagged/sentry)
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _iterableToArrayLimit(arr, i) {
|
|
6
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
7
|
+
if (null != _i) {
|
|
8
|
+
var _s,
|
|
9
|
+
_e,
|
|
10
|
+
_x,
|
|
11
|
+
_r,
|
|
12
|
+
_arr = [],
|
|
13
|
+
_n = !0,
|
|
14
|
+
_d = !1;
|
|
15
|
+
try {
|
|
16
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
17
|
+
if (Object(_i) !== _i) return;
|
|
18
|
+
_n = !1;
|
|
19
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
_d = !0, _e = err;
|
|
22
|
+
} finally {
|
|
23
|
+
try {
|
|
24
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
25
|
+
} finally {
|
|
26
|
+
if (_d) throw _e;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return _arr;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function _typeof(obj) {
|
|
33
|
+
"@babel/helpers - typeof";
|
|
34
|
+
|
|
35
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
36
|
+
return typeof obj;
|
|
37
|
+
} : function (obj) {
|
|
38
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
39
|
+
}, _typeof(obj);
|
|
40
|
+
}
|
|
41
|
+
function _slicedToArray(arr, i) {
|
|
42
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
43
|
+
}
|
|
44
|
+
function _arrayWithHoles(arr) {
|
|
45
|
+
if (Array.isArray(arr)) return arr;
|
|
46
|
+
}
|
|
47
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
48
|
+
if (!o) return;
|
|
49
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
50
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
51
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
52
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
53
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
54
|
+
}
|
|
55
|
+
function _arrayLikeToArray(arr, len) {
|
|
56
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
57
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
58
|
+
return arr2;
|
|
59
|
+
}
|
|
60
|
+
function _nonIterableRest() {
|
|
61
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* MIT License
|
|
66
|
+
*
|
|
67
|
+
* Copyright (c) 2020 Engineering at FullStory
|
|
68
|
+
*
|
|
69
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
70
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
71
|
+
* in the Software without restriction, including without limitation the rights
|
|
72
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
73
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
74
|
+
* furnished to do so, subject to the following conditions:
|
|
75
|
+
*
|
|
76
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
77
|
+
* copies or substantial portions of the Software.
|
|
78
|
+
*
|
|
79
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
80
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
81
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
82
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
83
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
84
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
85
|
+
* SOFTWARE.
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
var KNOWN_INCOMPATIBLE_PLUGINS = [
|
|
90
|
+
// This module might be causing an issue preventing clicks. For safety, we won't run on this module.
|
|
91
|
+
"react-native-testfairy",
|
|
92
|
+
// This module checks for unexpected property keys and throws an exception.
|
|
93
|
+
"@react-navigation"];
|
|
94
|
+
var DEFAULT_IGNORED_ELEMENTS = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr"];
|
|
95
|
+
|
|
96
|
+
var webComponentName = "data-sentry-component";
|
|
97
|
+
var webElementName = "data-sentry-element";
|
|
98
|
+
var webSourceFileName = "data-sentry-source-file";
|
|
99
|
+
var nativeComponentName = "dataSentryComponent";
|
|
100
|
+
var nativeElementName = "dataSentryElement";
|
|
101
|
+
var nativeSourceFileName = "dataSentrySourceFile";
|
|
102
|
+
function componentNameAnnotatePlugin(_ref) {
|
|
103
|
+
var t = _ref.types;
|
|
104
|
+
return {
|
|
105
|
+
visitor: {
|
|
106
|
+
FunctionDeclaration: function FunctionDeclaration(path, state) {
|
|
107
|
+
var _state$opts$ignoreCom;
|
|
108
|
+
if (!path.node.id || !path.node.id.name) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (isKnownIncompatiblePluginFromState(state)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
functionBodyPushAttributes(state.opts["annotate-fragments"] === true, t, path, path.node.id.name, sourceFileNameFromState(state), attributeNamesFromState(state), (_state$opts$ignoreCom = state.opts.ignoreComponents) !== null && _state$opts$ignoreCom !== void 0 ? _state$opts$ignoreCom : []);
|
|
115
|
+
},
|
|
116
|
+
ArrowFunctionExpression: function ArrowFunctionExpression(path, state) {
|
|
117
|
+
var _state$opts$ignoreCom2;
|
|
118
|
+
// We're expecting a `VariableDeclarator` like `const MyComponent =`
|
|
119
|
+
var parent = path.parent;
|
|
120
|
+
if (!parent || !("id" in parent) || !parent.id || !("name" in parent.id) || !parent.id.name) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (isKnownIncompatiblePluginFromState(state)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
functionBodyPushAttributes(state.opts["annotate-fragments"] === true, t, path, parent.id.name, sourceFileNameFromState(state), attributeNamesFromState(state), (_state$opts$ignoreCom2 = state.opts.ignoreComponents) !== null && _state$opts$ignoreCom2 !== void 0 ? _state$opts$ignoreCom2 : []);
|
|
127
|
+
},
|
|
128
|
+
ClassDeclaration: function ClassDeclaration(path, state) {
|
|
129
|
+
var _state$opts$ignoreCom3;
|
|
130
|
+
var name = path.get("id");
|
|
131
|
+
var properties = path.get("body").get("body");
|
|
132
|
+
var render = properties.find(function (prop) {
|
|
133
|
+
return prop.isClassMethod() && prop.get("key").isIdentifier({
|
|
134
|
+
name: "render"
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
if (!render || !render.traverse || isKnownIncompatiblePluginFromState(state)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
var ignoredComponents = (_state$opts$ignoreCom3 = state.opts.ignoreComponents) !== null && _state$opts$ignoreCom3 !== void 0 ? _state$opts$ignoreCom3 : [];
|
|
141
|
+
render.traverse({
|
|
142
|
+
ReturnStatement: function ReturnStatement(returnStatement) {
|
|
143
|
+
var arg = returnStatement.get("argument");
|
|
144
|
+
if (!arg.isJSXElement() && !arg.isJSXFragment()) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
processJSX(state.opts["annotate-fragments"] === true, t, arg, name.node && name.node.name, sourceFileNameFromState(state), attributeNamesFromState(state), ignoredComponents);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function functionBodyPushAttributes(annotateFragments, t, path, componentName, sourceFileName, attributeNames, ignoredComponents) {
|
|
155
|
+
var jsxNode;
|
|
156
|
+
var functionBody = path.get("body").get("body");
|
|
157
|
+
if (!("length" in functionBody) && functionBody.parent && (functionBody.parent.type === "JSXElement" || functionBody.parent.type === "JSXFragment")) {
|
|
158
|
+
var maybeJsxNode = functionBody.find(function (c) {
|
|
159
|
+
return c.type === "JSXElement" || c.type === "JSXFragment";
|
|
160
|
+
});
|
|
161
|
+
if (!maybeJsxNode) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
jsxNode = maybeJsxNode;
|
|
165
|
+
} else {
|
|
166
|
+
var returnStatement = functionBody.find(function (c) {
|
|
167
|
+
return c.type === "ReturnStatement";
|
|
168
|
+
});
|
|
169
|
+
if (!returnStatement) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
var arg = returnStatement.get("argument");
|
|
173
|
+
if (!arg) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (Array.isArray(arg)) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (!arg.isJSXFragment() && !arg.isJSXElement()) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
jsxNode = arg;
|
|
183
|
+
}
|
|
184
|
+
if (!jsxNode) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
processJSX(annotateFragments, t, jsxNode, componentName, sourceFileName, attributeNames, ignoredComponents);
|
|
188
|
+
}
|
|
189
|
+
function processJSX(annotateFragments, t, jsxNode, componentName, sourceFileName, attributeNames, ignoredComponents) {
|
|
190
|
+
if (!jsxNode) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// NOTE: I don't know of a case where `openingElement` would have more than one item,
|
|
195
|
+
// but it's safer to always iterate
|
|
196
|
+
var paths = jsxNode.get("openingElement");
|
|
197
|
+
var openingElements = Array.isArray(paths) ? paths : [paths];
|
|
198
|
+
openingElements.forEach(function (openingElement) {
|
|
199
|
+
applyAttributes(t, openingElement, componentName, sourceFileName, attributeNames, ignoredComponents);
|
|
200
|
+
});
|
|
201
|
+
var children = jsxNode.get("children");
|
|
202
|
+
// TODO: See why `Array.isArray` doesn't have correct behaviour here
|
|
203
|
+
if (children && !("length" in children)) {
|
|
204
|
+
// A single child was found, maybe a bit of static text
|
|
205
|
+
children = [children];
|
|
206
|
+
}
|
|
207
|
+
var shouldSetComponentName = annotateFragments;
|
|
208
|
+
children.forEach(function (child) {
|
|
209
|
+
// Happens for some node types like plain text
|
|
210
|
+
if (!child.node) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Children don't receive the data-component attribute so we pass null for componentName unless it's the first child of a Fragment with a node and `annotateFragments` is true
|
|
215
|
+
var openingElement = child.get("openingElement");
|
|
216
|
+
// TODO: Improve this. We never expect to have multiple opening elements
|
|
217
|
+
// but if it's possible, this should work
|
|
218
|
+
if (Array.isArray(openingElement)) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (shouldSetComponentName && openingElement && openingElement.node) {
|
|
222
|
+
shouldSetComponentName = false;
|
|
223
|
+
processJSX(annotateFragments, t, child, componentName, sourceFileName, attributeNames, ignoredComponents);
|
|
224
|
+
} else {
|
|
225
|
+
processJSX(annotateFragments, t, child, null, sourceFileName, attributeNames, ignoredComponents);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function applyAttributes(t, openingElement, componentName, sourceFileName, attributeNames, ignoredComponents) {
|
|
230
|
+
var _attributeNames = _slicedToArray(attributeNames, 3),
|
|
231
|
+
componentAttributeName = _attributeNames[0],
|
|
232
|
+
elementAttributeName = _attributeNames[1],
|
|
233
|
+
sourceFileAttributeName = _attributeNames[2];
|
|
234
|
+
if (isReactFragment(t, openingElement)) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
// e.g., Raw JSX text like the `A` in `<h1>a</h1>`
|
|
238
|
+
if (!openingElement.node) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (!openingElement.node.attributes) openingElement.node.attributes = [];
|
|
242
|
+
var elementName = getPathName(t, openingElement);
|
|
243
|
+
var isAnIgnoredComponent = ignoredComponents.some(function (ignoredComponent) {
|
|
244
|
+
return matchesIgnoreRule(ignoredComponent[0], sourceFileName) && matchesIgnoreRule(ignoredComponent[1], componentName) && matchesIgnoreRule(ignoredComponent[2], elementName);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// Add a stable attribute for the element name but only for non-DOM names
|
|
248
|
+
var isAnIgnoredElement = false;
|
|
249
|
+
if (!isAnIgnoredComponent && !hasAttributeWithName(openingElement, componentAttributeName) && (componentAttributeName !== elementAttributeName || !componentName)) {
|
|
250
|
+
if (DEFAULT_IGNORED_ELEMENTS.includes(elementName)) {
|
|
251
|
+
isAnIgnoredElement = true;
|
|
252
|
+
} else {
|
|
253
|
+
// TODO: Is it possible to avoid this null check?
|
|
254
|
+
if (elementAttributeName) {
|
|
255
|
+
openingElement.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(elementAttributeName), t.stringLiteral(elementName)));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Add a stable attribute for the component name (absent for non-root elements)
|
|
261
|
+
if (componentName && !isAnIgnoredComponent && !hasAttributeWithName(openingElement, componentAttributeName)) {
|
|
262
|
+
// TODO: Is it possible to avoid this null check?
|
|
263
|
+
if (componentAttributeName) {
|
|
264
|
+
openingElement.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(componentAttributeName), t.stringLiteral(componentName)));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Add a stable attribute for the source file name (absent for non-root elements)
|
|
269
|
+
if (sourceFileName && !isAnIgnoredComponent && (componentName || isAnIgnoredElement === false) && !hasAttributeWithName(openingElement, sourceFileAttributeName)) {
|
|
270
|
+
// TODO: Is it possible to avoid this null check?
|
|
271
|
+
if (sourceFileAttributeName) {
|
|
272
|
+
openingElement.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(sourceFileAttributeName), t.stringLiteral(sourceFileName)));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function sourceFileNameFromState(state) {
|
|
277
|
+
var name = fullSourceFileNameFromState(state);
|
|
278
|
+
if (!name) {
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
if (name.indexOf("/") !== -1) {
|
|
282
|
+
return name.split("/").pop();
|
|
283
|
+
} else if (name.indexOf("\\") !== -1) {
|
|
284
|
+
return name.split("\\").pop();
|
|
285
|
+
} else {
|
|
286
|
+
return name;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function fullSourceFileNameFromState(state) {
|
|
290
|
+
var _state$file$opts$pars;
|
|
291
|
+
// @ts-expect-error This type is incorrect in Babel, `sourceFileName` is the correct type
|
|
292
|
+
var name = (_state$file$opts$pars = state.file.opts.parserOpts) === null || _state$file$opts$pars === void 0 ? void 0 : _state$file$opts$pars.sourceFileName;
|
|
293
|
+
if (typeof name === "string") {
|
|
294
|
+
return name;
|
|
295
|
+
}
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
function isKnownIncompatiblePluginFromState(state) {
|
|
299
|
+
var fullSourceFileName = fullSourceFileNameFromState(state);
|
|
300
|
+
if (!fullSourceFileName) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
return KNOWN_INCOMPATIBLE_PLUGINS.some(function (pluginName) {
|
|
304
|
+
if (fullSourceFileName.includes("/node_modules/".concat(pluginName, "/")) || fullSourceFileName.includes("\\node_modules\\".concat(pluginName, "\\"))) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function attributeNamesFromState(state) {
|
|
311
|
+
if (state.opts["native"]) {
|
|
312
|
+
return [nativeComponentName, nativeElementName, nativeSourceFileName];
|
|
313
|
+
}
|
|
314
|
+
return [webComponentName, webElementName, webSourceFileName];
|
|
315
|
+
}
|
|
316
|
+
function isReactFragment(t, openingElement) {
|
|
317
|
+
if (openingElement.isJSXFragment()) {
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
var elementName = getPathName(t, openingElement);
|
|
321
|
+
if (elementName === "Fragment" || elementName === "React.Fragment") {
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// TODO: All these objects are typed as unknown, maybe an oversight in Babel types?
|
|
326
|
+
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") {
|
|
327
|
+
if (!("name" in openingElement.node)) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
var nodeName = openingElement.node.name;
|
|
331
|
+
if (_typeof(nodeName) !== "object" || !nodeName) {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
if ("object" in nodeName && "property" in nodeName) {
|
|
335
|
+
var nodeNameObject = nodeName.object;
|
|
336
|
+
var nodeNameProperty = nodeName.property;
|
|
337
|
+
if (_typeof(nodeNameObject) !== "object" || _typeof(nodeNameProperty) !== "object") {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
if (!nodeNameObject || !nodeNameProperty) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
var objectName = "name" in nodeNameObject && nodeNameObject.name;
|
|
344
|
+
var propertyName = "name" in nodeNameProperty && nodeNameProperty.name;
|
|
345
|
+
if (objectName === "React" && propertyName === "Fragment") {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
function matchesIgnoreRule(rule, name) {
|
|
353
|
+
return rule === "*" || rule === name;
|
|
354
|
+
}
|
|
355
|
+
function hasAttributeWithName(openingElement, name) {
|
|
356
|
+
if (!name) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
return openingElement.node.attributes.some(function (node) {
|
|
360
|
+
if (node.type === "JSXAttribute") {
|
|
361
|
+
return node.name.name === name;
|
|
362
|
+
}
|
|
363
|
+
return false;
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
function getPathName(t, path) {
|
|
367
|
+
if (!path.node) return UNKNOWN_ELEMENT_NAME;
|
|
368
|
+
if (!("name" in path.node)) {
|
|
369
|
+
return UNKNOWN_ELEMENT_NAME;
|
|
370
|
+
}
|
|
371
|
+
var name = path.node.name;
|
|
372
|
+
if (typeof name === "string") {
|
|
373
|
+
return name;
|
|
374
|
+
}
|
|
375
|
+
if (t.isIdentifier(name) || t.isJSXIdentifier(name)) {
|
|
376
|
+
return name.name;
|
|
377
|
+
}
|
|
378
|
+
if (t.isJSXNamespacedName(name)) {
|
|
379
|
+
return name.name.name;
|
|
380
|
+
}
|
|
381
|
+
return UNKNOWN_ELEMENT_NAME;
|
|
382
|
+
}
|
|
383
|
+
var UNKNOWN_ELEMENT_NAME = "unknown";
|
|
384
|
+
|
|
385
|
+
exports.componentNameAnnotatePlugin = componentNameAnnotatePlugin;
|
|
386
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/constants.ts","../../src/index.ts"],"sourcesContent":["/**\n * MIT License\n *\n * Copyright (c) 2020 Engineering at FullStory\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n */\n\nexport const KNOWN_INCOMPATIBLE_PLUGINS = [\n // This module might be causing an issue preventing clicks. For safety, we won't run on this module.\n \"react-native-testfairy\",\n // This module checks for unexpected property keys and throws an exception.\n \"@react-navigation\",\n];\n\nexport const DEFAULT_IGNORED_ELEMENTS = [\n \"a\",\n \"abbr\",\n \"address\",\n \"area\",\n \"article\",\n \"aside\",\n \"audio\",\n \"b\",\n \"base\",\n \"bdi\",\n \"bdo\",\n \"blockquote\",\n \"body\",\n \"br\",\n \"button\",\n \"canvas\",\n \"caption\",\n \"cite\",\n \"code\",\n \"col\",\n \"colgroup\",\n \"data\",\n \"datalist\",\n \"dd\",\n \"del\",\n \"details\",\n \"dfn\",\n \"dialog\",\n \"div\",\n \"dl\",\n \"dt\",\n \"em\",\n \"embed\",\n \"fieldset\",\n \"figure\",\n \"footer\",\n \"form\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"head\",\n \"header\",\n \"hgroup\",\n \"hr\",\n \"html\",\n \"i\",\n \"iframe\",\n \"img\",\n \"input\",\n \"ins\",\n \"kbd\",\n \"keygen\",\n \"label\",\n \"legend\",\n \"li\",\n \"link\",\n \"main\",\n \"map\",\n \"mark\",\n \"menu\",\n \"menuitem\",\n \"meter\",\n \"nav\",\n \"noscript\",\n \"object\",\n \"ol\",\n \"optgroup\",\n \"option\",\n \"output\",\n \"p\",\n \"param\",\n \"pre\",\n \"progress\",\n \"q\",\n \"rb\",\n \"rp\",\n \"rt\",\n \"rtc\",\n \"ruby\",\n \"s\",\n \"samp\",\n \"script\",\n \"section\",\n \"select\",\n \"small\",\n \"source\",\n \"span\",\n \"strong\",\n \"style\",\n \"sub\",\n \"summary\",\n \"sup\",\n \"table\",\n \"tbody\",\n \"td\",\n \"template\",\n \"textarea\",\n \"tfoot\",\n \"th\",\n \"thead\",\n \"time\",\n \"title\",\n \"tr\",\n \"track\",\n \"u\",\n \"ul\",\n \"var\",\n \"video\",\n \"wbr\",\n];\n","/**\n * MIT License\n *\n * Copyright (c) 2020 Engineering at FullStory\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n */\n\n/**\n * The following code is based on the FullStory Babel plugin, but has been modified to work\n * with Sentry products:\n *\n * - Added `sentry` to data properties, i.e `data-sentry-component`\n * - Converted to TypeScript\n * - Code cleanups\n */\n\nimport type * as Babel from \"@babel/core\";\nimport type { PluginObj, PluginPass } from \"@babel/core\";\n\nimport { DEFAULT_IGNORED_ELEMENTS, KNOWN_INCOMPATIBLE_PLUGINS } from \"./constants\";\n\nconst webComponentName = \"data-sentry-component\";\nconst webElementName = \"data-sentry-element\";\nconst webSourceFileName = \"data-sentry-source-file\";\n\nconst nativeComponentName = \"dataSentryComponent\";\nconst nativeElementName = \"dataSentryElement\";\nconst nativeSourceFileName = \"dataSentrySourceFile\";\n\ninterface AnnotationOpts {\n native?: boolean;\n \"annotate-fragments\"?: boolean;\n ignoreComponents?: IgnoredComponent[];\n}\n\ninterface AnnotationPluginPass extends PluginPass {\n opts: AnnotationOpts;\n}\n\ntype IgnoredComponent = [file: string, component: string, element: string];\n\ntype AnnotationPlugin = PluginObj<AnnotationPluginPass>;\n\nexport function componentNameAnnotatePlugin({ types: t }: typeof Babel): AnnotationPlugin {\n return {\n visitor: {\n FunctionDeclaration(path, state) {\n if (!path.node.id || !path.node.id.name) {\n return;\n }\n if (isKnownIncompatiblePluginFromState(state)) {\n return;\n }\n\n functionBodyPushAttributes(\n state.opts[\"annotate-fragments\"] === true,\n t,\n path,\n path.node.id.name,\n sourceFileNameFromState(state),\n attributeNamesFromState(state),\n state.opts.ignoreComponents ?? []\n );\n },\n ArrowFunctionExpression(path, state) {\n // We're expecting a `VariableDeclarator` like `const MyComponent =`\n const parent = path.parent;\n if (\n !parent ||\n !(\"id\" in parent) ||\n !parent.id ||\n !(\"name\" in parent.id) ||\n !parent.id.name\n ) {\n return;\n }\n\n if (isKnownIncompatiblePluginFromState(state)) {\n return;\n }\n\n functionBodyPushAttributes(\n state.opts[\"annotate-fragments\"] === true,\n t,\n path,\n parent.id.name,\n sourceFileNameFromState(state),\n attributeNamesFromState(state),\n state.opts.ignoreComponents ?? []\n );\n },\n ClassDeclaration(path, state) {\n const name = path.get(\"id\");\n const properties = path.get(\"body\").get(\"body\");\n const render = properties.find((prop) => {\n return prop.isClassMethod() && prop.get(\"key\").isIdentifier({ name: \"render\" });\n });\n\n if (!render || !render.traverse || isKnownIncompatiblePluginFromState(state)) {\n return;\n }\n\n const ignoredComponents = state.opts.ignoreComponents ?? [];\n\n render.traverse({\n ReturnStatement(returnStatement) {\n const arg = returnStatement.get(\"argument\");\n\n if (!arg.isJSXElement() && !arg.isJSXFragment()) {\n return;\n }\n\n processJSX(\n state.opts[\"annotate-fragments\"] === true,\n t,\n arg,\n name.node && name.node.name,\n sourceFileNameFromState(state),\n attributeNamesFromState(state),\n ignoredComponents\n );\n },\n });\n },\n },\n };\n}\n\nfunction functionBodyPushAttributes(\n annotateFragments: boolean,\n t: typeof Babel.types,\n path: Babel.NodePath<Babel.types.Function>,\n componentName: string,\n sourceFileName: string | undefined,\n attributeNames: string[],\n ignoredComponents: IgnoredComponent[]\n) {\n let jsxNode: Babel.NodePath;\n\n const functionBody = path.get(\"body\").get(\"body\");\n\n if (\n !(\"length\" in functionBody) &&\n functionBody.parent &&\n (functionBody.parent.type === \"JSXElement\" || functionBody.parent.type === \"JSXFragment\")\n ) {\n const maybeJsxNode = functionBody.find((c) => {\n return c.type === \"JSXElement\" || c.type === \"JSXFragment\";\n });\n\n if (!maybeJsxNode) {\n return;\n }\n\n jsxNode = maybeJsxNode;\n } else {\n const returnStatement = functionBody.find((c) => {\n return c.type === \"ReturnStatement\";\n });\n if (!returnStatement) {\n return;\n }\n\n const arg = returnStatement.get(\"argument\");\n if (!arg) {\n return;\n }\n\n if (Array.isArray(arg)) {\n return;\n }\n\n if (!arg.isJSXFragment() && !arg.isJSXElement()) {\n return;\n }\n\n jsxNode = arg;\n }\n\n if (!jsxNode) {\n return;\n }\n\n processJSX(\n annotateFragments,\n t,\n jsxNode,\n componentName,\n sourceFileName,\n attributeNames,\n ignoredComponents\n );\n}\n\nfunction processJSX(\n annotateFragments: boolean,\n t: typeof Babel.types,\n jsxNode: Babel.NodePath,\n componentName: string | null,\n sourceFileName: string | undefined,\n attributeNames: string[],\n ignoredComponents: IgnoredComponent[]\n) {\n if (!jsxNode) {\n return;\n }\n\n // NOTE: I don't know of a case where `openingElement` would have more than one item,\n // but it's safer to always iterate\n const paths = jsxNode.get(\"openingElement\");\n const openingElements = Array.isArray(paths) ? paths : [paths];\n\n openingElements.forEach((openingElement) => {\n applyAttributes(\n t,\n openingElement as Babel.NodePath<Babel.types.JSXOpeningElement>,\n componentName,\n sourceFileName,\n attributeNames,\n ignoredComponents\n );\n });\n\n let children = jsxNode.get(\"children\");\n // TODO: See why `Array.isArray` doesn't have correct behaviour here\n if (children && !(\"length\" in children)) {\n // A single child was found, maybe a bit of static text\n children = [children];\n }\n\n let shouldSetComponentName = annotateFragments;\n\n children.forEach((child) => {\n // Happens for some node types like plain text\n if (!child.node) {\n return;\n }\n\n // Children don't receive the data-component attribute so we pass null for componentName unless it's the first child of a Fragment with a node and `annotateFragments` is true\n const openingElement = child.get(\"openingElement\");\n // TODO: Improve this. We never expect to have multiple opening elements\n // but if it's possible, this should work\n if (Array.isArray(openingElement)) {\n return;\n }\n\n if (shouldSetComponentName && openingElement && openingElement.node) {\n shouldSetComponentName = false;\n processJSX(\n annotateFragments,\n t,\n child,\n componentName,\n sourceFileName,\n attributeNames,\n ignoredComponents\n );\n } else {\n processJSX(\n annotateFragments,\n t,\n child,\n null,\n sourceFileName,\n attributeNames,\n ignoredComponents\n );\n }\n });\n}\n\nfunction applyAttributes(\n t: typeof Babel.types,\n openingElement: Babel.NodePath<Babel.types.JSXOpeningElement>,\n componentName: string | null,\n sourceFileName: string | undefined,\n attributeNames: string[],\n ignoredComponents: IgnoredComponent[]\n) {\n const [componentAttributeName, elementAttributeName, sourceFileAttributeName] = attributeNames;\n\n if (isReactFragment(t, openingElement)) {\n return;\n }\n // e.g., Raw JSX text like the `A` in `<h1>a</h1>`\n if (!openingElement.node) {\n return;\n }\n\n if (!openingElement.node.attributes) openingElement.node.attributes = [];\n const elementName = getPathName(t, openingElement);\n\n const isAnIgnoredComponent = ignoredComponents.some(\n (ignoredComponent) =>\n matchesIgnoreRule(ignoredComponent[0], sourceFileName) &&\n matchesIgnoreRule(ignoredComponent[1], componentName) &&\n matchesIgnoreRule(ignoredComponent[2], elementName)\n );\n\n // Add a stable attribute for the element name but only for non-DOM names\n let isAnIgnoredElement = false;\n if (\n !isAnIgnoredComponent &&\n !hasAttributeWithName(openingElement, componentAttributeName) &&\n (componentAttributeName !== elementAttributeName || !componentName)\n ) {\n if (DEFAULT_IGNORED_ELEMENTS.includes(elementName)) {\n isAnIgnoredElement = true;\n } else {\n // TODO: Is it possible to avoid this null check?\n if (elementAttributeName) {\n openingElement.node.attributes.push(\n t.jSXAttribute(t.jSXIdentifier(elementAttributeName), t.stringLiteral(elementName))\n );\n }\n }\n }\n\n // Add a stable attribute for the component name (absent for non-root elements)\n if (\n componentName &&\n !isAnIgnoredComponent &&\n !hasAttributeWithName(openingElement, componentAttributeName)\n ) {\n // TODO: Is it possible to avoid this null check?\n if (componentAttributeName) {\n openingElement.node.attributes.push(\n t.jSXAttribute(t.jSXIdentifier(componentAttributeName), t.stringLiteral(componentName))\n );\n }\n }\n\n // Add a stable attribute for the source file name (absent for non-root elements)\n if (\n sourceFileName &&\n !isAnIgnoredComponent &&\n (componentName || isAnIgnoredElement === false) &&\n !hasAttributeWithName(openingElement, sourceFileAttributeName)\n ) {\n // TODO: Is it possible to avoid this null check?\n if (sourceFileAttributeName) {\n openingElement.node.attributes.push(\n t.jSXAttribute(t.jSXIdentifier(sourceFileAttributeName), t.stringLiteral(sourceFileName))\n );\n }\n }\n}\n\nfunction sourceFileNameFromState(state: AnnotationPluginPass) {\n const name = fullSourceFileNameFromState(state);\n if (!name) {\n return undefined;\n }\n\n if (name.indexOf(\"/\") !== -1) {\n return name.split(\"/\").pop();\n } else if (name.indexOf(\"\\\\\") !== -1) {\n return name.split(\"\\\\\").pop();\n } else {\n return name;\n }\n}\n\nfunction fullSourceFileNameFromState(state: AnnotationPluginPass): string | null {\n // @ts-expect-error This type is incorrect in Babel, `sourceFileName` is the correct type\n const name = state.file.opts.parserOpts?.sourceFileName as unknown;\n\n if (typeof name === \"string\") {\n return name;\n }\n\n return null;\n}\n\nfunction isKnownIncompatiblePluginFromState(state: AnnotationPluginPass) {\n const fullSourceFileName = fullSourceFileNameFromState(state);\n\n if (!fullSourceFileName) {\n return false;\n }\n\n return KNOWN_INCOMPATIBLE_PLUGINS.some((pluginName) => {\n if (\n fullSourceFileName.includes(`/node_modules/${pluginName}/`) ||\n fullSourceFileName.includes(`\\\\node_modules\\\\${pluginName}\\\\`)\n ) {\n return true;\n }\n\n return false;\n });\n}\n\nfunction attributeNamesFromState(state: AnnotationPluginPass): [string, string, string] {\n if (state.opts.native) {\n return [nativeComponentName, nativeElementName, nativeSourceFileName];\n }\n\n return [webComponentName, webElementName, webSourceFileName];\n}\n\nfunction isReactFragment(t: typeof Babel.types, openingElement: Babel.NodePath): boolean {\n if (openingElement.isJSXFragment()) {\n return true;\n }\n\n const elementName = getPathName(t, openingElement);\n\n if (elementName === \"Fragment\" || elementName === \"React.Fragment\") {\n return true;\n }\n\n // TODO: All these objects are typed as unknown, maybe an oversight in Babel types?\n if (\n openingElement.node &&\n \"name\" in openingElement.node &&\n openingElement.node.name &&\n typeof openingElement.node.name === \"object\" &&\n \"type\" in openingElement.node.name &&\n openingElement.node.name.type === \"JSXMemberExpression\"\n ) {\n if (!(\"name\" in openingElement.node)) {\n return false;\n }\n\n const nodeName = openingElement.node.name;\n if (typeof nodeName !== \"object\" || !nodeName) {\n return false;\n }\n\n if (\"object\" in nodeName && \"property\" in nodeName) {\n const nodeNameObject = nodeName.object;\n const nodeNameProperty = nodeName.property;\n\n if (typeof nodeNameObject !== \"object\" || typeof nodeNameProperty !== \"object\") {\n return false;\n }\n\n if (!nodeNameObject || !nodeNameProperty) {\n return false;\n }\n\n const objectName = \"name\" in nodeNameObject && nodeNameObject.name;\n const propertyName = \"name\" in nodeNameProperty && nodeNameProperty.name;\n\n if (objectName === \"React\" && propertyName === \"Fragment\") {\n return true;\n }\n }\n }\n\n return false;\n}\n\nfunction matchesIgnoreRule(rule: string, name: string | undefined | null) {\n return rule === \"*\" || rule === name;\n}\n\nfunction hasAttributeWithName(\n openingElement: Babel.NodePath<Babel.types.JSXOpeningElement>,\n name: string | undefined | null\n): boolean {\n if (!name) {\n return false;\n }\n\n return openingElement.node.attributes.some((node) => {\n if (node.type === \"JSXAttribute\") {\n return node.name.name === name;\n }\n\n return false;\n });\n}\n\nfunction getPathName(t: typeof Babel.types, path: Babel.NodePath): string {\n if (!path.node) return UNKNOWN_ELEMENT_NAME;\n if (!(\"name\" in path.node)) {\n return UNKNOWN_ELEMENT_NAME;\n }\n\n const name = path.node.name;\n\n if (typeof name === \"string\") {\n return name;\n }\n\n if (t.isIdentifier(name) || t.isJSXIdentifier(name)) {\n return name.name;\n }\n\n if (t.isJSXNamespacedName(name)) {\n return name.name.name;\n }\n\n return UNKNOWN_ELEMENT_NAME;\n}\n\nconst UNKNOWN_ELEMENT_NAME = \"unknown\";\n"],"names":["KNOWN_INCOMPATIBLE_PLUGINS","DEFAULT_IGNORED_ELEMENTS","webComponentName","webElementName","webSourceFileName","nativeComponentName","nativeElementName","nativeSourceFileName","componentNameAnnotatePlugin","_ref","t","types","visitor","FunctionDeclaration","path","state","_state$opts$ignoreCom","node","id","name","isKnownIncompatiblePluginFromState","functionBodyPushAttributes","opts","sourceFileNameFromState","attributeNamesFromState","ignoreComponents","ArrowFunctionExpression","_state$opts$ignoreCom2","parent","ClassDeclaration","_state$opts$ignoreCom3","get","properties","render","find","prop","isClassMethod","isIdentifier","traverse","ignoredComponents","ReturnStatement","returnStatement","arg","isJSXElement","isJSXFragment","processJSX","annotateFragments","componentName","sourceFileName","attributeNames","jsxNode","functionBody","type","maybeJsxNode","c","Array","isArray","paths","openingElements","forEach","openingElement","applyAttributes","children","shouldSetComponentName","child","_attributeNames","_slicedToArray","componentAttributeName","elementAttributeName","sourceFileAttributeName","isReactFragment","attributes","elementName","getPathName","isAnIgnoredComponent","some","ignoredComponent","matchesIgnoreRule","isAnIgnoredElement","hasAttributeWithName","includes","push","jSXAttribute","jSXIdentifier","stringLiteral","fullSourceFileNameFromState","undefined","indexOf","split","pop","_state$file$opts$pars","file","parserOpts","fullSourceFileName","pluginName","concat","_typeof","nodeName","nodeNameObject","object","nodeNameProperty","property","objectName","propertyName","rule","UNKNOWN_ELEMENT_NAME","isJSXIdentifier","isJSXNamespacedName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,IAAMA,0BAA0B,GAAG;AACxC;AACA,wBAAwB;AACxB;AACA,mBAAmB,CACpB,CAAA;AAEM,IAAMC,wBAAwB,GAAG,CACtC,GAAG,EACH,MAAM,EACN,SAAS,EACT,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,EACP,GAAG,EACH,MAAM,EACN,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,MAAM,EACN,KAAK,EACL,UAAU,EACV,MAAM,EACN,UAAU,EACV,IAAI,EACJ,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,GAAG,EACH,QAAQ,EACR,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,UAAU,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,OAAO,EAC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,OAAO,KAAK,CAAA;AACd,GAAC,CAAC,CAAA;AACJ,CAAA;AAEA,SAASsD,WAAWA,CAAC/D,CAAqB,EAAEI,IAAoB,EAAU;AACxE,EAAA,IAAI,CAACA,IAAI,CAACG,IAAI,EAAE,OAAOwF,oBAAoB,CAAA;AAC3C,EAAA,IAAI,EAAE,MAAM,IAAI3F,IAAI,CAACG,IAAI,CAAC,EAAE;AAC1B,IAAA,OAAOwF,oBAAoB,CAAA;AAC7B,GAAA;AAEA,EAAA,IAAMtF,IAAI,GAAGL,IAAI,CAACG,IAAI,CAACE,IAAI,CAAA;AAE3B,EAAA,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;AAC5B,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;AAEA,EAAA,IAAIT,CAAC,CAAC2B,YAAY,CAAClB,IAAI,CAAC,IAAIT,CAAC,CAACgG,eAAe,CAACvF,IAAI,CAAC,EAAE;IACnD,OAAOA,IAAI,CAACA,IAAI,CAAA;AAClB,GAAA;AAEA,EAAA,IAAIT,CAAC,CAACiG,mBAAmB,CAACxF,IAAI,CAAC,EAAE;AAC/B,IAAA,OAAOA,IAAI,CAACA,IAAI,CAACA,IAAI,CAAA;AACvB,GAAA;AAEA,EAAA,OAAOsF,oBAAoB,CAAA;AAC7B,CAAA;AAEA,IAAMA,oBAAoB,GAAG,SAAS;;;;"}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
function _iterableToArrayLimit(arr, i) {
|
|
2
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
3
|
+
if (null != _i) {
|
|
4
|
+
var _s,
|
|
5
|
+
_e,
|
|
6
|
+
_x,
|
|
7
|
+
_r,
|
|
8
|
+
_arr = [],
|
|
9
|
+
_n = !0,
|
|
10
|
+
_d = !1;
|
|
11
|
+
try {
|
|
12
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
13
|
+
if (Object(_i) !== _i) return;
|
|
14
|
+
_n = !1;
|
|
15
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
_d = !0, _e = err;
|
|
18
|
+
} finally {
|
|
19
|
+
try {
|
|
20
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
21
|
+
} finally {
|
|
22
|
+
if (_d) throw _e;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return _arr;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function _typeof(obj) {
|
|
29
|
+
"@babel/helpers - typeof";
|
|
30
|
+
|
|
31
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
32
|
+
return typeof obj;
|
|
33
|
+
} : function (obj) {
|
|
34
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
35
|
+
}, _typeof(obj);
|
|
36
|
+
}
|
|
37
|
+
function _slicedToArray(arr, i) {
|
|
38
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
39
|
+
}
|
|
40
|
+
function _arrayWithHoles(arr) {
|
|
41
|
+
if (Array.isArray(arr)) return arr;
|
|
42
|
+
}
|
|
43
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
44
|
+
if (!o) return;
|
|
45
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
46
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
47
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
48
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
49
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
50
|
+
}
|
|
51
|
+
function _arrayLikeToArray(arr, len) {
|
|
52
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
53
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
54
|
+
return arr2;
|
|
55
|
+
}
|
|
56
|
+
function _nonIterableRest() {
|
|
57
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* MIT License
|
|
62
|
+
*
|
|
63
|
+
* Copyright (c) 2020 Engineering at FullStory
|
|
64
|
+
*
|
|
65
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
66
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
67
|
+
* in the Software without restriction, including without limitation the rights
|
|
68
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
69
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
70
|
+
* furnished to do so, subject to the following conditions:
|
|
71
|
+
*
|
|
72
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
73
|
+
* copies or substantial portions of the Software.
|
|
74
|
+
*
|
|
75
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
76
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
77
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
78
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
79
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
80
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
81
|
+
* SOFTWARE.
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
var KNOWN_INCOMPATIBLE_PLUGINS = [
|
|
86
|
+
// This module might be causing an issue preventing clicks. For safety, we won't run on this module.
|
|
87
|
+
"react-native-testfairy",
|
|
88
|
+
// This module checks for unexpected property keys and throws an exception.
|
|
89
|
+
"@react-navigation"];
|
|
90
|
+
var DEFAULT_IGNORED_ELEMENTS = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr"];
|
|
91
|
+
|
|
92
|
+
var webComponentName = "data-sentry-component";
|
|
93
|
+
var webElementName = "data-sentry-element";
|
|
94
|
+
var webSourceFileName = "data-sentry-source-file";
|
|
95
|
+
var nativeComponentName = "dataSentryComponent";
|
|
96
|
+
var nativeElementName = "dataSentryElement";
|
|
97
|
+
var nativeSourceFileName = "dataSentrySourceFile";
|
|
98
|
+
function componentNameAnnotatePlugin(_ref) {
|
|
99
|
+
var t = _ref.types;
|
|
100
|
+
return {
|
|
101
|
+
visitor: {
|
|
102
|
+
FunctionDeclaration: function FunctionDeclaration(path, state) {
|
|
103
|
+
var _state$opts$ignoreCom;
|
|
104
|
+
if (!path.node.id || !path.node.id.name) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (isKnownIncompatiblePluginFromState(state)) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
functionBodyPushAttributes(state.opts["annotate-fragments"] === true, t, path, path.node.id.name, sourceFileNameFromState(state), attributeNamesFromState(state), (_state$opts$ignoreCom = state.opts.ignoreComponents) !== null && _state$opts$ignoreCom !== void 0 ? _state$opts$ignoreCom : []);
|
|
111
|
+
},
|
|
112
|
+
ArrowFunctionExpression: function ArrowFunctionExpression(path, state) {
|
|
113
|
+
var _state$opts$ignoreCom2;
|
|
114
|
+
// We're expecting a `VariableDeclarator` like `const MyComponent =`
|
|
115
|
+
var parent = path.parent;
|
|
116
|
+
if (!parent || !("id" in parent) || !parent.id || !("name" in parent.id) || !parent.id.name) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (isKnownIncompatiblePluginFromState(state)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
functionBodyPushAttributes(state.opts["annotate-fragments"] === true, t, path, parent.id.name, sourceFileNameFromState(state), attributeNamesFromState(state), (_state$opts$ignoreCom2 = state.opts.ignoreComponents) !== null && _state$opts$ignoreCom2 !== void 0 ? _state$opts$ignoreCom2 : []);
|
|
123
|
+
},
|
|
124
|
+
ClassDeclaration: function ClassDeclaration(path, state) {
|
|
125
|
+
var _state$opts$ignoreCom3;
|
|
126
|
+
var name = path.get("id");
|
|
127
|
+
var properties = path.get("body").get("body");
|
|
128
|
+
var render = properties.find(function (prop) {
|
|
129
|
+
return prop.isClassMethod() && prop.get("key").isIdentifier({
|
|
130
|
+
name: "render"
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
if (!render || !render.traverse || isKnownIncompatiblePluginFromState(state)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
var ignoredComponents = (_state$opts$ignoreCom3 = state.opts.ignoreComponents) !== null && _state$opts$ignoreCom3 !== void 0 ? _state$opts$ignoreCom3 : [];
|
|
137
|
+
render.traverse({
|
|
138
|
+
ReturnStatement: function ReturnStatement(returnStatement) {
|
|
139
|
+
var arg = returnStatement.get("argument");
|
|
140
|
+
if (!arg.isJSXElement() && !arg.isJSXFragment()) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
processJSX(state.opts["annotate-fragments"] === true, t, arg, name.node && name.node.name, sourceFileNameFromState(state), attributeNamesFromState(state), ignoredComponents);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function functionBodyPushAttributes(annotateFragments, t, path, componentName, sourceFileName, attributeNames, ignoredComponents) {
|
|
151
|
+
var jsxNode;
|
|
152
|
+
var functionBody = path.get("body").get("body");
|
|
153
|
+
if (!("length" in functionBody) && functionBody.parent && (functionBody.parent.type === "JSXElement" || functionBody.parent.type === "JSXFragment")) {
|
|
154
|
+
var maybeJsxNode = functionBody.find(function (c) {
|
|
155
|
+
return c.type === "JSXElement" || c.type === "JSXFragment";
|
|
156
|
+
});
|
|
157
|
+
if (!maybeJsxNode) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
jsxNode = maybeJsxNode;
|
|
161
|
+
} else {
|
|
162
|
+
var returnStatement = functionBody.find(function (c) {
|
|
163
|
+
return c.type === "ReturnStatement";
|
|
164
|
+
});
|
|
165
|
+
if (!returnStatement) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
var arg = returnStatement.get("argument");
|
|
169
|
+
if (!arg) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (Array.isArray(arg)) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (!arg.isJSXFragment() && !arg.isJSXElement()) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
jsxNode = arg;
|
|
179
|
+
}
|
|
180
|
+
if (!jsxNode) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
processJSX(annotateFragments, t, jsxNode, componentName, sourceFileName, attributeNames, ignoredComponents);
|
|
184
|
+
}
|
|
185
|
+
function processJSX(annotateFragments, t, jsxNode, componentName, sourceFileName, attributeNames, ignoredComponents) {
|
|
186
|
+
if (!jsxNode) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// NOTE: I don't know of a case where `openingElement` would have more than one item,
|
|
191
|
+
// but it's safer to always iterate
|
|
192
|
+
var paths = jsxNode.get("openingElement");
|
|
193
|
+
var openingElements = Array.isArray(paths) ? paths : [paths];
|
|
194
|
+
openingElements.forEach(function (openingElement) {
|
|
195
|
+
applyAttributes(t, openingElement, componentName, sourceFileName, attributeNames, ignoredComponents);
|
|
196
|
+
});
|
|
197
|
+
var children = jsxNode.get("children");
|
|
198
|
+
// TODO: See why `Array.isArray` doesn't have correct behaviour here
|
|
199
|
+
if (children && !("length" in children)) {
|
|
200
|
+
// A single child was found, maybe a bit of static text
|
|
201
|
+
children = [children];
|
|
202
|
+
}
|
|
203
|
+
var shouldSetComponentName = annotateFragments;
|
|
204
|
+
children.forEach(function (child) {
|
|
205
|
+
// Happens for some node types like plain text
|
|
206
|
+
if (!child.node) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Children don't receive the data-component attribute so we pass null for componentName unless it's the first child of a Fragment with a node and `annotateFragments` is true
|
|
211
|
+
var openingElement = child.get("openingElement");
|
|
212
|
+
// TODO: Improve this. We never expect to have multiple opening elements
|
|
213
|
+
// but if it's possible, this should work
|
|
214
|
+
if (Array.isArray(openingElement)) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (shouldSetComponentName && openingElement && openingElement.node) {
|
|
218
|
+
shouldSetComponentName = false;
|
|
219
|
+
processJSX(annotateFragments, t, child, componentName, sourceFileName, attributeNames, ignoredComponents);
|
|
220
|
+
} else {
|
|
221
|
+
processJSX(annotateFragments, t, child, null, sourceFileName, attributeNames, ignoredComponents);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function applyAttributes(t, openingElement, componentName, sourceFileName, attributeNames, ignoredComponents) {
|
|
226
|
+
var _attributeNames = _slicedToArray(attributeNames, 3),
|
|
227
|
+
componentAttributeName = _attributeNames[0],
|
|
228
|
+
elementAttributeName = _attributeNames[1],
|
|
229
|
+
sourceFileAttributeName = _attributeNames[2];
|
|
230
|
+
if (isReactFragment(t, openingElement)) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
// e.g., Raw JSX text like the `A` in `<h1>a</h1>`
|
|
234
|
+
if (!openingElement.node) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (!openingElement.node.attributes) openingElement.node.attributes = [];
|
|
238
|
+
var elementName = getPathName(t, openingElement);
|
|
239
|
+
var isAnIgnoredComponent = ignoredComponents.some(function (ignoredComponent) {
|
|
240
|
+
return matchesIgnoreRule(ignoredComponent[0], sourceFileName) && matchesIgnoreRule(ignoredComponent[1], componentName) && matchesIgnoreRule(ignoredComponent[2], elementName);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// Add a stable attribute for the element name but only for non-DOM names
|
|
244
|
+
var isAnIgnoredElement = false;
|
|
245
|
+
if (!isAnIgnoredComponent && !hasAttributeWithName(openingElement, componentAttributeName) && (componentAttributeName !== elementAttributeName || !componentName)) {
|
|
246
|
+
if (DEFAULT_IGNORED_ELEMENTS.includes(elementName)) {
|
|
247
|
+
isAnIgnoredElement = true;
|
|
248
|
+
} else {
|
|
249
|
+
// TODO: Is it possible to avoid this null check?
|
|
250
|
+
if (elementAttributeName) {
|
|
251
|
+
openingElement.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(elementAttributeName), t.stringLiteral(elementName)));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Add a stable attribute for the component name (absent for non-root elements)
|
|
257
|
+
if (componentName && !isAnIgnoredComponent && !hasAttributeWithName(openingElement, componentAttributeName)) {
|
|
258
|
+
// TODO: Is it possible to avoid this null check?
|
|
259
|
+
if (componentAttributeName) {
|
|
260
|
+
openingElement.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(componentAttributeName), t.stringLiteral(componentName)));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Add a stable attribute for the source file name (absent for non-root elements)
|
|
265
|
+
if (sourceFileName && !isAnIgnoredComponent && (componentName || isAnIgnoredElement === false) && !hasAttributeWithName(openingElement, sourceFileAttributeName)) {
|
|
266
|
+
// TODO: Is it possible to avoid this null check?
|
|
267
|
+
if (sourceFileAttributeName) {
|
|
268
|
+
openingElement.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(sourceFileAttributeName), t.stringLiteral(sourceFileName)));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function sourceFileNameFromState(state) {
|
|
273
|
+
var name = fullSourceFileNameFromState(state);
|
|
274
|
+
if (!name) {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
if (name.indexOf("/") !== -1) {
|
|
278
|
+
return name.split("/").pop();
|
|
279
|
+
} else if (name.indexOf("\\") !== -1) {
|
|
280
|
+
return name.split("\\").pop();
|
|
281
|
+
} else {
|
|
282
|
+
return name;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function fullSourceFileNameFromState(state) {
|
|
286
|
+
var _state$file$opts$pars;
|
|
287
|
+
// @ts-expect-error This type is incorrect in Babel, `sourceFileName` is the correct type
|
|
288
|
+
var name = (_state$file$opts$pars = state.file.opts.parserOpts) === null || _state$file$opts$pars === void 0 ? void 0 : _state$file$opts$pars.sourceFileName;
|
|
289
|
+
if (typeof name === "string") {
|
|
290
|
+
return name;
|
|
291
|
+
}
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
function isKnownIncompatiblePluginFromState(state) {
|
|
295
|
+
var fullSourceFileName = fullSourceFileNameFromState(state);
|
|
296
|
+
if (!fullSourceFileName) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
return KNOWN_INCOMPATIBLE_PLUGINS.some(function (pluginName) {
|
|
300
|
+
if (fullSourceFileName.includes("/node_modules/".concat(pluginName, "/")) || fullSourceFileName.includes("\\node_modules\\".concat(pluginName, "\\"))) {
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function attributeNamesFromState(state) {
|
|
307
|
+
if (state.opts["native"]) {
|
|
308
|
+
return [nativeComponentName, nativeElementName, nativeSourceFileName];
|
|
309
|
+
}
|
|
310
|
+
return [webComponentName, webElementName, webSourceFileName];
|
|
311
|
+
}
|
|
312
|
+
function isReactFragment(t, openingElement) {
|
|
313
|
+
if (openingElement.isJSXFragment()) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
var elementName = getPathName(t, openingElement);
|
|
317
|
+
if (elementName === "Fragment" || elementName === "React.Fragment") {
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// TODO: All these objects are typed as unknown, maybe an oversight in Babel types?
|
|
322
|
+
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") {
|
|
323
|
+
if (!("name" in openingElement.node)) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
var nodeName = openingElement.node.name;
|
|
327
|
+
if (_typeof(nodeName) !== "object" || !nodeName) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
if ("object" in nodeName && "property" in nodeName) {
|
|
331
|
+
var nodeNameObject = nodeName.object;
|
|
332
|
+
var nodeNameProperty = nodeName.property;
|
|
333
|
+
if (_typeof(nodeNameObject) !== "object" || _typeof(nodeNameProperty) !== "object") {
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
if (!nodeNameObject || !nodeNameProperty) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
var objectName = "name" in nodeNameObject && nodeNameObject.name;
|
|
340
|
+
var propertyName = "name" in nodeNameProperty && nodeNameProperty.name;
|
|
341
|
+
if (objectName === "React" && propertyName === "Fragment") {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
function matchesIgnoreRule(rule, name) {
|
|
349
|
+
return rule === "*" || rule === name;
|
|
350
|
+
}
|
|
351
|
+
function hasAttributeWithName(openingElement, name) {
|
|
352
|
+
if (!name) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
return openingElement.node.attributes.some(function (node) {
|
|
356
|
+
if (node.type === "JSXAttribute") {
|
|
357
|
+
return node.name.name === name;
|
|
358
|
+
}
|
|
359
|
+
return false;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function getPathName(t, path) {
|
|
363
|
+
if (!path.node) return UNKNOWN_ELEMENT_NAME;
|
|
364
|
+
if (!("name" in path.node)) {
|
|
365
|
+
return UNKNOWN_ELEMENT_NAME;
|
|
366
|
+
}
|
|
367
|
+
var name = path.node.name;
|
|
368
|
+
if (typeof name === "string") {
|
|
369
|
+
return name;
|
|
370
|
+
}
|
|
371
|
+
if (t.isIdentifier(name) || t.isJSXIdentifier(name)) {
|
|
372
|
+
return name.name;
|
|
373
|
+
}
|
|
374
|
+
if (t.isJSXNamespacedName(name)) {
|
|
375
|
+
return name.name.name;
|
|
376
|
+
}
|
|
377
|
+
return UNKNOWN_ELEMENT_NAME;
|
|
378
|
+
}
|
|
379
|
+
var UNKNOWN_ELEMENT_NAME = "unknown";
|
|
380
|
+
|
|
381
|
+
export { componentNameAnnotatePlugin };
|
|
382
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/constants.ts","../../src/index.ts"],"sourcesContent":["/**\n * MIT License\n *\n * Copyright (c) 2020 Engineering at FullStory\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n */\n\nexport const KNOWN_INCOMPATIBLE_PLUGINS = [\n // This module might be causing an issue preventing clicks. For safety, we won't run on this module.\n \"react-native-testfairy\",\n // This module checks for unexpected property keys and throws an exception.\n \"@react-navigation\",\n];\n\nexport const DEFAULT_IGNORED_ELEMENTS = [\n \"a\",\n \"abbr\",\n \"address\",\n \"area\",\n \"article\",\n \"aside\",\n \"audio\",\n \"b\",\n \"base\",\n \"bdi\",\n \"bdo\",\n \"blockquote\",\n \"body\",\n \"br\",\n \"button\",\n \"canvas\",\n \"caption\",\n \"cite\",\n \"code\",\n \"col\",\n \"colgroup\",\n \"data\",\n \"datalist\",\n \"dd\",\n \"del\",\n \"details\",\n \"dfn\",\n \"dialog\",\n \"div\",\n \"dl\",\n \"dt\",\n \"em\",\n \"embed\",\n \"fieldset\",\n \"figure\",\n \"footer\",\n \"form\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"head\",\n \"header\",\n \"hgroup\",\n \"hr\",\n \"html\",\n \"i\",\n \"iframe\",\n \"img\",\n \"input\",\n \"ins\",\n \"kbd\",\n \"keygen\",\n \"label\",\n \"legend\",\n \"li\",\n \"link\",\n \"main\",\n \"map\",\n \"mark\",\n \"menu\",\n \"menuitem\",\n \"meter\",\n \"nav\",\n \"noscript\",\n \"object\",\n \"ol\",\n \"optgroup\",\n \"option\",\n \"output\",\n \"p\",\n \"param\",\n \"pre\",\n \"progress\",\n \"q\",\n \"rb\",\n \"rp\",\n \"rt\",\n \"rtc\",\n \"ruby\",\n \"s\",\n \"samp\",\n \"script\",\n \"section\",\n \"select\",\n \"small\",\n \"source\",\n \"span\",\n \"strong\",\n \"style\",\n \"sub\",\n \"summary\",\n \"sup\",\n \"table\",\n \"tbody\",\n \"td\",\n \"template\",\n \"textarea\",\n \"tfoot\",\n \"th\",\n \"thead\",\n \"time\",\n \"title\",\n \"tr\",\n \"track\",\n \"u\",\n \"ul\",\n \"var\",\n \"video\",\n \"wbr\",\n];\n","/**\n * MIT License\n *\n * Copyright (c) 2020 Engineering at FullStory\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n */\n\n/**\n * The following code is based on the FullStory Babel plugin, but has been modified to work\n * with Sentry products:\n *\n * - Added `sentry` to data properties, i.e `data-sentry-component`\n * - Converted to TypeScript\n * - Code cleanups\n */\n\nimport type * as Babel from \"@babel/core\";\nimport type { PluginObj, PluginPass } from \"@babel/core\";\n\nimport { DEFAULT_IGNORED_ELEMENTS, KNOWN_INCOMPATIBLE_PLUGINS } from \"./constants\";\n\nconst webComponentName = \"data-sentry-component\";\nconst webElementName = \"data-sentry-element\";\nconst webSourceFileName = \"data-sentry-source-file\";\n\nconst nativeComponentName = \"dataSentryComponent\";\nconst nativeElementName = \"dataSentryElement\";\nconst nativeSourceFileName = \"dataSentrySourceFile\";\n\ninterface AnnotationOpts {\n native?: boolean;\n \"annotate-fragments\"?: boolean;\n ignoreComponents?: IgnoredComponent[];\n}\n\ninterface AnnotationPluginPass extends PluginPass {\n opts: AnnotationOpts;\n}\n\ntype IgnoredComponent = [file: string, component: string, element: string];\n\ntype AnnotationPlugin = PluginObj<AnnotationPluginPass>;\n\nexport function componentNameAnnotatePlugin({ types: t }: typeof Babel): AnnotationPlugin {\n return {\n visitor: {\n FunctionDeclaration(path, state) {\n if (!path.node.id || !path.node.id.name) {\n return;\n }\n if (isKnownIncompatiblePluginFromState(state)) {\n return;\n }\n\n functionBodyPushAttributes(\n state.opts[\"annotate-fragments\"] === true,\n t,\n path,\n path.node.id.name,\n sourceFileNameFromState(state),\n attributeNamesFromState(state),\n state.opts.ignoreComponents ?? []\n );\n },\n ArrowFunctionExpression(path, state) {\n // We're expecting a `VariableDeclarator` like `const MyComponent =`\n const parent = path.parent;\n if (\n !parent ||\n !(\"id\" in parent) ||\n !parent.id ||\n !(\"name\" in parent.id) ||\n !parent.id.name\n ) {\n return;\n }\n\n if (isKnownIncompatiblePluginFromState(state)) {\n return;\n }\n\n functionBodyPushAttributes(\n state.opts[\"annotate-fragments\"] === true,\n t,\n path,\n parent.id.name,\n sourceFileNameFromState(state),\n attributeNamesFromState(state),\n state.opts.ignoreComponents ?? []\n );\n },\n ClassDeclaration(path, state) {\n const name = path.get(\"id\");\n const properties = path.get(\"body\").get(\"body\");\n const render = properties.find((prop) => {\n return prop.isClassMethod() && prop.get(\"key\").isIdentifier({ name: \"render\" });\n });\n\n if (!render || !render.traverse || isKnownIncompatiblePluginFromState(state)) {\n return;\n }\n\n const ignoredComponents = state.opts.ignoreComponents ?? [];\n\n render.traverse({\n ReturnStatement(returnStatement) {\n const arg = returnStatement.get(\"argument\");\n\n if (!arg.isJSXElement() && !arg.isJSXFragment()) {\n return;\n }\n\n processJSX(\n state.opts[\"annotate-fragments\"] === true,\n t,\n arg,\n name.node && name.node.name,\n sourceFileNameFromState(state),\n attributeNamesFromState(state),\n ignoredComponents\n );\n },\n });\n },\n },\n };\n}\n\nfunction functionBodyPushAttributes(\n annotateFragments: boolean,\n t: typeof Babel.types,\n path: Babel.NodePath<Babel.types.Function>,\n componentName: string,\n sourceFileName: string | undefined,\n attributeNames: string[],\n ignoredComponents: IgnoredComponent[]\n) {\n let jsxNode: Babel.NodePath;\n\n const functionBody = path.get(\"body\").get(\"body\");\n\n if (\n !(\"length\" in functionBody) &&\n functionBody.parent &&\n (functionBody.parent.type === \"JSXElement\" || functionBody.parent.type === \"JSXFragment\")\n ) {\n const maybeJsxNode = functionBody.find((c) => {\n return c.type === \"JSXElement\" || c.type === \"JSXFragment\";\n });\n\n if (!maybeJsxNode) {\n return;\n }\n\n jsxNode = maybeJsxNode;\n } else {\n const returnStatement = functionBody.find((c) => {\n return c.type === \"ReturnStatement\";\n });\n if (!returnStatement) {\n return;\n }\n\n const arg = returnStatement.get(\"argument\");\n if (!arg) {\n return;\n }\n\n if (Array.isArray(arg)) {\n return;\n }\n\n if (!arg.isJSXFragment() && !arg.isJSXElement()) {\n return;\n }\n\n jsxNode = arg;\n }\n\n if (!jsxNode) {\n return;\n }\n\n processJSX(\n annotateFragments,\n t,\n jsxNode,\n componentName,\n sourceFileName,\n attributeNames,\n ignoredComponents\n );\n}\n\nfunction processJSX(\n annotateFragments: boolean,\n t: typeof Babel.types,\n jsxNode: Babel.NodePath,\n componentName: string | null,\n sourceFileName: string | undefined,\n attributeNames: string[],\n ignoredComponents: IgnoredComponent[]\n) {\n if (!jsxNode) {\n return;\n }\n\n // NOTE: I don't know of a case where `openingElement` would have more than one item,\n // but it's safer to always iterate\n const paths = jsxNode.get(\"openingElement\");\n const openingElements = Array.isArray(paths) ? paths : [paths];\n\n openingElements.forEach((openingElement) => {\n applyAttributes(\n t,\n openingElement as Babel.NodePath<Babel.types.JSXOpeningElement>,\n componentName,\n sourceFileName,\n attributeNames,\n ignoredComponents\n );\n });\n\n let children = jsxNode.get(\"children\");\n // TODO: See why `Array.isArray` doesn't have correct behaviour here\n if (children && !(\"length\" in children)) {\n // A single child was found, maybe a bit of static text\n children = [children];\n }\n\n let shouldSetComponentName = annotateFragments;\n\n children.forEach((child) => {\n // Happens for some node types like plain text\n if (!child.node) {\n return;\n }\n\n // Children don't receive the data-component attribute so we pass null for componentName unless it's the first child of a Fragment with a node and `annotateFragments` is true\n const openingElement = child.get(\"openingElement\");\n // TODO: Improve this. We never expect to have multiple opening elements\n // but if it's possible, this should work\n if (Array.isArray(openingElement)) {\n return;\n }\n\n if (shouldSetComponentName && openingElement && openingElement.node) {\n shouldSetComponentName = false;\n processJSX(\n annotateFragments,\n t,\n child,\n componentName,\n sourceFileName,\n attributeNames,\n ignoredComponents\n );\n } else {\n processJSX(\n annotateFragments,\n t,\n child,\n null,\n sourceFileName,\n attributeNames,\n ignoredComponents\n );\n }\n });\n}\n\nfunction applyAttributes(\n t: typeof Babel.types,\n openingElement: Babel.NodePath<Babel.types.JSXOpeningElement>,\n componentName: string | null,\n sourceFileName: string | undefined,\n attributeNames: string[],\n ignoredComponents: IgnoredComponent[]\n) {\n const [componentAttributeName, elementAttributeName, sourceFileAttributeName] = attributeNames;\n\n if (isReactFragment(t, openingElement)) {\n return;\n }\n // e.g., Raw JSX text like the `A` in `<h1>a</h1>`\n if (!openingElement.node) {\n return;\n }\n\n if (!openingElement.node.attributes) openingElement.node.attributes = [];\n const elementName = getPathName(t, openingElement);\n\n const isAnIgnoredComponent = ignoredComponents.some(\n (ignoredComponent) =>\n matchesIgnoreRule(ignoredComponent[0], sourceFileName) &&\n matchesIgnoreRule(ignoredComponent[1], componentName) &&\n matchesIgnoreRule(ignoredComponent[2], elementName)\n );\n\n // Add a stable attribute for the element name but only for non-DOM names\n let isAnIgnoredElement = false;\n if (\n !isAnIgnoredComponent &&\n !hasAttributeWithName(openingElement, componentAttributeName) &&\n (componentAttributeName !== elementAttributeName || !componentName)\n ) {\n if (DEFAULT_IGNORED_ELEMENTS.includes(elementName)) {\n isAnIgnoredElement = true;\n } else {\n // TODO: Is it possible to avoid this null check?\n if (elementAttributeName) {\n openingElement.node.attributes.push(\n t.jSXAttribute(t.jSXIdentifier(elementAttributeName), t.stringLiteral(elementName))\n );\n }\n }\n }\n\n // Add a stable attribute for the component name (absent for non-root elements)\n if (\n componentName &&\n !isAnIgnoredComponent &&\n !hasAttributeWithName(openingElement, componentAttributeName)\n ) {\n // TODO: Is it possible to avoid this null check?\n if (componentAttributeName) {\n openingElement.node.attributes.push(\n t.jSXAttribute(t.jSXIdentifier(componentAttributeName), t.stringLiteral(componentName))\n );\n }\n }\n\n // Add a stable attribute for the source file name (absent for non-root elements)\n if (\n sourceFileName &&\n !isAnIgnoredComponent &&\n (componentName || isAnIgnoredElement === false) &&\n !hasAttributeWithName(openingElement, sourceFileAttributeName)\n ) {\n // TODO: Is it possible to avoid this null check?\n if (sourceFileAttributeName) {\n openingElement.node.attributes.push(\n t.jSXAttribute(t.jSXIdentifier(sourceFileAttributeName), t.stringLiteral(sourceFileName))\n );\n }\n }\n}\n\nfunction sourceFileNameFromState(state: AnnotationPluginPass) {\n const name = fullSourceFileNameFromState(state);\n if (!name) {\n return undefined;\n }\n\n if (name.indexOf(\"/\") !== -1) {\n return name.split(\"/\").pop();\n } else if (name.indexOf(\"\\\\\") !== -1) {\n return name.split(\"\\\\\").pop();\n } else {\n return name;\n }\n}\n\nfunction fullSourceFileNameFromState(state: AnnotationPluginPass): string | null {\n // @ts-expect-error This type is incorrect in Babel, `sourceFileName` is the correct type\n const name = state.file.opts.parserOpts?.sourceFileName as unknown;\n\n if (typeof name === \"string\") {\n return name;\n }\n\n return null;\n}\n\nfunction isKnownIncompatiblePluginFromState(state: AnnotationPluginPass) {\n const fullSourceFileName = fullSourceFileNameFromState(state);\n\n if (!fullSourceFileName) {\n return false;\n }\n\n return KNOWN_INCOMPATIBLE_PLUGINS.some((pluginName) => {\n if (\n fullSourceFileName.includes(`/node_modules/${pluginName}/`) ||\n fullSourceFileName.includes(`\\\\node_modules\\\\${pluginName}\\\\`)\n ) {\n return true;\n }\n\n return false;\n });\n}\n\nfunction attributeNamesFromState(state: AnnotationPluginPass): [string, string, string] {\n if (state.opts.native) {\n return [nativeComponentName, nativeElementName, nativeSourceFileName];\n }\n\n return [webComponentName, webElementName, webSourceFileName];\n}\n\nfunction isReactFragment(t: typeof Babel.types, openingElement: Babel.NodePath): boolean {\n if (openingElement.isJSXFragment()) {\n return true;\n }\n\n const elementName = getPathName(t, openingElement);\n\n if (elementName === \"Fragment\" || elementName === \"React.Fragment\") {\n return true;\n }\n\n // TODO: All these objects are typed as unknown, maybe an oversight in Babel types?\n if (\n openingElement.node &&\n \"name\" in openingElement.node &&\n openingElement.node.name &&\n typeof openingElement.node.name === \"object\" &&\n \"type\" in openingElement.node.name &&\n openingElement.node.name.type === \"JSXMemberExpression\"\n ) {\n if (!(\"name\" in openingElement.node)) {\n return false;\n }\n\n const nodeName = openingElement.node.name;\n if (typeof nodeName !== \"object\" || !nodeName) {\n return false;\n }\n\n if (\"object\" in nodeName && \"property\" in nodeName) {\n const nodeNameObject = nodeName.object;\n const nodeNameProperty = nodeName.property;\n\n if (typeof nodeNameObject !== \"object\" || typeof nodeNameProperty !== \"object\") {\n return false;\n }\n\n if (!nodeNameObject || !nodeNameProperty) {\n return false;\n }\n\n const objectName = \"name\" in nodeNameObject && nodeNameObject.name;\n const propertyName = \"name\" in nodeNameProperty && nodeNameProperty.name;\n\n if (objectName === \"React\" && propertyName === \"Fragment\") {\n return true;\n }\n }\n }\n\n return false;\n}\n\nfunction matchesIgnoreRule(rule: string, name: string | undefined | null) {\n return rule === \"*\" || rule === name;\n}\n\nfunction hasAttributeWithName(\n openingElement: Babel.NodePath<Babel.types.JSXOpeningElement>,\n name: string | undefined | null\n): boolean {\n if (!name) {\n return false;\n }\n\n return openingElement.node.attributes.some((node) => {\n if (node.type === \"JSXAttribute\") {\n return node.name.name === name;\n }\n\n return false;\n });\n}\n\nfunction getPathName(t: typeof Babel.types, path: Babel.NodePath): string {\n if (!path.node) return UNKNOWN_ELEMENT_NAME;\n if (!(\"name\" in path.node)) {\n return UNKNOWN_ELEMENT_NAME;\n }\n\n const name = path.node.name;\n\n if (typeof name === \"string\") {\n return name;\n }\n\n if (t.isIdentifier(name) || t.isJSXIdentifier(name)) {\n return name.name;\n }\n\n if (t.isJSXNamespacedName(name)) {\n return name.name.name;\n }\n\n return UNKNOWN_ELEMENT_NAME;\n}\n\nconst UNKNOWN_ELEMENT_NAME = \"unknown\";\n"],"names":["KNOWN_INCOMPATIBLE_PLUGINS","DEFAULT_IGNORED_ELEMENTS","webComponentName","webElementName","webSourceFileName","nativeComponentName","nativeElementName","nativeSourceFileName","componentNameAnnotatePlugin","_ref","t","types","visitor","FunctionDeclaration","path","state","_state$opts$ignoreCom","node","id","name","isKnownIncompatiblePluginFromState","functionBodyPushAttributes","opts","sourceFileNameFromState","attributeNamesFromState","ignoreComponents","ArrowFunctionExpression","_state$opts$ignoreCom2","parent","ClassDeclaration","_state$opts$ignoreCom3","get","properties","render","find","prop","isClassMethod","isIdentifier","traverse","ignoredComponents","ReturnStatement","returnStatement","arg","isJSXElement","isJSXFragment","processJSX","annotateFragments","componentName","sourceFileName","attributeNames","jsxNode","functionBody","type","maybeJsxNode","c","Array","isArray","paths","openingElements","forEach","openingElement","applyAttributes","children","shouldSetComponentName","child","_attributeNames","_slicedToArray","componentAttributeName","elementAttributeName","sourceFileAttributeName","isReactFragment","attributes","elementName","getPathName","isAnIgnoredComponent","some","ignoredComponent","matchesIgnoreRule","isAnIgnoredElement","hasAttributeWithName","includes","push","jSXAttribute","jSXIdentifier","stringLiteral","fullSourceFileNameFromState","undefined","indexOf","split","pop","_state$file$opts$pars","file","parserOpts","fullSourceFileName","pluginName","concat","_typeof","nodeName","nodeNameObject","object","nodeNameProperty","property","objectName","propertyName","rule","UNKNOWN_ELEMENT_NAME","isJSXIdentifier","isJSXNamespacedName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,IAAMA,0BAA0B,GAAG;AACxC;AACA,wBAAwB;AACxB;AACA,mBAAmB,CACpB,CAAA;AAEM,IAAMC,wBAAwB,GAAG,CACtC,GAAG,EACH,MAAM,EACN,SAAS,EACT,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,EACP,GAAG,EACH,MAAM,EACN,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,MAAM,EACN,KAAK,EACL,UAAU,EACV,MAAM,EACN,UAAU,EACV,IAAI,EACJ,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,IAAI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;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020 Engineering at FullStory
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export declare const KNOWN_INCOMPATIBLE_PLUGINS: string[];
|
|
26
|
+
export declare const DEFAULT_IGNORED_ELEMENTS: string[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020 Engineering at FullStory
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* The following code is based on the FullStory Babel plugin, but has been modified to work
|
|
27
|
+
* with Sentry products:
|
|
28
|
+
*
|
|
29
|
+
* - Added `sentry` to data properties, i.e `data-sentry-component`
|
|
30
|
+
* - Converted to TypeScript
|
|
31
|
+
* - Code cleanups
|
|
32
|
+
*/
|
|
33
|
+
import type * as Babel from "@babel/core";
|
|
34
|
+
import type { PluginObj, PluginPass } from "@babel/core";
|
|
35
|
+
interface AnnotationOpts {
|
|
36
|
+
native?: boolean;
|
|
37
|
+
"annotate-fragments"?: boolean;
|
|
38
|
+
ignoreComponents?: IgnoredComponent[];
|
|
39
|
+
}
|
|
40
|
+
interface AnnotationPluginPass extends PluginPass {
|
|
41
|
+
opts: AnnotationOpts;
|
|
42
|
+
}
|
|
43
|
+
type IgnoredComponent = [file: string, component: string, element: string];
|
|
44
|
+
type AnnotationPlugin = PluginObj<AnnotationPluginPass>;
|
|
45
|
+
export declare function componentNameAnnotatePlugin({ types: t }: typeof Babel): AnnotationPlugin;
|
|
46
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sentry/babel-plugin-component-annotate",
|
|
3
|
+
"version": "2.13.0",
|
|
4
|
+
"description": "A Babel plugin that annotates frontend components with additional data to enrich the experience in Sentry",
|
|
5
|
+
"repository": "git://github.com/getsentry/sentry-javascript-bundler-plugins.git",
|
|
6
|
+
"homepage": "https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/babel-plugin-component-annotate",
|
|
7
|
+
"author": "Sentry",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"Sentry",
|
|
11
|
+
"React",
|
|
12
|
+
"bundler",
|
|
13
|
+
"plugin",
|
|
14
|
+
"babel",
|
|
15
|
+
"component",
|
|
16
|
+
"annotate"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/esm/index.mjs",
|
|
27
|
+
"require": "./dist/cjs/index.js",
|
|
28
|
+
"types": "./dist/types/index.d.ts"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "dist/cjs/index.js",
|
|
32
|
+
"module": "dist/esm/index.mjs",
|
|
33
|
+
"types": "dist/types/index.d.ts",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "rimraf ./out && run-p build:rollup build:types",
|
|
36
|
+
"build:watch": "run-p build:rollup:watch build:types:watch",
|
|
37
|
+
"build:rollup": "rollup --config rollup.config.js",
|
|
38
|
+
"build:rollup:watch": "rollup --config rollup.config.js --watch --no-watch.clearScreen",
|
|
39
|
+
"build:types": "tsc --project types.tsconfig.json",
|
|
40
|
+
"build:types:watch": "tsc --project types.tsconfig.json --watch --preserveWatchOutput",
|
|
41
|
+
"build:npm": "npm pack",
|
|
42
|
+
"check:types": "run-p check:types:src check:types:test",
|
|
43
|
+
"check:types:src": "tsc --project ./src/tsconfig.json --noEmit",
|
|
44
|
+
"check:types:test": "tsc --project ./test/tsconfig.json --noEmit",
|
|
45
|
+
"clean": "run-s clean:build",
|
|
46
|
+
"clean:all": "run-p clean clean:deps",
|
|
47
|
+
"clean:build": "rimraf ./dist *.tgz",
|
|
48
|
+
"clean:deps": "rimraf node_modules",
|
|
49
|
+
"test": "jest",
|
|
50
|
+
"lint": "eslint ./src ./test"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@babel/core": "7.18.5",
|
|
54
|
+
"@babel/preset-env": "7.18.2",
|
|
55
|
+
"@babel/preset-react": "^7.23.3",
|
|
56
|
+
"@babel/preset-typescript": "7.17.12",
|
|
57
|
+
"@rollup/plugin-babel": "5.3.1",
|
|
58
|
+
"@rollup/plugin-node-resolve": "13.3.0",
|
|
59
|
+
"@sentry-internal/eslint-config": "2.13.0",
|
|
60
|
+
"@sentry-internal/sentry-bundler-plugin-tsconfig": "2.13.0",
|
|
61
|
+
"@swc/core": "^1.2.205",
|
|
62
|
+
"@swc/jest": "^0.2.21",
|
|
63
|
+
"@types/jest": "^28.1.3",
|
|
64
|
+
"@types/node": "^18.6.3",
|
|
65
|
+
"@types/uuid": "^9.0.1",
|
|
66
|
+
"eslint": "^8.18.0",
|
|
67
|
+
"jest": "^28.1.1",
|
|
68
|
+
"rimraf": "^3.0.2",
|
|
69
|
+
"rollup": "2.75.7",
|
|
70
|
+
"ts-node": "^10.9.1",
|
|
71
|
+
"typescript": "^4.7.4"
|
|
72
|
+
},
|
|
73
|
+
"volta": {
|
|
74
|
+
"extends": "../../package.json"
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">= 14"
|
|
78
|
+
}
|
|
79
|
+
}
|