noibu-react-native 0.0.6 → 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/dist/api/clientConfig.js +3 -2
- package/dist/api/metroplexSocket.js +4 -3
- package/dist/api/storedMetrics.js +3 -2
- package/dist/entry/init.js +7 -7
- package/dist/monitors/AppNavigationMonitor.d.ts +23 -0
- package/dist/monitors/AppNavigationMonitor.js +63 -0
- package/dist/monitors/clickMonitor.js +1 -1
- package/dist/monitors/httpDataBundler.js +3 -2
- 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 +2 -0
- package/dist/pageVisit/pageVisitEventError/pageVisitEventError.js +6 -4
- package/dist/types/NavigationIntegration.d.ts +7 -0
- package/dist/types/ReactNative.d.ts +2 -1
- package/dist/utils/function.d.ts +0 -7
- package/dist/utils/function.js +11 -17
- package/package.json +4 -1
- package/dist/monitors/locationChangeMonitor.js +0 -18
package/dist/api/clientConfig.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import uuid from 'react-native-uuid';
|
|
2
2
|
import { MAX_METROPLEX_SOCKET_INNACTIVE_TIME, SEVERITY, NOIBU_BROWSER_ID_KYWRD, PV_SEQ_NUM_RESET_TIME_MINUTES, JS_ENV, MAX_PAGEVISIT_VISITED, CLIENT_LOCK_TIME_MINUTES, GET_SCRIPT_ID, MAX_COLLECT_ERROR_LOG } from '../constants.js';
|
|
3
|
-
import { stringifyJSON, getUserAgent, asString,
|
|
3
|
+
import { stringifyJSON, getUserAgent, asString, makeRequest } from '../utils/function.js';
|
|
4
4
|
import Storage from '../storage/storage.js';
|
|
5
|
+
import { AppNavigationMonitor } from '../monitors/AppNavigationMonitor.js';
|
|
5
6
|
|
|
6
7
|
/** @module ClientConfig */
|
|
7
8
|
/**
|
|
@@ -306,7 +307,7 @@ class ClientConfig {
|
|
|
306
307
|
'maximum limit of collect errors sent.';
|
|
307
308
|
}
|
|
308
309
|
const errorContent = {
|
|
309
|
-
url:
|
|
310
|
+
url: AppNavigationMonitor.getInstance().globalUrl,
|
|
310
311
|
err_msg: errMsg,
|
|
311
312
|
sev: severity,
|
|
312
313
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import uuid from 'react-native-uuid';
|
|
2
|
-
import {
|
|
2
|
+
import { getUserAgent, stringifyJSON, getUserLanguage } from '../utils/function.js';
|
|
3
3
|
import { addSafeEventListener } from '../utils/eventlistener.js';
|
|
4
4
|
import { GET_METROPLEX_BASE_SOCKET_URL, METROPLEX_FRAG_ROUTE, GET_METROPLEX_POST_URL, METROPLEX_RETRY_FREQUENCY, META_DATA_METROPLEX_TYPE, PAGE_VISIT_META_DATA_ATT_NAME, HTTP_DATA_METROPLEX_TYPE, PAGE_VISIT_HTTP_DATA_ATT_NAME, VIDEO_METROPLEX_TYPE, PAGE_VISIT_VID_FRAG_ATT_NAME, PV_METROPLEX_TYPE, PAGE_VISIT_PART_ATT_NAME, SEQ_NUM_ATT_NAME, WORK_REQUEST_ATT_NAME, PV_EVENTS_ATT_NAME, TYPE_ATT_NAME, USERSTEP_EVENT_TYPE, GET_MAX_METROPLEX_RECONNECTION_NUMBER, MAX_METROPLEX_CONNECTION_COUNT, GET_METROPLEX_CONSECUTIVE_CONNECTION_DELAY, END_AT_ATT_NAME, SEVERITY, OK_SOCKET_MESSAGE, CLOSE_CONNECTION_FORCEFULLY, BLOCK_SOCKET_MESSAGE, STOP_STORING_PV_SOCKET_MESSAGE, STOP_STORING_VID_SOCKET_MESSAGE, MAX_BEACON_PAYLOAD_SIZE, PAGE_VISIT_INFORMATION_ATT_NAME, VIDEO_PART_COUNT_ATT_NAME, IS_LAST_ATT_NAME, BROWSER_ID_ATT_NAME, PV_ID_ATT_NAME, VER_ATT_NAME, CURRENT_PV_VERSION, PV_SEQ_ATT_NAME, ON_URL_ATT_NAME, REF_URL_ATT_NAME, STARTED_AT_ATT_NAME, CONN_COUNT_ATT_NAME, COLLECT_VER_ATT_NAME, CURRENT_NOIBUJS_VERSION, SCRIPT_ID_ATT_NAME, GET_SCRIPT_ID, SCRIPT_INSTANCE_ID_ATT_NAME, METROPLEX_SOCKET_INSTANCE_ID_ATT_NAME, SOCKET_INSTANCE_ID_ATT_NAME, LANG_ATT_NAME, HELP_CODE_ATT_NAME } from '../constants.js';
|
|
5
5
|
import ClientConfig from './clientConfig.js';
|
|
@@ -8,6 +8,7 @@ import StoredPageVisit from './storedPageVisit.js';
|
|
|
8
8
|
import { safePerformanceNow } from '../utils/performance.js';
|
|
9
9
|
import { isDateOverwritten } from '../utils/date.js';
|
|
10
10
|
import HelpCode from './helpCode.js';
|
|
11
|
+
import { AppNavigationMonitor } from '../monitors/AppNavigationMonitor.js';
|
|
11
12
|
|
|
12
13
|
/** @module MetroplexSocket */
|
|
13
14
|
|
|
@@ -61,7 +62,7 @@ class MetroplexSocket {
|
|
|
61
62
|
// setting initial URL at the start in order to guarentee that the
|
|
62
63
|
// current page visit has the real initial onURL. Fragments and SPA's
|
|
63
64
|
// can change the URL without reloading the page.
|
|
64
|
-
this.
|
|
65
|
+
this._initialURL = AppNavigationMonitor.getInstance().globalUrl;
|
|
65
66
|
this.initialReferingURL = '';
|
|
66
67
|
this.sessionTimestamp = new Date();
|
|
67
68
|
|
|
@@ -801,7 +802,7 @@ class MetroplexSocket {
|
|
|
801
802
|
[PV_ID_ATT_NAME]: ClientConfig.getInstance().pageVisitId,
|
|
802
803
|
[VER_ATT_NAME]: CURRENT_PV_VERSION,
|
|
803
804
|
[PV_SEQ_ATT_NAME]: await ClientConfig.getInstance().getPageVisitSeq(),
|
|
804
|
-
[ON_URL_ATT_NAME]: this.
|
|
805
|
+
[ON_URL_ATT_NAME]: this._initialURL,
|
|
805
806
|
[REF_URL_ATT_NAME]: this.initialReferingURL,
|
|
806
807
|
[STARTED_AT_ATT_NAME]: this.sessionTimestamp.toISOString(),
|
|
807
808
|
[CONN_COUNT_ATT_NAME]: this.connectionCount,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BROWSER_ID_ATT_NAME, PV_ID_ATT_NAME, COLLECT_VER_ATT_NAME, CURRENT_NOIBUJS_VERSION, VER_ATT_NAME, CURRENT_METRICS_VERSION, EXP_VIDEO_LENGTH_ATT_NAME, PV_EXP_VF_SEQ_ATT_NAME, PV_EXP_PART_COUNTER_ATT_NAME, PV_EXP_HTTP_DATA_SEQ_ATT_NAME, PV_HTTP_PAYLOADS_COLLECTED_ATT_NAME, PV_HTTP_PAYLOADS_DROPPED_OVERSIZE_ATT_NAME, PV_HTTP_PAYLOADS_DROPPED_TYPE_ATT_NAME, PV_HTTP_REQUESTS_DROPPED_OVER_LIMIT, VIDEO_CLICKS_ATT_NAME, PV_CLICKS_ATT_NAME, DID_CUT_PV_ATT_NAME, DID_CUT_VID_ATT_NAME, DID_START_VID_ATT_NAME, HTTP_COUNT_EXPECTED_ATT_NAME, ERR_COUNT_EXPECTED_ATT_NAME, ON_URL_ATT_NAME, GET_METROPLEX_METRICS_URL } from '../constants.js';
|
|
2
2
|
import ClientConfig from './clientConfig.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getUserAgent, stringifyJSON } from '../utils/function.js';
|
|
4
4
|
import { addSafeEventListener } from '../utils/eventlistener.js';
|
|
5
|
+
import { AppNavigationMonitor } from '../monitors/AppNavigationMonitor.js';
|
|
5
6
|
|
|
6
7
|
/** @module StoredMetrics */
|
|
7
8
|
|
|
@@ -179,7 +180,7 @@ class StoredMetrics {
|
|
|
179
180
|
[DID_START_VID_ATT_NAME]: this.didStartVideo,
|
|
180
181
|
[HTTP_COUNT_EXPECTED_ATT_NAME]: this.httpCount,
|
|
181
182
|
[ERR_COUNT_EXPECTED_ATT_NAME]: this.errCount,
|
|
182
|
-
[ON_URL_ATT_NAME]:
|
|
183
|
+
[ON_URL_ATT_NAME]: AppNavigationMonitor.getInstance().globalUrl,
|
|
183
184
|
};
|
|
184
185
|
global.fetch(GET_METROPLEX_METRICS_URL(), {
|
|
185
186
|
method: 'POST',
|
package/dist/entry/init.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import uuid from 'react-native-uuid';
|
|
2
|
+
import { KeyboardInputMonitor } from '../monitors/keyboardInputMonitor.js';
|
|
3
|
+
import { ClickMonitor } from '../monitors/clickMonitor.js';
|
|
4
|
+
import { PageMonitor } from '../monitors/pageMonitor.js';
|
|
5
|
+
import { HTTPDataBundler } from '../monitors/httpDataBundler.js';
|
|
2
6
|
import { monitorErrors } from '../monitors/errorMonitor.js';
|
|
3
7
|
import { monitorRequests } from '../monitors/requestMonitor.js';
|
|
4
|
-
import { ClickMonitor } from '../monitors/clickMonitor.js';
|
|
5
|
-
import { KeyboardInputMonitor } from '../monitors/keyboardInputMonitor.js';
|
|
6
|
-
import { monitorLocation } from '../monitors/locationChangeMonitor.js';
|
|
7
|
-
import { PageVisit } from '../pageVisit/pageVisit.js';
|
|
8
8
|
import { GET_METROPLEX_BASE_SOCKET_URL, GET_METROPLEX_BASE_HTTP_URL, SEVERITY, METROPLEX_ERROR_ROUTE } from '../constants.js';
|
|
9
9
|
import ClientConfig from '../api/clientConfig.js';
|
|
10
|
-
import { PageMonitor } from '../monitors/pageMonitor.js';
|
|
11
|
-
import { HTTPDataBundler } from '../monitors/httpDataBundler.js';
|
|
12
10
|
import { isInvalidURLConfig, isNoibuJSAlreadyLoaded } from '../utils/function.js';
|
|
11
|
+
import { PageVisit } from '../pageVisit/pageVisit.js';
|
|
13
12
|
import MetroplexSocket from '../api/metroplexSocket.js';
|
|
14
13
|
import StoredPageVisit from '../api/storedPageVisit.js';
|
|
15
14
|
import HelpCode from '../api/helpCode.js';
|
|
15
|
+
import { AppNavigationMonitor } from '../monitors/AppNavigationMonitor.js';
|
|
16
16
|
|
|
17
17
|
/** @module Init */
|
|
18
18
|
// these are set via rollup
|
|
@@ -56,12 +56,12 @@ function globalInit(customerConfig) {
|
|
|
56
56
|
const keyboardInputMonitor = new KeyboardInputMonitor();
|
|
57
57
|
const clickMonitor = ClickMonitor.getInstance();
|
|
58
58
|
const pageMonitor = PageMonitor.getInstance();
|
|
59
|
+
AppNavigationMonitor.getInstance();
|
|
59
60
|
HTTPDataBundler.getInstance();
|
|
60
61
|
// monitoring calls
|
|
61
62
|
monitorErrors();
|
|
62
63
|
monitorRequests();
|
|
63
64
|
clickMonitor.monitorClicks();
|
|
64
|
-
monitorLocation();
|
|
65
65
|
keyboardInputMonitor.monitor();
|
|
66
66
|
pageMonitor.monitor();
|
|
67
67
|
// todo: disable types here until metroplex socket file moves to ts
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attaches corresponding listener to the passed navigation integration
|
|
3
|
+
*/
|
|
4
|
+
export declare class AppNavigationMonitor {
|
|
5
|
+
private static instance;
|
|
6
|
+
private breadcrumbs;
|
|
7
|
+
/**
|
|
8
|
+
* guesses which navigation is used in app, and registers a listener if found
|
|
9
|
+
*/
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Gets the singleton instance
|
|
13
|
+
*/
|
|
14
|
+
static getInstance(): AppNavigationMonitor;
|
|
15
|
+
/**
|
|
16
|
+
* gets current global url
|
|
17
|
+
*/
|
|
18
|
+
get globalUrl(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Called when the event needs to be emitted
|
|
21
|
+
*/
|
|
22
|
+
private reportLocationChange;
|
|
23
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { SEVERITY, URL_ATT_NAME, LOCATION_EVENT_TYPE } from '../constants.js';
|
|
2
|
+
import { getMaxSubstringAllowed } from '../utils/function.js';
|
|
3
|
+
import { InputMonitor } from './inputMonitor.js';
|
|
4
|
+
import { ReactNativeNavigationIntegration } from './integrations/react-native-navigation-integration.js';
|
|
5
|
+
import ClientConfig from '../api/clientConfig.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Attaches corresponding listener to the passed navigation integration
|
|
9
|
+
*/
|
|
10
|
+
class AppNavigationMonitor {
|
|
11
|
+
static instance;
|
|
12
|
+
breadcrumbs = [];
|
|
13
|
+
/**
|
|
14
|
+
* guesses which navigation is used in app, and registers a listener if found
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
try {
|
|
18
|
+
// eslint-disable-next-line global-require,@typescript-eslint/no-var-requires,import/no-extraneous-dependencies
|
|
19
|
+
const rnNavigation = require('react-native-navigation')?.Navigation;
|
|
20
|
+
if (rnNavigation) {
|
|
21
|
+
new ReactNativeNavigationIntegration().register(rnNavigation, breadcrumbs => {
|
|
22
|
+
this.breadcrumbs = breadcrumbs;
|
|
23
|
+
this.reportLocationChange();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(`AppNavigationMonitor: ${e}`, false, SEVERITY.error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Gets the singleton instance
|
|
33
|
+
*/
|
|
34
|
+
static getInstance() {
|
|
35
|
+
if (!AppNavigationMonitor.instance) {
|
|
36
|
+
AppNavigationMonitor.instance = new AppNavigationMonitor();
|
|
37
|
+
}
|
|
38
|
+
return AppNavigationMonitor.instance;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* gets current global url
|
|
42
|
+
*/
|
|
43
|
+
get globalUrl() {
|
|
44
|
+
const globalUrl = new URL('https://localhost');
|
|
45
|
+
globalUrl.hostname = ClientConfig.getInstance().customerDomain;
|
|
46
|
+
if (this.breadcrumbs.length) {
|
|
47
|
+
globalUrl.pathname = this.breadcrumbs.join('/');
|
|
48
|
+
}
|
|
49
|
+
return getMaxSubstringAllowed(globalUrl.toString());
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Called when the event needs to be emitted
|
|
53
|
+
*/
|
|
54
|
+
reportLocationChange() {
|
|
55
|
+
const payload = {
|
|
56
|
+
[URL_ATT_NAME]: this.globalUrl,
|
|
57
|
+
};
|
|
58
|
+
// storing the location change in the page visit queue
|
|
59
|
+
InputMonitor.getInstance().addEvent(payload, LOCATION_EVENT_TYPE);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { AppNavigationMonitor };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
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
|
-
import { getProperGlobalUrl, checkHttpDataCollectionEnabled, getHttpPayloadAllowedURLs } from '../utils/function.js';
|
|
3
2
|
import ClientConfig from '../api/clientConfig.js';
|
|
4
3
|
import StoredMetrics from '../api/storedMetrics.js';
|
|
5
4
|
import { safeFromEntries, iterateObjectRecursively } from '../utils/object.js';
|
|
5
|
+
import { checkHttpDataCollectionEnabled, getHttpPayloadAllowedURLs } from '../utils/function.js';
|
|
6
|
+
import { AppNavigationMonitor } from './AppNavigationMonitor.js';
|
|
6
7
|
|
|
7
8
|
/** @module HTTPDataBundler */
|
|
8
9
|
|
|
@@ -19,7 +20,7 @@ class HTTPDataBundler {
|
|
|
19
20
|
);
|
|
20
21
|
|
|
21
22
|
// pull out the domain hostname
|
|
22
|
-
const initialURL =
|
|
23
|
+
const initialURL = AppNavigationMonitor.getInstance().globalUrl;
|
|
23
24
|
this.initialURLPartsReversed = [];
|
|
24
25
|
if (initialURL && initialURL.length > 0) {
|
|
25
26
|
try {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NavigationDelegate } from 'react-native-navigation/lib/dist/src/NavigationDelegate';
|
|
2
|
+
import { NavigationIntegration } from '../../types/NavigationIntegration';
|
|
3
|
+
/**
|
|
4
|
+
* react-native-navigation adapter
|
|
5
|
+
*/
|
|
6
|
+
export declare class ReactNativeNavigationIntegration implements NavigationIntegration {
|
|
7
|
+
private stack;
|
|
8
|
+
private stackPointers;
|
|
9
|
+
/**
|
|
10
|
+
* attaches provided listeners to the integration
|
|
11
|
+
*/
|
|
12
|
+
register(navigation: NavigationDelegate, onNavigation: (breadcrumbs: string[]) => void): void;
|
|
13
|
+
/**
|
|
14
|
+
* Listens to ComponentWillAppear events
|
|
15
|
+
* @param onNavigation
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
private getListener;
|
|
19
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-native-navigation adapter
|
|
3
|
+
*/
|
|
4
|
+
class ReactNativeNavigationIntegration {
|
|
5
|
+
stack = [];
|
|
6
|
+
stackPointers = {};
|
|
7
|
+
/**
|
|
8
|
+
* attaches provided listeners to the integration
|
|
9
|
+
*/
|
|
10
|
+
register(navigation, onNavigation) {
|
|
11
|
+
navigation
|
|
12
|
+
.events()
|
|
13
|
+
.registerComponentWillAppearListener(this.getListener(onNavigation));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Listens to ComponentWillAppear events
|
|
17
|
+
* @param onNavigation
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
getListener(onNavigation) {
|
|
21
|
+
return (event) => {
|
|
22
|
+
if (this.stackPointers[event.componentName] === undefined) {
|
|
23
|
+
this.stackPointers[event.componentName] = this.stack.push(event.componentName);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.stack.forEach((id, i) => {
|
|
27
|
+
if (i >= this.stackPointers[event.componentName]) {
|
|
28
|
+
delete this.stackPointers[id];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
this.stack.length = this.stackPointers[event.componentName];
|
|
32
|
+
}
|
|
33
|
+
onNavigation(this.stack.slice(1)); // slice 1 to skip root component
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { ReactNativeNavigationIntegration };
|
|
@@ -6,7 +6,9 @@ import 'react-native-device-info';
|
|
|
6
6
|
import 'react-native-localize';
|
|
7
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
|
+
import 'react-native-uuid';
|
|
9
10
|
import { addSafeEventListener } from '../utils/eventlistener.js';
|
|
11
|
+
import '@react-native-async-storage/async-storage';
|
|
10
12
|
import { HTTPDataBundler } from './httpDataBundler.js';
|
|
11
13
|
import GqlErrorValidator from './gqlErrorValidator.js';
|
|
12
14
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { isValidURL, getOnURL,
|
|
1
|
+
import { isValidURL, getOnURL, getJSStack, stringifyJSON, getMaxSubstringAllowed } from '../../utils/function.js';
|
|
2
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';
|
|
6
6
|
import StoredMetrics from '../../api/storedMetrics.js';
|
|
7
|
+
import { AppNavigationMonitor } from '../../monitors/AppNavigationMonitor.js';
|
|
7
8
|
|
|
8
9
|
/** @module PageVisitEventError */
|
|
9
10
|
|
|
@@ -69,7 +70,9 @@ function getPVErrorFromXMLHttpRequest(errPayload, httpDataSeqNum) {
|
|
|
69
70
|
*/
|
|
70
71
|
function getPVErrorFromErrorEvent(errPayload) {
|
|
71
72
|
return {
|
|
72
|
-
[URL_ATT_NAME]: getOnURL(
|
|
73
|
+
[URL_ATT_NAME]: getOnURL(
|
|
74
|
+
errPayload.filename || AppNavigationMonitor.getInstance().globalUrl,
|
|
75
|
+
),
|
|
73
76
|
[TYPE_ATT_NAME]: JS_EVENT_TYPE,
|
|
74
77
|
[JS_ERROR_ATT_NAME]: getJSStack(errPayload.error),
|
|
75
78
|
};
|
|
@@ -80,8 +83,7 @@ function getPVErrorFromErrorEvent(errPayload) {
|
|
|
80
83
|
*/
|
|
81
84
|
function getPVErrorFromErrorLog(errPayload) {
|
|
82
85
|
return {
|
|
83
|
-
|
|
84
|
-
[URL_ATT_NAME]: getOnURL(getProperGlobalUrl()), // todo should be current navigation
|
|
86
|
+
[URL_ATT_NAME]: getOnURL(AppNavigationMonitor.getInstance().globalUrl),
|
|
85
87
|
[TYPE_ATT_NAME]: JS_EVENT_TYPE,
|
|
86
88
|
[JS_ERROR_ATT_NAME]: getJSStack(errPayload),
|
|
87
89
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NavigationDelegate } from 'react-native-navigation/lib/dist/src/NavigationDelegate';
|
|
2
|
+
/**
|
|
3
|
+
* interface enforces constructor signature
|
|
4
|
+
*/
|
|
5
|
+
export interface NavigationIntegration {
|
|
6
|
+
register(navigation: NavigationDelegate, onNavigation: (breadcrumbs: string[]) => void): void;
|
|
7
|
+
}
|
package/dist/utils/function.d.ts
CHANGED
|
@@ -7,13 +7,6 @@ import { JError, JStackFrame } from '../types/PageVisit';
|
|
|
7
7
|
* length :optional, max length that stringToVerify can be
|
|
8
8
|
*/
|
|
9
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
10
|
/**
|
|
18
11
|
* Processes the raw stack frames and creates a readable stack in a safe manner
|
|
19
12
|
* @param {StackFrame[]} rawFrames
|
package/dist/utils/function.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import DeviceInfo from 'react-native-device-info';
|
|
2
2
|
import { getLocales } from 'react-native-localize';
|
|
3
3
|
import { parseStack } from './stacktrace-parser.js';
|
|
4
|
-
import {
|
|
4
|
+
import { MAX_STRING_LENGTH, MAX_BEACON_PAYLOAD_SIZE, REQUIRED_DATA_PROCESSING_URLS, PII_EMAIL_PATTERN, PII_REDACTION_REPLACEMENT_STRING, PII_DIGIT_PATTERN, DEFAULT_STACK_FRAME_FIELD_VALUE } from '../constants.js';
|
|
5
5
|
import ClientConfig from '../api/clientConfig.js';
|
|
6
|
+
import { AppNavigationMonitor } from '../monitors/AppNavigationMonitor.js';
|
|
6
7
|
|
|
7
8
|
/** @module Functions */
|
|
8
9
|
/**
|
|
@@ -26,17 +27,6 @@ function getMaxSubstringAllowed(stringToVerify, length = MAX_STRING_LENGTH) {
|
|
|
26
27
|
return stringToVerify;
|
|
27
28
|
return stringToVerify.substring(0, length);
|
|
28
29
|
}
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* todo implement navigation
|
|
32
|
-
* getProperGlobalUrl gets the proper global url from the window
|
|
33
|
-
* @returns {string}
|
|
34
|
-
*/
|
|
35
|
-
function getProperGlobalUrl() {
|
|
36
|
-
const globalUrl = new URL('https://localhost');
|
|
37
|
-
globalUrl.hostname = ClientConfig.getInstance().customerDomain;
|
|
38
|
-
return getMaxSubstringAllowed(globalUrl.toString());
|
|
39
|
-
}
|
|
40
30
|
/**
|
|
41
31
|
* Processes the raw stack frames and creates a readable stack in a safe manner
|
|
42
32
|
* @param {StackFrame[]} rawFrames
|
|
@@ -230,7 +220,12 @@ async function getUserAgent() {
|
|
|
230
220
|
if (userAgentCache) {
|
|
231
221
|
return userAgentCache;
|
|
232
222
|
}
|
|
233
|
-
|
|
223
|
+
try {
|
|
224
|
+
userAgentCache = await DeviceInfo.getUserAgent();
|
|
225
|
+
}
|
|
226
|
+
catch (e) {
|
|
227
|
+
userAgentCache = '';
|
|
228
|
+
}
|
|
234
229
|
return userAgentCache;
|
|
235
230
|
}
|
|
236
231
|
/**
|
|
@@ -286,11 +281,10 @@ function maskTextInput(text) {
|
|
|
286
281
|
* gets the onURL of a string, defaulting to the location of the webpage
|
|
287
282
|
*/
|
|
288
283
|
function getOnURL(realOnURL) {
|
|
289
|
-
let onURL = getProperGlobalUrl();
|
|
290
284
|
if (realOnURL && realOnURL.trim() !== '' && realOnURL !== 'undefined') {
|
|
291
|
-
|
|
285
|
+
return asString(getMaxSubstringAllowed(realOnURL));
|
|
292
286
|
}
|
|
293
|
-
return
|
|
287
|
+
return AppNavigationMonitor.getInstance().globalUrl;
|
|
294
288
|
}
|
|
295
289
|
/** gets the user language from the browser */
|
|
296
290
|
function getUserLanguage() {
|
|
@@ -318,4 +312,4 @@ function isInstanceOf(instance, type) {
|
|
|
318
312
|
}
|
|
319
313
|
}
|
|
320
314
|
|
|
321
|
-
export { asString, checkHttpDataCollectionEnabled, getBlockedElements, getHttpPayloadAllowedURLs, getJSStack, getMaxSubstringAllowed, getOnURL,
|
|
315
|
+
export { asString, checkHttpDataCollectionEnabled, getBlockedElements, getHttpPayloadAllowedURLs, getJSStack, getMaxSubstringAllowed, getOnURL, getUserAgent, getUserLanguage, isInstanceOf, isInvalidURLConfig, isNoibuJSAlreadyLoaded, isStackTrace, isValidURL, makeRequest, maskTextInput, processFrames, stringifyJSON };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "noibu-react-native",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
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",
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
"lint_output": "eslint src -c .eslintrc.json --ext js,ts,jsx,tsx -f json > eslint_report.json",
|
|
22
22
|
"codecov": "codecov"
|
|
23
23
|
},
|
|
24
|
+
"optionalDependencies": {
|
|
25
|
+
"react-native-navigation": "7"
|
|
26
|
+
},
|
|
24
27
|
"dependencies": {
|
|
25
28
|
"react": ">=16.11.0",
|
|
26
29
|
"react-native": ">=0.63.0",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import 'react-native-device-info';
|
|
2
|
-
import 'react-native-localize';
|
|
3
|
-
import 'react-native-uuid';
|
|
4
|
-
import '@react-native-async-storage/async-storage';
|
|
5
|
-
|
|
6
|
-
/** @module LocationMonitor */
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* will poll the url on a 1 second basis to see if it has changed
|
|
10
|
-
* there is currently no alternative to getting an accurate url
|
|
11
|
-
* change listener
|
|
12
|
-
*/
|
|
13
|
-
function monitorLocation() {
|
|
14
|
-
setInterval(() => {
|
|
15
|
-
}, 1000);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { monitorLocation };
|