noibu-react-native 0.1.1 → 0.1.2
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/dist/api/clientConfig.js +9 -1
- package/dist/api/inputManager.js +1 -1
- package/dist/api/metroplexSocket.js +15 -3
- package/dist/api/storedMetrics.js +2 -1
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +9 -2
- package/dist/entry/index.js +2 -0
- package/dist/entry/init.js +7 -0
- package/dist/monitors/clickMonitor.js +1 -1
- package/dist/monitors/errorMonitor.js +2 -2
- package/dist/monitors/httpDataBundler.js +62 -15
- package/dist/monitors/keyboardInputMonitor.js +1 -1
- package/dist/monitors/requestMonitor.js +47 -310
- package/dist/pageVisit/{pageVisitEventError/pageVisitEventError.js → pageVisitEventError.js} +18 -19
- package/dist/pageVisit/{pageVisitEventHTTP/pageVisitEventHTTP.js → pageVisitEventHTTP.js} +15 -7
- package/dist/pageVisit/{userStep/userStep.js → userStep.js} +2 -2
- package/dist/types/globals.d.ts +4 -3
- package/dist/utils/function.js +5 -1
- package/dist/utils/log.d.ts +5 -0
- package/dist/utils/log.js +15 -0
- package/dist/utils/object.d.ts +41 -0
- package/dist/utils/object.js +85 -108
- package/dist/utils/performance.d.ts +6 -0
- package/dist/utils/performance.js +1 -2
- package/package.json +1 -1
- package/dist/pageVisit/pageVisitEventError/blacklistedDomains.js +0 -9
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** @module Object */
|
|
2
|
+
type Func = (...args: any[]) => any;
|
|
3
|
+
/**
|
|
4
|
+
* Replaces an attribute value found in an object with another value
|
|
5
|
+
* sourceObject: source object whose attribute will get replaced
|
|
6
|
+
* attributeName: the attribute key whose value will be replace
|
|
7
|
+
* processingFunction: function that accepts the original value
|
|
8
|
+
* and returns the newValue
|
|
9
|
+
* @param {} sourceObject
|
|
10
|
+
* @param {} attributeName
|
|
11
|
+
* @param {} processingFunction
|
|
12
|
+
*/
|
|
13
|
+
export declare const replace: <A extends { [k in K]: Func; }, K extends keyof A>(sourceObject: A, attributeName: K, processingFunction: (arg: A[K]) => A[K]) => void;
|
|
14
|
+
/**
|
|
15
|
+
* unwraps wrapped property, so we can use it without side effects
|
|
16
|
+
* @param anything
|
|
17
|
+
*/
|
|
18
|
+
export declare function unwrapNoibuWrapped<T>(anything: {
|
|
19
|
+
__noibu_original__?: T;
|
|
20
|
+
} & T): NonNullable<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Checks whether the prototype's property is writeable. If it is not,
|
|
23
|
+
* checks whether the property can be made writeable. If it can, it is
|
|
24
|
+
* set to writeable.
|
|
25
|
+
* @param {object} proto
|
|
26
|
+
* @param {string} property
|
|
27
|
+
* @returns {boolean} Whether the property on the prototype is (or is now) writeable
|
|
28
|
+
*/
|
|
29
|
+
export declare const propWriteableOrMadeWriteable: (proto: object, property: never) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Iterates object recursively and calls visit function
|
|
32
|
+
* for each property allowing to override its value
|
|
33
|
+
* @param {Object} instance An object to iterate through
|
|
34
|
+
* @param {Function} visit A callback function that is called for each property
|
|
35
|
+
* There are 3 arguments: current object, current property and its value
|
|
36
|
+
* @param {{depth: number}} limit Use limit config object to set depth of the recursion
|
|
37
|
+
*/
|
|
38
|
+
export declare const iterateObjectRecursively: (instance: Record<any, any>, visit: (i: Record<any, any>, p: any, v: any) => any, limit?: {
|
|
39
|
+
depth: number;
|
|
40
|
+
}) => void;
|
|
41
|
+
export {};
|
package/dist/utils/object.js
CHANGED
|
@@ -10,39 +10,43 @@
|
|
|
10
10
|
* @param {} processingFunction
|
|
11
11
|
*/
|
|
12
12
|
const replace = (sourceObject, attributeName, processingFunction) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const originalAttribute = sourceObject[attributeName];
|
|
18
|
-
const newValue = processingFunction(originalAttribute);
|
|
19
|
-
|
|
20
|
-
if (typeof newValue === 'function') {
|
|
21
|
-
try {
|
|
22
|
-
newValue.prototype = newValue.prototype || {};
|
|
23
|
-
Object.defineProperties(newValue, {
|
|
24
|
-
__noibu__: {
|
|
25
|
-
enumerable: false,
|
|
26
|
-
value: true,
|
|
27
|
-
},
|
|
28
|
-
__noibu_original__: {
|
|
29
|
-
enumerable: false,
|
|
30
|
-
value: originalAttribute,
|
|
31
|
-
},
|
|
32
|
-
__noibu_wrapped__: {
|
|
33
|
-
enumerable: false,
|
|
34
|
-
value: newValue,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
} catch (err) {
|
|
38
|
-
// silent fail
|
|
13
|
+
if (!(attributeName in sourceObject)) {
|
|
14
|
+
return;
|
|
39
15
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
const originalAttribute = sourceObject[attributeName];
|
|
17
|
+
const newValue = processingFunction(originalAttribute);
|
|
18
|
+
if (typeof newValue === 'function') {
|
|
19
|
+
try {
|
|
20
|
+
newValue.prototype = newValue.prototype || {};
|
|
21
|
+
Object.defineProperties(newValue, {
|
|
22
|
+
__noibu__: {
|
|
23
|
+
enumerable: false,
|
|
24
|
+
value: true,
|
|
25
|
+
},
|
|
26
|
+
__noibu_original__: {
|
|
27
|
+
enumerable: false,
|
|
28
|
+
value: originalAttribute,
|
|
29
|
+
},
|
|
30
|
+
__noibu_wrapped__: {
|
|
31
|
+
enumerable: false,
|
|
32
|
+
value: newValue,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
// silent fail
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line no-param-reassign
|
|
41
|
+
sourceObject[attributeName] = newValue;
|
|
44
42
|
};
|
|
45
|
-
|
|
43
|
+
/**
|
|
44
|
+
* unwraps wrapped property, so we can use it without side effects
|
|
45
|
+
* @param anything
|
|
46
|
+
*/
|
|
47
|
+
function unwrapNoibuWrapped(anything) {
|
|
48
|
+
return anything.__noibu_original__ || anything;
|
|
49
|
+
}
|
|
46
50
|
/**
|
|
47
51
|
* Checks whether the prototype's property is writeable. If it is not,
|
|
48
52
|
* checks whether the property can be made writeable. If it can, it is
|
|
@@ -52,50 +56,29 @@ const replace = (sourceObject, attributeName, processingFunction) => {
|
|
|
52
56
|
* @returns {boolean} Whether the property on the prototype is (or is now) writeable
|
|
53
57
|
*/
|
|
54
58
|
const propWriteableOrMadeWriteable = (proto, property) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Getting the properties that this the prototype
|
|
64
|
-
// has under the open property
|
|
65
|
-
const propDescriptor = Object.getOwnPropertyDescriptor(proto, property);
|
|
66
|
-
|
|
67
|
-
// Checking if the open property is read-only
|
|
68
|
-
if (!propDescriptor.writable) {
|
|
69
|
-
// Checking if we can write to it
|
|
70
|
-
if (propDescriptor.configurable) {
|
|
71
|
-
// Making it writable to wrap it
|
|
72
|
-
Object.defineProperty(proto, property, {
|
|
73
|
-
writable: true,
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
return false;
|
|
59
|
+
if (!proto ||
|
|
60
|
+
!proto.hasOwnProperty ||
|
|
61
|
+
!Object.prototype.hasOwnProperty.call(proto, property)) {
|
|
62
|
+
return false;
|
|
77
63
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
return obj;
|
|
64
|
+
// Getting the properties that this the prototype
|
|
65
|
+
// has under the open property
|
|
66
|
+
const propDescriptor = Object.getOwnPropertyDescriptor(proto, property);
|
|
67
|
+
// Checking if the open property is read-only
|
|
68
|
+
if (!propDescriptor?.writable) {
|
|
69
|
+
// Checking if we can write to it
|
|
70
|
+
if (propDescriptor?.configurable) {
|
|
71
|
+
// Making it writable to wrap it
|
|
72
|
+
Object.defineProperty(proto, property, {
|
|
73
|
+
writable: true,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
97
81
|
};
|
|
98
|
-
|
|
99
82
|
/**
|
|
100
83
|
* Iterates object recursively and calls visit function
|
|
101
84
|
* for each property allowing to override its value
|
|
@@ -104,41 +87,35 @@ const safeFromEntries = entries => {
|
|
|
104
87
|
* There are 3 arguments: current object, current property and its value
|
|
105
88
|
* @param {{depth: number}} limit Use limit config object to set depth of the recursion
|
|
106
89
|
*/
|
|
107
|
-
const iterateObjectRecursively = (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
iterate(instance[property], depth + 1);
|
|
90
|
+
const iterateObjectRecursively = (instance, visit, limit = { depth: 5 }) => {
|
|
91
|
+
/* eslint-disable no-shadow, no-restricted-syntax, no-param-reassign, guard-for-in */
|
|
92
|
+
/**
|
|
93
|
+
* internal recursive function
|
|
94
|
+
* @param {Object} inst Current object
|
|
95
|
+
* @param {Number} depth Current depth
|
|
96
|
+
*/
|
|
97
|
+
const iterate = (inst, depth) => {
|
|
98
|
+
// stop to go deeper if it is deep enough already
|
|
99
|
+
if (depth > limit.depth)
|
|
100
|
+
return;
|
|
101
|
+
for (const property in inst) {
|
|
102
|
+
try {
|
|
103
|
+
// call visit function and assign its result if not undefined
|
|
104
|
+
const newValue = visit(inst, property, inst[property]);
|
|
105
|
+
if (newValue !== undefined) {
|
|
106
|
+
inst[property] = newValue;
|
|
107
|
+
}
|
|
108
|
+
// go one level deeper if it is an object
|
|
109
|
+
if (inst[property] !== null && typeof inst[property] === 'object') {
|
|
110
|
+
iterate(inst[property], depth + 1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
// just continue to the next property
|
|
115
|
+
}
|
|
134
116
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
iterate(instance, 1);
|
|
117
|
+
};
|
|
118
|
+
iterate(instance, 1);
|
|
142
119
|
};
|
|
143
120
|
|
|
144
|
-
export { iterateObjectRecursively, propWriteableOrMadeWriteable, replace,
|
|
121
|
+
export { iterateObjectRecursively, propWriteableOrMadeWriteable, replace, unwrapNoibuWrapped };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { timestampWrapper } from './date.js';
|
|
2
2
|
|
|
3
3
|
/** @module Performance */
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Wrapper function for window.performance.now() to ensure
|
|
7
6
|
* it's available before calling it. If it's not available,
|
|
8
7
|
* we return Date.now() instead.
|
|
9
8
|
*/
|
|
10
9
|
function safePerformanceNow() {
|
|
11
|
-
|
|
10
|
+
return timestampWrapper(Date.now());
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export { safePerformanceNow };
|
package/package.json
CHANGED