noibu-react-native 0.2.2 → 0.2.4
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/dist/api/clientConfig.js +225 -217
- package/dist/api/helpCode.js +61 -87
- package/dist/api/metroplexSocket.js +460 -463
- package/dist/api/storedPageVisit.js +150 -208
- package/dist/constants.js +10 -2
- package/dist/entry/init.js +65 -63
- package/dist/monitors/{appNavigationMonitor.js → AppNavigationMonitor.js} +12 -22
- package/dist/monitors/ClickMonitor.js +198 -0
- package/dist/monitors/ErrorMonitor.js +206 -0
- package/dist/monitors/KeyboardInputMonitor.js +60 -0
- package/dist/monitors/PageMonitor.js +98 -0
- package/dist/monitors/RequestMonitor.js +390 -0
- package/dist/monitors/http-tools/GqlErrorValidator.js +259 -0
- package/dist/monitors/http-tools/HTTPDataBundler.js +458 -0
- package/dist/monitors/integrations/react-native-navigation-integration.js +4 -2
- package/dist/pageVisit/EventDebouncer.js +99 -0
- package/dist/pageVisit/pageVisitEventError.js +2 -2
- package/dist/pageVisit/pageVisitEventHTTP.js +79 -93
- package/dist/react/ErrorBoundary.js +18 -15
- package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +3 -2
- package/dist/sessionRecorder/sessionRecorder.js +152 -151
- package/dist/{api → src/api}/clientConfig.d.ts +2 -2
- package/dist/{api → src/api}/helpCode.d.ts +10 -16
- package/dist/{api → src/api}/metroplexSocket.d.ts +48 -67
- package/dist/{api → src/api}/storedPageVisit.d.ts +12 -21
- package/dist/{constants.d.ts → src/constants.d.ts} +45 -0
- package/dist/{entry → src/entry}/init.d.ts +1 -1
- package/dist/src/monitors/AppNavigationMonitor.d.ts +18 -0
- package/dist/src/monitors/ClickMonitor.d.ts +31 -0
- package/dist/src/monitors/ErrorMonitor.d.ts +63 -0
- package/dist/{monitors/keyboardInputMonitor.d.ts → src/monitors/KeyboardInputMonitor.d.ts} +7 -4
- package/dist/{monitors/pageMonitor.d.ts → src/monitors/PageMonitor.d.ts} +6 -8
- package/dist/src/monitors/RequestMonitor.d.ts +94 -0
- package/dist/src/monitors/http-tools/GqlErrorValidator.d.ts +59 -0
- package/dist/src/monitors/http-tools/HTTPDataBundler.d.ts +112 -0
- package/dist/{monitors → src/monitors}/integrations/react-native-navigation-integration.d.ts +3 -2
- package/dist/src/pageVisit/EventDebouncer.d.ts +24 -0
- package/dist/{pageVisit → src/pageVisit}/pageVisit.d.ts +1 -1
- 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 +2 -2
- package/dist/{storage → src/storage}/storageProvider.d.ts +3 -3
- package/dist/{utils → src/utils}/function.d.ts +27 -7
- package/dist/{utils → src/utils}/object.d.ts +11 -8
- package/dist/src/utils/piiRedactor.d.ts +11 -0
- package/dist/src/utils/polyfills.d.ts +4 -0
- package/dist/storage/rnStorageProvider.js +7 -4
- 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/Metroplex.types.d.ts +73 -0
- package/dist/types/Monitor.d.ts +11 -0
- package/dist/types/Monitor.js +19 -0
- package/dist/types/PageVisit.types.d.ts +8 -0
- package/dist/types/PageVisitErrors.types.d.ts +114 -0
- package/dist/types/PageVisitEvents.types.d.ts +91 -0
- package/dist/types/PageVisitMetrics.types.d.ts +27 -0
- package/dist/types/Storage.d.ts +1 -1
- package/dist/types/StoredPageVisit.types.d.ts +4 -47
- package/dist/types/WrappedObjects.d.ts +6 -0
- package/dist/utils/function.js +110 -77
- package/dist/utils/object.js +59 -6
- package/dist/utils/piiRedactor.js +98 -0
- package/dist/utils/polyfills.js +24 -0
- package/package.json +8 -8
- package/dist/monitors/appNavigationMonitor.d.ts +0 -22
- package/dist/monitors/clickMonitor.d.ts +0 -44
- package/dist/monitors/clickMonitor.js +0 -251
- package/dist/monitors/errorMonitor.d.ts +0 -28
- package/dist/monitors/errorMonitor.js +0 -180
- package/dist/monitors/gqlErrorValidator.d.ts +0 -82
- package/dist/monitors/gqlErrorValidator.js +0 -306
- package/dist/monitors/httpDataBundler.d.ts +0 -161
- package/dist/monitors/httpDataBundler.js +0 -725
- package/dist/monitors/inputMonitor.d.ts +0 -34
- package/dist/monitors/inputMonitor.js +0 -138
- package/dist/monitors/keyboardInputMonitor.js +0 -66
- package/dist/monitors/pageMonitor.js +0 -122
- package/dist/monitors/requestMonitor.d.ts +0 -10
- package/dist/monitors/requestMonitor.js +0 -401
- package/dist/pageVisit/pageVisitEventHTTP.d.ts +0 -18
- package/dist/types/PageVisit.d.ts +0 -22
- package/dist/types/ReactNative.d.ts +0 -4
- package/dist/types/globals.d.ts +0 -45
- /package/dist/{api → src/api}/inputManager.d.ts +0 -0
- /package/dist/{api → src/api}/storedMetrics.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/{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,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Try detecting GraphQL errors from http response
|
|
3
|
+
*/
|
|
4
|
+
export default class GqlErrorValidator {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves GQL error object based on fetch request/response
|
|
7
|
+
*/
|
|
8
|
+
static fromFetch(url: string, options: RequestInit | undefined, request: Request | undefined, response: Response): Promise<unknown[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves GQL error object based on XHR object
|
|
11
|
+
*/
|
|
12
|
+
static fromXhr(url: string, xhr: unknown): Promise<unknown[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Try safely parse a string and return null if fails
|
|
15
|
+
*/
|
|
16
|
+
static _parseJsonSafely(content: string): any;
|
|
17
|
+
/**
|
|
18
|
+
* Try to get content type for fetch arguments
|
|
19
|
+
*/
|
|
20
|
+
static _getContentTypeFromFetchArguments(options?: RequestInit, request?: Request): string;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if request is aborted
|
|
23
|
+
* If it has been aborted we are not able to consume the response
|
|
24
|
+
*/
|
|
25
|
+
static _isRequestAborted(options?: RequestInit, request?: RequestInit): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Determines if request should be processed
|
|
28
|
+
*/
|
|
29
|
+
static _shouldHandleRequest(url: string, contentType?: string | null): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Sanitizes payload object
|
|
32
|
+
*/
|
|
33
|
+
static _validate(data: unknown, validationIssues: string[]): unknown[];
|
|
34
|
+
/**
|
|
35
|
+
* Sanitizes message object
|
|
36
|
+
*/
|
|
37
|
+
static _validateMessage(error: object): void;
|
|
38
|
+
/**
|
|
39
|
+
* Sanitizes extensions object
|
|
40
|
+
* @param {any} error
|
|
41
|
+
*/
|
|
42
|
+
static _validateExtensions(error: any): void;
|
|
43
|
+
/**
|
|
44
|
+
* Sanitizes locations object
|
|
45
|
+
*/
|
|
46
|
+
static _validateLocations(error: object, validationIssues: string[]): void;
|
|
47
|
+
/**
|
|
48
|
+
* Sanitizes path object
|
|
49
|
+
*/
|
|
50
|
+
static _validatePath(error: object, validationIssues: string[]): void;
|
|
51
|
+
/**
|
|
52
|
+
* Posts error
|
|
53
|
+
*/
|
|
54
|
+
static _postError(message: unknown): void;
|
|
55
|
+
/**
|
|
56
|
+
* Posts issue found during object sanitization
|
|
57
|
+
*/
|
|
58
|
+
static _postValidationIssues(validationIssues: string[]): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { WrappedXMLHttpRequest } from '../../../types/WrappedObjects';
|
|
2
|
+
import { Singleton } from '../../../types/Monitor';
|
|
3
|
+
import { HTTPDataBundle } from '../../../types/PageVisitEvents.types';
|
|
4
|
+
/** Bundles HTTP payloads and headers */
|
|
5
|
+
export declare class HTTPDataBundler extends Singleton {
|
|
6
|
+
contentTypeReadableRegex: RegExp;
|
|
7
|
+
hostname: string;
|
|
8
|
+
initialURLPartsReversed: string[];
|
|
9
|
+
httpDataCollectionEnabled: boolean;
|
|
10
|
+
httpDataAllowedRelativeRegex: RegExp | null;
|
|
11
|
+
httpDataAllowedAbsoluteRegex: RegExp | null;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the ClickMonitor instance
|
|
14
|
+
*/
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Builds the HTTP payload allowed regexes for full and relative URLs
|
|
18
|
+
* @param allowedURLs A list of allowed URLs
|
|
19
|
+
* @param absolute Use only absolute URLs if true, use only relative URL if false
|
|
20
|
+
* @returns a regex of allowed URLs
|
|
21
|
+
*/
|
|
22
|
+
private static buildAllowedRegex;
|
|
23
|
+
/**
|
|
24
|
+
* Takes an iterator and returns a map of strings representing headers.
|
|
25
|
+
* param {object} headersIterable any iterable object
|
|
26
|
+
* returns a map of strings (as expected by metroplex) representing HTTP
|
|
27
|
+
* request or response headers
|
|
28
|
+
*/
|
|
29
|
+
static headersMapFromIterable(headersIterable: Iterable<any[]>): Map<any, any>;
|
|
30
|
+
/**
|
|
31
|
+
* Takes a string of headers with 'name: value' and returns
|
|
32
|
+
* a map of strings representing headers.
|
|
33
|
+
* headersString is all the headers in one string
|
|
34
|
+
* returns a map of strings (as expected by metroplex) representing HTTP
|
|
35
|
+
* request or response headers
|
|
36
|
+
*/
|
|
37
|
+
static headersMapFromString(headersString: unknown): Map<string, string>;
|
|
38
|
+
/**
|
|
39
|
+
* For an XHR object, checks the responseType property and handles the response or
|
|
40
|
+
* responseText property accordingly to return a string representation of the response.
|
|
41
|
+
* @returns a string representation of the response, or null if this fails.
|
|
42
|
+
*/
|
|
43
|
+
static getResponseStringFromXHR(xhr: WrappedXMLHttpRequest): Promise<any>;
|
|
44
|
+
/**
|
|
45
|
+
* Builds an HTTP Data bundle
|
|
46
|
+
*/
|
|
47
|
+
bundleHTTPData(url: string, requestHeaders: Map<string, string> | undefined, rawRequestPayload: any, responseHeaders: Map<string, string>, rawResponsePayload: any, method: string, isError: boolean): HTTPDataBundle | null;
|
|
48
|
+
/**
|
|
49
|
+
* Validates a request based on the URL and method. When enabled, will handle
|
|
50
|
+
* de-duping the requests
|
|
51
|
+
*/
|
|
52
|
+
isValidRequest(method: unknown): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Checks two things: that the URL is either on the same domain (or an address relative to the
|
|
55
|
+
* current domain), and also checks that the config http_data_collection flag is enabled.
|
|
56
|
+
* @param {string} url
|
|
57
|
+
* @returns boolean indicating whether the URL passed is either relative (in which case it is
|
|
58
|
+
* inherently on the current domain) or matches the current domain.
|
|
59
|
+
*/
|
|
60
|
+
shouldContinueForURL(url: any): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Determines if the URL is absolute or relative
|
|
63
|
+
* returns boolean indicating whether the URL passed is either absolute or relative
|
|
64
|
+
*/
|
|
65
|
+
static isAbsoluteURL(url: unknown): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Checks whether HTTP payloads can be collected on this URL
|
|
68
|
+
* returns boolean indicating whether HTTP payloads can be collected on this URL
|
|
69
|
+
*/
|
|
70
|
+
shouldCollectPayloadForURL(url: any): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Double checks content length if we couldn't read the headers, and redacts PII
|
|
73
|
+
* returns the restricted payload
|
|
74
|
+
*/
|
|
75
|
+
restrictPayload(payload: string, url: string, isError: boolean): string;
|
|
76
|
+
/**
|
|
77
|
+
* Returns true if the content-length header is of acceptable size.
|
|
78
|
+
* Too big gets rejected
|
|
79
|
+
* If the headers are not found, check actual content for length
|
|
80
|
+
* @param {Headers} headers
|
|
81
|
+
* @returns boolean true if acceptable to collect
|
|
82
|
+
*/
|
|
83
|
+
contentLengthAcceptable(headers: Map<string, string>, isError: boolean): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Returns true if the content type according to the headers is valid for collection.
|
|
86
|
+
* Also returns assumed true if content type is not stated in headers.
|
|
87
|
+
* @param {Map} headersMap
|
|
88
|
+
* @returns boolean true if acceptable to collect
|
|
89
|
+
*/
|
|
90
|
+
private contentTypeAcceptable;
|
|
91
|
+
/**
|
|
92
|
+
* Returns a descriptive string if we have to drop payload based on the length
|
|
93
|
+
* or type listed in the headers passed. Returns an empty string otherwise.
|
|
94
|
+
*/
|
|
95
|
+
getReasonPayloadIsDropped(headers: any, isError: boolean): string;
|
|
96
|
+
/**
|
|
97
|
+
* Returns content length from the headers, if available.
|
|
98
|
+
* If headers are not found or length is not a number, return -1
|
|
99
|
+
*/
|
|
100
|
+
contentLength(headersObject: any): number;
|
|
101
|
+
/**
|
|
102
|
+
* Accepts a value that could be any type used as a request payload,
|
|
103
|
+
* and returns a string representation, or null if this fails.
|
|
104
|
+
*/
|
|
105
|
+
stringFromRequestBody(value: any, requestHeaders?: Map<string, string>): any;
|
|
106
|
+
/**
|
|
107
|
+
* Removes possible PII from headers.
|
|
108
|
+
* @param {Map} dirtyHeaders a Map of HTTP response or request headers
|
|
109
|
+
* @returns {Map|null} a map of headers with PII redacted
|
|
110
|
+
*/
|
|
111
|
+
removePIIHeaders(dirtyHeaders: Map<string, string> | undefined): typeof dirtyHeaders | null;
|
|
112
|
+
}
|
package/dist/{monitors → src/monitors}/integrations/react-native-navigation-integration.d.ts
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { NavigationIntegration } from '
|
|
1
|
+
import { NavigationIntegration } from '../../../types/NavigationIntegration';
|
|
2
|
+
import { NavigationRoot } from 'react-native-navigation/lib/dist/src/Navigation';
|
|
2
3
|
/**
|
|
3
4
|
* react-native-navigation adapter
|
|
4
5
|
*/
|
|
@@ -8,7 +9,7 @@ export declare class ReactNativeNavigationIntegration implements NavigationInteg
|
|
|
8
9
|
/**
|
|
9
10
|
* attaches provided listeners to the integration
|
|
10
11
|
*/
|
|
11
|
-
register(navigation:
|
|
12
|
+
register(navigation: NavigationRoot, onNavigation: (breadcrumbs: string[]) => void): void;
|
|
12
13
|
/**
|
|
13
14
|
* Listens to ComponentWillAppear events, keeps track of visited screens and
|
|
14
15
|
* pops them if the same page is visited to prevent cycles
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Singleton } from '../../types/Monitor';
|
|
2
|
+
/**
|
|
3
|
+
* Singleton class responsible for debouncing all events
|
|
4
|
+
* that are registered
|
|
5
|
+
*/
|
|
6
|
+
export declare class EventDebouncer extends Singleton {
|
|
7
|
+
private readonly eventsToDebounce;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of EventDebouncer
|
|
10
|
+
*/
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Creates an event object with the event and the time it was added then pushes
|
|
14
|
+
* that event object to the queue of events waiting to be debounced.
|
|
15
|
+
*/
|
|
16
|
+
addEvent(event: any, type: keyof typeof this.eventsToDebounce, occurredAt?: number): void;
|
|
17
|
+
/**
|
|
18
|
+
* Adds the events from the object to the page visit and sets up a timer
|
|
19
|
+
* to send the events if no more are received without the timeout
|
|
20
|
+
*/
|
|
21
|
+
_debouncePvEvents(type: string): void;
|
|
22
|
+
/** Sets up the page hide handler to try to push remaining events in the queues */
|
|
23
|
+
_setupUnloadHandler(): void;
|
|
24
|
+
}
|
|
@@ -17,7 +17,7 @@ export class PageVisit {
|
|
|
17
17
|
* @param {} pvEvents
|
|
18
18
|
* @param {} partCounter
|
|
19
19
|
*/
|
|
20
|
-
static makePageVisitFrag(pvEvents: any, partCounter: any):
|
|
20
|
+
static makePageVisitFrag(pvEvents: any, partCounter: any): import("../../types/Metroplex.types").PageVisitFrag | import("../../types/Metroplex.types").VideoFrag;
|
|
21
21
|
partCounter: number;
|
|
22
22
|
pvMap: {};
|
|
23
23
|
pvEventLength: number;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HTTPDataBundle, PVEventHTTPPayload } from '../../types/PageVisitEvents.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: PVEventHTTPPayload;
|
|
9
|
+
httpData: HTTPDataBundle | null;
|
|
10
|
+
isGqlError: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the http event for the pv
|
|
13
|
+
*/
|
|
14
|
+
constructor(httpEvent: Partial<PVEventHTTPPayload>, 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 { IStorage, StorageValue } from '
|
|
1
|
+
import { IStorage, StorageValue } from '../../types/Storage';
|
|
2
2
|
/**
|
|
3
3
|
* Encapsulates storage api
|
|
4
4
|
*/
|
|
@@ -20,7 +20,7 @@ export default class Storage implements IStorage {
|
|
|
20
20
|
/** Checks if storage is available */
|
|
21
21
|
isAvailable(): Promise<boolean>;
|
|
22
22
|
/** Loads value from storage */
|
|
23
|
-
load
|
|
23
|
+
load(key: string): Promise<string | null>;
|
|
24
24
|
/** Saves value to storage */
|
|
25
25
|
save(key: string, value: StorageValue): Promise<void>;
|
|
26
26
|
/**
|
|
@@ -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
|
*/
|
|
@@ -9,12 +9,12 @@ export default abstract class StorageProvider {
|
|
|
9
9
|
/** Checks if provider is available */
|
|
10
10
|
static isAvailable<T extends Provider>(resolver: () => T): Promise<{
|
|
11
11
|
result: boolean;
|
|
12
|
-
error: Error
|
|
12
|
+
error: Error;
|
|
13
13
|
}>;
|
|
14
14
|
/**
|
|
15
15
|
* Loads value from storage
|
|
16
16
|
*/
|
|
17
|
-
load<R = StorageValue>(key: string): Promise<
|
|
17
|
+
load<R = StorageValue>(key: string): Promise<string | R>;
|
|
18
18
|
/** Saves value to storage */
|
|
19
19
|
save(key: string, value: StorageValue): Promise<void>;
|
|
20
20
|
/**
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { RawStackFrame } from './stacktrace-parser';
|
|
2
2
|
import { REQUIRED_DATA_PROCESSING_URLS } from '../constants';
|
|
3
|
-
import {
|
|
3
|
+
import { JSErrorOutputMessage } from '../../types/PageVisitErrors.types';
|
|
4
4
|
/**
|
|
5
5
|
* returns a string that satisfies a max length
|
|
6
6
|
* stringToVerify: string that needs to be verified
|
|
7
7
|
* length :optional, max length that stringToVerify can be
|
|
8
8
|
*/
|
|
9
|
-
export declare function getMaxSubstringAllowed(stringToVerify: string, length?:
|
|
9
|
+
export declare function getMaxSubstringAllowed(stringToVerify: string, length?: number): string;
|
|
10
10
|
/**
|
|
11
11
|
* Processes the raw stack frames and creates a readable stack in a safe manner
|
|
12
|
-
* @param {StackFrame[]} rawFrames
|
|
13
12
|
*/
|
|
14
|
-
export declare function processFrames(rawFrames: RawStackFrame[]):
|
|
13
|
+
export declare function processFrames(rawFrames: RawStackFrame[]): {
|
|
14
|
+
file: string;
|
|
15
|
+
line: string;
|
|
16
|
+
mname: string;
|
|
17
|
+
column?: number;
|
|
18
|
+
}[];
|
|
15
19
|
/**
|
|
16
20
|
* Retrieves the javascript stack and message from an error event object
|
|
17
21
|
* @param errObj error to extract stack from
|
|
@@ -19,11 +23,11 @@ export declare function processFrames(rawFrames: RawStackFrame[]): JStackFrame[]
|
|
|
19
23
|
export declare function getJSStack(errObj: {
|
|
20
24
|
stack: string;
|
|
21
25
|
message: string;
|
|
22
|
-
}):
|
|
26
|
+
}): JSErrorOutputMessage;
|
|
23
27
|
/**
|
|
24
28
|
* Checks if possiblyStacktrace has any stack frames present
|
|
25
29
|
*/
|
|
26
|
-
export declare function isStackTrace(
|
|
30
|
+
export declare function isStackTrace(_possiblyStacktrace: unknown): _possiblyStacktrace is string;
|
|
27
31
|
/**
|
|
28
32
|
* counts the number of bytes
|
|
29
33
|
*/
|
|
@@ -75,8 +79,24 @@ export declare function maskTextInput(text: string): string;
|
|
|
75
79
|
* It's safer than `instanceof` operator as it handles cases
|
|
76
80
|
* where type is not actually a type but an object.
|
|
77
81
|
*/
|
|
78
|
-
export declare function isInstanceOf(instance: unknown, type:
|
|
82
|
+
export declare function isInstanceOf<T>(instance: unknown, type: T): instance is T;
|
|
79
83
|
/**
|
|
80
84
|
* To grab the video recorder type based on the device we run the app on.
|
|
81
85
|
*/
|
|
82
86
|
export declare function getVideoRecorderType(): Promise<string>;
|
|
87
|
+
/** String.trim, but safe */
|
|
88
|
+
export declare function safeTrim(text: unknown): string;
|
|
89
|
+
/**
|
|
90
|
+
* Tries to get the stack trace from the given error object and returns it.
|
|
91
|
+
* If the error object does not have a stack trace, an empty string is returned.
|
|
92
|
+
*
|
|
93
|
+
* @param {Error} error - The error object from which to retrieve the stack trace.
|
|
94
|
+
* @returns {string} The stack trace of the error, if available. Otherwise, an empty string is returned.
|
|
95
|
+
*/
|
|
96
|
+
export declare function tryGetStackTrace(error: any): string;
|
|
97
|
+
/**
|
|
98
|
+
* Checks whether the given value is a string or an instance of String.
|
|
99
|
+
* @param {*} value - The value to be checked.
|
|
100
|
+
* @returns {boolean} Returns true if the value is a string or an instance of String, otherwise returns false.
|
|
101
|
+
*/
|
|
102
|
+
export declare function isString(value: any): value is string | String;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @module Object */
|
|
2
|
-
type Func = (...args: any[]) => any;
|
|
3
2
|
/**
|
|
4
3
|
* Replaces an attribute value found in an object with another value
|
|
5
4
|
* sourceObject: source object whose attribute will get replaced
|
|
@@ -10,23 +9,21 @@ type Func = (...args: any[]) => any;
|
|
|
10
9
|
* @param {} attributeName
|
|
11
10
|
* @param {} processingFunction
|
|
12
11
|
*/
|
|
13
|
-
export declare const replace: <A extends { [k in K]:
|
|
12
|
+
export declare const replace: <A extends { [k in K]: Function; }, K extends keyof A>(sourceObject: A, attributeName: K, processingFunction: (arg: A[K]) => A[K]) => void;
|
|
14
13
|
/**
|
|
15
14
|
* unwraps wrapped property, so we can use it without side effects
|
|
16
15
|
* @param anything
|
|
17
16
|
*/
|
|
18
17
|
export declare function unwrapNoibuWrapped<T>(anything: {
|
|
19
18
|
__noibu_original__?: T;
|
|
20
|
-
} & T):
|
|
19
|
+
} & T): T;
|
|
21
20
|
/**
|
|
22
21
|
* Checks whether the prototype's property is writeable. If it is not,
|
|
23
22
|
* checks whether the property can be made writeable. If it can, it is
|
|
24
23
|
* set to writeable.
|
|
25
|
-
*
|
|
26
|
-
* @param {string} property
|
|
27
|
-
* @returns {boolean} Whether the property on the prototype is (or is now) writeable
|
|
24
|
+
* returns Whether the property on the prototype is (or is now) writeable
|
|
28
25
|
*/
|
|
29
|
-
export declare const propWriteableOrMadeWriteable: (proto:
|
|
26
|
+
export declare const propWriteableOrMadeWriteable: <T>(proto: T, property: keyof T) => boolean;
|
|
30
27
|
/**
|
|
31
28
|
* Iterates object recursively and calls visit function
|
|
32
29
|
* for each property allowing to override its value
|
|
@@ -38,4 +35,10 @@ export declare const propWriteableOrMadeWriteable: (proto: object, property: key
|
|
|
38
35
|
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
36
|
depth: number;
|
|
40
37
|
}) => void;
|
|
41
|
-
export
|
|
38
|
+
export declare const safeEntries: (obj: unknown | Record<string, string | null> | Headers) => [string, string][];
|
|
39
|
+
/**
|
|
40
|
+
* Replaces the behaviour of Object.fromEntries() as it is not supported on all browsers
|
|
41
|
+
* @param {Iterable} entries The iterable to parse into an object
|
|
42
|
+
* @returns An object containing the same key/values as the iterable passed
|
|
43
|
+
*/
|
|
44
|
+
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;
|
|
@@ -1,3 +1,4 @@
|
|
|
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
|
|
|
@@ -22,10 +23,12 @@ class RNStorageProvider extends StorageProvider {
|
|
|
22
23
|
* Calculates used scape
|
|
23
24
|
* @returns {Number}
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
});
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
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) {
|