noibu-react-native 0.2.7 → 0.2.9

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