noibu-react-native 0.2.6 → 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.
Files changed (97) hide show
  1. package/README.md +15 -15
  2. package/dist/api/{clientConfig.js → ClientConfig.js} +69 -52
  3. package/dist/api/{helpCode.js → HelpCode.js} +6 -13
  4. package/dist/api/InputManager.js +156 -0
  5. package/dist/api/{metroplexSocket.js → MetroplexSocket.js} +189 -178
  6. package/dist/api/StoredMetrics.js +158 -0
  7. package/dist/api/{storedPageVisit.js → StoredPageVisit.js} +61 -48
  8. package/dist/const_matchers.js +1 -5
  9. package/dist/constants.js +15 -390
  10. package/dist/entry/index.js +3 -4
  11. package/dist/entry/init.js +33 -19
  12. package/dist/monitors/AppNavigationMonitor.js +19 -19
  13. package/dist/monitors/BaseMonitor.js +9 -4
  14. package/dist/monitors/ClickMonitor.js +72 -76
  15. package/dist/monitors/ErrorMonitor.js +45 -55
  16. package/dist/monitors/KeyboardInputMonitor.js +13 -11
  17. package/dist/monitors/PageMonitor.js +25 -2
  18. package/dist/monitors/RequestMonitor.js +46 -57
  19. package/dist/monitors/http-tools/GqlErrorValidator.js +39 -69
  20. package/dist/monitors/http-tools/HTTPDataBundler.js +71 -66
  21. package/dist/monitors/integrations/{react-native-navigation-integration.js → ReactNativeNavigationIntegration.js} +15 -12
  22. package/dist/pageVisit/EventDebouncer.js +43 -74
  23. package/dist/pageVisit/HttpEventManager.js +88 -0
  24. package/dist/pageVisit/PageVisitManager.js +99 -0
  25. package/dist/pageVisit/pageVisitEventError.js +170 -280
  26. package/dist/react/ErrorBoundary.js +3 -6
  27. package/dist/sessionRecorder/{sessionRecorder.js → SessionRecorder.js} +58 -70
  28. package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +3 -5
  29. package/dist/storage/{rnStorageProvider.js → RNStorageProvider.js} +3 -7
  30. package/dist/storage/{storage.js → Storage.js} +17 -30
  31. package/dist/storage/{storageProvider.js → StorageProvider.js} +7 -8
  32. package/dist/utils/date.js +39 -50
  33. package/dist/utils/eventlistener.js +5 -12
  34. package/dist/utils/function.js +42 -113
  35. package/dist/utils/log.js +5 -5
  36. package/dist/utils/object.js +12 -12
  37. package/dist/utils/piiRedactor.js +31 -3
  38. package/dist/utils/stacktrace-parser.js +29 -21
  39. package/package.json +14 -14
  40. package/dist/api/inputManager.js +0 -227
  41. package/dist/api/storedMetrics.js +0 -198
  42. package/dist/pageVisit/pageVisit.js +0 -181
  43. package/dist/pageVisit/pageVisitEventHTTP.js +0 -98
  44. package/dist/pageVisit/userStep.js +0 -20
  45. package/dist/src/api/clientConfig.d.ts +0 -100
  46. package/dist/src/api/clientConfig.test.d.ts +0 -1
  47. package/dist/src/api/helpCode.d.ts +0 -23
  48. package/dist/src/api/inputManager.d.ts +0 -87
  49. package/dist/src/api/metroplexSocket.d.ts +0 -137
  50. package/dist/src/api/storedMetrics.d.ts +0 -73
  51. package/dist/src/api/storedPageVisit.d.ts +0 -40
  52. package/dist/src/const_matchers.d.ts +0 -1
  53. package/dist/src/constants.d.ts +0 -290
  54. package/dist/src/entry/index.d.ts +0 -14
  55. package/dist/src/entry/init.d.ts +0 -5
  56. package/dist/src/monitors/AppNavigationMonitor.d.ts +0 -18
  57. package/dist/src/monitors/BaseMonitor.d.ts +0 -13
  58. package/dist/src/monitors/BaseMonitor.test.d.ts +0 -1
  59. package/dist/src/monitors/ClickMonitor.d.ts +0 -31
  60. package/dist/src/monitors/ErrorMonitor.d.ts +0 -63
  61. package/dist/src/monitors/KeyboardInputMonitor.d.ts +0 -20
  62. package/dist/src/monitors/PageMonitor.d.ts +0 -20
  63. package/dist/src/monitors/RequestMonitor.d.ts +0 -94
  64. package/dist/src/monitors/http-tools/GqlErrorValidator.d.ts +0 -59
  65. package/dist/src/monitors/http-tools/HTTPDataBundler.d.ts +0 -112
  66. package/dist/src/monitors/integrations/react-native-navigation-integration.d.ts +0 -20
  67. package/dist/src/pageVisit/EventDebouncer.d.ts +0 -24
  68. package/dist/src/pageVisit/pageVisit.d.ts +0 -52
  69. package/dist/src/pageVisit/pageVisitEventError.d.ts +0 -15
  70. package/dist/src/pageVisit/pageVisitEventHTTP.d.ts +0 -25
  71. package/dist/src/pageVisit/userStep.d.ts +0 -5
  72. package/dist/src/react/ErrorBoundary.d.ts +0 -72
  73. package/dist/src/sessionRecorder/nativeSessionRecorderSubscription.d.ts +0 -79
  74. package/dist/src/sessionRecorder/sessionRecorder.d.ts +0 -60
  75. package/dist/src/sessionRecorder/types.d.ts +0 -91
  76. package/dist/src/storage/rnStorageProvider.d.ts +0 -23
  77. package/dist/src/storage/storage.d.ts +0 -39
  78. package/dist/src/storage/storageProvider.d.ts +0 -26
  79. package/dist/src/utils/date.d.ts +0 -6
  80. package/dist/src/utils/eventlistener.d.ts +0 -8
  81. package/dist/src/utils/function.d.ts +0 -102
  82. package/dist/src/utils/log.d.ts +0 -4
  83. package/dist/src/utils/object.d.ts +0 -44
  84. package/dist/src/utils/performance.d.ts +0 -6
  85. package/dist/src/utils/piiRedactor.d.ts +0 -11
  86. package/dist/src/utils/polyfills.d.ts +0 -4
  87. package/dist/src/utils/stacktrace-parser.d.ts +0 -7
  88. package/dist/types/Config.d.ts +0 -31
  89. package/dist/types/Metroplex.types.d.ts +0 -73
  90. package/dist/types/NavigationIntegration.d.ts +0 -6
  91. package/dist/types/PageVisit.types.d.ts +0 -8
  92. package/dist/types/PageVisitErrors.types.d.ts +0 -114
  93. package/dist/types/PageVisitEvents.types.d.ts +0 -91
  94. package/dist/types/PageVisitMetrics.types.d.ts +0 -27
  95. package/dist/types/Storage.d.ts +0 -14
  96. package/dist/types/StoredPageVisit.types.d.ts +0 -11
  97. 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.6" ;
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
- try {
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
- try {
353
- return "1000";
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
- try {
366
- // webpack variables
367
- const metroplexBaseURL = IS_NJS_VERSION_BETA()
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
- try {
387
- // webpack variable
388
- const metroplexBaseURL = IS_NJS_VERSION_BETA()
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
- const httpBase = GET_METROPLEX_BASE_HTTP_URL();
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()}/${METROPLEX_METRICS_ROUTE}`;
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 { APP_NAVIGATION_EVENT_TYPE, BLOCKED_HTTP_HEADER_KEYS, BLOCKLISTED_DOMAINS, BLOCK_SOCKET_MESSAGE, BODY_USED_ERROR, BROWSER_ID_ATT_NAME, CLICK_EVENT_TYPE, CLIENT_LOCK_TIME_MINUTES, CLOSE_CONNECTION_FORCEFULLY, COLLECT_VER_ATT_NAME, CONN_COUNT_ATT_NAME, CONSOLE_FUNCTION_OVERRIDES, CONTENT_LENGTH, CONTENT_TYPE, CSS_CLASS_ATT_NAME, CSS_URLS_ATT_NAME, CURRENT_METRICS_VERSION, CURRENT_NOIBUJS_VERSION, CURRENT_PV_VERSION, CUSTOM_ERROR_EVENT_TYPE, CUSTOM_ID_NAME_TYPE, CUSTOM_ID_VALUE_TYPE, DEFAULT_STACK_FRAME_FIELD_VALUE, DEFAULT_WEBSITE_SUBDOMAIN_PATTERN, DID_CUT_PV_ATT_NAME, DID_CUT_VID_ATT_NAME, DID_START_VID_ATT_NAME, END_AT_ATT_NAME, ERROR_EVENT_ERROR_TYPE, ERROR_EVENT_TYPE, ERROR_EVENT_UNHANDLED_REJECTION_TYPE, ERROR_LOG_EVENT_ERROR_TYPE, ERROR_SOURCE_ATT_NAME, ERR_COUNT_EXPECTED_ATT_NAME, EVENT_ERROR_TYPE, EXP_VIDEO_LENGTH_ATT_NAME, FETCH_EXCEPTION_ERROR_TYPE, 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, GQL_ERROR_ATT_NAME, GQL_ERROR_TYPE, GQL_EVENT_TYPE, HELP_CODE_ATT_NAME, HTMLID_ATT_NAME, HTTP_BODY_DROPPED_LENGTH_MSG, HTTP_BODY_DROPPED_TYPE_MSG, HTTP_BODY_NULL_STRING, HTTP_CODE_ATT_NAME, HTTP_COUNT_EXPECTED_ATT_NAME, HTTP_DATA_METROPLEX_TYPE, HTTP_DATA_PAYLOAD_ATT_NAME, HTTP_DATA_REQ_HEADERS_ATT_NAME, HTTP_DATA_RESP_HEADERS_ATT_NAME, HTTP_DATA_RESP_PAYLOAD_ATT_NAME, HTTP_EVENT_TYPE, HTTP_METHOD_ATT_NAME, HTTP_PII_BLOCKING_PATTERNS, HTTP_RESP_CODE_ATT_NAME, HTTP_RESP_LENGTH_ATT_NAME, HTTP_RESP_TIME_ATT_NAME, HUMAN_READABLE_CONTENT_TYPE_REGEX, IS_LAST_ATT_NAME, IS_NJS_VERSION_BETA, JS_ENV, JS_ERROR_ATT_NAME, JS_EVENT_TYPE, JS_STACK_FILE_ATT_NAME, JS_STACK_FRAMES_ATT_NAME, JS_STACK_LINE_ATT_NAME, JS_STACK_MESSAGE_ATT_NAME, JS_STACK_METHOD_ATT_NAME, KEYBOARD_EVENT_TYPE, LENGTH_ATT_NAME, MAX_BEACON_PAYLOAD_SIZE, MAX_COLLECT_ERROR_LOG, MAX_CUSTOM_ERRORS_PER_PAGEVISIT, MAX_CUSTOM_IDS_PER_PAGEVISIT, MAX_FRAMES_IN_ARRAY, MAX_HTTP_DATA_EVENT_COUNT, MAX_HTTP_DATA_IF_ERROR_EVENT_COUNT, MAX_HTTP_DATA_PAYLOAD_LENGTH, MAX_METROPLEX_CONNECTION_COUNT, MAX_METROPLEX_SOCKET_INNACTIVE_TIME, MAX_PAGEVISIT_EVENTS, MAX_PAGEVISIT_PARTS, MAX_PAGEVISIT_VISITED, MAX_RECORDER_EVENT_BUFFER, MAX_RETRY_MSG_Q_SIZE, MAX_STRING_LENGTH, MAX_SUCCESS_HTTP_DATA_PAYLOAD_LENGTH, MAX_TIME_FOR_RECORDER_USER_EVENTS, MAX_TIME_FOR_UNSENT_DATA_MILLIS, META_DATA_METROPLEX_TYPE, METROPLEX_ERROR_ROUTE, METROPLEX_FRAG_ROUTE, METROPLEX_FULL_PV_ROUTE, METROPLEX_METRICS_ROUTE, METROPLEX_RETRY_FREQUENCY, METROPLEX_SOCKET_INSTANCE_ID_ATT_NAME, NOIBUJS_SDK_ADD_ERROR_FROM_JS_FMW_FUNCTION, NOIBUJS_SDK_ADD_ERROR_FUNCTION, NOIBUJS_SDK_ADD_ID_FUNCTION, NOIBUJS_SDK_REQUEST_HELP_CODE, NOIBU_BROWSER_ID_KYWRD, NOIBU_INPUT_URLS, NOIBU_LOCAL_STORAGE_TEST_KEY, NOIBU_STORED_PAGE_VISIT, OCCURRED_AT_ATT_NAME, OK_SOCKET_MESSAGE, ON_URL_ATT_NAME, PAGE_EVENTS_DOCUMENT, PAGE_EVENTS_WINDOW, PAGE_EVENT_TYPE, PAGE_VISIT_HTTP_DATA_ATT_NAME, PAGE_VISIT_INFORMATION_ATT_NAME, PAGE_VISIT_META_DATA_ATT_NAME, PAGE_VISIT_PART_ATT_NAME, PAGE_VISIT_VID_FRAG_ATT_NAME, PII_DIGIT_PATTERN, PII_EMAIL_PATTERN, PII_REDACTION_REPLACEMENT_STRING, POST_METRICS_EVENT_NAME, PV_CLICKS_ATT_NAME, PV_EVENTS_ATT_NAME, PV_EXP_HTTP_DATA_SEQ_ATT_NAME, PV_EXP_PART_COUNTER_ATT_NAME, PV_EXP_VF_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, PV_ID_ATT_NAME, PV_METROPLEX_TYPE, PV_PART_COUNTER_ATT_NAME, PV_SEQ_ATT_NAME, PV_SEQ_NUM_RESET_TIME_MINUTES, REF_URL_ATT_NAME, REQUIRED_DATA_PROCESSING_URLS, RESPONSE_ERROR_TYPE, SCRIPT_ID_ATT_NAME, SCRIPT_INSTANCE_ID_ATT_NAME, SEQ_NUM_ATT_NAME, SEVERITY, SOCKET_INSTANCE_ID_ATT_NAME, SOURCE_ATT_NAME, STACK_TRACE_SANITIZE_REGEXP, STARTED_AT_ATT_NAME, STOP_STORING_PV_SOCKET_MESSAGE, STOP_STORING_VID_SOCKET_MESSAGE, TAGNAME_ATT_NAME, TEXT_ATT_NAME, TYPE_ATT_NAME, URL_ATT_NAME, USERSTEP_EVENT_TYPE, VER_ATT_NAME, VIDEO_CLICKS_ATT_NAME, VIDEO_FRAG_ATT_NAME, VIDEO_METROPLEX_TYPE, VIDEO_PART_COUNT_ATT_NAME, VIDEO_RECORDER_ATT_NAME, WHITELIST_HTML_ID_TEXT_REGEX, WORK_REQUEST_ATT_NAME, WRAPPED_EXCEPTION_ERROR_TYPE, XML_HTTP_REQUEST_ERROR_TYPE };
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 };
@@ -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/inputManager.js';
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;
@@ -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, METROPLEX_ERROR_ROUTE, SEVERITY } from '../constants.js';
6
- import ClientConfig from '../api/clientConfig.js';
7
- import { isInvalidURLConfig, isNoibuJSAlreadyLoaded } from '../utils/function.js';
8
- import { PageVisit } from '../pageVisit/pageVisit.js';
9
- import MetroplexSocket from '../api/metroplexSocket.js';
10
- import StoredPageVisit from '../api/storedPageVisit.js';
11
- import HelpCode from '../api/helpCode.js';
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/sessionRecorder.js';
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}/${METROPLEX_ERROR_ROUTE}`;
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
- PageVisit.configureInstance();
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((e) => ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(`Error during metroplexSocket initial connection: ${e}`, false, SEVERITY.error));
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 (err) {
82
- ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(`Error during globalInit: ${err}`, true, SEVERITY.error);
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, APP_NAVIGATION_EVENT_TYPE } from '../constants.js';
2
- import { ReactNativeNavigationIntegration } from './integrations/react-native-navigation-integration.js';
3
- import ClientConfig from '../api/clientConfig.js';
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
- new ReactNativeNavigationIntegration().register(rnNavigation, AppNavigationMonitor.onNavigation);
18
+ ReactNativeNavigationIntegration.getInstance().register(rnNavigation, AppNavigationMonitor.onNavigation);
21
19
  }
22
20
  }
23
21
  catch (e) {
24
- ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(`AppNavigationMonitor: ${e}`, false, SEVERITY.error);
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 payload = { location: currentLocation || '' };
39
- EventDebouncer.getInstance().addEvent(payload, APP_NAVIGATION_EVENT_TYPE);
35
+ const event = {
36
+ app_nav: { location: currentLocation || '' },
37
+ type: EventType.ApplicationNavigation,
38
+ };
39
+ EventDebouncer.getInstance().debounce(event);
40
40
  }
41
41
  }
42
42