noibu-react-native 0.2.4 → 0.2.5
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/dist/api/clientConfig.js +20 -27
- package/dist/api/helpCode.js +1 -1
- package/dist/api/metroplexSocket.js +1 -1
- package/dist/api/storedPageVisit.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/entry/init.js +2 -4
- package/dist/monitors/AppNavigationMonitor.js +1 -1
- package/dist/{types/Monitor.js → monitors/BaseMonitor.js} +5 -1
- package/dist/monitors/ClickMonitor.js +1 -1
- package/dist/monitors/ErrorMonitor.js +1 -1
- package/dist/monitors/KeyboardInputMonitor.js +1 -1
- package/dist/monitors/PageMonitor.js +1 -1
- package/dist/monitors/RequestMonitor.js +1 -1
- package/dist/monitors/http-tools/HTTPDataBundler.js +1 -1
- package/dist/pageVisit/EventDebouncer.js +1 -1
- package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +22 -5
- package/dist/sessionRecorder/sessionRecorder.js +4 -1
- package/dist/src/api/clientConfig.d.ts +7 -12
- package/dist/src/api/clientConfig.test.d.ts +1 -0
- package/dist/src/api/helpCode.d.ts +1 -1
- package/dist/src/api/metroplexSocket.d.ts +1 -1
- package/dist/src/api/storedPageVisit.d.ts +1 -1
- package/dist/src/monitors/AppNavigationMonitor.d.ts +1 -1
- package/dist/{types/Monitor.d.ts → src/monitors/BaseMonitor.d.ts} +3 -1
- package/dist/src/monitors/BaseMonitor.test.d.ts +1 -0
- package/dist/src/monitors/ClickMonitor.d.ts +1 -1
- package/dist/src/monitors/ErrorMonitor.d.ts +1 -1
- package/dist/src/monitors/KeyboardInputMonitor.d.ts +1 -1
- package/dist/src/monitors/PageMonitor.d.ts +1 -1
- package/dist/src/monitors/RequestMonitor.d.ts +1 -1
- package/dist/src/monitors/http-tools/HTTPDataBundler.d.ts +1 -1
- package/dist/src/pageVisit/EventDebouncer.d.ts +1 -1
- package/dist/src/sessionRecorder/nativeSessionRecorderSubscription.d.ts +15 -0
- package/package.json +8 -5
package/dist/api/clientConfig.js
CHANGED
|
@@ -5,6 +5,7 @@ import { stringifyJSON, getMaxSubstringAllowed, getUserAgent, makeRequest } from
|
|
|
5
5
|
import Storage from '../storage/storage.js';
|
|
6
6
|
import { noibuLog } from '../utils/log.js';
|
|
7
7
|
import { unwrapNoibuWrapped } from '../utils/object.js';
|
|
8
|
+
import { Singleton } from '../monitors/BaseMonitor.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Singleton class to manage the client configuration
|
|
@@ -12,54 +13,46 @@ import { unwrapNoibuWrapped } from '../utils/object.js';
|
|
|
12
13
|
* status of the client script as well as managing all storage
|
|
13
14
|
* storing and retrieval.
|
|
14
15
|
*/
|
|
15
|
-
class ClientConfig {
|
|
16
|
+
class ClientConfig extends Singleton {
|
|
16
17
|
/**
|
|
17
18
|
* Creates a ClientConfig singleton instance
|
|
18
19
|
*/
|
|
19
20
|
constructor(noibuErrorURL, customerConfig) {
|
|
20
|
-
|
|
21
|
-
// sets up this.browserId, this.disabledStatus
|
|
21
|
+
super();
|
|
22
22
|
this.pageVisitId = uuid.v4();
|
|
23
|
-
// variables stored in storage
|
|
24
|
-
this.isClientDisabled = false;
|
|
25
23
|
this.browserId = '';
|
|
26
24
|
this.pageVisitSeq = null;
|
|
27
25
|
// This variable tracks the last time the user was active in this session.
|
|
28
26
|
// It is also written to storage. Initialized to now so the session can be
|
|
29
27
|
// timed out even if a PV is never sent.
|
|
30
28
|
this.lastActiveTime = new Date();
|
|
31
|
-
// error URL to send Noibu errors to
|
|
32
|
-
this.noibuErrorURL = noibuErrorURL;
|
|
33
29
|
// error sent to backend counter
|
|
34
30
|
this.cltErrorPostCounter = 0;
|
|
35
31
|
// variables for checking if the socket is inactive
|
|
36
32
|
// used a class variables in order to be changed in testing
|
|
37
33
|
this.maxSocketInactiveTime = MAX_METROPLEX_SOCKET_INNACTIVE_TIME;
|
|
34
|
+
this.locationBreadcrumbs = [];
|
|
35
|
+
this.isClientDisabled = false;
|
|
36
|
+
this.noibuErrorURL = noibuErrorURL;
|
|
38
37
|
this.customerDomain = customerConfig.domain;
|
|
39
38
|
this.listOfUrlsToCollectHttpDataFrom =
|
|
40
39
|
customerConfig.listOfUrlsToCollectHttpDataFrom;
|
|
41
40
|
this.enableHttpDataCollection = customerConfig.enableHttpDataCollection;
|
|
42
41
|
this.blockedElements = customerConfig.blockedElements;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
yield this.instance._setupStorageVars();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
42
|
+
if (!noibuErrorURL || !this.hasAllNecessaryArgs()) {
|
|
43
|
+
const reason = Object.assign({ msg: 'ClientConfig was not properly configured' }, customerConfig);
|
|
44
|
+
void this.postNoibuErrorAndOptionallyDisableClient(reason, true, SEVERITY.error);
|
|
45
|
+
this.configurationPromise = Promise.reject(reason);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// sets up this.browserId, this.isClientDisabled, this.pageVisitSeq
|
|
49
|
+
this.configurationPromise = this._setupStorageVars();
|
|
54
50
|
}
|
|
55
51
|
/**
|
|
56
|
-
*
|
|
52
|
+
* Convenience method to check correct setup
|
|
57
53
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
throw new Error('ClientConfig was not configured');
|
|
61
|
-
}
|
|
62
|
-
return this.instance;
|
|
54
|
+
hasAllNecessaryArgs() {
|
|
55
|
+
return (!!this.customerDomain && this.globalUrl.includes(this.customerDomain));
|
|
63
56
|
}
|
|
64
57
|
/** lockClient will disable the client script for a single pagevisit for
|
|
65
58
|
* duration given in minuntes */
|
|
@@ -285,7 +278,7 @@ class ClientConfig {
|
|
|
285
278
|
/** gets current global url */
|
|
286
279
|
get globalUrl() {
|
|
287
280
|
const globalUrl = new URL('https://localhost');
|
|
288
|
-
globalUrl.hostname =
|
|
281
|
+
globalUrl.hostname = this.customerDomain;
|
|
289
282
|
if (this.locationBreadcrumbs.length) {
|
|
290
283
|
globalUrl.pathname = this.locationBreadcrumbs.join('/');
|
|
291
284
|
}
|
|
@@ -296,8 +289,8 @@ class ClientConfig {
|
|
|
296
289
|
* and disable the client if required
|
|
297
290
|
* severity expects one of the SEVERITY_x level constants, or else error will be used
|
|
298
291
|
*/
|
|
299
|
-
postNoibuErrorAndOptionallyDisableClient(errorMsg_1
|
|
300
|
-
return __awaiter(this, arguments, void 0, function* (errorMsg, disableClient, severity, keepAlive = false) {
|
|
292
|
+
postNoibuErrorAndOptionallyDisableClient(errorMsg_1) {
|
|
293
|
+
return __awaiter(this, arguments, void 0, function* (errorMsg, disableClient = false, severity = SEVERITY.error, keepAlive = false) {
|
|
301
294
|
noibuLog('postNoibuErrorAndOptionallyDisableClient', {
|
|
302
295
|
errorMsg,
|
|
303
296
|
disableClient,
|
package/dist/api/helpCode.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __awaiter } from 'tslib';
|
|
|
2
2
|
import MetroplexSocket from './metroplexSocket.js';
|
|
3
3
|
import { SEVERITY } from '../constants.js';
|
|
4
4
|
import ClientConfig from './clientConfig.js';
|
|
5
|
-
import { Singleton } from '../
|
|
5
|
+
import { Singleton } from '../monitors/BaseMonitor.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* HelpCode class is responsible for help code feature related functionality
|
|
@@ -10,7 +10,7 @@ import { safePerformanceNow } from '../utils/performance.js';
|
|
|
10
10
|
import { isDateOverwritten } from '../utils/date.js';
|
|
11
11
|
import { unwrapNoibuWrapped } from '../utils/object.js';
|
|
12
12
|
import { noibuLog } from '../utils/log.js';
|
|
13
|
-
import { Singleton } from '../
|
|
13
|
+
import { Singleton } from '../monitors/BaseMonitor.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Implements rolling window of specified size,
|
|
@@ -3,7 +3,7 @@ import { PV_METROPLEX_TYPE, PAGE_VISIT_PART_ATT_NAME, PV_EVENTS_ATT_NAME, TYPE_A
|
|
|
3
3
|
import ClientConfig from './clientConfig.js';
|
|
4
4
|
import { stringifyJSON, makeRequest } from '../utils/function.js';
|
|
5
5
|
import Storage from '../storage/storage.js';
|
|
6
|
-
import { Singleton } from '../
|
|
6
|
+
import { Singleton } from '../monitors/BaseMonitor.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This class holds the final page visit. It flushes it to storage and then
|
package/dist/constants.js
CHANGED
|
@@ -321,7 +321,7 @@ const CONTENT_LENGTH = 'content-length';
|
|
|
321
321
|
* Gets the script id from the cookie object, returns default if cannot be found
|
|
322
322
|
*/
|
|
323
323
|
function GET_SCRIPT_ID() {
|
|
324
|
-
return "1.0.104-rn-sdk-0.2.
|
|
324
|
+
return "1.0.104-rn-sdk-0.2.5" ;
|
|
325
325
|
}
|
|
326
326
|
/**
|
|
327
327
|
*
|
package/dist/entry/init.js
CHANGED
|
@@ -41,10 +41,8 @@ function globalInit(customerConfig) {
|
|
|
41
41
|
const noibuErrorURL = `${urlConfig.metroplexHTTPBase}/${METROPLEX_ERROR_ROUTE}`;
|
|
42
42
|
// catch any errors that happened during initialization and send collect error
|
|
43
43
|
try {
|
|
44
|
-
yield ClientConfig.
|
|
45
|
-
|
|
46
|
-
customerConfig,
|
|
47
|
-
});
|
|
44
|
+
yield ClientConfig.getInstance(noibuErrorURL, customerConfig)
|
|
45
|
+
.configurationPromise;
|
|
48
46
|
// create an instance ID for this script
|
|
49
47
|
const instanceId = uuid.v4();
|
|
50
48
|
// verifying if collect was disabled by other microservices
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SEVERITY, APP_NAVIGATION_EVENT_TYPE } from '../constants.js';
|
|
2
2
|
import { ReactNativeNavigationIntegration } from './integrations/react-native-navigation-integration.js';
|
|
3
3
|
import ClientConfig from '../api/clientConfig.js';
|
|
4
|
-
import { Singleton } from '../types/Monitor.js';
|
|
5
4
|
import { EventDebouncer } from '../pageVisit/EventDebouncer.js';
|
|
5
|
+
import { Singleton } from './BaseMonitor.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Attaches corresponding listener to the passed navigation integration
|
|
@@ -9,10 +9,14 @@ class Singleton {
|
|
|
9
9
|
// Use 'this' to reference the current class constructor
|
|
10
10
|
if (!Singleton.instances.has(this)) {
|
|
11
11
|
noibuLog('Creating new Singleton instance:', this.name);
|
|
12
|
-
Singleton.instances.set(this, new this(...args));
|
|
12
|
+
Singleton.instances.set(this, new this(...(args !== null && args !== void 0 ? args : [])));
|
|
13
13
|
}
|
|
14
14
|
return Singleton.instances.get(this);
|
|
15
15
|
}
|
|
16
|
+
/** used for testing only */
|
|
17
|
+
resetInstances() {
|
|
18
|
+
Singleton.instances.clear();
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
Singleton.instances = new Map();
|
|
18
22
|
|
|
@@ -7,7 +7,7 @@ import { WHITELIST_TEXT_REGEX_STRING } from '../const_matchers.js';
|
|
|
7
7
|
import { maskTextInput } from '../utils/function.js';
|
|
8
8
|
import { timestampWrapper } from '../utils/date.js';
|
|
9
9
|
import ClientConfig from '../api/clientConfig.js';
|
|
10
|
-
import { Singleton } from '
|
|
10
|
+
import { Singleton } from './BaseMonitor.js';
|
|
11
11
|
|
|
12
12
|
/** @module ClickMonitor */
|
|
13
13
|
/** Monitors the clicks which we capture and later process */
|
|
@@ -2,7 +2,7 @@ import { asString, isStackTrace } from '../utils/function.js';
|
|
|
2
2
|
import { ERROR_EVENT_ERROR_TYPE, STACK_TRACE_SANITIZE_REGEXP, ERROR_EVENT_UNHANDLED_REJECTION_TYPE, CONSOLE_FUNCTION_OVERRIDES, ERROR_LOG_EVENT_ERROR_TYPE } from '../constants.js';
|
|
3
3
|
import { saveErrorToPagevisit } from '../pageVisit/pageVisitEventError.js';
|
|
4
4
|
import { replace } from '../utils/object.js';
|
|
5
|
-
import { Singleton } from '
|
|
5
|
+
import { Singleton } from './BaseMonitor.js';
|
|
6
6
|
|
|
7
7
|
/* eslint-disable @typescript-eslint/ban-types,prefer-arrow-callback */
|
|
8
8
|
/** @module ErrorMonitor */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { updatePayload } from '../pageVisit/userStep.js';
|
|
2
2
|
import { SOURCE_ATT_NAME, TEXT_ATT_NAME, TAGNAME_ATT_NAME, TYPE_ATT_NAME, KEYBOARD_EVENT_TYPE } from '../constants.js';
|
|
3
3
|
import { EventDebouncer } from '../pageVisit/EventDebouncer.js';
|
|
4
|
-
import { Singleton } from '../types/Monitor.js';
|
|
5
4
|
import { TextInput } from 'react-native';
|
|
5
|
+
import { Singleton } from './BaseMonitor.js';
|
|
6
6
|
|
|
7
7
|
/** @module KeyboardInputMonitor */
|
|
8
8
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PAGE_EVENTS_WINDOW, PAGE_EVENTS_DOCUMENT, PAGE_EVENT_TYPE } from '../constants.js';
|
|
2
2
|
import { addSafeEventListener } from '../utils/eventlistener.js';
|
|
3
3
|
import { EventDebouncer } from '../pageVisit/EventDebouncer.js';
|
|
4
|
-
import { Singleton } from '
|
|
4
|
+
import { Singleton } from './BaseMonitor.js';
|
|
5
5
|
|
|
6
6
|
/** @module PageMonitor */
|
|
7
7
|
/** Monitors the page events which we capture and later process */
|
|
@@ -11,7 +11,7 @@ import { promiseAll } from '../utils/polyfills.js';
|
|
|
11
11
|
import { addSafeEventListener } from '../utils/eventlistener.js';
|
|
12
12
|
import { HTTPDataBundler } from './http-tools/HTTPDataBundler.js';
|
|
13
13
|
import GqlErrorValidator from './http-tools/GqlErrorValidator.js';
|
|
14
|
-
import { Singleton } from '
|
|
14
|
+
import { Singleton } from './BaseMonitor.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Monitors all requests
|
|
@@ -5,7 +5,7 @@ import StoredMetrics from '../../api/storedMetrics.js';
|
|
|
5
5
|
import { safeFromEntries, safeEntries } from '../../utils/object.js';
|
|
6
6
|
import { safeTrim, stringifyJSON, isString } from '../../utils/function.js';
|
|
7
7
|
import { removePII } from '../../utils/piiRedactor.js';
|
|
8
|
-
import { Singleton } from '
|
|
8
|
+
import { Singleton } from '../BaseMonitor.js';
|
|
9
9
|
|
|
10
10
|
/** Bundles HTTP payloads and headers */
|
|
11
11
|
class HTTPDataBundler extends Singleton {
|
|
@@ -3,7 +3,7 @@ import { APP_NAVIGATION_EVENT_TYPE, PAGE_EVENT_TYPE, MAX_TIME_FOR_UNSENT_DATA_MI
|
|
|
3
3
|
import { timestampWrapper } from '../utils/date.js';
|
|
4
4
|
import { addSafeEventListener } from '../utils/eventlistener.js';
|
|
5
5
|
import ClientConfig from '../api/clientConfig.js';
|
|
6
|
-
import { Singleton } from '../
|
|
6
|
+
import { Singleton } from '../monitors/BaseMonitor.js';
|
|
7
7
|
|
|
8
8
|
/** @module EventDebouncer */
|
|
9
9
|
/**
|
|
@@ -46,13 +46,30 @@ function initialize(projectId, config) {
|
|
|
46
46
|
const refinedMaximumDailyNetworkUsageInMB = maximumDailyNetworkUsageInMB !== null && maximumDailyNetworkUsageInMB !== void 0 ? maximumDailyNetworkUsageInMB : 0;
|
|
47
47
|
NativeSessionRecorder.initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains, disableOnLowEndDevices, enableDailyNetworkUsageLimit, refinedMaximumDailyNetworkUsageInMB);
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Subscribes to a native event emitted by the Noibu Session Recorder.
|
|
51
|
+
*
|
|
52
|
+
* This function listens for the `noibuRecordingEvent` emitted from the native layer (only on Android)
|
|
53
|
+
* and invokes the provided callback whenever the event occurs. If the platform is not Android,
|
|
54
|
+
* the function will do nothing and return a no-op unsubscribe function.
|
|
55
|
+
*
|
|
56
|
+
* @param {function(RecorderEvent): void} callback - A callback function that will be invoked with
|
|
57
|
+
* the event data whenever the `noibuRecordingEvent` is emitted.
|
|
58
|
+
*
|
|
59
|
+
* @returns {UnsubscribeFn} A function to unsubscribe from the event. On Android, this will remove
|
|
60
|
+
* the event listener. On other platforms, it will be a no-op.
|
|
61
|
+
*
|
|
62
|
+
* @throws {Error} If the Noibu Session Recorder is not initialized before calling this function.
|
|
63
|
+
*/
|
|
49
64
|
function subscribeToNativeEvent(callback) {
|
|
50
|
-
if (
|
|
51
|
-
|
|
65
|
+
if (Platform.OS === 'android') {
|
|
66
|
+
if (!nativeModuleEmitter) {
|
|
67
|
+
throw new Error('You have to initialize Noibu Session Recorder first');
|
|
68
|
+
}
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
70
|
+
nativeModuleEmitter.addListener('noibuRecordingEvent', callback);
|
|
71
|
+
// return () => subscription.remove();
|
|
52
72
|
}
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
54
|
-
nativeModuleEmitter.addListener('noibuRecordingEvent', callback);
|
|
55
|
-
// return () => subscription.remove();
|
|
56
73
|
return () => { };
|
|
57
74
|
}
|
|
58
75
|
|
|
@@ -8,6 +8,7 @@ import { MAX_TIME_FOR_RECORDER_USER_EVENTS, SEVERITY, MAX_RECORDER_EVENT_BUFFER,
|
|
|
8
8
|
import MetroplexSocket from '../api/metroplexSocket.js';
|
|
9
9
|
import { addSafeEventListener } from '../utils/eventlistener.js';
|
|
10
10
|
import { noibuLog } from '../utils/log.js';
|
|
11
|
+
import { Platform } from 'react-native';
|
|
11
12
|
|
|
12
13
|
/** Singleton class to record user sessions */
|
|
13
14
|
class SessionRecorder {
|
|
@@ -36,7 +37,9 @@ class SessionRecorder {
|
|
|
36
37
|
const nativeSessionRecorderConfig = {
|
|
37
38
|
logLevel: LogLevel.Verbose,
|
|
38
39
|
};
|
|
39
|
-
|
|
40
|
+
if (Platform.OS === 'android') {
|
|
41
|
+
initialize('abc1234', nativeSessionRecorderConfig);
|
|
42
|
+
}
|
|
40
43
|
this.instance = new SessionRecorder();
|
|
41
44
|
// todo handle RN clicks
|
|
42
45
|
addSafeEventListener(window, 'click', () => {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { SEVERITY } from '../constants';
|
|
2
2
|
import { CustomerConfig, StoredConfig } from '../../types/Config';
|
|
3
|
+
import { Singleton } from '../monitors/BaseMonitor';
|
|
3
4
|
/**
|
|
4
5
|
* Singleton class to manage the client configuration
|
|
5
6
|
* this class will be responsible for controlling the disabled
|
|
6
7
|
* status of the client script as well as managing all storage
|
|
7
8
|
* storing and retrieval.
|
|
8
9
|
*/
|
|
9
|
-
export default class ClientConfig {
|
|
10
|
+
export default class ClientConfig extends Singleton {
|
|
10
11
|
readonly pageVisitId: string;
|
|
11
12
|
browserId: StoredConfig['BrowserId'];
|
|
12
13
|
private pageVisitSeq;
|
|
@@ -15,26 +16,20 @@ export default class ClientConfig {
|
|
|
15
16
|
private cltErrorPostCounter;
|
|
16
17
|
private readonly maxSocketInactiveTime;
|
|
17
18
|
private locationBreadcrumbs;
|
|
18
|
-
private static instance;
|
|
19
|
-
static noibuErrorURL: string;
|
|
20
19
|
customerDomain: string;
|
|
21
20
|
isClientDisabled: boolean;
|
|
21
|
+
configurationPromise: Promise<void>;
|
|
22
22
|
readonly listOfUrlsToCollectHttpDataFrom: CustomerConfig['listOfUrlsToCollectHttpDataFrom'];
|
|
23
23
|
readonly enableHttpDataCollection: CustomerConfig['enableHttpDataCollection'];
|
|
24
24
|
readonly blockedElements: CustomerConfig['blockedElements'];
|
|
25
25
|
/**
|
|
26
26
|
* Creates a ClientConfig singleton instance
|
|
27
27
|
*/
|
|
28
|
-
constructor(noibuErrorURL
|
|
29
|
-
/** Configures the singleton instance */
|
|
30
|
-
static configureInstance({ noibuErrorURL, customerConfig, }: {
|
|
31
|
-
noibuErrorURL: string;
|
|
32
|
-
customerConfig: CustomerConfig;
|
|
33
|
-
}): Promise<void>;
|
|
28
|
+
constructor(noibuErrorURL?: string, customerConfig?: CustomerConfig);
|
|
34
29
|
/**
|
|
35
|
-
*
|
|
30
|
+
* Convenience method to check correct setup
|
|
36
31
|
*/
|
|
37
|
-
|
|
32
|
+
private hasAllNecessaryArgs;
|
|
38
33
|
/** lockClient will disable the client script for a single pagevisit for
|
|
39
34
|
* duration given in minuntes */
|
|
40
35
|
lockClient(duration: number, msg: string): Promise<void>;
|
|
@@ -97,7 +92,7 @@ export default class ClientConfig {
|
|
|
97
92
|
* and disable the client if required
|
|
98
93
|
* severity expects one of the SEVERITY_x level constants, or else error will be used
|
|
99
94
|
*/
|
|
100
|
-
postNoibuErrorAndOptionallyDisableClient(errorMsg: any, disableClient
|
|
95
|
+
postNoibuErrorAndOptionallyDisableClient(errorMsg: any, disableClient?: boolean, severity?: (typeof SEVERITY)[keyof typeof SEVERITY], keepAlive?: boolean): Promise<void>;
|
|
101
96
|
/**
|
|
102
97
|
* Returns true if the page visit is considered to be inactive
|
|
103
98
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PAGE_VISIT_PART_ATT_NAME, PAGE_VISIT_VID_FRAG_ATT_NAME } from '../constants';
|
|
2
|
-
import { Singleton } from '../../types/Monitor';
|
|
3
2
|
import { CompletePageVisit, InboundMessageType, OutboundMessageType, OutboundMessageTypeMap, PageVisitFrag, PageVisitInfo, SlidingMessage, VideoFrag } from '../../types/Metroplex.types';
|
|
4
3
|
import { PVEventMessage } from '../../types/PageVisitEvents.types';
|
|
4
|
+
import { Singleton } from '../monitors/BaseMonitor';
|
|
5
5
|
/**
|
|
6
6
|
* Implements rolling window of specified size,
|
|
7
7
|
* but only makes a cut once array length exceeds 150%.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Singleton } from '../../types/Monitor';
|
|
2
1
|
import { CompletePageVisit, PageVisitFrag, PageVisitInfo, SlidingMessage } from '../../types/Metroplex.types';
|
|
2
|
+
import { Singleton } from '../monitors/BaseMonitor';
|
|
3
3
|
/**
|
|
4
4
|
* This class holds the final page visit. It flushes it to storage and then
|
|
5
5
|
* finally sends it to Metroplex via the post route when the next page is loaded
|
|
@@ -7,5 +7,7 @@ export interface Monitor {
|
|
|
7
7
|
export declare abstract class Singleton {
|
|
8
8
|
private static instances;
|
|
9
9
|
/** returns singleton instance */
|
|
10
|
-
static getInstance<T extends Singleton>(this: new (...args:
|
|
10
|
+
static getInstance<T extends Singleton, A extends any[]>(this: new (...args: A) => T, ...args: A): T;
|
|
11
|
+
/** used for testing only */
|
|
12
|
+
protected resetInstances(): void;
|
|
11
13
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @module ClickMonitor */
|
|
2
|
-
import { Monitor, Singleton } from '
|
|
2
|
+
import { Monitor, Singleton } from './BaseMonitor';
|
|
3
3
|
/** Monitors the clicks which we capture and later process */
|
|
4
4
|
export declare class ClickMonitor extends Singleton implements Monitor {
|
|
5
5
|
private static textCapturedWhiteListRegex;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Monitor, Singleton } from '
|
|
1
|
+
import { Monitor, Singleton } from './BaseMonitor';
|
|
2
2
|
type Event = any;
|
|
3
3
|
/** Monitors the page events which we capture and later process */
|
|
4
4
|
export declare class PageMonitor extends Singleton implements Monitor {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WrappedXMLHttpRequest } from '../../../types/WrappedObjects';
|
|
2
|
-
import { Singleton } from '../../../types/Monitor';
|
|
3
2
|
import { HTTPDataBundle } from '../../../types/PageVisitEvents.types';
|
|
3
|
+
import { Singleton } from '../BaseMonitor';
|
|
4
4
|
/** Bundles HTTP payloads and headers */
|
|
5
5
|
export declare class HTTPDataBundler extends Singleton {
|
|
6
6
|
contentTypeReadableRegex: RegExp;
|
|
@@ -61,4 +61,19 @@ export declare function setCustomUserId(customUserId: string): void;
|
|
|
61
61
|
export declare function setCustomSessionId(customSessionId: string): void;
|
|
62
62
|
export type RecorderEvent = import('./types').RecorderEvent;
|
|
63
63
|
export type UnsubscribeFn = import('./types').UnsubscribeFn;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribes to a native event emitted by the Noibu Session Recorder.
|
|
66
|
+
*
|
|
67
|
+
* This function listens for the `noibuRecordingEvent` emitted from the native layer (only on Android)
|
|
68
|
+
* and invokes the provided callback whenever the event occurs. If the platform is not Android,
|
|
69
|
+
* the function will do nothing and return a no-op unsubscribe function.
|
|
70
|
+
*
|
|
71
|
+
* @param {function(RecorderEvent): void} callback - A callback function that will be invoked with
|
|
72
|
+
* the event data whenever the `noibuRecordingEvent` is emitted.
|
|
73
|
+
*
|
|
74
|
+
* @returns {UnsubscribeFn} A function to unsubscribe from the event. On Android, this will remove
|
|
75
|
+
* the event listener. On other platforms, it will be a no-op.
|
|
76
|
+
*
|
|
77
|
+
* @throws {Error} If the Noibu Session Recorder is not initialized before calling this function.
|
|
78
|
+
*/
|
|
64
79
|
export declare function subscribeToNativeEvent(callback: (event: RecorderEvent) => void): UnsubscribeFn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "noibu-react-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
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",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build": "node ./build.js",
|
|
18
18
|
"build:dev": "node ./build.watch.js",
|
|
19
19
|
"prepare": "npm run clean; npm run build;",
|
|
20
|
-
"test": "jest --coverage
|
|
20
|
+
"test": "jest --coverage",
|
|
21
21
|
"tsc": "tsc",
|
|
22
22
|
"lint": "eslint src -c .eslintrc.json --ext js,ts,jsx,tsx",
|
|
23
23
|
"lint_output": "eslint src -c .eslintrc.json --ext js,ts,jsx,tsx -f json > eslint_report.json",
|
|
@@ -45,15 +45,18 @@
|
|
|
45
45
|
"react-native-uuid": "^2.0.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"@babel/core": "^7.26.0",
|
|
49
|
+
"@babel/preset-env": "^7.26.0",
|
|
50
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
48
51
|
"@jest/globals": "^29.7.0",
|
|
49
|
-
"@react-native-async-storage/async-storage": "1.19.0",
|
|
52
|
+
"@react-native-async-storage/async-storage": "^1.19.0",
|
|
50
53
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
51
54
|
"@rollup/plugin-json": "^6.0.0",
|
|
52
55
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
53
56
|
"@rollup/plugin-replace": "^5.0.2",
|
|
54
57
|
"@rollup/plugin-typescript": "^11.1.1",
|
|
55
58
|
"@tsconfig/react-native": "^3.0.2",
|
|
56
|
-
"@types/jest": "^29.5.
|
|
59
|
+
"@types/jest": "^29.5.14",
|
|
57
60
|
"@types/node": "^20.2.3",
|
|
58
61
|
"@types/react": "16.14.62",
|
|
59
62
|
"@types/react-test-renderer": "^18.0.0",
|
|
@@ -79,7 +82,7 @@
|
|
|
79
82
|
"rimraf": "^5.0.1",
|
|
80
83
|
"rollup": "^4.27.4",
|
|
81
84
|
"rollup-plugin-dotenv": "^0.5.0",
|
|
82
|
-
"ts-jest": "^29.2.
|
|
85
|
+
"ts-jest": "^29.2.5",
|
|
83
86
|
"typescript": "^5.5.3"
|
|
84
87
|
}
|
|
85
88
|
}
|