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.
package/README.md CHANGED
@@ -27,6 +27,11 @@ Install using favourite node package manager (npm, yarn, etc.):
27
27
  npm install noibu-react-native --save
28
28
  ```
29
29
 
30
+ Additionally, for iOS target do:
31
+ ```bash
32
+ npx pod-install
33
+ ```
34
+
30
35
  ## Usage
31
36
 
32
37
  Call a setup method and wrap your root App component into SDK ErrorBoundary:
@@ -36,7 +41,7 @@ import React from 'react';
36
41
  import { View, Text } from 'react-native';
37
42
  import { ErrorBoundary, setupNoibu } from 'noibu-react-native';
38
43
 
39
- setupNoibu({ domain: 'react-native-app.myshop.com' })
44
+ setupNoibu({ domain: 'react-native-app.myshop.com' });
40
45
 
41
46
  export default function App() {
42
47
  return (
@@ -59,6 +64,26 @@ That's it! First time the module is set up, it runs an init and starts listening
59
64
 
60
65
  ## Configuration
61
66
 
67
+ `setupNoibu(config): void` method accepts following parameters:
68
+ - `config` which consists of
69
+ - `@property domain {string}` - indicates which Noibu dashboard session recordings should go to ([learn more about domains](https://help.noibu.com/hc/en-us/articles/4846518088845-Domains-Overview))
70
+ - `@property [blockedElements] {string[]}` - lets you specify component ids to be ignored by SDK when collecting error information
71
+ - `@property [enableHttpDataCollection] {boolean}` - indicates whether SDK should collect HTTP information like headers or body from requests
72
+ - `@property [listOfUrlsToCollectHttpDataFrom] {string[]}` - is an allow list of URLs to allow HTTP data collection from, works best with `enableHttpDataCollection` enabled
73
+
74
+ Example:
75
+ ```js
76
+ setupNoibu({
77
+ domain: 'react-native-app.myshop.com',
78
+ enableHttpDataCollection: true,
79
+ listOfUrlsToCollectHttpDataFrom: [
80
+ 'https://react-native-app.myshop.com/backend',
81
+ 'https://example.com/some-path/',
82
+ ],
83
+ blockedElements: ['sensitive-info']
84
+ });
85
+ ```
86
+
62
87
  ErrorBoundary component has a few useful properties described here https://help.noibu.com/hc/en-us/articles/9562254753677-Noibu-React-SDK under the section _ErrorBoundary Class -> Props_.
63
88
 
64
89
  ## API Reference
@@ -67,7 +92,7 @@ Apart from exporting ErrorBoundary component, noibu-react-native module has Noib
67
92
 
68
93
  ### `NoibuJS`
69
94
 
70
- #### `requestHelpCode(alert?: boolean): Promise<string>`
95
+ #### `requestHelpCode(): Promise<string>`
71
96
 
72
97
  Requests a help code from the HelpCode instance. To read more about help codes, refer to the page: https://help.noibu.com/hc/en-us/articles/14051818012813-How-to-Find-a-Session-with-Help-Code
73
98
 
@@ -139,11 +164,6 @@ import { NoibuJS } from 'noibu-react-native';
139
164
  NoibuJS.addJsSdkError(new Error('My Error'), 'myModule.js');
140
165
  ```
141
166
 
142
- ## Publishing
143
-
144
- Ci has a job to publish a new version of the SDK, but has to be manually triggered.
145
- Docker image used for publishing is noibujssdkci:0.2
146
-
147
167
  ## Contributing
148
168
 
149
169
  You can contribute by checking out the project page and open issues. https://linear.app/noibu/project/react-native-sdk-5ccd19a3343a
