noibu-react-native 0.2.5 → 0.2.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/README.md +15 -15
- package/android/build.gradle +1 -1
- package/dist/api/{clientConfig.js → ClientConfig.js} +69 -52
- package/dist/api/{helpCode.js → HelpCode.js} +6 -13
- package/dist/api/InputManager.js +156 -0
- package/dist/api/{metroplexSocket.js → MetroplexSocket.js} +189 -178
- package/dist/api/StoredMetrics.js +158 -0
- package/dist/api/{storedPageVisit.js → StoredPageVisit.js} +61 -48
- package/dist/const_matchers.js +1 -5
- package/dist/constants.js +15 -390
- package/dist/entry/index.js +3 -4
- package/dist/entry/init.js +33 -19
- package/dist/monitors/AppNavigationMonitor.js +19 -19
- package/dist/monitors/BaseMonitor.js +9 -4
- package/dist/monitors/ClickMonitor.js +72 -76
- package/dist/monitors/ErrorMonitor.js +45 -55
- package/dist/monitors/KeyboardInputMonitor.js +13 -11
- package/dist/monitors/PageMonitor.js +25 -2
- package/dist/monitors/RequestMonitor.js +46 -57
- package/dist/monitors/http-tools/GqlErrorValidator.js +39 -69
- package/dist/monitors/http-tools/HTTPDataBundler.js +71 -66
- package/dist/monitors/integrations/{react-native-navigation-integration.js → ReactNativeNavigationIntegration.js} +15 -12
- package/dist/pageVisit/EventDebouncer.js +43 -74
- package/dist/pageVisit/HttpEventManager.js +88 -0
- package/dist/pageVisit/PageVisitManager.js +99 -0
- package/dist/pageVisit/pageVisitEventError.js +170 -280
- package/dist/react/ErrorBoundary.js +3 -6
- package/dist/sessionRecorder/{sessionRecorder.js → SessionRecorder.js} +58 -70
- package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +3 -5
- package/dist/storage/{rnStorageProvider.js → RNStorageProvider.js} +3 -7
- package/dist/storage/{storage.js → Storage.js} +17 -30
- package/dist/storage/{storageProvider.js → StorageProvider.js} +7 -8
- package/dist/utils/date.js +39 -50
- package/dist/utils/eventlistener.js +5 -12
- package/dist/utils/function.js +42 -113
- package/dist/utils/log.js +5 -5
- package/dist/utils/object.js +12 -12
- package/dist/utils/piiRedactor.js +31 -3
- package/dist/utils/stacktrace-parser.js +29 -21
- package/package.json +14 -14
- package/dist/api/inputManager.js +0 -227
- package/dist/api/storedMetrics.js +0 -198
- package/dist/pageVisit/pageVisit.js +0 -181
- package/dist/pageVisit/pageVisitEventHTTP.js +0 -98
- package/dist/pageVisit/userStep.js +0 -20
- package/dist/src/api/clientConfig.d.ts +0 -100
- package/dist/src/api/clientConfig.test.d.ts +0 -1
- package/dist/src/api/helpCode.d.ts +0 -23
- package/dist/src/api/inputManager.d.ts +0 -87
- package/dist/src/api/metroplexSocket.d.ts +0 -137
- package/dist/src/api/storedMetrics.d.ts +0 -73
- package/dist/src/api/storedPageVisit.d.ts +0 -40
- package/dist/src/const_matchers.d.ts +0 -1
- package/dist/src/constants.d.ts +0 -290
- package/dist/src/entry/index.d.ts +0 -14
- package/dist/src/entry/init.d.ts +0 -5
- package/dist/src/monitors/AppNavigationMonitor.d.ts +0 -18
- package/dist/src/monitors/BaseMonitor.d.ts +0 -13
- package/dist/src/monitors/BaseMonitor.test.d.ts +0 -1
- package/dist/src/monitors/ClickMonitor.d.ts +0 -31
- package/dist/src/monitors/ErrorMonitor.d.ts +0 -63
- package/dist/src/monitors/KeyboardInputMonitor.d.ts +0 -20
- package/dist/src/monitors/PageMonitor.d.ts +0 -20
- package/dist/src/monitors/RequestMonitor.d.ts +0 -94
- package/dist/src/monitors/http-tools/GqlErrorValidator.d.ts +0 -59
- package/dist/src/monitors/http-tools/HTTPDataBundler.d.ts +0 -112
- package/dist/src/monitors/integrations/react-native-navigation-integration.d.ts +0 -20
- package/dist/src/pageVisit/EventDebouncer.d.ts +0 -24
- package/dist/src/pageVisit/pageVisit.d.ts +0 -52
- package/dist/src/pageVisit/pageVisitEventError.d.ts +0 -15
- package/dist/src/pageVisit/pageVisitEventHTTP.d.ts +0 -25
- package/dist/src/pageVisit/userStep.d.ts +0 -5
- package/dist/src/react/ErrorBoundary.d.ts +0 -72
- package/dist/src/sessionRecorder/nativeSessionRecorderSubscription.d.ts +0 -79
- package/dist/src/sessionRecorder/sessionRecorder.d.ts +0 -60
- package/dist/src/sessionRecorder/types.d.ts +0 -91
- package/dist/src/storage/rnStorageProvider.d.ts +0 -23
- package/dist/src/storage/storage.d.ts +0 -39
- package/dist/src/storage/storageProvider.d.ts +0 -26
- package/dist/src/utils/date.d.ts +0 -6
- package/dist/src/utils/eventlistener.d.ts +0 -8
- package/dist/src/utils/function.d.ts +0 -102
- package/dist/src/utils/log.d.ts +0 -4
- package/dist/src/utils/object.d.ts +0 -44
- package/dist/src/utils/performance.d.ts +0 -6
- package/dist/src/utils/piiRedactor.d.ts +0 -11
- package/dist/src/utils/polyfills.d.ts +0 -4
- package/dist/src/utils/stacktrace-parser.d.ts +0 -7
- package/dist/types/Config.d.ts +0 -31
- package/dist/types/Metroplex.types.d.ts +0 -73
- package/dist/types/NavigationIntegration.d.ts +0 -6
- package/dist/types/PageVisit.types.d.ts +0 -8
- package/dist/types/PageVisitErrors.types.d.ts +0 -114
- package/dist/types/PageVisitEvents.types.d.ts +0 -91
- package/dist/types/PageVisitMetrics.types.d.ts +0 -27
- package/dist/types/Storage.d.ts +0 -14
- package/dist/types/StoredPageVisit.types.d.ts +0 -11
- package/dist/types/WrappedObjects.d.ts +0 -6
package/dist/constants.js
CHANGED
|
@@ -1,113 +1,16 @@
|
|
|
1
|
+
import { MetroplexRoute } from './node_modules/@noibu/metroplex-ts-bindings/dist/index.js';
|
|
2
|
+
|
|
1
3
|
/** @module Constants */
|
|
2
4
|
// current collect version to be sent to front end services
|
|
3
5
|
// The Collect version should only change if we change the protocol between
|
|
4
6
|
// metroplex and collect as a different collect version than the one
|
|
5
|
-
// expected will result in noibujs locking himself for 45 minutes.
|
|
6
7
|
const CURRENT_NOIBUJS_VERSION = 2;
|
|
7
|
-
const MAX_FRAMES_IN_ARRAY = 50;
|
|
8
8
|
const MAX_STRING_LENGTH = 1024;
|
|
9
|
-
// the maximum size of http data payload that will be captured, otherwise it is dropped
|
|
10
|
-
const MAX_HTTP_DATA_PAYLOAD_LENGTH = 50000;
|
|
11
|
-
// number of errors that collect can send to metroplex before shutting himself off.
|
|
12
|
-
const MAX_COLLECT_ERROR_LOG = 50;
|
|
13
|
-
const MAX_PAGEVISIT_PARTS = 10000;
|
|
14
|
-
// maximum number of HTTP data events to collect per page visit
|
|
15
|
-
const MAX_HTTP_DATA_EVENT_COUNT = 100;
|
|
16
9
|
// The max number of milliseconds the front end should wait before sending
|
|
17
10
|
// data to Metroplex
|
|
18
11
|
const MAX_TIME_FOR_UNSENT_DATA_MILLIS = 500;
|
|
19
|
-
const NOIBU_BROWSER_ID_KYWRD = 'n_browser_data';
|
|
20
|
-
// The local storage key used to store the last page visit
|
|
21
|
-
const NOIBU_STORED_PAGE_VISIT = 'n_stored_page_visit';
|
|
22
|
-
// The local storage key used to test whether writing to local storage is supported
|
|
23
|
-
const NOIBU_LOCAL_STORAGE_TEST_KEY = 'n_key';
|
|
24
|
-
// The amount of time to lock the client for if they have exceeded things
|
|
25
|
-
// like the maximum number of pagevisits
|
|
26
|
-
const CLIENT_LOCK_TIME_MINUTES = 45;
|
|
27
|
-
// The amount of inactive time required for us to reset the page visit sequence numbers
|
|
28
|
-
const PV_SEQ_NUM_RESET_TIME_MINUTES = 45;
|
|
29
|
-
// urls needed to communicate with our fe components
|
|
30
|
-
const REQUIRED_DATA_PROCESSING_URLS = [
|
|
31
|
-
'metroplexSocketBase',
|
|
32
|
-
'metroplexHTTPBase',
|
|
33
|
-
'domain',
|
|
34
|
-
];
|
|
35
|
-
const HTTP_BODY_DROPPED_TYPE_MSG = 'Dropped due to unsupported type.';
|
|
36
|
-
const HTTP_BODY_DROPPED_LENGTH_MSG = 'Dropped due to length.';
|
|
37
|
-
const HTTP_BODY_NULL_STRING = 'null';
|
|
38
|
-
// HTTP request/response header keys to be blocked - these must be lowercase.
|
|
39
|
-
const BLOCKED_HTTP_HEADER_KEYS = [
|
|
40
|
-
// Auth token
|
|
41
|
-
'authorization',
|
|
42
|
-
// Email address
|
|
43
|
-
'from',
|
|
44
|
-
// Auth token
|
|
45
|
-
'proxy-authorization',
|
|
46
|
-
// MD5 hash of body could leak PII, obsolete so this shouldn't be a regular issue.
|
|
47
|
-
'content-md5',
|
|
48
|
-
// Cookies could include PII.
|
|
49
|
-
'cookie',
|
|
50
|
-
// IP address
|
|
51
|
-
'x-forwarded-for',
|
|
52
|
-
// IP address
|
|
53
|
-
'x-real-ip',
|
|
54
|
-
// Uniquely-identifiable device ID
|
|
55
|
-
'x-device-id',
|
|
56
|
-
// Uniquely-identifiable request ID
|
|
57
|
-
'x-request-id',
|
|
58
|
-
// Auth token
|
|
59
|
-
'x-auth-token',
|
|
60
|
-
// Uniquely-identifiable user ID
|
|
61
|
-
'x-user-id',
|
|
62
|
-
// Could contain IP address
|
|
63
|
-
'x-forwarded-for',
|
|
64
|
-
// Verizon injects this into requests on their network, contains PII
|
|
65
|
-
'x-uidh',
|
|
66
|
-
// Cookies
|
|
67
|
-
'set-cookie',
|
|
68
|
-
// IP addres
|
|
69
|
-
'forwarded',
|
|
70
|
-
];
|
|
71
|
-
const PII_DIGIT_PATTERN = /[0-9]+/g;
|
|
72
|
-
// eslint-disable-next-line max-len
|
|
73
12
|
const PII_EMAIL_PATTERN = /\b[a-z0-9!#$%&'*+/=?^_‘{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_‘{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\b/g;
|
|
74
|
-
// Regex patterns for a best-effort attempt at blocking PII in HTTP requests
|
|
75
|
-
const HTTP_PII_BLOCKING_PATTERNS = [
|
|
76
|
-
// Match credit cards [https://www.regular-expressions.info/creditcard.html]
|
|
77
|
-
// Visa
|
|
78
|
-
/\b4\d{12}(?:\d{3})?\b/g,
|
|
79
|
-
// MasterCard
|
|
80
|
-
/\b(?:5[1-5]\d{2}|222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}\b/g,
|
|
81
|
-
// Amex
|
|
82
|
-
/\b3[47]\d{13}\b/g,
|
|
83
|
-
// Diners Club
|
|
84
|
-
/\b3(?:0[0-5]|[68]\d)\d{11}\b/g,
|
|
85
|
-
// Discover
|
|
86
|
-
/\b6(?:011|5\d{2})\d{12}\b/g,
|
|
87
|
-
// JCB
|
|
88
|
-
/\b(?:2131|1800|35\d{3})\d{11}\b/g,
|
|
89
|
-
// Emails [https://www.regular-expressions.info/email.html]
|
|
90
|
-
PII_EMAIL_PATTERN,
|
|
91
|
-
// US SSN with or without dashes
|
|
92
|
-
// [https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s12.html]
|
|
93
|
-
/\b(?!000|666)[0-8]\d{2}[-.● ]?(?!00)\d{2}[-.● ]?(?!0000)\d{4}\b/g,
|
|
94
|
-
// Canadian SIN with or without dashes [https://regexpattern.com/social-insurance-number-ca]
|
|
95
|
-
/\b(\d{3}[-.● ]?\d{3}[-.● ]?\d{3})\b/g,
|
|
96
|
-
// International phone numbers
|
|
97
|
-
// [https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s03.html]
|
|
98
|
-
/\+(?:\d●?){6,14}\d\b/g,
|
|
99
|
-
// US/Canada phone numbers
|
|
100
|
-
// [https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s02.html]
|
|
101
|
-
/(\b|\+)?(1[-.● ]?)?\(?(\d{3})\)?[-.● ]?(\d{3})[-.● ]?(\d{4})\b/g,
|
|
102
|
-
];
|
|
103
|
-
const DEFAULT_WEBSITE_SUBDOMAIN_PATTERN = /^www\d{0,2}$/;
|
|
104
13
|
const PII_REDACTION_REPLACEMENT_STRING = '******';
|
|
105
|
-
// default string for stack frame fields
|
|
106
|
-
const DEFAULT_STACK_FRAME_FIELD_VALUE = '_';
|
|
107
|
-
// current PageVisit version to be sent from front end services
|
|
108
|
-
const CURRENT_PV_VERSION = 5;
|
|
109
|
-
// current metrics version to be sent from front end services.
|
|
110
|
-
const CURRENT_METRICS_VERSION = 1;
|
|
111
14
|
// severity levels for the collect error log
|
|
112
15
|
const SEVERITY = {
|
|
113
16
|
error: 'error',
|
|
@@ -119,313 +22,58 @@ const SEVERITY = {
|
|
|
119
22
|
// to our backend. This needs to be less than Silverbolt's session innactivity
|
|
120
23
|
// time so that PVs don't become part of a separate web session.
|
|
121
24
|
const MAX_METROPLEX_SOCKET_INNACTIVE_TIME = 60 * 35;
|
|
122
|
-
// maximum number of page visits assigned to a single browser id
|
|
123
|
-
const MAX_PAGEVISIT_VISITED = 300;
|
|
124
|
-
const MAX_PAGEVISIT_EVENTS = 200;
|
|
125
|
-
// maximum ids that a user can add to a pagevisit
|
|
126
|
-
const MAX_CUSTOM_IDS_PER_PAGEVISIT = 10;
|
|
127
|
-
const MAX_CUSTOM_ERRORS_PER_PAGEVISIT = 500;
|
|
128
|
-
const NOIBUJS_SDK_REQUEST_HELP_CODE = 'requestHelpCode';
|
|
129
|
-
const NOIBUJS_SDK_ADD_ID_FUNCTION = 'addCustomAttribute';
|
|
130
|
-
const NOIBUJS_SDK_ADD_ERROR_FUNCTION = 'addError';
|
|
131
|
-
const NOIBUJS_SDK_ADD_ERROR_FROM_JS_FMW_FUNCTION = 'addJsSdkError';
|
|
132
|
-
// will return a regex that will match
|
|
133
|
-
// any keywords that may indicate that users are moving
|
|
134
|
-
// forward in the sales funnel. It will match add to cart, checkout,
|
|
135
|
-
// and any other relevant text.
|
|
136
|
-
// INFO: WHEN ARCEE CHANGES THE REGEX PATTERN, THIS NEEDS TO CHANGE TOO
|
|
137
|
-
// will return a regex that will match
|
|
138
|
-
// any keywords that may indicate that users are moving
|
|
139
|
-
// forward in the sales funnel. It will match add to cart, checkout,
|
|
140
|
-
// and any other relevant text.
|
|
141
|
-
// INFO: WHEN ARCEE CHANGES THE REGEX PATERN, THIS NEEDS TO CHANGE TOO
|
|
142
|
-
// text that have this id will not be masked, change arcee/src/models/websessions/pv_event.rs
|
|
143
|
-
const WHITELIST_HTML_ID_TEXT_REGEX = 'method|finance|sagepay|cart|bag|coupon|affirm|karna|sezzle|button';
|
|
144
|
-
// regex of human readable content based on content-type header
|
|
145
|
-
const HUMAN_READABLE_CONTENT_TYPE_REGEX = 'text|json|xml|html|graphql|x-www-form-urlencoded|form-data';
|
|
146
|
-
// the following constants are the data types that metroplex expexcts
|
|
147
|
-
const PV_METROPLEX_TYPE = 'p';
|
|
148
|
-
const VIDEO_METROPLEX_TYPE = 'v';
|
|
149
|
-
const META_DATA_METROPLEX_TYPE = 'm';
|
|
150
|
-
const HTTP_DATA_METROPLEX_TYPE = 'h';
|
|
151
|
-
// type for custom id metadata type
|
|
152
|
-
const CUSTOM_ID_NAME_TYPE = 'id_name';
|
|
153
|
-
const CUSTOM_ID_VALUE_TYPE = 'id_val';
|
|
154
|
-
// the following constants are attribute names that metroplex expects
|
|
155
|
-
// TODO: write functions that will create the necessary objects to be
|
|
156
|
-
// used as data input for metroplex instead of creating those objects them in the
|
|
157
|
-
// js files
|
|
158
|
-
const BROWSER_ID_ATT_NAME = 'br_id';
|
|
159
|
-
const PV_ID_ATT_NAME = 'pv_id';
|
|
160
|
-
const VER_ATT_NAME = 'v';
|
|
161
|
-
const PV_SEQ_ATT_NAME = 'seq';
|
|
162
|
-
const VIDEO_RECORDER_ATT_NAME = 'video_recorder';
|
|
163
|
-
const ON_URL_ATT_NAME = 'on_url';
|
|
164
|
-
const URL_ATT_NAME = 'url';
|
|
165
|
-
const REF_URL_ATT_NAME = 'ref_url';
|
|
166
|
-
const STARTED_AT_ATT_NAME = 'start_at';
|
|
167
|
-
const PV_EVENTS_ATT_NAME = 'events';
|
|
168
|
-
const PV_PART_COUNTER_ATT_NAME = 'pc';
|
|
169
|
-
const CONN_COUNT_ATT_NAME = 'conc';
|
|
170
|
-
const COLLECT_VER_ATT_NAME = 'cv';
|
|
171
|
-
const VIDEO_FRAG_ATT_NAME = 'vid';
|
|
172
|
-
const CSS_URLS_ATT_NAME = 'css_urls';
|
|
173
|
-
const END_AT_ATT_NAME = 'end_at';
|
|
174
|
-
const LENGTH_ATT_NAME = 'len';
|
|
175
|
-
const IS_LAST_ATT_NAME = 'last';
|
|
176
|
-
const TYPE_ATT_NAME = 'type';
|
|
177
|
-
const OCCURRED_AT_ATT_NAME = 'occ_at';
|
|
178
|
-
const HTTP_CODE_ATT_NAME = 'h_code';
|
|
179
|
-
const JS_ERROR_ATT_NAME = 'j_err';
|
|
180
|
-
const GQL_ERROR_ATT_NAME = 'gql_err';
|
|
181
|
-
const TAGNAME_ATT_NAME = 'tag';
|
|
182
|
-
const SOURCE_ATT_NAME = 'src';
|
|
183
|
-
const TEXT_ATT_NAME = 'txt';
|
|
184
|
-
const HTMLID_ATT_NAME = 'hid';
|
|
185
|
-
const HTTP_METHOD_ATT_NAME = 'mtd';
|
|
186
|
-
const HTTP_RESP_CODE_ATT_NAME = 'code';
|
|
187
|
-
const HTTP_RESP_TIME_ATT_NAME = 'r_time';
|
|
188
|
-
const HTTP_RESP_LENGTH_ATT_NAME = 'resp_len';
|
|
189
|
-
const HTTP_DATA_PAYLOAD_ATT_NAME = 'rqp';
|
|
190
|
-
const HTTP_DATA_RESP_PAYLOAD_ATT_NAME = 'rsp';
|
|
191
|
-
const HTTP_DATA_REQ_HEADERS_ATT_NAME = 'rqh';
|
|
192
|
-
const HTTP_DATA_RESP_HEADERS_ATT_NAME = 'rsh';
|
|
193
|
-
const JS_STACK_LINE_ATT_NAME = 'line';
|
|
194
|
-
const JS_STACK_METHOD_ATT_NAME = 'mname';
|
|
195
|
-
const JS_STACK_FILE_ATT_NAME = 'file';
|
|
196
|
-
const JS_STACK_FRAMES_ATT_NAME = 'frames';
|
|
197
|
-
const JS_STACK_MESSAGE_ATT_NAME = 'msg';
|
|
198
|
-
const ERROR_SOURCE_ATT_NAME = 'err_src';
|
|
199
|
-
const CSS_CLASS_ATT_NAME = 'class';
|
|
200
|
-
const SEQ_NUM_ATT_NAME = 'seq_num';
|
|
201
|
-
const HELP_CODE_ATT_NAME = 'hc';
|
|
202
|
-
const WORK_REQUEST_ATT_NAME = 'wr';
|
|
203
|
-
const SCRIPT_ID_ATT_NAME = 'script_id';
|
|
204
|
-
const SCRIPT_INSTANCE_ID_ATT_NAME = 'script_inst_id';
|
|
205
|
-
const METROPLEX_SOCKET_INSTANCE_ID_ATT_NAME = 'mp_sock_inst_id';
|
|
206
|
-
const SOCKET_INSTANCE_ID_ATT_NAME = 'sock_inst_id';
|
|
207
|
-
// The following are page visit metrics attributes
|
|
208
|
-
const EXP_VIDEO_LENGTH_ATT_NAME = 'exp_vid_len';
|
|
209
|
-
const PV_EXP_VF_SEQ_ATT_NAME = 'exp_vf_seq';
|
|
210
|
-
const PV_EXP_PART_COUNTER_ATT_NAME = 'exp_pc_seq';
|
|
211
|
-
const VIDEO_CLICKS_ATT_NAME = 'vid_clicks';
|
|
212
|
-
const PV_CLICKS_ATT_NAME = 'pv_clicks';
|
|
213
|
-
const DID_CUT_PV_ATT_NAME = 'did_cut_pv';
|
|
214
|
-
const DID_CUT_VID_ATT_NAME = 'did_cut_vid';
|
|
215
|
-
const DID_START_VID_ATT_NAME = 'did_start_vid';
|
|
216
|
-
const HTTP_COUNT_EXPECTED_ATT_NAME = 'exp_http';
|
|
217
|
-
const ERR_COUNT_EXPECTED_ATT_NAME = 'exp_err';
|
|
218
|
-
// http data metrics
|
|
219
|
-
const PV_EXP_HTTP_DATA_SEQ_ATT_NAME = 'exp_http_seq';
|
|
220
|
-
const PV_HTTP_PAYLOADS_COLLECTED_ATT_NAME = 'http_payloads';
|
|
221
|
-
const PV_HTTP_PAYLOADS_DROPPED_OVERSIZE_ATT_NAME = 'http_drop_oversize';
|
|
222
|
-
const PV_HTTP_PAYLOADS_DROPPED_TYPE_ATT_NAME = 'http_drop_type';
|
|
223
|
-
const PV_HTTP_REQUESTS_DROPPED_OVER_LIMIT = 'http_over_limit';
|
|
224
|
-
// the following are event types
|
|
225
|
-
const HTTP_EVENT_TYPE = 'http';
|
|
226
|
-
const JS_EVENT_TYPE = 'js';
|
|
227
|
-
const GQL_EVENT_TYPE = 'gql';
|
|
228
|
-
const USERSTEP_EVENT_TYPE = 'userstep';
|
|
229
|
-
const CLICK_EVENT_TYPE = 'click';
|
|
230
|
-
const KEYBOARD_EVENT_TYPE = 'kbd';
|
|
231
|
-
const ERROR_EVENT_TYPE = 'err';
|
|
232
|
-
const PAGE_EVENT_TYPE = 'page';
|
|
233
|
-
const APP_NAVIGATION_EVENT_TYPE = 'app_nav';
|
|
234
|
-
// complete page visit attributes
|
|
235
|
-
const PAGE_VISIT_INFORMATION_ATT_NAME = 'pvi';
|
|
236
|
-
const PAGE_VISIT_PART_ATT_NAME = 'pvp';
|
|
237
|
-
const PAGE_VISIT_VID_FRAG_ATT_NAME = 'pvvf';
|
|
238
|
-
const PAGE_VISIT_META_DATA_ATT_NAME = 'pvm';
|
|
239
|
-
const PAGE_VISIT_HTTP_DATA_ATT_NAME = 'pvh';
|
|
240
|
-
const VIDEO_PART_COUNT_ATT_NAME = 'vpnum';
|
|
241
25
|
// max size that can be sent from a beacon
|
|
242
26
|
// set to be 59kb right now
|
|
243
27
|
const MAX_BEACON_PAYLOAD_SIZE = 59000;
|
|
244
|
-
const MAX_RETRY_MSG_Q_SIZE = 500;
|
|
245
|
-
// maximum number of connection a single page visit can reach
|
|
246
|
-
const MAX_METROPLEX_CONNECTION_COUNT = 100;
|
|
247
|
-
// All urls that NoibuJS may talk to
|
|
248
|
-
const NOIBU_INPUT_URLS = [
|
|
249
|
-
'i.noibu',
|
|
250
|
-
'i.staging.noibu',
|
|
251
|
-
'input.staging.noibu',
|
|
252
|
-
'input.b.noibu',
|
|
253
|
-
'input.noibu',
|
|
254
|
-
'vf.staging.noibu',
|
|
255
|
-
'vf.noibu',
|
|
256
|
-
];
|
|
257
|
-
// the following are the routes declared in our backend systems
|
|
258
|
-
const METROPLEX_FRAG_ROUTE = 'pv_part';
|
|
259
|
-
const METROPLEX_ERROR_ROUTE = 'collect_error';
|
|
260
|
-
const METROPLEX_METRICS_ROUTE = 'metrics';
|
|
261
|
-
const METROPLEX_FULL_PV_ROUTE = 'pv';
|
|
262
|
-
// this message will be received from the socket if the client has to stop
|
|
263
|
-
// sending video messages
|
|
264
|
-
const STOP_STORING_VID_SOCKET_MESSAGE = 'vid_block';
|
|
265
|
-
// his message will be sent to the client if the client has to stop
|
|
266
|
-
// sending pv messages
|
|
267
|
-
const STOP_STORING_PV_SOCKET_MESSAGE = 'pv_block';
|
|
268
|
-
// this message will be received from the socket if the client has to stop
|
|
269
|
-
// execution and lock itself
|
|
270
|
-
const BLOCK_SOCKET_MESSAGE = 'full_block';
|
|
271
|
-
// message received when the connection needs to be closed for the session
|
|
272
|
-
const CLOSE_CONNECTION_FORCEFULLY = 'close_conn';
|
|
273
|
-
// this message will be received from the socket occasionnaly to indicate
|
|
274
|
-
// that the socket is healthy
|
|
275
|
-
const OK_SOCKET_MESSAGE = 'ok';
|
|
276
|
-
// types of error events
|
|
277
|
-
const XML_HTTP_REQUEST_ERROR_TYPE = 'XMLHttpRequest';
|
|
278
|
-
const ERROR_EVENT_ERROR_TYPE = 'ErrorEvent';
|
|
279
|
-
const ERROR_EVENT_UNHANDLED_REJECTION_TYPE = 'UnhandledRejectionError';
|
|
280
|
-
const EVENT_ERROR_TYPE = 'Event';
|
|
281
|
-
const RESPONSE_ERROR_TYPE = 'Response';
|
|
282
|
-
const GQL_ERROR_TYPE = 'GQLError';
|
|
283
|
-
const WRAPPED_EXCEPTION_ERROR_TYPE = 'WrappedException';
|
|
284
|
-
const FETCH_EXCEPTION_ERROR_TYPE = 'FetchException';
|
|
285
|
-
const ERROR_LOG_EVENT_ERROR_TYPE = 'ErrorLogEvent';
|
|
286
|
-
const CUSTOM_ERROR_EVENT_TYPE = 'CustomError';
|
|
287
|
-
// console functions that we override to capture errors
|
|
288
|
-
const CONSOLE_FUNCTION_OVERRIDES = ['error', 'warn', 'log'];
|
|
289
|
-
// page events we track in the session
|
|
290
|
-
// don't include beforeunload, it will affect bfcache
|
|
291
|
-
const PAGE_EVENTS_WINDOW = [
|
|
292
|
-
'pagehide',
|
|
293
|
-
'pageshow',
|
|
294
|
-
'focus',
|
|
295
|
-
'blur',
|
|
296
|
-
'popstate',
|
|
297
|
-
'online',
|
|
298
|
-
'offline',
|
|
299
|
-
'messageerror',
|
|
300
|
-
'languagechange',
|
|
301
|
-
'hashchange',
|
|
302
|
-
'beforeprint',
|
|
303
|
-
'afterprint',
|
|
304
|
-
'load',
|
|
305
|
-
'resize',
|
|
306
|
-
];
|
|
307
|
-
const PAGE_EVENTS_DOCUMENT = [
|
|
308
|
-
'visibilitychange',
|
|
309
|
-
'resume',
|
|
310
|
-
'freeze',
|
|
311
|
-
'readystatechange',
|
|
312
|
-
'cut',
|
|
313
|
-
'copy',
|
|
314
|
-
'paste',
|
|
315
|
-
];
|
|
316
28
|
// headers
|
|
317
29
|
const CONTENT_TYPE = 'content-type';
|
|
318
|
-
const CONTENT_LENGTH = 'content-length';
|
|
319
30
|
/**
|
|
320
|
-
*
|
|
321
31
|
* Gets the script id from the cookie object, returns default if cannot be found
|
|
322
32
|
*/
|
|
323
33
|
function GET_SCRIPT_ID() {
|
|
324
|
-
return "1.0.104-rn-sdk-0.2.
|
|
34
|
+
return "1.0.104-rn-sdk-0.2.7" ;
|
|
325
35
|
}
|
|
326
36
|
/**
|
|
327
|
-
*
|
|
328
|
-
* Checks if the script version is beta
|
|
329
|
-
*/
|
|
330
|
-
function IS_NJS_VERSION_BETA() {
|
|
331
|
-
return false;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
*
|
|
335
37
|
* Gets the max metro recon number
|
|
336
38
|
*/
|
|
337
39
|
function GET_MAX_METROPLEX_RECONNECTION_NUMBER() {
|
|
338
|
-
|
|
339
|
-
return "20";
|
|
340
|
-
}
|
|
341
|
-
catch (err) {
|
|
342
|
-
// during testing, we only try to connect twice before abandoning
|
|
343
|
-
return 2;
|
|
344
|
-
}
|
|
40
|
+
return parseInt("20") ;
|
|
345
41
|
}
|
|
346
42
|
/**
|
|
347
|
-
*
|
|
348
43
|
* Returns the amount of time in milliseconds to delay a new connection by
|
|
349
44
|
* if we have exceeded the max consecutive connection count
|
|
350
45
|
*/
|
|
351
46
|
function GET_METROPLEX_CONSECUTIVE_CONNECTION_DELAY() {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
catch (err) {
|
|
356
|
-
// during testing, we only delay by 1 second
|
|
357
|
-
return 1000;
|
|
358
|
-
}
|
|
47
|
+
return parseInt("1000")
|
|
48
|
+
;
|
|
359
49
|
}
|
|
360
50
|
/**
|
|
361
|
-
*
|
|
362
51
|
* gets the base url for metroplex's websocket connection
|
|
363
52
|
*/
|
|
364
53
|
function GET_METROPLEX_BASE_SOCKET_URL() {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
? // eslint-disable-next-line no-undef
|
|
369
|
-
BETA_METROPLEX_BASE_SOCKET_URL
|
|
370
|
-
: // eslint-disable-next-line no-undef
|
|
371
|
-
"wss://input.noibu.com";
|
|
372
|
-
// removing the leading / if any
|
|
373
|
-
if (metroplexBaseURL.endsWith('/')) {
|
|
374
|
-
return metroplexBaseURL.slice(0, -1);
|
|
375
|
-
}
|
|
376
|
-
return metroplexBaseURL;
|
|
377
|
-
}
|
|
378
|
-
catch (err) {
|
|
379
|
-
return 'ws://localhost:3000';
|
|
380
|
-
}
|
|
54
|
+
const metroplexBaseURL = "wss://input.noibu.com";
|
|
55
|
+
// removing trailing / if any
|
|
56
|
+
return metroplexBaseURL.endsWith('/') ? metroplexBaseURL.slice(0, -1) : metroplexBaseURL;
|
|
381
57
|
}
|
|
382
58
|
/**
|
|
383
59
|
* gets the base url for metroplex's HTTP requests
|
|
384
60
|
*/
|
|
385
61
|
function GET_METROPLEX_BASE_HTTP_URL() {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
? // eslint-disable-next-line no-undef
|
|
390
|
-
BETA_METROPLEX_BASE_HTTP_URL
|
|
391
|
-
: // eslint-disable-next-line no-undef
|
|
392
|
-
"https://input.noibu.com";
|
|
393
|
-
// removing the leading / if any
|
|
394
|
-
if (metroplexBaseURL.endsWith('/')) {
|
|
395
|
-
return metroplexBaseURL.slice(0, -1);
|
|
396
|
-
}
|
|
397
|
-
return metroplexBaseURL;
|
|
398
|
-
}
|
|
399
|
-
catch (err) {
|
|
400
|
-
return 'http://localhost:3000';
|
|
401
|
-
}
|
|
62
|
+
const metroplexBaseURL = "https://input.noibu.com";
|
|
63
|
+
// removing trailing / if any
|
|
64
|
+
return metroplexBaseURL.endsWith('/') ? metroplexBaseURL.slice(0, -1) : metroplexBaseURL;
|
|
402
65
|
}
|
|
403
66
|
/**
|
|
404
|
-
*
|
|
405
67
|
* Returns the URL that accepts http post requests
|
|
406
68
|
*/
|
|
407
69
|
function GET_METROPLEX_POST_URL() {
|
|
408
|
-
|
|
409
|
-
return `${httpBase}/${METROPLEX_FULL_PV_ROUTE}`;
|
|
70
|
+
return `${GET_METROPLEX_BASE_HTTP_URL()}/${MetroplexRoute.PageVisit}`;
|
|
410
71
|
}
|
|
411
72
|
/**
|
|
412
|
-
*
|
|
413
73
|
* Returns the URL for posting metrics data to Metroplex
|
|
414
74
|
*/
|
|
415
75
|
function GET_METROPLEX_METRICS_URL() {
|
|
416
|
-
return `${GET_METROPLEX_BASE_HTTP_URL()}/${
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
*
|
|
420
|
-
* gets the current env
|
|
421
|
-
*/
|
|
422
|
-
function JS_ENV() {
|
|
423
|
-
try {
|
|
424
|
-
return CURR_ENV;
|
|
425
|
-
}
|
|
426
|
-
catch (err) {
|
|
427
|
-
return 'test';
|
|
428
|
-
}
|
|
76
|
+
return `${GET_METROPLEX_BASE_HTTP_URL()}/${MetroplexRoute.Metrics}`;
|
|
429
77
|
}
|
|
430
78
|
/**
|
|
431
79
|
* gets the current env
|
|
@@ -433,28 +81,5 @@ function JS_ENV() {
|
|
|
433
81
|
function GET_DEVICE_ENV() {
|
|
434
82
|
return "react-native-expo" ;
|
|
435
83
|
}
|
|
436
|
-
// gets the frequency at which the client resends the message that were not confirmed by metroplex
|
|
437
|
-
const METROPLEX_RETRY_FREQUENCY = 30000;
|
|
438
|
-
const STACK_TRACE_SANITIZE_REGEXP = /(nbuGlobalPromiseRejectWrapper|(hermes.*InternalBytecode\/InternalBytecode))/gi;
|
|
439
|
-
const BLOCKLISTED_DOMAINS = {
|
|
440
|
-
'input.noibu.com': true,
|
|
441
|
-
'input.staging.noibu.com': true,
|
|
442
|
-
'vf.noibu.com': true,
|
|
443
|
-
'vf.staging.noibu.com': true,
|
|
444
|
-
'cdn.noibu.com': true,
|
|
445
|
-
};
|
|
446
|
-
// Maximum number of events in the RRWEB session recorder buffer
|
|
447
|
-
// before sending to Metroplex
|
|
448
|
-
const MAX_RECORDER_EVENT_BUFFER = 10;
|
|
449
|
-
// the max amount of time to wait for user events until freezing rrweb mutation events
|
|
450
|
-
const MAX_TIME_FOR_RECORDER_USER_EVENTS = 2000;
|
|
451
|
-
// custom event name for posting metrics
|
|
452
|
-
const POST_METRICS_EVENT_NAME = 'noibuPostMetrics';
|
|
453
|
-
const BODY_USED_ERROR = 'Response data unavailable due to an improperly wrapped fetch call';
|
|
454
|
-
// maximum number of HTTP data events including errors to collect per page visit
|
|
455
|
-
const MAX_HTTP_DATA_IF_ERROR_EVENT_COUNT = 120;
|
|
456
|
-
// the maximum size of http data payload that will be capture for success, otherwise it is dropped
|
|
457
|
-
// this is 64k
|
|
458
|
-
const MAX_SUCCESS_HTTP_DATA_PAYLOAD_LENGTH = 65536;
|
|
459
84
|
|
|
460
|
-
export {
|
|
85
|
+
export { CONTENT_TYPE, CURRENT_NOIBUJS_VERSION, GET_DEVICE_ENV, GET_MAX_METROPLEX_RECONNECTION_NUMBER, GET_METROPLEX_BASE_HTTP_URL, GET_METROPLEX_BASE_SOCKET_URL, GET_METROPLEX_CONSECUTIVE_CONNECTION_DELAY, GET_METROPLEX_METRICS_URL, GET_METROPLEX_POST_URL, GET_SCRIPT_ID, MAX_BEACON_PAYLOAD_SIZE, MAX_METROPLEX_SOCKET_INNACTIVE_TIME, MAX_STRING_LENGTH, MAX_TIME_FOR_UNSENT_DATA_MILLIS, PII_EMAIL_PATTERN, PII_REDACTION_REPLACEMENT_STRING, SEVERITY };
|
package/dist/entry/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import 'react-native-url-polyfill/auto';
|
|
2
|
+
import 'whatwg-fetch';
|
|
2
3
|
import globalInit from './init.js';
|
|
3
4
|
import { ErrorBoundary as ErrorBoundary$1 } from '../react/ErrorBoundary.js';
|
|
4
|
-
import InputManager from '../api/
|
|
5
|
+
import InputManager from '../api/InputManager.js';
|
|
5
6
|
import { noibuLog } from '../utils/log.js';
|
|
6
7
|
|
|
7
8
|
noibuLog('imported');
|
|
8
|
-
/**
|
|
9
|
-
* @param config
|
|
10
|
-
*/
|
|
9
|
+
/** @param config */
|
|
11
10
|
const setupNoibu = globalInit;
|
|
12
11
|
const NoibuJS = InputManager.getInstance().exposeFunctions();
|
|
13
12
|
const ErrorBoundary = ErrorBoundary$1;
|
package/dist/entry/init.js
CHANGED
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import uuid from 'react-native-uuid';
|
|
3
|
+
import { MetroplexRoute } from '../node_modules/@noibu/metroplex-ts-bindings/dist/index.js';
|
|
3
4
|
import { KeyboardInputMonitor } from '../monitors/KeyboardInputMonitor.js';
|
|
4
5
|
import { PageMonitor } from '../monitors/PageMonitor.js';
|
|
5
|
-
import { GET_METROPLEX_BASE_SOCKET_URL, GET_METROPLEX_BASE_HTTP_URL
|
|
6
|
-
import ClientConfig from '../api/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import MetroplexSocket from '../api/
|
|
10
|
-
import StoredPageVisit from '../api/
|
|
11
|
-
import HelpCode from '../api/
|
|
6
|
+
import { SEVERITY, GET_METROPLEX_BASE_SOCKET_URL, GET_METROPLEX_BASE_HTTP_URL } from '../constants.js';
|
|
7
|
+
import ClientConfig from '../api/ClientConfig.js';
|
|
8
|
+
import { isNoibuJSAlreadyLoaded } from '../utils/function.js';
|
|
9
|
+
import { PageVisitManager } from '../pageVisit/PageVisitManager.js';
|
|
10
|
+
import MetroplexSocket from '../api/MetroplexSocket.js';
|
|
11
|
+
import StoredPageVisit from '../api/StoredPageVisit.js';
|
|
12
|
+
import HelpCode from '../api/HelpCode.js';
|
|
12
13
|
import { AppNavigationMonitor } from '../monitors/AppNavigationMonitor.js';
|
|
13
14
|
import { noibuLog } from '../utils/log.js';
|
|
14
|
-
import SessionRecorder from '../sessionRecorder/
|
|
15
|
+
import SessionRecorder from '../sessionRecorder/SessionRecorder.js';
|
|
15
16
|
import { ClickMonitor } from '../monitors/ClickMonitor.js';
|
|
16
17
|
import { ErrorMonitor } from '../monitors/ErrorMonitor.js';
|
|
17
18
|
import { HTTPDataBundler } from '../monitors/http-tools/HTTPDataBundler.js';
|
|
18
19
|
import RequestMonitor from '../monitors/RequestMonitor.js';
|
|
19
20
|
|
|
21
|
+
// urls needed to communicate with our fe components
|
|
22
|
+
const REQUIRED_DATA_PROCESSING_URLS = ['metroplexSocketBase', 'metroplexHTTPBase', 'domain'];
|
|
23
|
+
/**
|
|
24
|
+
* isInvalidURLConfig will verify that Collect is being initializes with
|
|
25
|
+
* the correct env vars.
|
|
26
|
+
*/
|
|
27
|
+
function isInvalidURLConfig(urls) {
|
|
28
|
+
for (let i = 0; i < REQUIRED_DATA_PROCESSING_URLS.length; i += 1) {
|
|
29
|
+
const u = REQUIRED_DATA_PROCESSING_URLS[i];
|
|
30
|
+
if (!urls[u]) {
|
|
31
|
+
noibuLog('urlConfig invalid, reason', u);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
20
37
|
// these are set via rollup
|
|
21
38
|
const urlConfig = {
|
|
22
39
|
metroplexSocketBase: GET_METROPLEX_BASE_SOCKET_URL(),
|
|
23
40
|
metroplexHTTPBase: GET_METROPLEX_BASE_HTTP_URL(),
|
|
24
41
|
};
|
|
25
|
-
/**
|
|
26
|
-
* initilializes the script to start executing all of NJS features
|
|
27
|
-
*/
|
|
42
|
+
/** initilializes the script to start executing all of NJS features */
|
|
28
43
|
function globalInit(customerConfig) {
|
|
29
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
45
|
noibuLog('global init started');
|
|
@@ -38,11 +53,10 @@ function globalInit(customerConfig) {
|
|
|
38
53
|
noibuLog('exiting');
|
|
39
54
|
return;
|
|
40
55
|
}
|
|
41
|
-
const noibuErrorURL = `${urlConfig.metroplexHTTPBase}/${
|
|
56
|
+
const noibuErrorURL = `${urlConfig.metroplexHTTPBase}/${MetroplexRoute.CollectError}`;
|
|
42
57
|
// catch any errors that happened during initialization and send collect error
|
|
43
58
|
try {
|
|
44
|
-
yield ClientConfig.getInstance(noibuErrorURL, customerConfig)
|
|
45
|
-
.configurationPromise;
|
|
59
|
+
yield ClientConfig.getInstance(noibuErrorURL, customerConfig).configurationPromise;
|
|
46
60
|
// create an instance ID for this script
|
|
47
61
|
const instanceId = uuid.v4();
|
|
48
62
|
// verifying if collect was disabled by other microservices
|
|
@@ -54,7 +68,7 @@ function globalInit(customerConfig) {
|
|
|
54
68
|
// Call MetroplexSocket getInstance to have it setup the socket before anything
|
|
55
69
|
// else accesses it
|
|
56
70
|
const metroplexSocket = MetroplexSocket.getInstance(instanceId);
|
|
57
|
-
|
|
71
|
+
PageVisitManager.getInstance();
|
|
58
72
|
// Call the stored page visit get instance, so we post the previous page visit right away
|
|
59
73
|
StoredPageVisit.getInstance();
|
|
60
74
|
// singleton monitors
|
|
@@ -71,18 +85,18 @@ function globalInit(customerConfig) {
|
|
|
71
85
|
pageMonitor.monitor();
|
|
72
86
|
SessionRecorder.getInstance().recordUserSession();
|
|
73
87
|
if (metroplexSocket.connectionPromise) {
|
|
74
|
-
metroplexSocket.connectionPromise.catch((
|
|
88
|
+
metroplexSocket.connectionPromise.catch((error) => ClientConfig.getInstance().postInternalError({ msg: `Error during metroplexSocket initial connection`, error }, false, SEVERITY.error));
|
|
75
89
|
}
|
|
76
90
|
else {
|
|
77
91
|
throw new Error('metroplex socket not ready');
|
|
78
92
|
}
|
|
79
93
|
noibuLog('global init finished');
|
|
80
94
|
}
|
|
81
|
-
catch (
|
|
82
|
-
ClientConfig.getInstance().
|
|
95
|
+
catch (error) {
|
|
96
|
+
ClientConfig.getInstance().postInternalError({ msg: `Error during globalInit`, error }, true, SEVERITY.error);
|
|
83
97
|
noibuLog('exiting');
|
|
84
98
|
}
|
|
85
99
|
});
|
|
86
100
|
}
|
|
87
101
|
|
|
88
|
-
export { globalInit as default };
|
|
102
|
+
export { REQUIRED_DATA_PROCESSING_URLS, globalInit as default, isInvalidURLConfig };
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { SEVERITY
|
|
2
|
-
import { ReactNativeNavigationIntegration } from './integrations/
|
|
3
|
-
import ClientConfig from '../api/
|
|
1
|
+
import { SEVERITY } from '../constants.js';
|
|
2
|
+
import { ReactNativeNavigationIntegration } from './integrations/ReactNativeNavigationIntegration.js';
|
|
3
|
+
import ClientConfig from '../api/ClientConfig.js';
|
|
4
4
|
import { EventDebouncer } from '../pageVisit/EventDebouncer.js';
|
|
5
5
|
import { Singleton } from './BaseMonitor.js';
|
|
6
|
+
import '../node_modules/@noibu/metroplex-ts-bindings/dist/index.js';
|
|
7
|
+
import { EventType } from '../node_modules/@noibu/metroplex-ts-bindings/dist/EventType.js';
|
|
6
8
|
|
|
7
|
-
/**
|
|
8
|
-
* Attaches corresponding listener to the passed navigation integration
|
|
9
|
-
*/
|
|
9
|
+
/** Attaches corresponding listener to the passed navigation integration */
|
|
10
10
|
class AppNavigationMonitor extends Singleton {
|
|
11
|
-
/**
|
|
12
|
-
* Main method for starting the monitoring
|
|
13
|
-
*/
|
|
11
|
+
/** Main method for starting the monitoring */
|
|
14
12
|
monitor() {
|
|
15
13
|
try {
|
|
16
14
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
15
|
const Navigation = require('react-native-navigation');
|
|
18
16
|
const rnNavigation = Navigation === null || Navigation === void 0 ? void 0 : Navigation.Navigation;
|
|
19
17
|
if (rnNavigation) {
|
|
20
|
-
|
|
18
|
+
ReactNativeNavigationIntegration.getInstance().register(rnNavigation, AppNavigationMonitor.onNavigation);
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
21
|
catch (e) {
|
|
24
|
-
ClientConfig.getInstance().
|
|
22
|
+
ClientConfig.getInstance().postInternalError({
|
|
23
|
+
msg: `Error while trying to attach to navigation events`,
|
|
24
|
+
error: e,
|
|
25
|
+
}, false, SEVERITY.error);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
|
-
/**
|
|
28
|
-
* handler for updating navigation breadcrumbs and notifying metro of location change
|
|
29
|
-
*/
|
|
28
|
+
/** handler for updating navigation breadcrumbs and notifying metro of location change */
|
|
30
29
|
static onNavigation(breadcrumbs) {
|
|
31
30
|
ClientConfig.getInstance().currentLocationBreadcrumbs = breadcrumbs;
|
|
32
31
|
AppNavigationMonitor.reportLocationChange(breadcrumbs.pop());
|
|
33
32
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Called when the event needs to be emitted
|
|
36
|
-
*/
|
|
33
|
+
/** Called when the event needs to be emitted */
|
|
37
34
|
static reportLocationChange(currentLocation) {
|
|
38
|
-
const
|
|
39
|
-
|
|
35
|
+
const event = {
|
|
36
|
+
app_nav: { location: currentLocation || '' },
|
|
37
|
+
type: EventType.ApplicationNavigation,
|
|
38
|
+
};
|
|
39
|
+
EventDebouncer.getInstance().debounce(event);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|