noibu-react-native 0.0.4 → 0.0.6
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/README.md +22 -7
- package/dist/api/clientConfig.d.ts +101 -0
- package/dist/api/clientConfig.js +315 -387
- package/dist/api/helpCode.js +2 -2
- package/dist/api/inputManager.js +3 -9
- package/dist/api/metroplexSocket.js +6 -31
- package/dist/api/storedPageVisit.js +3 -3
- package/dist/constants.d.ts +7 -40
- package/dist/constants.js +8 -65
- package/dist/entry/index.d.ts +2 -3
- package/dist/entry/index.js +1 -9
- package/dist/entry/init.d.ts +5 -0
- package/dist/entry/init.js +54 -69
- package/dist/monitors/clickMonitor.js +9 -56
- package/dist/monitors/errorMonitor.js +1 -1
- package/dist/monitors/gqlErrorValidator.js +3 -3
- package/dist/monitors/httpDataBundler.js +10 -10
- package/dist/monitors/requestMonitor.js +8 -8
- package/dist/pageVisit/pageVisitEventError/pageVisitEventError.js +4 -4
- package/dist/storage/storage.d.ts +3 -2
- package/dist/storage/storageProvider.d.ts +6 -5
- package/dist/types/Config.d.ts +27 -0
- package/dist/types/PageVisit.d.ts +22 -0
- package/dist/types/ReactNative.d.ts +3 -0
- package/dist/types/Storage.d.ts +14 -0
- package/dist/types/globals.d.ts +34 -0
- package/dist/utils/date.js +2 -2
- package/dist/utils/eventlistener.js +3 -3
- package/dist/utils/function.d.ts +100 -0
- package/dist/utils/function.js +208 -312
- package/dist/utils/stacktrace-parser.d.ts +6 -8
- package/dist/utils/stacktrace-parser.js +5 -5
- package/package.json +2 -1
- package/dist/monitors/elementMonitor.js +0 -177
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MAX_FRAMES_IN_ARRAY, MAX_STRING_LENGTH
|
|
1
|
+
import { MAX_FRAMES_IN_ARRAY, MAX_STRING_LENGTH } from '../constants.js';
|
|
2
2
|
|
|
3
3
|
/* eslint-disable require-jsdoc,prefer-destructuring,camelcase */
|
|
4
4
|
// This is a loose copy of ravenjs code
|
|
@@ -56,14 +56,14 @@ const extractSafariExtensionDetails = (func, filename) => {
|
|
|
56
56
|
};
|
|
57
57
|
function createFrame(filename, func, lineno, colno) {
|
|
58
58
|
const frame = {
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
file: filename,
|
|
60
|
+
mname: func,
|
|
61
61
|
};
|
|
62
62
|
if (lineno !== undefined) {
|
|
63
|
-
frame
|
|
63
|
+
frame.line = lineno;
|
|
64
64
|
}
|
|
65
65
|
if (colno !== undefined) {
|
|
66
|
-
frame
|
|
66
|
+
frame.column = colno;
|
|
67
67
|
}
|
|
68
68
|
return frame;
|
|
69
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "noibu-react-native",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"targetNjsVersion": "1.0.104",
|
|
4
5
|
"description": "React-Native SDK for NoibuJS to collect errors in React-Native applications",
|
|
5
6
|
"main": "dist/entry/index.js",
|
|
6
7
|
"types": "dist/entry/index.d.ts",
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { GET_ATTRIBUTE_SELECTORS } from '../constants.js';
|
|
2
|
-
import InputManager from '../api/inputManager.js';
|
|
3
|
-
|
|
4
|
-
/** @module ElementMonitor */
|
|
5
|
-
|
|
6
|
-
/** Monitors the elements matching query selectors and passes them to the InputManager */
|
|
7
|
-
class ElementMonitor {
|
|
8
|
-
/**
|
|
9
|
-
* gets the singleton instance
|
|
10
|
-
* @returns {ElementMonitor}
|
|
11
|
-
*/
|
|
12
|
-
static getInstance() {
|
|
13
|
-
if (!this.instance) {
|
|
14
|
-
this.instance = new ElementMonitor();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return this.instance;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Safely calls `querySelectorAll` on the given node and returns an array of
|
|
22
|
-
* matching child elements. If `querySelectorAll` returns a falsy value,
|
|
23
|
-
* an empty array is returned.
|
|
24
|
-
*
|
|
25
|
-
* @private
|
|
26
|
-
* @param {Node} node - The node on which to call `querySelectorAll`.
|
|
27
|
-
* @param {string} selector - The CSS selector used to match child elements.
|
|
28
|
-
* @returns {Array<Element>} An array of matching child elements.
|
|
29
|
-
*/
|
|
30
|
-
_safeQueryAll(node, selector) {
|
|
31
|
-
const matchingChildElements = node.querySelectorAll(selector);
|
|
32
|
-
if (!matchingChildElements) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return Array.from(matchingChildElements);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Processes the given elements by adding their custom attributes to the InputManager.
|
|
41
|
-
*
|
|
42
|
-
* @private
|
|
43
|
-
* @param {NodeList|Array} elements - The list of elements to be processed.
|
|
44
|
-
* @param {string} selector - The selector corresponding to the elements being processed.
|
|
45
|
-
*/
|
|
46
|
-
_processMatchingElements(elements, selector) {
|
|
47
|
-
elements.forEach(element => {
|
|
48
|
-
if (!element) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const selectorText = element.textContent;
|
|
53
|
-
|
|
54
|
-
if (!selectorText) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
InputManager.getInstance()._addCustomAttribute(selector, selectorText);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Finds and processes matching elements within the added nodes by checking if
|
|
64
|
-
* they match any of the attribute selectors from GET_ATTRIBUTE_SELECTORS().
|
|
65
|
-
* If a node or any of its descendants match, their custom attributes are added
|
|
66
|
-
* to the InputManager.
|
|
67
|
-
*
|
|
68
|
-
* @private
|
|
69
|
-
* @param {NodeList|Array} addedNodes - The list of nodes that were added or
|
|
70
|
-
* modified in the DOM. Each node in the list will be checked against the
|
|
71
|
-
* attribute selectors, and their matching descendants will also be processed.
|
|
72
|
-
*/
|
|
73
|
-
_findAndAddMatchingElementsInNodes(addedNodes) {
|
|
74
|
-
const attributeSelectorNames = Object.keys(GET_ATTRIBUTE_SELECTORS());
|
|
75
|
-
attributeSelectorNames.forEach(name => {
|
|
76
|
-
const selector = GET_ATTRIBUTE_SELECTORS()[name];
|
|
77
|
-
if (!selector) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
addedNodes.forEach(node => {
|
|
82
|
-
// move to the next node its not an element node
|
|
83
|
-
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
let matchingElements = [];
|
|
88
|
-
|
|
89
|
-
if (node.matches(selector)) {
|
|
90
|
-
matchingElements.push(node);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const matchingChildElements = this._safeQueryAll(node, selector);
|
|
94
|
-
matchingElements = matchingElements.concat(matchingChildElements);
|
|
95
|
-
|
|
96
|
-
this._processMatchingElements(matchingElements, name);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** Sets up a MutationObserver to monitor added elements and attribute changes */
|
|
102
|
-
_setupMutationObserver() {
|
|
103
|
-
const observer = new MutationObserver(mutations => {
|
|
104
|
-
mutations.forEach(mutation => {
|
|
105
|
-
// Handle childList mutations
|
|
106
|
-
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
|
|
107
|
-
this._findAndAddMatchingElementsInNodes(mutation.addedNodes);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Handle attribute mutations
|
|
111
|
-
if (mutation.type === 'attributes') {
|
|
112
|
-
const targetNode = mutation.target;
|
|
113
|
-
if (targetNode.nodeType === Node.ELEMENT_NODE) {
|
|
114
|
-
this._findAndAddMatchingElementsInNodes([targetNode]);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// the observer will get called when children are added and changed
|
|
121
|
-
const observerConfig = { childList: true, subtree: true, attributes: true };
|
|
122
|
-
observer.observe(document.documentElement, observerConfig);
|
|
123
|
-
this.observer = observer;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Finds and adds matching elements to the InputManager */
|
|
127
|
-
_findAndAddMatchingElements() {
|
|
128
|
-
const attributeSelectorNames = Object.keys(GET_ATTRIBUTE_SELECTORS());
|
|
129
|
-
attributeSelectorNames.forEach(name => {
|
|
130
|
-
const selector = GET_ATTRIBUTE_SELECTORS()[name];
|
|
131
|
-
if (!selector) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const elements = this._safeQueryAll(document, selector);
|
|
135
|
-
this._processMatchingElements(elements, name);
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/** Starts monitoring elements matching query selectors */
|
|
140
|
-
monitor() {
|
|
141
|
-
const attributeNames = Object.keys(GET_ATTRIBUTE_SELECTORS());
|
|
142
|
-
// if we have no attributes to look for, do not setup the listeners
|
|
143
|
-
if (attributeNames.length === 0) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
this._findAndAddMatchingElements();
|
|
147
|
-
if (typeof MutationObserver !== 'undefined') {
|
|
148
|
-
this._setupMutationObserver();
|
|
149
|
-
} else {
|
|
150
|
-
// Fallback using setInterval if MutationObserver is not supported
|
|
151
|
-
this.interval = setInterval(() => {
|
|
152
|
-
this._findAndAddMatchingElements();
|
|
153
|
-
}, 5000); // Check for changes every N seconds
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Disconnects the MutationObserver instance, if it exists and has a valid disconnect method.
|
|
159
|
-
* This is needed for testing since we want to properly tear down mutation listeners
|
|
160
|
-
* @private
|
|
161
|
-
*/
|
|
162
|
-
_disconnectObserver() {
|
|
163
|
-
if (
|
|
164
|
-
this.observer &&
|
|
165
|
-
this.observer.disconnect &&
|
|
166
|
-
typeof this.observer.disconnect === 'function'
|
|
167
|
-
) {
|
|
168
|
-
this.observer.disconnect();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (this.interval) {
|
|
172
|
-
clearInterval(this.interval);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export { ElementMonitor };
|