noibu-react-native 0.2.1 → 0.2.3
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 +1 -1
- package/android/src/main/java/com/noibu/sessionreplay/reactnative/NoibuSessionReplayModule.kt +10 -0
- package/dist/api/clientConfig.js +225 -217
- package/dist/api/metroplexSocket.js +406 -416
- package/dist/constants.js +14 -2
- package/dist/entry/init.js +58 -56
- package/dist/monitors/appNavigationMonitor.js +2 -3
- package/dist/monitors/clickMonitor.js +16 -9
- package/dist/monitors/errorMonitor.js +30 -8
- package/dist/monitors/gqlErrorValidator.js +4 -4
- package/dist/monitors/httpDataBundler.js +525 -713
- package/dist/monitors/integrations/react-native-navigation-integration.js +4 -2
- package/dist/monitors/requestMonitor.js +350 -365
- package/dist/pageVisit/eventDebouncer.js +110 -0
- package/dist/pageVisit/pageVisitEventError.js +1 -1
- package/dist/pageVisit/pageVisitEventHTTP.js +78 -93
- package/dist/react/ErrorBoundary.js +18 -15
- package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +3 -2
- package/dist/sessionRecorder/sessionRecorder.js +151 -150
- package/dist/{api → src/api}/clientConfig.d.ts +1 -1
- package/dist/{api → src/api}/metroplexSocket.d.ts +25 -25
- package/dist/{constants.d.ts → src/constants.d.ts} +44 -0
- package/dist/{entry → src/entry}/init.d.ts +1 -1
- package/dist/{monitors → src/monitors}/clickMonitor.d.ts +1 -1
- package/dist/{monitors → src/monitors}/gqlErrorValidator.d.ts +6 -6
- package/dist/src/monitors/httpDataBundler.d.ts +127 -0
- package/dist/src/monitors/requestMonitor.d.ts +10 -0
- package/dist/src/pageVisit/eventDebouncer.d.ts +31 -0
- package/dist/src/pageVisit/pageVisitEventHTTP.d.ts +25 -0
- package/dist/{sessionRecorder → src/sessionRecorder}/types.d.ts +1 -1
- package/dist/{storage → src/storage}/rnStorageProvider.d.ts +1 -1
- package/dist/{storage → src/storage}/storage.d.ts +1 -1
- package/dist/{storage → src/storage}/storageProvider.d.ts +3 -3
- package/dist/{utils → src/utils}/function.d.ts +25 -4
- package/dist/{utils → src/utils}/object.d.ts +9 -4
- package/dist/src/utils/piiRedactor.d.ts +11 -0
- package/dist/src/utils/polyfills.d.ts +7 -0
- package/dist/storage/rnStorageProvider.js +7 -5
- package/dist/storage/storage.js +43 -35
- package/dist/storage/storageProvider.js +23 -19
- package/dist/types/Config.d.ts +24 -20
- package/dist/types/PageVisit.types.d.ts +151 -0
- package/dist/types/PageVisitMetrics.types.d.ts +27 -0
- package/dist/types/RRWeb.d.ts +48 -0
- package/dist/types/StoredPageVisit.types.d.ts +2 -4
- package/dist/types/WrappedObjects.d.ts +6 -0
- package/dist/utils/function.js +110 -76
- package/dist/utils/object.js +58 -6
- package/dist/utils/piiRedactor.js +98 -0
- package/dist/utils/polyfills.js +24 -0
- package/package.json +24 -9
- package/dist/monitors/httpDataBundler.d.ts +0 -161
- package/dist/monitors/requestMonitor.d.ts +0 -10
- package/dist/pageVisit/pageVisitEventHTTP.d.ts +0 -18
- package/dist/types/PageVisit.d.ts +0 -22
- package/dist/types/globals.d.ts +0 -45
- /package/dist/{api → src/api}/helpCode.d.ts +0 -0
- /package/dist/{api → src/api}/inputManager.d.ts +0 -0
- /package/dist/{api → src/api}/storedMetrics.d.ts +0 -0
- /package/dist/{api → src/api}/storedPageVisit.d.ts +0 -0
- /package/dist/{const_matchers.d.ts → src/const_matchers.d.ts} +0 -0
- /package/dist/{entry → src/entry}/index.d.ts +0 -0
- /package/dist/{monitors → src/monitors}/appNavigationMonitor.d.ts +0 -0
- /package/dist/{monitors → src/monitors}/errorMonitor.d.ts +0 -0
- /package/dist/{monitors → src/monitors}/inputMonitor.d.ts +0 -0
- /package/dist/{monitors → src/monitors}/integrations/react-native-navigation-integration.d.ts +0 -0
- /package/dist/{monitors → src/monitors}/keyboardInputMonitor.d.ts +0 -0
- /package/dist/{monitors → src/monitors}/pageMonitor.d.ts +0 -0
- /package/dist/{pageVisit → src/pageVisit}/pageVisit.d.ts +0 -0
- /package/dist/{pageVisit → src/pageVisit}/pageVisitEventError.d.ts +0 -0
- /package/dist/{pageVisit → src/pageVisit}/userStep.d.ts +0 -0
- /package/dist/{react → src/react}/ErrorBoundary.d.ts +0 -0
- /package/dist/{sessionRecorder → src/sessionRecorder}/nativeSessionRecorderSubscription.d.ts +0 -0
- /package/dist/{sessionRecorder → src/sessionRecorder}/sessionRecorder.d.ts +0 -0
- /package/dist/{utils → src/utils}/date.d.ts +0 -0
- /package/dist/{utils → src/utils}/eventlistener.d.ts +0 -0
- /package/dist/{utils → src/utils}/log.d.ts +0 -0
- /package/dist/{utils → src/utils}/performance.d.ts +0 -0
- /package/dist/{utils → src/utils}/stacktrace-parser.d.ts +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { HTTPDataBundle } from '../../types/PageVisit.types';
|
|
2
|
+
import { WrappedXMLHttpRequest } from '../../types/WrappedObjects';
|
|
3
|
+
/** Bundles HTTP payloads and headers */
|
|
4
|
+
export declare class HTTPDataBundler {
|
|
5
|
+
contentTypeReadableRegex: RegExp;
|
|
6
|
+
hostname: string;
|
|
7
|
+
initialURLPartsReversed: string[];
|
|
8
|
+
httpDataCollectionEnabled: boolean;
|
|
9
|
+
httpDataAllowedRelativeRegex: RegExp | null;
|
|
10
|
+
httpDataAllowedAbsoluteRegex: RegExp | null;
|
|
11
|
+
private static instance;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the ClickMonitor instance
|
|
14
|
+
*/
|
|
15
|
+
constructor();
|
|
16
|
+
/** gets the singleton instance
|
|
17
|
+
* @returns {HTTPDataBundler}
|
|
18
|
+
* */
|
|
19
|
+
static getInstance(): HTTPDataBundler;
|
|
20
|
+
/**
|
|
21
|
+
* Builds the HTTP payload allowed regexes for full and relative URLs
|
|
22
|
+
* @param allowedURLs A list of allowed URLs
|
|
23
|
+
* @param absolute Use only absolute URLs if true, use only relative URL if false
|
|
24
|
+
* @returns a regex of allowed URLs
|
|
25
|
+
*/
|
|
26
|
+
static buildAllowedRegex(allowedURLs: unknown | unknown[], absolute: boolean): RegExp | null;
|
|
27
|
+
/**
|
|
28
|
+
* Takes an iterator and returns a map of strings representing headers.
|
|
29
|
+
* @param {object} headersIterable any iterable object
|
|
30
|
+
* @returns a map of strings (as expected by metroplex) representing HTTP
|
|
31
|
+
* request or response headers
|
|
32
|
+
*/
|
|
33
|
+
static headersMapFromIterable(headersIterable: any): Map<any, any>;
|
|
34
|
+
/**
|
|
35
|
+
* Takes a string of headers with 'name: value' and returns
|
|
36
|
+
* a map of strings representing headers.
|
|
37
|
+
* headersString is all the headers in one string
|
|
38
|
+
* returns a map of strings (as expected by metroplex) representing HTTP
|
|
39
|
+
* request or response headers
|
|
40
|
+
*/
|
|
41
|
+
static headersMapFromString(headersString: unknown): Map<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* For an XHR object, checks the responseType property and handles the response or
|
|
44
|
+
* responseText property accordingly to return a string representation of the response.
|
|
45
|
+
* @returns a string representation of the response, or null if this fails.
|
|
46
|
+
*/
|
|
47
|
+
static getResponseStringFromXHR(xhr: WrappedXMLHttpRequest): Promise<any>;
|
|
48
|
+
/**
|
|
49
|
+
* Takes a URL and returns true if it is determined to be on the same domain as the URL
|
|
50
|
+
* the script is running on. Ignores protocol and path, and allows the URL to be a subdomain.
|
|
51
|
+
* @param {string} requestURL the URL of a request to compare to the script website's URL
|
|
52
|
+
* @param {bool} isHostnameCheck the URL is a domain hostname, could be a super or sub domain
|
|
53
|
+
*/
|
|
54
|
+
isURLSameDomain(requestURL: any, isHostnameCheck?: boolean): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Builds an HTTP Data bundle
|
|
57
|
+
*/
|
|
58
|
+
bundleHTTPData(url: string, requestHeaders: Map<string, string> | undefined, rawRequestPayload: any, responseHeaders: Map<string, string>, rawResponsePayload: any, method: string, isError: boolean): HTTPDataBundle | null;
|
|
59
|
+
/**
|
|
60
|
+
* Validates a request based on the URL and method. When enabled, will handle
|
|
61
|
+
* de-duping the requests
|
|
62
|
+
* @param {string} url
|
|
63
|
+
* @param {string} method
|
|
64
|
+
* @returns boolean indicating whether the validation passed
|
|
65
|
+
*/
|
|
66
|
+
isValidRequest(url: any, method: any): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Checks two things: that the URL is either on the same domain (or an address relative to the
|
|
69
|
+
* current domain), and also checks that the config http_data_collection flag is enabled.
|
|
70
|
+
* @param {string} url
|
|
71
|
+
* @returns boolean indicating whether the URL passed is either relative (in which case it is
|
|
72
|
+
* inherently on the current domain) or matches the current domain.
|
|
73
|
+
*/
|
|
74
|
+
shouldContinueForURL(url: any): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Determins if the URL is absolute or relative
|
|
77
|
+
* @param {string} url
|
|
78
|
+
* @returns boolean indicating whether the URL passed is either absolute or relative
|
|
79
|
+
*/
|
|
80
|
+
static isAbsoluteURL(url: any): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Checks whether HTTP payloads can be collected on this URL
|
|
83
|
+
* @returns boolean indicating whether HTTP payloads can be collected on this URL
|
|
84
|
+
*/
|
|
85
|
+
shouldCollectPayloadForURL(url: any): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Double checks content length if we couldn't read the headers, and redacts PII
|
|
88
|
+
* returns the restricted payload
|
|
89
|
+
*/
|
|
90
|
+
restrictPayload(payload: string, url: string, isError: boolean): string;
|
|
91
|
+
/**
|
|
92
|
+
* Returns true if the content-length header is of acceptable size.
|
|
93
|
+
* Too big gets rejected
|
|
94
|
+
* If the headers are not found, check actual content for length
|
|
95
|
+
* @param {Headers} headers
|
|
96
|
+
* @returns boolean true if acceptable to collect
|
|
97
|
+
*/
|
|
98
|
+
contentLengthAcceptable(headers: Map<string, string>, isError: boolean): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Returns true if the content type according to the headers is valid for collection.
|
|
101
|
+
* Also returns assumed true if content type is not stated in headers.
|
|
102
|
+
* @param {Map} headersMap
|
|
103
|
+
* @returns boolean true if acceptable to collect
|
|
104
|
+
*/
|
|
105
|
+
private contentTypeAcceptable;
|
|
106
|
+
/**
|
|
107
|
+
* Returns a descriptive string if we have to drop payload based on the length
|
|
108
|
+
* or type listed in the headers passed. Returns an empty string otherwise.
|
|
109
|
+
*/
|
|
110
|
+
getReasonPayloadIsDropped(headers: any, isError: boolean): string;
|
|
111
|
+
/**
|
|
112
|
+
* Returns content length from the headers, if available.
|
|
113
|
+
* If headers are not found or length is not a number, return -1
|
|
114
|
+
*/
|
|
115
|
+
contentLength(headersObject: any): number;
|
|
116
|
+
/**
|
|
117
|
+
* Accepts a value that could be any type used as a request payload,
|
|
118
|
+
* and returns a string representation, or null if this fails.
|
|
119
|
+
*/
|
|
120
|
+
stringFromRequestBody(value: any, requestHeaders?: Map<string, string>): any;
|
|
121
|
+
/**
|
|
122
|
+
* Removes possible PII from headers.
|
|
123
|
+
* @param {Map} dirtyHeaders a Map of HTTP response or request headers
|
|
124
|
+
* @returns {Map|null} a map of headers with PII redacted
|
|
125
|
+
*/
|
|
126
|
+
removePIIHeaders(dirtyHeaders: Map<string, string> | undefined): typeof dirtyHeaders | null;
|
|
127
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @module RequestMonitor */
|
|
2
|
+
import 'react-native/Libraries/Network/fetch';
|
|
3
|
+
/**
|
|
4
|
+
* Handles fetch failure
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleFetchFailure(maybeErr: unknown, url: unknown): void;
|
|
7
|
+
/**
|
|
8
|
+
* Monitors all requests
|
|
9
|
+
*/
|
|
10
|
+
export declare function monitorRequests(): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singleton class responsible for debouncing all events
|
|
3
|
+
* that are registered
|
|
4
|
+
*/
|
|
5
|
+
export declare class EventDebouncer {
|
|
6
|
+
private readonly eventsToDebounce;
|
|
7
|
+
private static instance;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of EventDebouncer
|
|
10
|
+
*/
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* gets the instance of EventDebouncer
|
|
14
|
+
*/
|
|
15
|
+
static getInstance(): EventDebouncer;
|
|
16
|
+
/** will debounce all events that are of this type by the debounce period
|
|
17
|
+
*/
|
|
18
|
+
registerInputType(type: string, debouncePeriod: number, eventName?: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Creates an event object with the event and the time it was added then pushes
|
|
21
|
+
* that event object to the queue of events waiting to be debounced.
|
|
22
|
+
*/
|
|
23
|
+
addEvent(event: any, type: string, occurredAt?: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Adds the events from the object to the page visit and sets up a timer
|
|
26
|
+
* to send the events if no more are received without the timeout
|
|
27
|
+
*/
|
|
28
|
+
_debouncePvEvents(type: string): void;
|
|
29
|
+
/** Sets up the page hide handler to try to push remaining events in the queues */
|
|
30
|
+
_setupUnloadHandler(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HTTPDataBundle, PVEventHTTP } from '../../types/PageVisit.types';
|
|
2
|
+
/**
|
|
3
|
+
* Determines if a response is a failure
|
|
4
|
+
*/
|
|
5
|
+
export declare function isHttpCodeFailure(code: unknown): boolean;
|
|
6
|
+
/** Class representing a PageVisitEventHTTP */
|
|
7
|
+
export declare class PageVisitEventHTTP {
|
|
8
|
+
httpEvent: PVEventHTTP;
|
|
9
|
+
httpData: HTTPDataBundle | null;
|
|
10
|
+
isGqlError: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the http event for the pv
|
|
13
|
+
*/
|
|
14
|
+
constructor(httpEvent: Partial<PVEventHTTP>, httpData: HTTPDataBundle | null, isGqlError?: boolean);
|
|
15
|
+
/** Saves the HTTP event to the pageVisit Queue */
|
|
16
|
+
saveHTTPEvent(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if sending data is allowed based on the HTTP status code and count.
|
|
19
|
+
* status - The HTTP status code to evaluate.
|
|
20
|
+
* count - The count of events to consider.
|
|
21
|
+
* isGqlError - Whether the context is considered as a GQL error.
|
|
22
|
+
* Returns `true` if sending data is allowed, `false` otherwise.
|
|
23
|
+
*/
|
|
24
|
+
static isSendAllowed(status: number, count: number, isGqlError?: boolean): boolean;
|
|
25
|
+
}
|
|
@@ -84,7 +84,7 @@ export type RecorderEvent = {
|
|
|
84
84
|
};
|
|
85
85
|
export type NativeFrames = {
|
|
86
86
|
p: (number | boolean | SubPicture)[][];
|
|
87
|
-
a: (number[] | (number | string
|
|
87
|
+
a: (number[] | (number | string | string[])[])[];
|
|
88
88
|
e: (string | number)[];
|
|
89
89
|
};
|
|
90
90
|
export type UnsubscribeFn = () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Provider, StorageValue } from '
|
|
1
|
+
import { Provider, StorageValue } from '../../types/Storage';
|
|
2
2
|
/**
|
|
3
3
|
* Base implementation for LocalStorage and SessionStorage
|
|
4
4
|
*/
|
|
@@ -7,9 +7,9 @@ export default abstract class StorageProvider {
|
|
|
7
7
|
/** Creates new instance based on provided provider type */
|
|
8
8
|
constructor(provider: Provider);
|
|
9
9
|
/** Checks if provider is available */
|
|
10
|
-
static isAvailable(resolver: () =>
|
|
10
|
+
static isAvailable<T extends Provider>(resolver: () => T): Promise<{
|
|
11
11
|
result: boolean;
|
|
12
|
-
error:
|
|
12
|
+
error: Error | null;
|
|
13
13
|
}>;
|
|
14
14
|
/**
|
|
15
15
|
* Loads value from storage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RawStackFrame } from './stacktrace-parser';
|
|
2
2
|
import { REQUIRED_DATA_PROCESSING_URLS } from '../constants';
|
|
3
|
-
import {
|
|
3
|
+
import { JSErrorOutputMessage } from '../../types/PageVisit.types';
|
|
4
4
|
/**
|
|
5
5
|
* returns a string that satisfies a max length
|
|
6
6
|
* stringToVerify: string that needs to be verified
|
|
@@ -11,7 +11,12 @@ export declare function getMaxSubstringAllowed(stringToVerify: string, length?:
|
|
|
11
11
|
* Processes the raw stack frames and creates a readable stack in a safe manner
|
|
12
12
|
* @param {StackFrame[]} rawFrames
|
|
13
13
|
*/
|
|
14
|
-
export declare function processFrames(rawFrames: RawStackFrame[]):
|
|
14
|
+
export declare function processFrames(rawFrames: RawStackFrame[]): {
|
|
15
|
+
file: string;
|
|
16
|
+
line: string;
|
|
17
|
+
mname: string;
|
|
18
|
+
column?: number;
|
|
19
|
+
}[];
|
|
15
20
|
/**
|
|
16
21
|
* Retrieves the javascript stack and message from an error event object
|
|
17
22
|
* @param errObj error to extract stack from
|
|
@@ -19,11 +24,11 @@ export declare function processFrames(rawFrames: RawStackFrame[]): JStackFrame[]
|
|
|
19
24
|
export declare function getJSStack(errObj: {
|
|
20
25
|
stack: string;
|
|
21
26
|
message: string;
|
|
22
|
-
}):
|
|
27
|
+
}): JSErrorOutputMessage;
|
|
23
28
|
/**
|
|
24
29
|
* Checks if possiblyStacktrace has any stack frames present
|
|
25
30
|
*/
|
|
26
|
-
export declare function isStackTrace(
|
|
31
|
+
export declare function isStackTrace(_possiblyStacktrace: string): boolean;
|
|
27
32
|
/**
|
|
28
33
|
* counts the number of bytes
|
|
29
34
|
*/
|
|
@@ -80,3 +85,19 @@ export declare function isInstanceOf(instance: unknown, type: unknown): boolean;
|
|
|
80
85
|
* To grab the video recorder type based on the device we run the app on.
|
|
81
86
|
*/
|
|
82
87
|
export declare function getVideoRecorderType(): Promise<string>;
|
|
88
|
+
/** String.trim, but safe */
|
|
89
|
+
export declare function safeTrim(text: unknown): string;
|
|
90
|
+
/**
|
|
91
|
+
* Tries to get the stack trace from the given error object and returns it.
|
|
92
|
+
* If the error object does not have a stack trace, an empty string is returned.
|
|
93
|
+
*
|
|
94
|
+
* @param {Error} error - The error object from which to retrieve the stack trace.
|
|
95
|
+
* @returns {string} The stack trace of the error, if available. Otherwise, an empty string is returned.
|
|
96
|
+
*/
|
|
97
|
+
export declare function tryGetStackTrace(error: any): string;
|
|
98
|
+
/**
|
|
99
|
+
* Checks whether the given value is a string or an instance of String.
|
|
100
|
+
* @param {*} value - The value to be checked.
|
|
101
|
+
* @returns {boolean} Returns true if the value is a string or an instance of String, otherwise returns false.
|
|
102
|
+
*/
|
|
103
|
+
export declare function isString(value: any): value is string | String;
|
|
@@ -22,11 +22,9 @@ export declare function unwrapNoibuWrapped<T>(anything: {
|
|
|
22
22
|
* Checks whether the prototype's property is writeable. If it is not,
|
|
23
23
|
* checks whether the property can be made writeable. If it can, it is
|
|
24
24
|
* set to writeable.
|
|
25
|
-
*
|
|
26
|
-
* @param {string} property
|
|
27
|
-
* @returns {boolean} Whether the property on the prototype is (or is now) writeable
|
|
25
|
+
* returns Whether the property on the prototype is (or is now) writeable
|
|
28
26
|
*/
|
|
29
|
-
export declare const propWriteableOrMadeWriteable: (proto:
|
|
27
|
+
export declare const propWriteableOrMadeWriteable: <T>(proto: T, property: keyof T) => boolean;
|
|
30
28
|
/**
|
|
31
29
|
* Iterates object recursively and calls visit function
|
|
32
30
|
* for each property allowing to override its value
|
|
@@ -38,4 +36,11 @@ export declare const propWriteableOrMadeWriteable: (proto: object, property: key
|
|
|
38
36
|
export declare const iterateObjectRecursively: (instance: Record<any, any>, visit: (i: typeof instance, p: keyof typeof i, v: (typeof i)[typeof p]) => typeof v, limit?: {
|
|
39
37
|
depth: number;
|
|
40
38
|
}) => void;
|
|
39
|
+
export declare const safeEntries: (obj: unknown | Record<string, string | null> | Headers) => [string, string | null][];
|
|
40
|
+
/**
|
|
41
|
+
* Replaces the behaviour of Object.fromEntries() as it is not supported on all browsers
|
|
42
|
+
* @param {Iterable} entries The iterable to parse into an object
|
|
43
|
+
* @returns An object containing the same key/values as the iterable passed
|
|
44
|
+
*/
|
|
45
|
+
export declare const safeFromEntries: <T>(entries: unknown) => Record<string, T>;
|
|
41
46
|
export {};
|
|
@@ -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,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In case Promise.all is not available, use this polyfill
|
|
3
|
+
*/
|
|
4
|
+
export declare const promiseAll: {
|
|
5
|
+
<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
|
|
6
|
+
<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>;
|
|
7
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
1
2
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
3
|
import StorageProvider from './storageProvider.js';
|
|
3
4
|
|
|
4
|
-
// eslint-disable-next-line max-classes-per-file
|
|
5
5
|
/**
|
|
6
6
|
* React native storage provider implementation
|
|
7
7
|
*/
|
|
@@ -23,10 +23,12 @@ class RNStorageProvider extends StorageProvider {
|
|
|
23
23
|
* Calculates used scape
|
|
24
24
|
* @returns {Number}
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
calculateUsedSize() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const keys = yield AsyncStorage.getAllKeys();
|
|
29
|
+
const items = yield AsyncStorage.multiGet(keys);
|
|
30
|
+
return items.reduce((sum, [key, item]) => sum + key.length + (item || '').length, 0);
|
|
31
|
+
});
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
|
package/dist/storage/storage.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
1
2
|
import RNStorageProvider from './rnStorageProvider.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Encapsulates storage api
|
|
5
6
|
*/
|
|
6
7
|
class Storage {
|
|
7
|
-
_isRNStorageAvailable;
|
|
8
|
-
_rnStorageError;
|
|
9
|
-
static _instance;
|
|
10
|
-
_provider;
|
|
11
|
-
_type;
|
|
12
8
|
/**
|
|
13
9
|
* Creates new instance assessing available options
|
|
14
10
|
*/
|
|
@@ -31,53 +27,65 @@ class Storage {
|
|
|
31
27
|
return this._instance;
|
|
32
28
|
}
|
|
33
29
|
/** Checks if storage is available */
|
|
34
|
-
|
|
35
|
-
return (
|
|
30
|
+
isAvailable() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return (yield this._provider) !== null;
|
|
33
|
+
});
|
|
36
34
|
}
|
|
37
35
|
/** Loads value from storage */
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
load(key) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const provider = yield this._provider;
|
|
39
|
+
if (provider !== null) {
|
|
40
|
+
return provider.load(key);
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
});
|
|
44
44
|
}
|
|
45
45
|
/** Saves value to storage */
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
save(key, value) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const provider = yield this._provider;
|
|
49
|
+
if (provider !== null) {
|
|
50
|
+
return provider.save(key, value);
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
});
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
56
|
* Removes value from storage
|
|
55
57
|
* @param {String} key
|
|
56
58
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
remove(key) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const provider = yield this._provider;
|
|
62
|
+
if (provider !== null) {
|
|
63
|
+
return provider.remove(key);
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
});
|
|
63
67
|
}
|
|
64
68
|
/** Calculates used scape */
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
calculateUsedSize() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const provider = yield this._provider;
|
|
72
|
+
if (provider !== null) {
|
|
73
|
+
return provider.calculateUsedSize();
|
|
74
|
+
}
|
|
75
|
+
return 0;
|
|
76
|
+
});
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
73
79
|
* Returns string indicating current provider type
|
|
74
80
|
* and availability for other storage types
|
|
75
81
|
* @returns {String}
|
|
76
82
|
*/
|
|
77
|
-
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
getDiagnoseInfo() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
return `storage provider: ${yield this
|
|
86
|
+
._type} (rnStorage available: ${yield this
|
|
87
|
+
._isRNStorageAvailable}, error: ${yield this._rnStorageError})`;
|
|
88
|
+
});
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
|
|
@@ -1,38 +1,42 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
1
2
|
import { NOIBU_LOCAL_STORAGE_TEST_KEY } from '../constants.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Base implementation for LocalStorage and SessionStorage
|
|
5
6
|
*/
|
|
6
7
|
class StorageProvider {
|
|
7
|
-
_provider;
|
|
8
8
|
/** Creates new instance based on provided provider type */
|
|
9
9
|
constructor(provider) {
|
|
10
10
|
this._provider = provider;
|
|
11
11
|
}
|
|
12
12
|
/** Checks if provider is available */
|
|
13
|
-
static
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
static isAvailable(resolver) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
let result = true;
|
|
16
|
+
let error = null;
|
|
17
|
+
try {
|
|
18
|
+
const provider = resolver();
|
|
19
|
+
yield provider.setItem(NOIBU_LOCAL_STORAGE_TEST_KEY, '0');
|
|
20
|
+
yield provider.removeItem(NOIBU_LOCAL_STORAGE_TEST_KEY);
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
result = false;
|
|
24
|
+
error = e;
|
|
25
|
+
}
|
|
26
|
+
return { result, error };
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Loads value from storage
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
load(key) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const value = yield this._provider.getItem(key);
|
|
35
|
+
if (value !== null) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
33
38
|
return value;
|
|
34
|
-
}
|
|
35
|
-
return value;
|
|
39
|
+
});
|
|
36
40
|
}
|
|
37
41
|
/** Saves value to storage */
|
|
38
42
|
save(key, value) {
|
package/dist/types/Config.d.ts
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
sel: string[];
|
|
3
|
-
scriptID: string;
|
|
4
|
-
njs_version: string;
|
|
5
|
-
nid_cookie: boolean;
|
|
6
|
-
http_data_collection: boolean;
|
|
7
|
-
http_re: string[];
|
|
8
|
-
}
|
|
9
|
-
export interface CustomerConfig {
|
|
10
|
-
blockedElements?: Config['sel'];
|
|
11
|
-
listOfUrlsToCollectHttpDataFrom?: Config['http_re'];
|
|
12
|
-
enableHttpDataCollection?: Config['http_data_collection'];
|
|
13
|
-
domain: UrlConfig['domain'];
|
|
14
|
-
}
|
|
1
|
+
import { ATTRIBUTE_SELECTORS_ATT_NAME, BROWSER_ID_KEY, CLIENT_UNLOCK_TIME_KEY, CURRENT_PAGE_VISIT_COUNT_KEY, DISABLED_STATUS_KEY, HELP_CODE_EVENT_NAME, HTTP_DATA_COLLECTION_FLAG_NAME, HTTP_DATA_PAYLOAD_URL_REGEXES_FLAG_NAME, LAST_ACTIVE_TIME_KEY, PAGE_VISIT_ID_KEY, POST_METRICS_EVENT_NAME, WIN_BLOCKED_SELECTOR_ATT_NAME, WIN_NJS_VERSION_ATT_NAME, WIN_SCRIPT_ID_ATT_NAME } from '../src/constants';
|
|
15
2
|
export interface StoredConfig {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
[BROWSER_ID_KEY]: string;
|
|
4
|
+
[LAST_ACTIVE_TIME_KEY]?: Date;
|
|
5
|
+
[PAGE_VISIT_ID_KEY]?: string;
|
|
6
|
+
[CURRENT_PAGE_VISIT_COUNT_KEY]: number;
|
|
7
|
+
[CLIENT_UNLOCK_TIME_KEY]?: Date;
|
|
8
|
+
[DISABLED_STATUS_KEY]: boolean;
|
|
22
9
|
}
|
|
23
10
|
export type UrlConfig = {
|
|
24
11
|
metroplexSocketBase: string;
|
|
25
12
|
metroplexHTTPBase: string;
|
|
26
13
|
domain: string;
|
|
27
14
|
};
|
|
15
|
+
export interface CustomerConfig {
|
|
16
|
+
blockedElements?: NoibuConfig[typeof WIN_BLOCKED_SELECTOR_ATT_NAME];
|
|
17
|
+
listOfUrlsToCollectHttpDataFrom?: NoibuConfig[typeof HTTP_DATA_PAYLOAD_URL_REGEXES_FLAG_NAME];
|
|
18
|
+
enableHttpDataCollection?: NoibuConfig[typeof HTTP_DATA_COLLECTION_FLAG_NAME];
|
|
19
|
+
domain: UrlConfig['domain'];
|
|
20
|
+
}
|
|
21
|
+
export interface NoibuConfig {
|
|
22
|
+
[WIN_BLOCKED_SELECTOR_ATT_NAME]: string;
|
|
23
|
+
[WIN_SCRIPT_ID_ATT_NAME]: string;
|
|
24
|
+
[WIN_NJS_VERSION_ATT_NAME]: string;
|
|
25
|
+
[ATTRIBUTE_SELECTORS_ATT_NAME]: string;
|
|
26
|
+
[POST_METRICS_EVENT_NAME]: string;
|
|
27
|
+
[HELP_CODE_EVENT_NAME]: string;
|
|
28
|
+
[HTTP_DATA_COLLECTION_FLAG_NAME]: string;
|
|
29
|
+
[HTTP_DATA_PAYLOAD_URL_REGEXES_FLAG_NAME]: string[];
|
|
30
|
+
domain: string;
|
|
31
|
+
}
|