noibu-react-native 0.0.4 → 0.0.7
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 +317 -388
- package/dist/api/helpCode.js +2 -2
- package/dist/api/inputManager.js +3 -9
- package/dist/api/metroplexSocket.js +10 -34
- package/dist/api/storedMetrics.js +3 -2
- 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 +60 -75
- package/dist/monitors/AppNavigationMonitor.d.ts +23 -0
- package/dist/monitors/AppNavigationMonitor.js +63 -0
- package/dist/monitors/clickMonitor.js +10 -57
- package/dist/monitors/errorMonitor.js +1 -1
- package/dist/monitors/gqlErrorValidator.js +3 -3
- package/dist/monitors/httpDataBundler.js +13 -12
- package/dist/monitors/integrations/react-native-navigation-integration.d.ts +19 -0
- package/dist/monitors/integrations/react-native-navigation-integration.js +38 -0
- package/dist/monitors/keyboardInputMonitor.js +0 -1
- package/dist/monitors/requestMonitor.js +10 -8
- package/dist/pageVisit/pageVisitEventError/pageVisitEventError.js +10 -8
- 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/NavigationIntegration.d.ts +7 -0
- package/dist/types/PageVisit.d.ts +22 -0
- package/dist/types/ReactNative.d.ts +4 -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 +93 -0
- package/dist/utils/function.js +210 -320
- package/dist/utils/stacktrace-parser.d.ts +6 -8
- package/dist/utils/stacktrace-parser.js +5 -5
- package/package.json +5 -1
- package/dist/monitors/elementMonitor.js +0 -177
- package/dist/monitors/locationChangeMonitor.js +0 -18
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type StorageValue = unknown;
|
|
2
|
+
export interface IStorage {
|
|
3
|
+
isAvailable(): Promise<boolean>;
|
|
4
|
+
load<R = unknown>(key: string): Promise<R | null>;
|
|
5
|
+
save(key: string, value: StorageValue): Promise<void>;
|
|
6
|
+
remove(key: string): Promise<void>;
|
|
7
|
+
calculateUsedSize(): Promise<number>;
|
|
8
|
+
getDiagnoseInfo(): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
export interface Provider {
|
|
11
|
+
getItem(key: string): Promise<string | null>;
|
|
12
|
+
setItem(key: string, value: string): Promise<void>;
|
|
13
|
+
removeItem(key: string): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="react-native" />
|
|
2
|
+
declare global {
|
|
3
|
+
const METROPLEX_BASE_SOCKET_URL: string;
|
|
4
|
+
const BETA_METROPLEX_BASE_SOCKET_URL: string;
|
|
5
|
+
const METROPLEX_BASE_HTTP_URL: string;
|
|
6
|
+
const BETA_METROPLEX_BASE_HTTP_URL: string;
|
|
7
|
+
const CURR_ENV: string;
|
|
8
|
+
const MAX_PAGE_VISIT_BUFFER_SIZE: string;
|
|
9
|
+
const DEBOUNCE_PV_POST_ON_CLICK_FREQ: string;
|
|
10
|
+
const VID_POST_FREQUENCY: string;
|
|
11
|
+
const PAGEVISIT_POST_FREQUENCY: string;
|
|
12
|
+
const WRITE_TO_METROPLEX_FREQUENCY: number;
|
|
13
|
+
const CLIENT_SCRIPT_ID: string;
|
|
14
|
+
const MAX_METROPLEX_RECONNECTION_NUMBER: number;
|
|
15
|
+
const METROPLEX_CONSECUTIVE_CONNECTION_DELAY: number;
|
|
16
|
+
const SCRIPT_ID: string;
|
|
17
|
+
type Window = {
|
|
18
|
+
noibuJSLoaded?: boolean;
|
|
19
|
+
};
|
|
20
|
+
type global = {
|
|
21
|
+
window: Window;
|
|
22
|
+
console: Console;
|
|
23
|
+
noibuJSLoaded?: boolean;
|
|
24
|
+
ErrorUtils: any;
|
|
25
|
+
HermesInternal: null | {
|
|
26
|
+
enablePromiseRejectionTracker?: any;
|
|
27
|
+
setPromiseRejectionTrackingHook?: any;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const global: global;
|
|
31
|
+
const globalThis: global;
|
|
32
|
+
const window: Window & global;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
package/dist/utils/date.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ClientConfig from '../api/clientConfig.js';
|
|
2
|
-
import {
|
|
2
|
+
import { SEVERITY } from '../constants.js';
|
|
3
3
|
|
|
4
4
|
/** @module Date */
|
|
5
5
|
|
|
@@ -51,7 +51,7 @@ function timestampWrapper(timestamp) {
|
|
|
51
51
|
`The date object has been overwritten and can't be processed properly.
|
|
52
52
|
Client has been disabled.`,
|
|
53
53
|
true,
|
|
54
|
-
|
|
54
|
+
SEVERITY.error,
|
|
55
55
|
true,
|
|
56
56
|
);
|
|
57
57
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SEVERITY } from '../constants.js';
|
|
2
2
|
import ClientConfig from '../api/clientConfig.js';
|
|
3
3
|
|
|
4
4
|
/** addSafeEventListener will add an event listener for the specified event
|
|
@@ -24,7 +24,7 @@ function addSafeEventListener(object, event, callback, capture) {
|
|
|
24
24
|
ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
|
|
25
25
|
`addEventListener callback error: ${e.message}`,
|
|
26
26
|
false,
|
|
27
|
-
|
|
27
|
+
SEVERITY.error,
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
};
|
|
@@ -59,7 +59,7 @@ function addSafeEventListener(object, event, callback, capture) {
|
|
|
59
59
|
ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
|
|
60
60
|
`addEventListener error: ${e.message}`,
|
|
61
61
|
false,
|
|
62
|
-
|
|
62
|
+
SEVERITY.error,
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { RawStackFrame } from './stacktrace-parser';
|
|
2
|
+
import { REQUIRED_DATA_PROCESSING_URLS } from '../constants';
|
|
3
|
+
import { JError, JStackFrame } from '../types/PageVisit';
|
|
4
|
+
/**
|
|
5
|
+
* returns a string that satisfies a max length
|
|
6
|
+
* stringToVerify: string that needs to be verified
|
|
7
|
+
* length :optional, max length that stringToVerify can be
|
|
8
|
+
*/
|
|
9
|
+
export declare function getMaxSubstringAllowed(stringToVerify: string, length?: 1024): string;
|
|
10
|
+
/**
|
|
11
|
+
* Processes the raw stack frames and creates a readable stack in a safe manner
|
|
12
|
+
* @param {StackFrame[]} rawFrames
|
|
13
|
+
*/
|
|
14
|
+
export declare function processFrames(rawFrames: RawStackFrame[]): JStackFrame[];
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the javascript stack and message from an error event object
|
|
17
|
+
* @param errObj error to extract stack from
|
|
18
|
+
*/
|
|
19
|
+
export declare function getJSStack(errObj: {
|
|
20
|
+
stack: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}): JError;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if possiblyStacktrace has any stack frames present
|
|
25
|
+
*/
|
|
26
|
+
export declare function isStackTrace(possiblyStacktrace: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* counts the number of bytes
|
|
29
|
+
*/
|
|
30
|
+
export declare function byteCount(s: string): number;
|
|
31
|
+
/**
|
|
32
|
+
* Stringify function that is aware of inner circular references and handles them by replacing with {} (empty object)
|
|
33
|
+
* taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value
|
|
34
|
+
*/
|
|
35
|
+
export declare function stringifyJSON(jsonObject: unknown): string;
|
|
36
|
+
/**
|
|
37
|
+
* Wrapper for a request, since we have to do some special handling
|
|
38
|
+
* @param method
|
|
39
|
+
* @param url
|
|
40
|
+
* @param data
|
|
41
|
+
* @param headers
|
|
42
|
+
* @param timeout
|
|
43
|
+
* @param sendAndForget
|
|
44
|
+
*/
|
|
45
|
+
export declare function makeRequest(method: string, url: string, data: unknown, headers: Record<string, string>, timeout: number, sendAndForget: boolean): Promise<unknown>;
|
|
46
|
+
/** checks if http data collection is enabled */
|
|
47
|
+
export declare function checkHttpDataCollectionEnabled(): boolean;
|
|
48
|
+
/** gets http data payload allowed URLs */
|
|
49
|
+
export declare function getHttpPayloadAllowedURLs(): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Gets selectors to prevent those elements from being recorded
|
|
52
|
+
*/
|
|
53
|
+
export declare function getBlockedElements(): string[];
|
|
54
|
+
/**
|
|
55
|
+
* makes sure the url sent is a valid URL
|
|
56
|
+
*/
|
|
57
|
+
export declare function isValidURL(str: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Because of the nature of user agent in react native, we have to make this async.
|
|
60
|
+
* But I promise, this is really fast, since we memoize the result for the whole session :)
|
|
61
|
+
* @returns {Promise<string>}
|
|
62
|
+
*/
|
|
63
|
+
export declare function getUserAgent(): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* isInvalidURLConfig will verify that Collect is being initializes with
|
|
66
|
+
* the correct env vars.
|
|
67
|
+
*/
|
|
68
|
+
export declare function isInvalidURLConfig(urls: Record<(typeof REQUIRED_DATA_PROCESSING_URLS)[number], string>): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* isNoibuJSAlreadyLoaded will verify if there are already other
|
|
71
|
+
* copies of NoibuJS runnung
|
|
72
|
+
*/
|
|
73
|
+
export declare function isNoibuJSAlreadyLoaded(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* asString will create a string out of anything passed to it.
|
|
76
|
+
*/
|
|
77
|
+
export declare function asString(obj: unknown): string;
|
|
78
|
+
/**
|
|
79
|
+
* masks textual content if it ressembles something sensitive
|
|
80
|
+
*/
|
|
81
|
+
export declare function maskTextInput(text: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* gets the onURL of a string, defaulting to the location of the webpage
|
|
84
|
+
*/
|
|
85
|
+
export declare function getOnURL(realOnURL: string): string;
|
|
86
|
+
/** gets the user language from the browser */
|
|
87
|
+
export declare function getUserLanguage(): string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Checks if the provided object is an instance of the specified type.
|
|
90
|
+
* It's safer than `instanceof` operator as it handles cases
|
|
91
|
+
* where type is not actually a type but an object.
|
|
92
|
+
*/
|
|
93
|
+
export declare function isInstanceOf(instance: unknown, type: unknown): boolean;
|