@@ -0,0 +1,101 @@
1
+ import { SEVERITY } from '../constants';
2
+ import { CustomerConfig, StoredConfig } from '../types/Config';
3
+ /**
4
+ * Singleton class to manage the client configuration
5
+ * this class will be responsible for controlling the disabled
6
+ * status of the client script as well as managing all storage
7
+ * storing and retrieval.
8
+ */
9
+ export default class ClientConfig {
10
+ private readonly pageVisitId;
11
+ private browserId;
12
+ private pageVisitSeq;
13
+ private lastActiveTime;
14
+ private noibuErrorURL;
15
+ private cltErrorPostCounter;
16
+ private readonly maxSocketInactiveTime;
17
+ private static instance;
18
+ private static noibuErrorURL;
19
+ customerDomain: string;
20
+ isClientDisabled: boolean;
21
+ readonly listOfUrlsToCollectHttpDataFrom: CustomerConfig['listOfUrlsToCollectHttpDataFrom'];
22
+ readonly enableHttpDataCollection: CustomerConfig['enableHttpDataCollection'];
23
+ readonly blockedElements: CustomerConfig['blockedElements'];
24
+ /**
25
+ * Creates a ClientConfig singleton instance
26
+ */
27
+ constructor(noibuErrorURL: string, customerConfig: CustomerConfig);
28
+ /** Configures the singleton instance */
29
+ static configureInstance({ noibuErrorURL, customerConfig, }: {
30
+ noibuErrorURL: string;
31
+ customerConfig: CustomerConfig;
32
+ }): void;
33
+ /**
34
+ * gets the singleton instance
35
+ * @returns {ClientConfig}
36
+ */
37
+ static getInstance(): ClientConfig;
38
+ /** lockClient will disable the client script for a single pagevisit for
39
+ * duration given in minuntes */
40
+ lockClient(duration: number, msg: string): Promise<void>;
41
+ /** Locks the client until the next page loads */
42
+ lockClientUntilNextPage(msg: string): void;
43
+ /** Updates the config object to store the given last active time */
44
+ updateLastActiveTime(lastActiveTime: Date): Promise<void>;
45
+ /** Gets the current page visit sequence number that should be used */
46
+ getPageVisitSeq(): Promise<number | null>;
47
+ /**
48
+ * Returns the client config object from storage or generates a new one
49
+ * What is stored in storage will look like this
50
+ * {
51
+ * BrowserId: UUIDV4
52
+ * ExpiryTime: DATE OBJ
53
+ * DisabledStatus: BOOL
54
+ * CurrentPageVisitCount: INT
55
+ * ClientUnlockTime: DATE OBJ
56
+ * LastActiveTime: DATE OBJ
57
+ * }
58
+ */
59
+ _getLsObject(): Promise<StoredConfig>;
60
+ /**
61
+ * Check if we have surpassed the last active time and the page visit seq number needs resetting
62
+ */
63
+ _pageVisitSeqNeedsReset(): Promise<boolean>;
64
+ /**
65
+ * _setupStorageVars will set all class variables that depend
66
+ * on the storage's value.
67
+ */
68
+ _setupStorageVars(): Promise<void>;
69
+ /**
70
+ * Function will get the Noibu Storage Object
71
+ * 1. Generate a brand new one
72
+ * Get it from storage if the expiry date is not in the past
73
+ * Generate a brand new one if the expiry date is in the past
74
+ */
75
+ _getClientState(): Promise<StoredConfig>;
76
+ /**
77
+ * _generateAndStoreData generates brand new data and then proceeds to store
78
+ * it.
79
+ */
80
+ _generateAndStoreData(): Promise<StoredConfig>;
81
+ /**
82
+ * _generateNewBrowserData will create new data to be stored in storage
83
+ * and persisted throughout a session
84
+ */
85
+ _generateNewBrowserData(): StoredConfig;
86
+ /**
87
+ * _storeBrowserData will store the passed object in storage.
88
+ * @param {} data the data to be stored
89
+ */
90
+ _storeBrowserData(data: StoredConfig): Promise<StoredConfig>;
91
+ /**
92
+ * postNoibuErrorAndOptionallyDisableClient will post errors that were thrown by collect
93
+ * and disable the client if required
94
+ * severity expects one of the SEVERITY_x level constants, or else error will be used
95
+ */
96
+ postNoibuErrorAndOptionallyDisableClient(errorMsg: string, disableClient: boolean, severity: (typeof SEVERITY)[keyof typeof SEVERITY], keepAlive?: boolean): Promise<void>;
97
+ /**
98
+ * Returns true if the page visit is considered to be inactive
99
+ */
100
+ isInactive(): boolean;
101
+ }