noibu-react-native 0.2.7 → 0.2.9
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/android/build.gradle +1 -1
- package/dist/api/ClientConfig.d.ts +99 -0
- package/dist/api/ClientConfig.js +24 -23
- package/dist/api/ClientConfig.test.d.ts +1 -0
- package/dist/api/HelpCode.d.ts +16 -0
- package/dist/api/HelpCode.js +2 -2
- package/dist/api/InputManager.d.ts +39 -0
- package/dist/api/InputManager.js +1 -3
- package/dist/api/MetroplexSocket.d.ts +132 -0
- package/dist/api/MetroplexSocket.js +4 -8
- package/dist/api/MetroplexSocket.test.d.ts +1 -0
- package/dist/api/StoredMetrics.d.ts +63 -0
- package/dist/api/StoredPageVisit.d.ts +43 -0
- package/dist/api/StoredPageVisit.js +4 -6
- package/dist/const_matchers.d.ts +1 -0
- package/dist/constants.d.ts +48 -0
- package/dist/constants.js +3 -10
- package/dist/entry/index.d.ts +13 -0
- package/dist/entry/init.d.ts +8 -0
- package/dist/entry/init.js +4 -4
- package/dist/monitors/AppNavigationMonitor.d.ts +10 -0
- package/dist/monitors/AppNavigationMonitor.js +2 -4
- package/dist/monitors/AppNavigationMonitor.test.d.ts +1 -0
- package/dist/monitors/BaseMonitor.d.ts +13 -0
- package/dist/monitors/BaseMonitor.test.d.ts +1 -0
- package/dist/monitors/ClickMonitor.d.ts +28 -0
- package/dist/monitors/ClickMonitor.js +1 -3
- package/dist/monitors/ClickMonitor.test.d.ts +1 -0
- package/dist/monitors/ErrorMonitor.d.ts +39 -0
- package/dist/monitors/ErrorMonitor.js +1 -2
- package/dist/monitors/KeyboardInputMonitor.d.ts +18 -0
- package/dist/monitors/KeyboardInputMonitor.js +1 -3
- package/dist/monitors/PageMonitor.d.ts +20 -0
- package/dist/monitors/PageMonitor.js +1 -2
- package/dist/monitors/RequestMonitor.d.ts +74 -0
- package/dist/monitors/RequestMonitor.js +8 -10
- package/dist/monitors/http-tools/GqlErrorValidator.d.ts +35 -0
- package/dist/monitors/http-tools/GqlErrorValidator.js +4 -3
- package/dist/monitors/http-tools/HTTPDataBundler.d.ts +106 -0
- package/dist/monitors/http-tools/HTTPDataBundler.js +6 -5
- package/dist/monitors/integrations/ReactNativeNavigationIntegration.d.ts +17 -0
- package/dist/pageVisit/EventDebouncer.d.ts +23 -0
- package/dist/pageVisit/HttpEventManager.d.ts +14 -0
- package/dist/pageVisit/HttpEventManager.js +1 -3
- package/dist/pageVisit/PageVisitManager.d.ts +31 -0
- package/dist/pageVisit/PageVisitManager.js +1 -2
- package/dist/pageVisit/pageVisitEventError.d.ts +12 -0
- package/dist/pageVisit/pageVisitEventError.js +2 -6
- package/dist/react/ErrorBoundary.d.ts +67 -0
- package/dist/sessionRecorder/SessionRecorder.d.ts +50 -0
- package/dist/sessionRecorder/SessionRecorder.js +7 -8
- package/dist/sessionRecorder/nativeSessionRecorderSubscription.d.ts +77 -0
- package/dist/sessionRecorder/types.d.ts +91 -0
- package/dist/storage/RNStorageProvider.d.ts +19 -0
- package/dist/storage/Storage.d.ts +29 -0
- package/dist/storage/StorageProvider.d.ts +23 -0
- package/dist/types/NavigationIntegration.d.ts +6 -0
- package/dist/utils/date.d.ts +7 -0
- package/dist/utils/date.js +2 -2
- package/dist/utils/eventlistener.d.ts +8 -0
- package/dist/utils/eventlistener.js +2 -3
- package/dist/utils/function.d.ts +72 -0
- package/dist/utils/log.d.ts +4 -0
- package/dist/utils/log.js +1 -3
- package/dist/utils/object.d.ts +46 -0
- package/dist/utils/performance.d.ts +6 -0
- package/dist/utils/piiRedactor.d.ts +11 -0
- package/dist/utils/polyfills.d.ts +4 -0
- package/dist/utils/stacktrace-parser.d.ts +8 -0
- package/dist/utils/stacktrace-parser.test.d.ts +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import StorageProvider from './StorageProvider';
|
|
2
|
+
/** React native storage provider implementation */
|
|
3
|
+
export default class RNStorageProvider extends StorageProvider {
|
|
4
|
+
/** Creates new instance */
|
|
5
|
+
constructor();
|
|
6
|
+
/**
|
|
7
|
+
* Checks if storage is available
|
|
8
|
+
* @returns {Object}
|
|
9
|
+
*/
|
|
10
|
+
static isAvailable(): Promise<{
|
|
11
|
+
result: boolean;
|
|
12
|
+
error: Error | null;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Calculates used scape
|
|
16
|
+
* @returns {Number}
|
|
17
|
+
*/
|
|
18
|
+
calculateUsedSize(): Promise<number>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Singleton } from '../monitors/BaseMonitor';
|
|
2
|
+
/** Encapsulates storage api */
|
|
3
|
+
export default class Storage extends Singleton implements IStorage {
|
|
4
|
+
private readonly isRNStorageAvailable;
|
|
5
|
+
private readonly rnStorageError;
|
|
6
|
+
private readonly provider;
|
|
7
|
+
private readonly type;
|
|
8
|
+
/** Creates new instance assessing available options */
|
|
9
|
+
constructor();
|
|
10
|
+
/** Checks if storage is available */
|
|
11
|
+
isAvailable(): Promise<boolean>;
|
|
12
|
+
/** Loads value from storage */
|
|
13
|
+
load(key: string): Promise<string | null>;
|
|
14
|
+
/** Saves value to storage */
|
|
15
|
+
save(key: string, value: StorageValue): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Removes value from storage
|
|
18
|
+
* @param {String} key
|
|
19
|
+
*/
|
|
20
|
+
remove(key: string): Promise<void>;
|
|
21
|
+
/** Calculates used scape */
|
|
22
|
+
calculateUsedSize(): Promise<number>;
|
|
23
|
+
/**
|
|
24
|
+
* Returns string indicating current provider type
|
|
25
|
+
* and availability for other storage types
|
|
26
|
+
* @returns {String}
|
|
27
|
+
*/
|
|
28
|
+
getDiagnoseInfo(): Promise<string>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base implementation for LocalStorage and SessionStorage
|
|
3
|
+
*/
|
|
4
|
+
export default abstract class StorageProvider {
|
|
5
|
+
provider: Provider;
|
|
6
|
+
/** Creates new instance based on provided provider type */
|
|
7
|
+
protected constructor(provider: Provider);
|
|
8
|
+
/** Checks if provider is available */
|
|
9
|
+
static isAvailable<T extends Provider>(resolver: () => T): Promise<{
|
|
10
|
+
result: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
}>;
|
|
13
|
+
/** Loads value from storage */
|
|
14
|
+
load<R = StorageValue>(key: string): Promise<R | null>;
|
|
15
|
+
/** Saves value to storage */
|
|
16
|
+
save(key: string, value: StorageValue): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Removes value from storage
|
|
19
|
+
* @param {String} key
|
|
20
|
+
*/
|
|
21
|
+
remove(key: string): Promise<void>;
|
|
22
|
+
abstract calculateUsedSize(): Promise<number>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Checks to see if the necessary Date functions that we use have been overwritten */
|
|
2
|
+
export declare function isDateOverwritten(): boolean;
|
|
3
|
+
/** Timestamp wrapper to properly handle timestamps
|
|
4
|
+
*/
|
|
5
|
+
export declare function timestampWrapper<T>(timestamp: T): number | T;
|
|
6
|
+
/** Get the current time in ISO format */
|
|
7
|
+
export declare function getOccurredNow(): string;
|
package/dist/utils/date.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ClientConfig from '../api/ClientConfig.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Severity } from 'noibu-metroplex-ts-bindings';
|
|
3
3
|
|
|
4
4
|
/** @module Date */
|
|
5
5
|
/** Checks to see if the necessary Date functions that we use have been overwritten */
|
|
@@ -39,7 +39,7 @@ function timestampWrapper(timestamp) {
|
|
|
39
39
|
ClientConfig.getInstance().postInternalError({
|
|
40
40
|
msg: `The date object has been overwritten and can't be processed properly.
|
|
41
41
|
Client has been disabled.`,
|
|
42
|
-
}, true,
|
|
42
|
+
}, true, Severity.ERROR, true);
|
|
43
43
|
}
|
|
44
44
|
return timestamp;
|
|
45
45
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** addSafeEventListener will add an event listener for the specified event
|
|
2
|
+
* but will catch and log any errors encountered
|
|
3
|
+
* @param {} object to attach the listener to
|
|
4
|
+
* @param {} event to listen to
|
|
5
|
+
* @param {} callback function to call
|
|
6
|
+
* @param {} [capture] additional arguments
|
|
7
|
+
*/
|
|
8
|
+
export function addSafeEventListener(object: any, event: any, callback: any, capture?: any): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SEVERITY } from '../constants.js';
|
|
2
1
|
import ClientConfig from '../api/ClientConfig.js';
|
|
3
2
|
|
|
4
3
|
/** addSafeEventListener will add an event listener for the specified event
|
|
@@ -24,7 +23,7 @@ function addSafeEventListener(object, event, callback, capture = false) {
|
|
|
24
23
|
ClientConfig.getInstance().postInternalError(
|
|
25
24
|
`addEventListener callback error: ${e.message}`,
|
|
26
25
|
false,
|
|
27
|
-
|
|
26
|
+
Severity.ERROR,
|
|
28
27
|
);
|
|
29
28
|
}
|
|
30
29
|
};
|
|
@@ -53,7 +52,7 @@ function addSafeEventListener(object, event, callback, capture = false) {
|
|
|
53
52
|
return;
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
|
-
ClientConfig.getInstance().postInternalError(`addEventListener error: ${e.message}`, false,
|
|
55
|
+
ClientConfig.getInstance().postInternalError(`addEventListener error: ${e.message}`, false, Severity.ERROR);
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { JSError } from 'noibu-metroplex-ts-bindings';
|
|
2
|
+
import { RawStackFrame } from './stacktrace-parser';
|
|
3
|
+
/**
|
|
4
|
+
* returns a string that satisfies a max length
|
|
5
|
+
* stringToVerify: string that needs to be verified
|
|
6
|
+
* length :optional, max length that stringToVerify can be
|
|
7
|
+
*/
|
|
8
|
+
export declare function getMaxSubstringAllowed(stringToVerify: string, length?: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Processes the raw stack frames and creates a readable stack in a safe manner
|
|
11
|
+
*/
|
|
12
|
+
export declare function processFrames(rawFrames: RawStackFrame[]): import("noibu-metroplex-ts-bindings").JSStackFrame[];
|
|
13
|
+
/** Retrieves the javascript stack and message from an error event object */
|
|
14
|
+
export declare function getJSStack(errObj?: {
|
|
15
|
+
stack?: string | NativeStackAndroid;
|
|
16
|
+
message?: string;
|
|
17
|
+
}): JSError;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if possiblyStacktrace has any stack frames present
|
|
20
|
+
*/
|
|
21
|
+
export declare function isStackTrace(_possiblyStacktrace: unknown): _possiblyStacktrace is string;
|
|
22
|
+
/**
|
|
23
|
+
* counts the number of bytes
|
|
24
|
+
*/
|
|
25
|
+
export declare function byteCount(s: string): number;
|
|
26
|
+
/**
|
|
27
|
+
* Stringify function that is aware of inner circular references and handles them by replacing with {} (empty object)
|
|
28
|
+
* taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value
|
|
29
|
+
*/
|
|
30
|
+
export declare function stringifyJSON(jsonObject: unknown): string;
|
|
31
|
+
/**
|
|
32
|
+
* Wrapper for a request with an ability to send-and-forget
|
|
33
|
+
* a send-and-forget request can outlive the page
|
|
34
|
+
*/
|
|
35
|
+
export declare function postRequest(url: string | URL, data: unknown, headers: Record<string, string>, sendAndForget?: boolean, timeout?: number): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* makes sure the url sent is a valid URL
|
|
38
|
+
*/
|
|
39
|
+
export declare function isValidURL(str: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Fakes the user agent retrieval, since there are no good libraries that support both expo and plain RN
|
|
42
|
+
* caches the result for the session
|
|
43
|
+
*/
|
|
44
|
+
export declare function getUserAgent(): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* isNoibuJSAlreadyLoaded will verify if there are already other
|
|
47
|
+
* copies of NoibuJS runnung
|
|
48
|
+
*/
|
|
49
|
+
export declare function isNoibuJSAlreadyLoaded(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* asString will create a string out of anything passed to it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function asString(obj: unknown): string;
|
|
54
|
+
/**
|
|
55
|
+
* masks textual content if it ressembles something sensitive
|
|
56
|
+
*/
|
|
57
|
+
export declare function maskTextInput(text: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if the provided object is an instance of the specified type.
|
|
60
|
+
* It's safer than `instanceof` operator as it handles cases
|
|
61
|
+
* where type is not actually a type but an object.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isInstanceOf<T>(instance: unknown, type: T): instance is T;
|
|
64
|
+
/** String.trim, but safe */
|
|
65
|
+
export declare function safeTrim(text: unknown): string;
|
|
66
|
+
/**
|
|
67
|
+
* Tries to get the stack trace from the given error object and returns it.
|
|
68
|
+
* If the error object does not have a stack trace, an empty string is returned.
|
|
69
|
+
*/
|
|
70
|
+
export declare function tryGetStackTrace(error: {
|
|
71
|
+
stack?: string;
|
|
72
|
+
}): string;
|
package/dist/utils/log.js
CHANGED
|
@@ -9,7 +9,5 @@ const getConsoleMethod = (ogProp) => {
|
|
|
9
9
|
};
|
|
10
10
|
/**log with level = info */
|
|
11
11
|
const noibuLog = (...msgs) => getConsoleMethod('log')('Noibu', ...msgs);
|
|
12
|
-
/**log with level = error */
|
|
13
|
-
const noibuErr = (...msgs) => getConsoleMethod('error')('Noibu', ...msgs);
|
|
14
12
|
|
|
15
|
-
export {
|
|
13
|
+
export { noibuLog };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** @module Object */
|
|
2
|
+
/**
|
|
3
|
+
* Replaces an attribute value found in an object with another value
|
|
4
|
+
* sourceObject: source object whose attribute will get replaced
|
|
5
|
+
* attributeName: the attribute key whose value will be replace
|
|
6
|
+
* processingFunction: function that accepts the original value
|
|
7
|
+
* and returns the newValue
|
|
8
|
+
*/
|
|
9
|
+
export declare function replace<Target extends object, Prop extends keyof Target>(sourceObject: Target, attributeName: Prop, processingFunction: (arg: Target[Prop]) => Target[Prop]): void;
|
|
10
|
+
/**
|
|
11
|
+
* unwraps wrapped property, so we can use it without side effects
|
|
12
|
+
*/
|
|
13
|
+
export declare function unwrapNoibuWrapped<T>(anything: {
|
|
14
|
+
__noibu_original__?: T;
|
|
15
|
+
} & T): NonNullable<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the given object is wrapped
|
|
18
|
+
*/
|
|
19
|
+
export declare function isNoibuWrapped<T extends object>(anything: T): anything is {
|
|
20
|
+
__noibu_original__?: T;
|
|
21
|
+
} & T;
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether the prototype's property is writeable. If it is not,
|
|
24
|
+
* checks whether the property can be made writeable. If it can, it is
|
|
25
|
+
* set to writeable.
|
|
26
|
+
* returns Whether the property on the prototype is (or is now) writeable
|
|
27
|
+
*/
|
|
28
|
+
export declare const propWriteableOrMadeWriteable: <T>(proto: T, property: keyof T) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Iterates object recursively and calls visit function
|
|
31
|
+
* for each property allowing to override its value
|
|
32
|
+
* @param {Object} instance An object to iterate through
|
|
33
|
+
* @param {Function} visit Target callback function that is called for each property
|
|
34
|
+
* There are 3 arguments: current object, current property and its value
|
|
35
|
+
* @param {{depth: number}} limit Use limit config object to set depth of the recursion
|
|
36
|
+
*/
|
|
37
|
+
export declare const iterateObjectRecursively: (instance: Record<any, any>, visit: (i: typeof instance, p: keyof typeof i, v: (typeof i)[typeof p]) => typeof v, limit?: {
|
|
38
|
+
depth: number;
|
|
39
|
+
}) => void;
|
|
40
|
+
export declare const safeEntries: (obj: unknown | Record<string, string | null> | Headers) => [string, string | null][];
|
|
41
|
+
/**
|
|
42
|
+
* Replaces the behaviour of Object.fromEntries() as it is not supported on all browsers
|
|
43
|
+
* @param {Iterable} entries The iterable to parse into an object
|
|
44
|
+
* @returns An object containing the same key/values as the iterable passed
|
|
45
|
+
*/
|
|
46
|
+
export declare const safeFromEntries: <T>(entries: unknown) => Record<string, T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redacts one string, returns redacted value or false if nothing to redact
|
|
3
|
+
*/
|
|
4
|
+
export declare function shouldRedact(field: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Takes a string and redacts any PII we're able to detect
|
|
7
|
+
*
|
|
8
|
+
* content - the string from which we want to redact PII
|
|
9
|
+
* returns the string with any PII we're able to detect redacted.
|
|
10
|
+
*/
|
|
11
|
+
export declare function removePII(content: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "noibu-react-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"targetNjsVersion": "1.0.104",
|
|
5
5
|
"description": "React-Native SDK for NoibuJS to collect errors in React-Native applications",
|
|
6
6
|
"main": "dist/entry/index.js",
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
"optional": true
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"noibu-metroplex-ts-bindings": "1.0.27"
|
|
31
|
+
},
|
|
29
32
|
"optionalDependencies": {
|
|
30
33
|
"@react-native-async-storage/async-storage": "^1.19.0",
|
|
31
34
|
"fflate": "^0.8.2",
|
|
@@ -49,7 +52,6 @@
|
|
|
49
52
|
"@babel/preset-typescript": "^7.26.0",
|
|
50
53
|
"@eslint/eslintrc": "^3.2.0",
|
|
51
54
|
"@jest/globals": "^29.7.0",
|
|
52
|
-
"@noibu/metroplex-ts-bindings": "1.0.24",
|
|
53
55
|
"@react-native-async-storage/async-storage": "^1.19.0",
|
|
54
56
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
55
57
|
"@rollup/plugin-json": "^6.0.0",
|