noibu-react-native 0.0.3 → 0.0.6

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.
@@ -4,14 +4,12 @@ import { PageVisit } from '../pageVisit/pageVisit.js';
4
4
  import { updatePayload } from '../pageVisit/userStep/userStep.js';
5
5
  import StoredMetrics from '../api/storedMetrics.js';
6
6
  import { WHITELIST_TEXT_REGEX_STRING } from '../const_matchers.js';
7
- import { getBlockedCSSForCurrentDomain, maskTextInput } from '../utils/function.js';
7
+ import { maskTextInput, getBlockedElements } from '../utils/function.js';
8
8
  import { timestampWrapper } from '../utils/date.js';
9
9
 
10
10
  /** @module ClickMonitor */
11
11
 
12
12
 
13
- const maxParentIteration = 5;
14
-
15
13
  /** Monitors the clicks which we capture and later process */
16
14
  class ClickMonitor {
17
15
  /**
@@ -70,7 +68,6 @@ class ClickMonitor {
70
68
  * @param {} event
71
69
  */
72
70
  _onClickHandle(event) {
73
- const blockedCSS = getBlockedCSSForCurrentDomain();
74
71
  if (event) {
75
72
  const { _targetInst: target } = event;
76
73
  const targetClassName = target.elementType;
@@ -80,7 +77,7 @@ class ClickMonitor {
80
77
  // to process the image name, else we need to get the textual content
81
78
  // todo process images
82
79
 
83
- text = this._getTextualContentFromEl(target, false, blockedCSS);
80
+ text = this._getTextualContentFromEl(target);
84
81
 
85
82
  let textFromElement = this._trimText(text);
86
83
 
@@ -140,54 +137,11 @@ class ClickMonitor {
140
137
  }
141
138
  }
142
139
 
143
- /**
144
- * parseTextFromParentElement will parse the parents of an element to try
145
- * and find textual content if no text can be extracted from the clicked element
146
- * @param {} element
147
- * @param {Array.<String>} blockedCSS
148
- */
149
- _parseTextFromParentElement(element, blockedCSS) {
150
- let iteratableElement = element;
151
- const parentElements = [];
152
- let parentIterations = 0;
153
- while (iteratableElement) {
154
- if (
155
- parentIterations >= maxParentIteration ||
156
- !iteratableElement.parentNode
157
- ) {
158
- break;
159
- }
160
- iteratableElement = iteratableElement.parentNode;
161
- parentElements.push(iteratableElement);
162
- parentIterations += 1;
163
- }
164
-
165
- for (let i = 0; i < parentElements.length; i += 1) {
166
- const el = parentElements[i];
167
- // we only get the text content if the clicked element has a button parent
168
- if (el && el.tagName === 'BUTTON') {
169
- // we disable the linter because we use 1 level recursion.
170
- // eslint-disable-next-line no-use-before-define
171
- return this._getTextualContentFromEl(el, false, blockedCSS);
172
- }
173
- }
174
-
175
- return '';
176
- }
177
-
178
140
  /** Gets the textual content from an element, if any
179
141
  * @param {} element
180
- * @param {} parseParent
181
- * @param {Array.<String>} blockedCSS
182
142
  */
183
- _getTextualContentFromEl(element, parseParent, blockedCSS) {
184
- return this._parseInnerContent(
185
- element,
186
- '',
187
- 100,
188
- { value: 0, limit: 100 },
189
- blockedCSS,
190
- );
143
+ _getTextualContentFromEl(element) {
144
+ return this._parseInnerContent(element, '', 100, { value: 0, limit: 100 });
191
145
  }
192
146
 
193
147
  /** Parse and trim text
@@ -207,7 +161,7 @@ class ClickMonitor {
207
161
  if (index > 0) {
208
162
  parsedText = `${parsedText.substring(0, index)}...`;
209
163
  } else {
210
- // If the are no ' ' characters then the text is likely not valid so just
164
+ // If there are no ' ' characters then the text is likely not valid so just
211
165
  // return '...'.
212
166
  parsedText = '...';
213
167
  }
@@ -217,13 +171,12 @@ class ClickMonitor {
217
171
 
218
172
  /**
219
173
  * Recursively parses element's inner content and masks blocked css classes
220
- * @param {HTMLElement} element
174
+ * @param {NReactNative.Node} element
221
175
  * @param {String} text
222
176
  * @param {Number} textLimit
223
177
  * @param {Object} counter
224
- * @param {Array.<String>} blockedCSS
225
178
  */
226
- _parseInnerContent(element, text, textLimit, counter, blockedCSS) {
179
+ _parseInnerContent(element, text, textLimit, counter) {
227
180
  /* eslint-disable no-restricted-syntax */
228
181
  /* eslint-disable no-param-reassign */
229
182
 
@@ -237,7 +190,7 @@ class ClickMonitor {
237
190
 
238
191
  counter.value += 1;
239
192
 
240
- if (blockedCSS.includes(element.memoizedProps.testID)) {
193
+ if (getBlockedElements().includes(element.memoizedProps.testID)) {
241
194
  return `${text}${text ? ' ' : ''}*`;
242
195
  }
243
196
 
@@ -260,7 +213,7 @@ class ClickMonitor {
260
213
  /**
261
214
  * normalize value and append to the resulting text if not empty
262
215
  * @param {String} text
263
- * @param {Array.<String>} values
216
+ * @param {Array.<any>} values
264
217
  */
265
218
  _parseAndAppendText(text, values) {
266
219
  const goodValues = [];
@@ -50,7 +50,7 @@ function constructErrors(args) {
50
50
  const stacks = [];
51
51
  const messages = [];
52
52
  args.forEach(sm => {
53
- if (isStackTrace(sm)) {
53
+ if (isStackTrace()) {
54
54
  stacks.push(sm);
55
55
  const lines = sm.split('\n');
56
56
  if (isStackTrace(lines[0])) {
@@ -122,10 +122,12 @@ function configureEventListeners() {
122
122
  function monitorErrors() {
123
123
  // wrapping all listeners as soon as possible after we set the above listener
124
124
  configureEventListeners();
125
- global.ErrorUtils.setGlobalHandler((error) => {
125
+ const existingHandler = global.ErrorUtils.getGlobalHandler() || (() => { });
126
+ global.ErrorUtils.setGlobalHandler((error, ...rest) => {
126
127
  saveErrorToPagevisit(ERROR_EVENT_ERROR_TYPE, {
127
128
  error,
128
129
  });
130
+ return existingHandler(error, ...rest);
129
131
  });
130
132
  if (global.HermesInternal) {
131
133
  global.HermesInternal.enablePromiseRejectionTracker({
@@ -1,4 +1,4 @@
1
- import { CONTENT_TYPE, SEVERITY_ERROR } from '../constants.js';
1
+ import { CONTENT_TYPE, SEVERITY } from '../constants.js';
2
2
  import { isInstanceOf, getMaxSubstringAllowed } from '../utils/function.js';
3
3
  import ClientConfig from '../api/clientConfig.js';
4
4
 
@@ -285,7 +285,7 @@ class GqlErrorValidator {
285
285
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
286
286
  `GQL parse error: ${message}`,
287
287
  false,
288
- SEVERITY_ERROR,
288
+ SEVERITY.error,
289
289
  );
290
290
  }
291
291
 
@@ -298,7 +298,7 @@ class GqlErrorValidator {
298
298
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
299
299
  `GQL error validation warning: ${message}`,
300
300
  false,
301
- SEVERITY_ERROR,
301
+ SEVERITY.error,
302
302
  );
303
303
  }
304
304
  }
@@ -1,4 +1,4 @@
1
- import { HUMAN_READABLE_CONTENT_TYPE_REGEX, DEFAULT_WEBSITE_SUBDOMAIN_PATTERN, SEVERITY_WARN, HTTP_BODY_NULL_STRING, HTTP_DATA_REQ_HEADERS_ATT_NAME, HTTP_DATA_PAYLOAD_ATT_NAME, HTTP_DATA_RESP_HEADERS_ATT_NAME, HTTP_DATA_RESP_PAYLOAD_ATT_NAME, HTTP_BODY_DROPPED_LENGTH_MSG, HTTP_BODY_DROPPED_TYPE_MSG, MAX_HTTP_DATA_PAYLOAD_LENGTH, CONTENT_TYPE, CONTENT_LENGTH, BLOCKED_HTTP_HEADER_KEYS, PII_REDACTION_REPLACEMENT_STRING, HTTP_PII_BLOCKING_PATTERNS } from '../constants.js';
1
+ import { HUMAN_READABLE_CONTENT_TYPE_REGEX, DEFAULT_WEBSITE_SUBDOMAIN_PATTERN, SEVERITY, HTTP_BODY_NULL_STRING, HTTP_DATA_REQ_HEADERS_ATT_NAME, HTTP_DATA_PAYLOAD_ATT_NAME, HTTP_DATA_RESP_HEADERS_ATT_NAME, HTTP_DATA_RESP_PAYLOAD_ATT_NAME, HTTP_BODY_DROPPED_LENGTH_MSG, HTTP_BODY_DROPPED_TYPE_MSG, MAX_HTTP_DATA_PAYLOAD_LENGTH, CONTENT_TYPE, CONTENT_LENGTH, BLOCKED_HTTP_HEADER_KEYS, PII_REDACTION_REPLACEMENT_STRING, HTTP_PII_BLOCKING_PATTERNS } from '../constants.js';
2
2
  import { getProperGlobalUrl, checkHttpDataCollectionEnabled, getHttpPayloadAllowedURLs } from '../utils/function.js';
3
3
  import ClientConfig from '../api/clientConfig.js';
4
4
  import StoredMetrics from '../api/storedMetrics.js';
@@ -39,7 +39,7 @@ class HTTPDataBundler {
39
39
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
40
40
  `Unable to determine hostname for initial URL: ${e}`,
41
41
  false,
42
- SEVERITY_WARN,
42
+ SEVERITY.warn,
43
43
  );
44
44
  }
45
45
  }
@@ -50,11 +50,11 @@ class HTTPDataBundler {
50
50
  const allowedURLs = getHttpPayloadAllowedURLs();
51
51
  this.httpDataAllowedAbsoluteRegex = HTTPDataBundler.buildAllowedRegex(
52
52
  allowedURLs,
53
- true,
53
+ 'absolute',
54
54
  );
55
55
  this.httpDataAllowedRelativeRegex = HTTPDataBundler.buildAllowedRegex(
56
56
  allowedURLs,
57
- false,
57
+ 'relative',
58
58
  );
59
59
  // track unique requests and only capture each once
60
60
  // TODO: disabled for beta. NOI-4253
@@ -100,14 +100,14 @@ class HTTPDataBundler {
100
100
  /**
101
101
  * Builds the HTTP payload allowed regexes for full and relative URLs
102
102
  * @param allowedURLs A list of allowed URLs
103
- * @param absolute Use only absolute URLs if true, use only relative URL if false
103
+ * @param {'absolute' | 'relative'} strategy Use only absolute URLs if true, use only relative URL if false
104
104
  * @returns a regex of allowed URLs
105
105
  */
106
- static buildAllowedRegex(allowedURLs, absolute) {
106
+ static buildAllowedRegex(allowedURLs, strategy) {
107
107
  if (!allowedURLs) return null;
108
108
  const allowedURLsFiltered = allowedURLs.filter(url => {
109
109
  const isAbsolute = HTTPDataBundler.isAbsoluteURL(url);
110
- return absolute ? isAbsolute : !isAbsolute;
110
+ return strategy === 'absolute' ? isAbsolute : !isAbsolute;
111
111
  });
112
112
  if (allowedURLsFiltered.length > 0) {
113
113
  const lowerCasedURLs = allowedURLsFiltered.map(url =>
@@ -189,7 +189,7 @@ class HTTPDataBundler {
189
189
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
190
190
  `Unable to stringify JSON response: ${e}`,
191
191
  false,
192
- SEVERITY_WARN,
192
+ SEVERITY.warn,
193
193
  );
194
194
  return null;
195
195
  }
@@ -221,7 +221,7 @@ class HTTPDataBundler {
221
221
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
222
222
  `Unable to determine hostname for request URL: ${e}`,
223
223
  false,
224
- SEVERITY_WARN,
224
+ SEVERITY.warn,
225
225
  );
226
226
 
227
227
  return false;
@@ -568,7 +568,7 @@ ${HTTPDataBundler.getInstance().contentLength(headers)}`;
568
568
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
569
569
  `Unable to stringify request body: ${e}`,
570
570
  false,
571
- SEVERITY_WARN,
571
+ SEVERITY.warn,
572
572
  );
573
573
  }
574
574
  return null;
@@ -4,7 +4,7 @@ import { PageVisitEventHTTP, isHttpCodeFailure } from '../pageVisit/pageVisitEve
4
4
  import { propWriteableOrMadeWriteable, replace } from '../utils/object.js';
5
5
  import 'react-native-device-info';
6
6
  import 'react-native-localize';
7
- import { PV_SEQ_ATT_NAME, XML_HTTP_REQUEST_ERROR_TYPE, GQL_ERROR_TYPE, SEVERITY_ERROR, SEVERITY_WARN, RESPONSE_ERROR_TYPE, HTTP_METHOD_ATT_NAME, HTTP_RESP_CODE_ATT_NAME, URL_ATT_NAME, HTTP_RESP_TIME_ATT_NAME, HTTP_RESP_LENGTH_ATT_NAME, FETCH_EXCEPTION_ERROR_TYPE } from '../constants.js';
7
+ import { PV_SEQ_ATT_NAME, XML_HTTP_REQUEST_ERROR_TYPE, GQL_ERROR_TYPE, SEVERITY, RESPONSE_ERROR_TYPE, HTTP_METHOD_ATT_NAME, HTTP_RESP_CODE_ATT_NAME, URL_ATT_NAME, HTTP_RESP_TIME_ATT_NAME, HTTP_RESP_LENGTH_ATT_NAME, FETCH_EXCEPTION_ERROR_TYPE } from '../constants.js';
8
8
  import ClientConfig from '../api/clientConfig.js';
9
9
  import { addSafeEventListener } from '../utils/eventlistener.js';
10
10
  import { HTTPDataBundler } from './httpDataBundler.js';
@@ -180,7 +180,7 @@ async function _buildHttpEventDataObjectsForFetch(
180
180
  };
181
181
 
182
182
  let httpData = null;
183
- // Only get the bodies of the request and response on error and if the URL is one we care about.
183
+ // Only get the bodies of the request and response if the URL is one we care about.
184
184
  if (HTTPDataBundler.getInstance().shouldContinueForURL(url)) {
185
185
  // add response payload length, if any
186
186
  if (response && response.headers) {
@@ -307,7 +307,7 @@ function wrapXMLHTTPSend(proto) {
307
307
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
308
308
  `Error in XHR.send() wrapper: ${e}`,
309
309
  false,
310
- SEVERITY_ERROR,
310
+ SEVERITY.error,
311
311
  );
312
312
  }
313
313
  return originalFunction.call(this, data);
@@ -349,7 +349,7 @@ function wrapXMLHTTPOpen(proto, shouldHandleLoadend) {
349
349
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
350
350
  `Unable to set custom properties on XHR object: ${error}`,
351
351
  false,
352
- SEVERITY_WARN,
352
+ SEVERITY.warn,
353
353
  );
354
354
  }
355
355
 
@@ -398,7 +398,7 @@ function wrapXMLHTTPOpen(proto, shouldHandleLoadend) {
398
398
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
399
399
  `Error in XHR.open() wrapper: ${e}`,
400
400
  false,
401
- SEVERITY_ERROR,
401
+ SEVERITY.error,
402
402
  );
403
403
  }
404
404
  return originalFunction.call(this, method, url, async, user, password);
@@ -433,7 +433,7 @@ function wrapXMLHTTPSetRequestHeader(proto) {
433
433
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
434
434
  `Error in XHR.setRequestHeader() wrapper: ${error}`,
435
435
  false,
436
- SEVERITY_ERROR,
436
+ SEVERITY.error,
437
437
  );
438
438
  }
439
439
  return originalFunction.call(this, header, value);
@@ -536,7 +536,7 @@ function setupGlobalFetchWrapper() {
536
536
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
537
537
  `Error in fetch() wrapper: ${e}`,
538
538
  false,
539
- SEVERITY_ERROR,
539
+ SEVERITY.error,
540
540
  );
541
541
  }
542
542
 
@@ -611,7 +611,7 @@ function setupGlobalFetchWrapper() {
611
611
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
612
612
  `Error in custom fetch() callback: ${e}`,
613
613
  false,
614
- SEVERITY_ERROR,
614
+ SEVERITY.error,
615
615
  );
616
616
  }
617
617
  })
@@ -1,5 +1,5 @@
1
1
  import { isValidURL, getOnURL, getProperGlobalUrl, getJSStack, stringifyJSON, getMaxSubstringAllowed } from '../../utils/function.js';
2
- import { EVENT_ERROR_TYPE, URL_ATT_NAME, ERROR_EVENT_TYPE, ERROR_EVENT_ERROR_TYPE, CUSTOM_ERROR_EVENT_TYPE, ERROR_EVENT_UNHANDLED_REJECTION_TYPE, ERROR_LOG_EVENT_ERROR_TYPE, FETCH_EXCEPTION_ERROR_TYPE, WRAPPED_EXCEPTION_ERROR_TYPE, GQL_ERROR_TYPE, RESPONSE_ERROR_TYPE, XML_HTTP_REQUEST_ERROR_TYPE, ERROR_SOURCE_ATT_NAME, TYPE_ATT_NAME, JS_EVENT_TYPE, JS_ERROR_ATT_NAME, JS_STACK_FRAMES_ATT_NAME, JS_STACK_FILE_ATT_NAME, JS_STACK_METHOD_ATT_NAME, SEVERITY_ERROR, JS_STACK_MESSAGE_ATT_NAME, HTTP_EVENT_TYPE, NOIBU_INPUT_URLS, HTTP_CODE_ATT_NAME, PV_SEQ_ATT_NAME, GQL_EVENT_TYPE, GQL_ERROR_ATT_NAME } from '../../constants.js';
2
+ import { EVENT_ERROR_TYPE, URL_ATT_NAME, ERROR_EVENT_TYPE, ERROR_EVENT_ERROR_TYPE, CUSTOM_ERROR_EVENT_TYPE, ERROR_EVENT_UNHANDLED_REJECTION_TYPE, ERROR_LOG_EVENT_ERROR_TYPE, FETCH_EXCEPTION_ERROR_TYPE, WRAPPED_EXCEPTION_ERROR_TYPE, GQL_ERROR_TYPE, RESPONSE_ERROR_TYPE, XML_HTTP_REQUEST_ERROR_TYPE, ERROR_SOURCE_ATT_NAME, TYPE_ATT_NAME, JS_EVENT_TYPE, JS_ERROR_ATT_NAME, JS_STACK_FRAMES_ATT_NAME, JS_STACK_FILE_ATT_NAME, JS_STACK_METHOD_ATT_NAME, SEVERITY, JS_STACK_MESSAGE_ATT_NAME, HTTP_EVENT_TYPE, NOIBU_INPUT_URLS, HTTP_CODE_ATT_NAME, PV_SEQ_ATT_NAME, GQL_EVENT_TYPE, GQL_ERROR_ATT_NAME } from '../../constants.js';
3
3
  import blacklisedDomains from './blacklistedDomains.js';
4
4
  import ClientConfig from '../../api/clientConfig.js';
5
5
  import { InputMonitor } from '../../monitors/inputMonitor.js';
@@ -218,7 +218,7 @@ function isCollectError(pvError) {
218
218
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
219
219
  pvError,
220
220
  false,
221
- SEVERITY_ERROR,
221
+ SEVERITY.error,
222
222
  );
223
223
  return true;
224
224
  }
@@ -236,7 +236,7 @@ function isCollectError(pvError) {
236
236
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
237
237
  pvError,
238
238
  false,
239
- SEVERITY_ERROR,
239
+ SEVERITY.error,
240
240
  );
241
241
  return true;
242
242
  }
@@ -255,7 +255,7 @@ function isCollectError(pvError) {
255
255
  ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
256
256
  pvError,
257
257
  false,
258
- SEVERITY_ERROR,
258
+ SEVERITY.error,
259
259
  );
260
260
  return true;
261
261
  }
@@ -1,7 +1,8 @@
1
+ import { IStorage, StorageValue } from '../types/Storage';
1
2
  /**
2
3
  * Encapsulates storage api
3
4
  */
4
- export default class Storage implements Noibu.Storage {
5
+ export default class Storage implements IStorage {
5
6
  private readonly _isRNStorageAvailable;
6
7
  private readonly _rnStorageError;
7
8
  private static _instance;
@@ -21,7 +22,7 @@ export default class Storage implements Noibu.Storage {
21
22
  /** Loads value from storage */
22
23
  load<R = unknown>(key: string): Promise<R | null>;
23
24
  /** Saves value to storage */
24
- save(key: string, value: Noibu.StorageValue): Promise<void>;
25
+ save(key: string, value: StorageValue): Promise<void>;
25
26
  /**
26
27
  * Removes value from storage
27
28
  * @param {String} key
@@ -1,21 +1,22 @@
1
+ import { Provider, StorageValue } from '../types/Storage';
1
2
  /**
2
3
  * Base implementation for LocalStorage and SessionStorage
3
4
  */
4
5
  export default abstract class StorageProvider {
5
- _provider: Noibu.Provider;
6
+ _provider: Provider;
6
7
  /** Creates new instance based on provided provider type */
7
- constructor(provider: Noibu.Provider);
8
+ constructor(provider: Provider);
8
9
  /** Checks if provider is available */
9
- static isAvailable(resolver: () => Noibu.Provider): Promise<{
10
+ static isAvailable(resolver: () => Provider): Promise<{
10
11
  result: boolean;
11
12
  error: unknown;
12
13
  }>;
13
14
  /**
14
15
  * Loads value from storage
15
16
  */
16
- load<R = Noibu.StorageValue>(key: string): Promise<R | null>;
17
+ load<R = StorageValue>(key: string): Promise<R | null>;
17
18
  /** Saves value to storage */
18
- save(key: string, value: Noibu.StorageValue): Promise<void>;
19
+ save(key: string, value: StorageValue): Promise<void>;
19
20
  /**
20
21
  * Removes value from storage
21
22
  * @param {String} key
@@ -0,0 +1,27 @@
1
+ export interface Config {
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
+ }
15
+ export interface StoredConfig {
16
+ BrowserId: string;
17
+ LastActive?: Date;
18
+ pvId?: string;
19
+ CurrentPageVisitCount: number;
20
+ ClientUnlockTime?: Date;
21
+ DisabledStatus: boolean;
22
+ }
23
+ export type UrlConfig = {
24
+ metroplexSocketBase: string;
25
+ metroplexHTTPBase: string;
26
+ domain: string;
27
+ };
@@ -0,0 +1,22 @@
1
+ export type Event = {
2
+ type: string;
3
+ };
4
+ export type EventPayload = Partial<{
5
+ txt: string;
6
+ src: string;
7
+ hid: string;
8
+ tag: string;
9
+ type: string;
10
+ class: string;
11
+ pvp: string;
12
+ }>;
13
+ export interface JError {
14
+ frames: JStackFrame[];
15
+ msg: string;
16
+ }
17
+ export interface JStackFrame {
18
+ column?: number;
19
+ line: string;
20
+ mname: string;
21
+ file: string;
22
+ }
@@ -0,0 +1,3 @@
1
+ export interface Node {
2
+ memoizedProps: any;
3
+ }
@@ -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 {};
@@ -1,5 +1,5 @@
1
1
  import ClientConfig from '../api/clientConfig.js';
2
- import { SEVERITY_ERROR } from '../constants.js';
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
- SEVERITY_ERROR,
54
+ SEVERITY.error,
55
55
  true,
56
56
  );
57
57
  }
@@ -1,4 +1,4 @@
1
- import { SEVERITY_ERROR } from '../constants.js';
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
- SEVERITY_ERROR,
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
- SEVERITY_ERROR,
62
+ SEVERITY.error,
63
63
  );
64
64
  }
65
65
  }
@@ -0,0 +1,100 @@
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
+ *
12
+ * todo implement navigation
13
+ * getProperGlobalUrl gets the proper global url from the window
14
+ * @returns {string}
15
+ */
16
+ export declare function getProperGlobalUrl(): string;
17
+ /**
18
+ * Processes the raw stack frames and creates a readable stack in a safe manner
19
+ * @param {StackFrame[]} rawFrames
20
+ */
21
+ export declare function processFrames(rawFrames: RawStackFrame[]): JStackFrame[];
22
+ /**
23
+ * Retrieves the javascript stack and message from an error event object
24
+ * @param errObj error to extract stack from
25
+ */
26
+ export declare function getJSStack(errObj: {
27
+ stack: string;
28
+ message: string;
29
+ }): JError;
30
+ /**
31
+ * Checks if possiblyStacktrace has any stack frames present
32
+ */
33
+ export declare function isStackTrace(possiblyStacktrace: string): boolean;
34
+ /**
35
+ * counts the number of bytes
36
+ */
37
+ export declare function byteCount(s: string): number;
38
+ /**
39
+ * Stringify function that is aware of inner circular references and handles them by replacing with {} (empty object)
40
+ * taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value
41
+ */
42
+ export declare function stringifyJSON(jsonObject: unknown): string;
43
+ /**
44
+ * Wrapper for a request, since we have to do some special handling
45
+ * @param method
46
+ * @param url
47
+ * @param data
48
+ * @param headers
49
+ * @param timeout
50
+ * @param sendAndForget
51
+ */
52
+ export declare function makeRequest(method: string, url: string, data: unknown, headers: Record<string, string>, timeout: number, sendAndForget: boolean): Promise<unknown>;
53
+ /** checks if http data collection is enabled */
54
+ export declare function checkHttpDataCollectionEnabled(): boolean;
55
+ /** gets http data payload allowed URLs */
56
+ export declare function getHttpPayloadAllowedURLs(): string[];
57
+ /**
58
+ * Gets selectors to prevent those elements from being recorded
59
+ */
60
+ export declare function getBlockedElements(): string[];
61
+ /**
62
+ * makes sure the url sent is a valid URL
63
+ */
64
+ export declare function isValidURL(str: string): boolean;
65
+ /**
66
+ * Because of the nature of user agent in react native, we have to make this async.
67
+ * But I promise, this is really fast, since we memoize the result for the whole session :)
68
+ * @returns {Promise<string>}
69
+ */
70
+ export declare function getUserAgent(): Promise<string>;
71
+ /**
72
+ * isInvalidURLConfig will verify that Collect is being initializes with
73
+ * the correct env vars.
74
+ */
75
+ export declare function isInvalidURLConfig(urls: Record<(typeof REQUIRED_DATA_PROCESSING_URLS)[number], string>): boolean;
76
+ /**
77
+ * isNoibuJSAlreadyLoaded will verify if there are already other
78
+ * copies of NoibuJS runnung
79
+ */
80
+ export declare function isNoibuJSAlreadyLoaded(): boolean;
81
+ /**
82
+ * asString will create a string out of anything passed to it.
83
+ */
84
+ export declare function asString(obj: unknown): string;
85
+ /**
86
+ * masks textual content if it ressembles something sensitive
87
+ */
88
+ export declare function maskTextInput(text: string): string;
89
+ /**
90
+ * gets the onURL of a string, defaulting to the location of the webpage
91
+ */
92
+ export declare function getOnURL(realOnURL: string): string;
93
+ /** gets the user language from the browser */
94
+ export declare function getUserLanguage(): string | null;
95
+ /**
96
+ * Checks if the provided object is an instance of the specified type.
97
+ * It's safer than `instanceof` operator as it handles cases
98
+ * where type is not actually a type but an object.
99
+ */
100
+ export declare function isInstanceOf(instance: unknown, type: unknown): boolean;