noibu-react-native 0.2.2 → 0.2.3

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 (78) hide show
  1. package/README.md +1 -1
  2. package/dist/api/clientConfig.js +225 -217
  3. package/dist/api/metroplexSocket.js +406 -416
  4. package/dist/constants.js +14 -2
  5. package/dist/entry/init.js +58 -56
  6. package/dist/monitors/appNavigationMonitor.js +2 -3
  7. package/dist/monitors/clickMonitor.js +16 -9
  8. package/dist/monitors/errorMonitor.js +30 -8
  9. package/dist/monitors/gqlErrorValidator.js +4 -4
  10. package/dist/monitors/httpDataBundler.js +525 -713
  11. package/dist/monitors/integrations/react-native-navigation-integration.js +4 -2
  12. package/dist/monitors/requestMonitor.js +350 -365
  13. package/dist/pageVisit/eventDebouncer.js +110 -0
  14. package/dist/pageVisit/pageVisitEventError.js +1 -1
  15. package/dist/pageVisit/pageVisitEventHTTP.js +78 -93
  16. package/dist/react/ErrorBoundary.js +18 -15
  17. package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +3 -2
  18. package/dist/sessionRecorder/sessionRecorder.js +151 -150
  19. package/dist/{api → src/api}/clientConfig.d.ts +1 -1
  20. package/dist/{api → src/api}/metroplexSocket.d.ts +25 -25
  21. package/dist/{constants.d.ts → src/constants.d.ts} +44 -0
  22. package/dist/{entry → src/entry}/init.d.ts +1 -1
  23. package/dist/{monitors → src/monitors}/clickMonitor.d.ts +1 -1
  24. package/dist/{monitors → src/monitors}/gqlErrorValidator.d.ts +6 -6
  25. package/dist/src/monitors/httpDataBundler.d.ts +127 -0
  26. package/dist/src/monitors/requestMonitor.d.ts +10 -0
  27. package/dist/src/pageVisit/eventDebouncer.d.ts +31 -0
  28. package/dist/src/pageVisit/pageVisitEventHTTP.d.ts +25 -0
  29. package/dist/{sessionRecorder → src/sessionRecorder}/types.d.ts +1 -1
  30. package/dist/{storage → src/storage}/storage.d.ts +1 -1
  31. package/dist/{storage → src/storage}/storageProvider.d.ts +1 -1
  32. package/dist/{utils → src/utils}/function.d.ts +25 -4
  33. package/dist/{utils → src/utils}/object.d.ts +9 -4
  34. package/dist/src/utils/piiRedactor.d.ts +11 -0
  35. package/dist/src/utils/polyfills.d.ts +7 -0
  36. package/dist/storage/rnStorageProvider.js +7 -4
  37. package/dist/storage/storage.js +43 -35
  38. package/dist/storage/storageProvider.js +23 -19
  39. package/dist/types/Config.d.ts +24 -20
  40. package/dist/types/PageVisit.types.d.ts +151 -0
  41. package/dist/types/PageVisitMetrics.types.d.ts +27 -0
  42. package/dist/types/RRWeb.d.ts +48 -0
  43. package/dist/types/StoredPageVisit.types.d.ts +2 -4
  44. package/dist/types/WrappedObjects.d.ts +6 -0
  45. package/dist/utils/function.js +110 -76
  46. package/dist/utils/object.js +58 -6
  47. package/dist/utils/piiRedactor.js +98 -0
  48. package/dist/utils/polyfills.js +24 -0
  49. package/package.json +5 -6
  50. package/dist/monitors/httpDataBundler.d.ts +0 -161
  51. package/dist/monitors/requestMonitor.d.ts +0 -10
  52. package/dist/pageVisit/pageVisitEventHTTP.d.ts +0 -18
  53. package/dist/types/PageVisit.d.ts +0 -22
  54. package/dist/types/globals.d.ts +0 -45
  55. /package/dist/{api → src/api}/helpCode.d.ts +0 -0
  56. /package/dist/{api → src/api}/inputManager.d.ts +0 -0
  57. /package/dist/{api → src/api}/storedMetrics.d.ts +0 -0
  58. /package/dist/{api → src/api}/storedPageVisit.d.ts +0 -0
  59. /package/dist/{const_matchers.d.ts → src/const_matchers.d.ts} +0 -0
  60. /package/dist/{entry → src/entry}/index.d.ts +0 -0
  61. /package/dist/{monitors → src/monitors}/appNavigationMonitor.d.ts +0 -0
  62. /package/dist/{monitors → src/monitors}/errorMonitor.d.ts +0 -0
  63. /package/dist/{monitors → src/monitors}/inputMonitor.d.ts +0 -0
  64. /package/dist/{monitors → src/monitors}/integrations/react-native-navigation-integration.d.ts +0 -0
  65. /package/dist/{monitors → src/monitors}/keyboardInputMonitor.d.ts +0 -0
  66. /package/dist/{monitors → src/monitors}/pageMonitor.d.ts +0 -0
  67. /package/dist/{pageVisit → src/pageVisit}/pageVisit.d.ts +0 -0
  68. /package/dist/{pageVisit → src/pageVisit}/pageVisitEventError.d.ts +0 -0
  69. /package/dist/{pageVisit → src/pageVisit}/userStep.d.ts +0 -0
  70. /package/dist/{react → src/react}/ErrorBoundary.d.ts +0 -0
  71. /package/dist/{sessionRecorder → src/sessionRecorder}/nativeSessionRecorderSubscription.d.ts +0 -0
  72. /package/dist/{sessionRecorder → src/sessionRecorder}/sessionRecorder.d.ts +0 -0
  73. /package/dist/{storage → src/storage}/rnStorageProvider.d.ts +0 -0
  74. /package/dist/{utils → src/utils}/date.d.ts +0 -0
  75. /package/dist/{utils → src/utils}/eventlistener.d.ts +0 -0
  76. /package/dist/{utils → src/utils}/log.d.ts +0 -0
  77. /package/dist/{utils → src/utils}/performance.d.ts +0 -0
  78. /package/dist/{utils → src/utils}/stacktrace-parser.d.ts +0 -0
@@ -1,3 +1,4 @@
1
+ import { __awaiter } from 'tslib';
1
2
  import uuid from 'react-native-uuid';
2
3
  import { getUserAgent, stringifyJSON, getVideoRecorderType } from '../utils/function.js';
3
4
  import { addSafeEventListener } from '../utils/eventlistener.js';
@@ -10,40 +11,8 @@ import { isDateOverwritten } from '../utils/date.js';
10
11
  import { unwrapNoibuWrapped } from '../utils/object.js';
11
12
  import { noibuLog } from '../utils/log.js';
12
13
 
13
- /** @module MetroplexSocket */
14
14
  /** Manages the socket to Metroplex */
15
15
  class MetroplexSocket {
16
- _initialURL;
17
- ackedOnce;
18
- connectionCount;
19
- // promise that will resolve once the socket is connected and metroplex has acknowledged
20
- connectionPromise;
21
- connectionURL;
22
- currentConnectionAttempts;
23
- forceClosed;
24
- helpCodeCb;
25
- initialReferingURL;
26
- static instance;
27
- instanceId;
28
- isRetryLoopDisabled;
29
- latestReceivedSeqNumStoredTime;
30
- latestReceivedSeqNumber;
31
- messageSequenceNum;
32
- metroRetryFrequencyMS;
33
- metroplexTypeLock;
34
- pageVisitInfoSent;
35
- postURL;
36
- previousMessageType;
37
- retryMessageQueue;
38
- retryMetroplexInterval;
39
- scriptInstanceId;
40
- sessionLength;
41
- sessionStartTime;
42
- sessionTimestamp;
43
- socket;
44
- socketInstanceId;
45
- socketCloseCodes;
46
- socketOpens;
47
16
  /**
48
17
  * Creates an instance of metroplex
49
18
  * id of script, to make sure only a single socket is open
@@ -165,50 +134,54 @@ class MetroplexSocket {
165
134
  * Queues the message if the connection isn't open yet.
166
135
  * returns true if message was sent succefully, false otherwise
167
136
  */
168
- async sendMessage(type, payload) {
169
- noibuLog('sendMessage start', { type, payload: JSON.stringify(payload) });
170
- // if we have a lock on this specific type, we dont send it
171
- if (type in this.metroplexTypeLock ||
172
- ClientConfig.getInstance().isClientDisabled) {
173
- noibuLog('sendMessage quitting due to', {
174
- typeInLock: type in this.metroplexTypeLock,
175
- isClientDisabled: ClientConfig.getInstance().isClientDisabled,
176
- });
177
- return false;
178
- }
179
- const payloadData = payload;
180
- if (type !== WORK_REQUEST_ATT_NAME) {
181
- // Increasing the message sequence number for every message we send to metroplex
182
- // and move the data to the retry queue.
183
- this._addSeqNumToPayload(type, payloadData);
184
- // push the message to the retry queue immediately in case socket isnt connected
185
- this.retryMessageQueue.push({ payload: payloadData, type });
186
- StoredPageVisit.getInstance().checkAndStoreRetryQueue(this.retryMessageQueue, await this.getPageInformation());
187
- }
188
- // send the socket message if we are connected and have sent page visit info
189
- if (this.isConnected() && this.pageVisitInfoSent) {
190
- // sending the data to metroplex
191
- await this._sendSocketMessage(payloadData);
192
- }
193
- this.previousMessageType = type;
194
- // Only update the last message send if its a page visit with user action
195
- // ensure this is done regardless of whether socket is connected or not,
196
- // so that pagehide will post PV if user is active but socket is not
197
- if (type === PV_METROPLEX_TYPE && payload[PAGE_VISIT_PART_ATT_NAME]) {
198
- const events = payload[PAGE_VISIT_PART_ATT_NAME][PV_EVENTS_ATT_NAME]
199
- ? payload[PAGE_VISIT_PART_ATT_NAME][PV_EVENTS_ATT_NAME]
200
- : [];
201
- await this._updateLatestPvTimestamp(events);
202
- }
203
- return true;
137
+ sendMessage(type, payload) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ noibuLog('sendMessage start', { type, payload: JSON.stringify(payload) });
140
+ // if we have a lock on this specific type, we dont send it
141
+ if (type in this.metroplexTypeLock ||
142
+ ClientConfig.getInstance().isClientDisabled) {
143
+ noibuLog('sendMessage quitting due to', {
144
+ typeInLock: type in this.metroplexTypeLock,
145
+ isClientDisabled: ClientConfig.getInstance().isClientDisabled,
146
+ });
147
+ return false;
148
+ }
149
+ const payloadData = payload;
150
+ if (type !== WORK_REQUEST_ATT_NAME) {
151
+ // Increasing the message sequence number for every message we send to metroplex
152
+ // and move the data to the retry queue.
153
+ this._addSeqNumToPayload(type, payloadData);
154
+ // push the message to the retry queue immediately in case socket isnt connected
155
+ this.retryMessageQueue.push({ payload: payloadData, type });
156
+ StoredPageVisit.getInstance().checkAndStoreRetryQueue(this.retryMessageQueue, yield this.getPageInformation());
157
+ }
158
+ // send the socket message if we are connected and have sent page visit info
159
+ if (this.isConnected() && this.pageVisitInfoSent) {
160
+ // sending the data to metroplex
161
+ yield this._sendSocketMessage(payloadData);
162
+ }
163
+ this.previousMessageType = type;
164
+ // Only update the last message send if its a page visit with user action
165
+ // ensure this is done regardless of whether socket is connected or not,
166
+ // so that pagehide will post PV if user is active but socket is not
167
+ if (type === PV_METROPLEX_TYPE && payload[PAGE_VISIT_PART_ATT_NAME]) {
168
+ const events = payload[PAGE_VISIT_PART_ATT_NAME][PV_EVENTS_ATT_NAME]
169
+ ? payload[PAGE_VISIT_PART_ATT_NAME][PV_EVENTS_ATT_NAME]
170
+ : [];
171
+ yield this._updateLatestPvTimestamp(events);
172
+ }
173
+ return true;
174
+ });
204
175
  }
205
176
  /** Updates the latest pv message sent timestamp if events contain any user steps
206
177
  */
207
- async _updateLatestPvTimestamp(events) {
208
- const userstepsEvents = events.filter(ev => ev[TYPE_ATT_NAME] === USERSTEP_EVENT_TYPE);
209
- if (userstepsEvents.length > 0) {
210
- await ClientConfig.getInstance().updateLastActiveTime(new Date());
211
- }
178
+ _updateLatestPvTimestamp(events) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ const userstepsEvents = events.filter(ev => ev[TYPE_ATT_NAME] === USERSTEP_EVENT_TYPE);
181
+ if (userstepsEvents.length > 0) {
182
+ yield ClientConfig.getInstance().updateLastActiveTime(new Date());
183
+ }
184
+ });
212
185
  }
213
186
  /** returns true if the socket is either connecting or connected to metroplex */
214
187
  isConnected() {
@@ -231,77 +204,79 @@ class MetroplexSocket {
231
204
  }
232
205
  /** Connects the web socket to metroplex and calls callback upon successfully connecting
233
206
  */
234
- async handleConnect(forceOpen) {
235
- noibuLog('metroplex handleConnect');
236
- // if we are connected or about to connect, we do not reset
237
- // the socket information
238
- if (!forceOpen && (this.isConnected() || this.isConnecting())) {
239
- return;
240
- }
241
- this.currentConnectionAttempts += 1;
242
- this.socket = new WebSocket(this.connectionURL, undefined, {
243
- headers: {
244
- 'User-Agent': await getUserAgent(), // must pass useragent explicitly
245
- },
246
- });
247
- this.socketInstanceId = uuid.v4();
248
- this.socket.onerror = error => {
249
- noibuLog('metroplex handleConnect, onerror', { error });
250
- // use for metrics
251
- // there is no useful error message/description from this event
252
- };
253
- // once the socket closes
254
- this.socket.onclose = async (event) => {
255
- noibuLog('metroplex handleConnect, onclose', { event });
256
- // Reset this to prevent sending messages before the PVI is sent on reconnect
257
- this.pageVisitInfoSent = false;
258
- // we do not reconnect if the page is unloading
259
- if (this.forceClosed) {
260
- return;
261
- }
262
- // track socket closure codes and times
263
- this.socketCloseCodes.push(`${!isDateOverwritten() ? new Date().toISOString() : ''}:${event.code}`);
264
- // we are already in the process of reconnecting
265
- // we do not attempt to reconnect yet
266
- if (this.isConnecting()) {
267
- return;
268
- }
269
- // Clear the interval that resends unconfirmed msgs so we don't try send while the socket
270
- // is and starting back up, after which it will be restarted
271
- if (this.retryMetroplexInterval) {
272
- clearInterval(this.retryMetroplexInterval);
273
- }
274
- // if we tried reconnecting too many times we abandon
275
- if (this.currentConnectionAttempts >=
276
- GET_MAX_METROPLEX_RECONNECTION_NUMBER()) {
277
- // if we tried beyond the threshold, we block ourselves a short
278
- // while fix the issue
279
- await ClientConfig.getInstance().lockClientUntilNextPage('Too many reconnection attempts, locking until next page');
280
- return;
281
- }
282
- // if we tried reconnecting too many times we abandon
283
- if (this.connectionCount >= MAX_METROPLEX_CONNECTION_COUNT) {
284
- // if we tried beyond the threshold, we block ourselves a short
285
- // while while fix the issue
286
- await ClientConfig.getInstance().lockClientUntilNextPage('Too many connections, locking until next page');
207
+ handleConnect(forceOpen) {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ noibuLog('metroplex handleConnect');
210
+ // if we are connected or about to connect, we do not reset
211
+ // the socket information
212
+ if (!forceOpen && (this.isConnected() || this.isConnecting())) {
287
213
  return;
288
214
  }
289
- // try to reconnect on close but after a certain delay based off unsuccessful connections
290
- setTimeout(() => {
291
- this.handleConnect(false);
292
- }, this.currentConnectionAttempts ** 2 * GET_METROPLEX_CONSECUTIVE_CONNECTION_DELAY());
293
- };
294
- // everytime we get a message from the socket
295
- this.socket.onmessage = event => {
296
- noibuLog('metroplex handleConnect, onmessage', { event });
297
- this._onSocketMessage(event);
298
- };
299
- // the moment we open the socket
300
- this.socket.onopen = () => {
301
- // track socket open codes and times
302
- this.socketOpens.push(`${!isDateOverwritten() ? new Date().toISOString() : ''}`);
303
- this._onSocketOpen();
304
- };
215
+ this.currentConnectionAttempts += 1;
216
+ this.socket = new WebSocket(this.connectionURL, undefined, {
217
+ headers: {
218
+ 'User-Agent': yield getUserAgent(), // must pass useragent explicitly
219
+ },
220
+ });
221
+ this.socketInstanceId = uuid.v4();
222
+ this.socket.onerror = error => {
223
+ noibuLog('metroplex handleConnect, onerror', { error });
224
+ // use for metrics
225
+ // there is no useful error message/description from this event
226
+ };
227
+ // once the socket closes
228
+ this.socket.onclose = (event) => __awaiter(this, void 0, void 0, function* () {
229
+ noibuLog('metroplex handleConnect, onclose', { event });
230
+ // Reset this to prevent sending messages before the PVI is sent on reconnect
231
+ this.pageVisitInfoSent = false;
232
+ // we do not reconnect if the page is unloading
233
+ if (this.forceClosed) {
234
+ return;
235
+ }
236
+ // track socket closure codes and times
237
+ this.socketCloseCodes.push(`${!isDateOverwritten() ? new Date().toISOString() : ''}:${event.code}`);
238
+ // we are already in the process of reconnecting
239
+ // we do not attempt to reconnect yet
240
+ if (this.isConnecting()) {
241
+ return;
242
+ }
243
+ // Clear the interval that resends unconfirmed msgs so we don't try send while the socket
244
+ // is and starting back up, after which it will be restarted
245
+ if (this.retryMetroplexInterval) {
246
+ clearInterval(this.retryMetroplexInterval);
247
+ }
248
+ // if we tried reconnecting too many times we abandon
249
+ if (this.currentConnectionAttempts >=
250
+ GET_MAX_METROPLEX_RECONNECTION_NUMBER()) {
251
+ // if we tried beyond the threshold, we block ourselves a short
252
+ // while fix the issue
253
+ yield ClientConfig.getInstance().lockClientUntilNextPage('Too many reconnection attempts, locking until next page');
254
+ return;
255
+ }
256
+ // if we tried reconnecting too many times we abandon
257
+ if (this.connectionCount >= MAX_METROPLEX_CONNECTION_COUNT) {
258
+ // if we tried beyond the threshold, we block ourselves a short
259
+ // while while fix the issue
260
+ yield ClientConfig.getInstance().lockClientUntilNextPage('Too many connections, locking until next page');
261
+ return;
262
+ }
263
+ // try to reconnect on close but after a certain delay based off unsuccessful connections
264
+ setTimeout(() => {
265
+ this.handleConnect(false);
266
+ }, Math.pow(this.currentConnectionAttempts, 2) * GET_METROPLEX_CONSECUTIVE_CONNECTION_DELAY());
267
+ });
268
+ // everytime we get a message from the socket
269
+ this.socket.onmessage = event => {
270
+ noibuLog('metroplex handleConnect, onmessage', { event });
271
+ this._onSocketMessage(event);
272
+ };
273
+ // the moment we open the socket
274
+ this.socket.onopen = () => {
275
+ // track socket open codes and times
276
+ this.socketOpens.push(`${!isDateOverwritten() ? new Date().toISOString() : ''}`);
277
+ this._onSocketOpen();
278
+ };
279
+ });
305
280
  }
306
281
  /**
307
282
  * connectSocket will establish a websocket connection to the metroplex
@@ -328,95 +303,96 @@ class MetroplexSocket {
328
303
  if (isPageVisit) {
329
304
  this.sessionLength = delta;
330
305
  }
331
- return {
332
- ...payload,
333
- [END_AT_ATT_NAME]: new Date(this.sessionTimestamp.getTime() + delta).toISOString(),
334
- };
306
+ return Object.assign(Object.assign({}, payload), { [END_AT_ATT_NAME]: new Date(this.sessionTimestamp.getTime() + delta).toISOString() });
335
307
  }
336
308
  /** open handler for socket */
337
- async _onSocketOpen() {
338
- // if we are not connected, we do not send any messages
339
- if (!this.isConnected() || ClientConfig.getInstance().isClientDisabled) {
340
- return;
341
- }
342
- await this._sendSocketMessage(await this.getPageInformation());
343
- // Set this to allow normal page visit and video frag messages to be sent
344
- this.pageVisitInfoSent = true;
345
- this.currentConnectionAttempts = 0;
346
- // Resend the pagevisit or video message type before sending data so reset the prev type
347
- this.previousMessageType = '';
348
- // attempt to send the unconfirmed messages again
349
- await this._sendUnconfirmedMessages(false);
350
- // setting up the socket retry mechanism
351
- this.setupRetryMechanism();
352
- // increasing the connection count everytime we connect
353
- this.connectionCount += 1;
309
+ _onSocketOpen() {
310
+ return __awaiter(this, void 0, void 0, function* () {
311
+ // if we are not connected, we do not send any messages
312
+ if (!this.isConnected() || ClientConfig.getInstance().isClientDisabled) {
313
+ return;
314
+ }
315
+ yield this._sendSocketMessage(yield this.getPageInformation());
316
+ // Set this to allow normal page visit and video frag messages to be sent
317
+ this.pageVisitInfoSent = true;
318
+ this.currentConnectionAttempts = 0;
319
+ // Resend the pagevisit or video message type before sending data so reset the prev type
320
+ this.previousMessageType = '';
321
+ // attempt to send the unconfirmed messages again
322
+ yield this._sendUnconfirmedMessages(false);
323
+ // setting up the socket retry mechanism
324
+ this.setupRetryMechanism();
325
+ // increasing the connection count everytime we connect
326
+ this.connectionCount += 1;
327
+ });
354
328
  }
355
329
  /** message handler for socket
356
330
  * @param {} event
357
331
  */
358
- async _onSocketMessage(event) {
359
- switch (event.data) {
360
- case STOP_STORING_VID_SOCKET_MESSAGE:
361
- // stopping vids from being sent
362
- this.metroplexTypeLock[VIDEO_METROPLEX_TYPE] = true;
363
- StoredMetrics.getInstance().setDidCutVideo();
364
- break;
365
- case STOP_STORING_PV_SOCKET_MESSAGE:
366
- // stopping pv from being sent
367
- this.metroplexTypeLock[PV_METROPLEX_TYPE] = true;
368
- StoredMetrics.getInstance().setDidCutPv();
369
- break;
370
- case BLOCK_SOCKET_MESSAGE:
371
- // we are disabling collect for 1 day if we get the
372
- // block message from metroplex. We are probably on it
373
- await ClientConfig.getInstance().lockClient(1440, 'Metroplex blocked script');
374
- this.close();
375
- break;
376
- case CLOSE_CONNECTION_FORCEFULLY:
377
- this.close();
378
- break;
379
- case OK_SOCKET_MESSAGE:
380
- // we do nothing on an OK
381
- break;
382
- default:
383
- // we now need to check if we receive text that contains
384
- // the text SEQ_NUM. if that is true, then its a seq num
385
- // and we need to clear out the retry queue.
386
- if (event.data.includes(SEQ_NUM_ATT_NAME)) {
387
- const seqNumSplit = event.data.split(`${SEQ_NUM_ATT_NAME}:`);
388
- if (seqNumSplit.length < 2) {
389
- ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(`Invalid message received from metroplex while clearing retry queue ${event.data}`, false, SEVERITY.error);
390
- break;
332
+ _onSocketMessage(event) {
333
+ return __awaiter(this, void 0, void 0, function* () {
334
+ switch (event.data) {
335
+ case STOP_STORING_VID_SOCKET_MESSAGE:
336
+ // stopping vids from being sent
337
+ this.metroplexTypeLock[VIDEO_METROPLEX_TYPE] = true;
338
+ StoredMetrics.getInstance().setDidCutVideo();
339
+ break;
340
+ case STOP_STORING_PV_SOCKET_MESSAGE:
341
+ // stopping pv from being sent
342
+ this.metroplexTypeLock[PV_METROPLEX_TYPE] = true;
343
+ StoredMetrics.getInstance().setDidCutPv();
344
+ break;
345
+ case BLOCK_SOCKET_MESSAGE:
346
+ // we are disabling collect for 1 day if we get the
347
+ // block message from metroplex. We are probably on it
348
+ yield ClientConfig.getInstance().lockClient(1440, 'Metroplex blocked script');
349
+ this.close();
350
+ break;
351
+ case CLOSE_CONNECTION_FORCEFULLY:
352
+ this.close();
353
+ break;
354
+ case OK_SOCKET_MESSAGE:
355
+ // we do nothing on an OK
356
+ break;
357
+ default:
358
+ // we now need to check if we receive text that contains
359
+ // the text SEQ_NUM. if that is true, then its a seq num
360
+ // and we need to clear out the retry queue.
361
+ if (event.data.includes(SEQ_NUM_ATT_NAME)) {
362
+ const seqNumSplit = event.data.split(`${SEQ_NUM_ATT_NAME}:`);
363
+ if (seqNumSplit.length < 2) {
364
+ ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(`Invalid message received from metroplex while clearing retry queue ${event.data}`, false, SEVERITY.error);
365
+ break;
366
+ }
367
+ // the second element in the string split is the sequence number
368
+ const seqNum = parseInt(seqNumSplit[1], 10);
369
+ // ignore sequence num if this is just page info, it will always be -1 and we don't want
370
+ // to disable the retry loop on this
371
+ if (seqNum === -1) {
372
+ break;
373
+ }
374
+ // we disable the retry loop if we start running behind
375
+ if (seqNum <= this.latestReceivedSeqNumber) {
376
+ this.isRetryLoopDisabled = true;
377
+ }
378
+ else {
379
+ this.isRetryLoopDisabled = false;
380
+ // setting the latest received seqNum
381
+ this.latestReceivedSeqNumber = seqNum;
382
+ // clear the retry queue when for this seqNum and below
383
+ this._clearRetryQueue(seqNum);
384
+ }
385
+ if (!this.ackedOnce) {
386
+ this.ackedOnce = true;
387
+ }
391
388
  }
392
- // the second element in the string split is the sequence number
393
- const seqNum = parseInt(seqNumSplit[1], 10);
394
- // ignore sequence num if this is just page info, it will always be -1 and we don't want
395
- // to disable the retry loop on this
396
- if (seqNum === -1) {
389
+ if (this._tryProcessHelpCodeResponse(event.data)) {
397
390
  break;
398
391
  }
399
- // we disable the retry loop if we start running behind
400
- if (seqNum <= this.latestReceivedSeqNumber) {
401
- this.isRetryLoopDisabled = true;
402
- }
403
- else {
404
- this.isRetryLoopDisabled = false;
405
- // setting the latest received seqNum
406
- this.latestReceivedSeqNumber = seqNum;
407
- // clear the retry queue when for this seqNum and below
408
- this._clearRetryQueue(seqNum);
409
- }
410
- if (!this.ackedOnce) {
411
- this.ackedOnce = true;
412
- }
413
- }
414
- if (this._tryProcessHelpCodeResponse(event.data)) {
415
392
  break;
416
- }
417
- break;
418
- // still need to collect the id sent back from metroplex
419
- }
393
+ // still need to collect the id sent back from metroplex
394
+ }
395
+ });
420
396
  }
421
397
  /**
422
398
  * Returns true if the message's payload has the payload type given and has a sequence
@@ -437,37 +413,39 @@ class MetroplexSocket {
437
413
  this._messagePayloadHasLargerSeqNum(message, PAGE_VISIT_VID_FRAG_ATT_NAME, seqNum));
438
414
  }
439
415
  /** will resend everything that is in the retry queue */
440
- async _sendUnconfirmedMessages(socketWasAlreadyOpen) {
441
- noibuLog('_sendUnconfirmedMessages');
442
- // we only check once. If the socket is disconnected midway, the events would
443
- // still be in the retry queue.
444
- if (!this.isConnected() || ClientConfig.getInstance().isClientDisabled) {
445
- return;
446
- }
447
- // We always send if this is on socket open
448
- if (socketWasAlreadyOpen) {
449
- // we do not send the messages to metroplex if we are falling behind on received
450
- // sequence numbers
451
- const someTimeAgo = new Date();
452
- someTimeAgo.setMilliseconds(someTimeAgo.getMilliseconds() - this.metroRetryFrequencyMS);
453
- if (someTimeAgo < this.latestReceivedSeqNumStoredTime) {
416
+ _sendUnconfirmedMessages(socketWasAlreadyOpen) {
417
+ return __awaiter(this, void 0, void 0, function* () {
418
+ noibuLog('_sendUnconfirmedMessages');
419
+ // we only check once. If the socket is disconnected midway, the events would
420
+ // still be in the retry queue.
421
+ if (!this.isConnected() || ClientConfig.getInstance().isClientDisabled) {
454
422
  return;
455
423
  }
456
- // we do not resend messages to metroplex if we are running behind
457
- if (this.isRetryLoopDisabled) {
458
- return;
424
+ // We always send if this is on socket open
425
+ if (socketWasAlreadyOpen) {
426
+ // we do not send the messages to metroplex if we are falling behind on received
427
+ // sequence numbers
428
+ const someTimeAgo = new Date();
429
+ someTimeAgo.setMilliseconds(someTimeAgo.getMilliseconds() - this.metroRetryFrequencyMS);
430
+ if (someTimeAgo < this.latestReceivedSeqNumStoredTime) {
431
+ return;
432
+ }
433
+ // we do not resend messages to metroplex if we are running behind
434
+ if (this.isRetryLoopDisabled) {
435
+ return;
436
+ }
459
437
  }
460
- }
461
- // removing all the messages with a blocked type from the retry queue
462
- this.retryMessageQueue = this.retryMessageQueue.filter(message => !(message.type in this.metroplexTypeLock));
463
- // we dont remove any items from this queue in this function
464
- for (let i = 0; i < this.retryMessageQueue.length; i += 1) {
465
- const { type, payload } = this.retryMessageQueue[i];
466
- // sending the data to metroplex
467
- // eslint-disable-next-line no-await-in-loop
468
- await this._sendSocketMessage(payload);
469
- this.previousMessageType = type;
470
- }
438
+ // removing all the messages with a blocked type from the retry queue
439
+ this.retryMessageQueue = this.retryMessageQueue.filter(message => !(message.type in this.metroplexTypeLock));
440
+ // we dont remove any items from this queue in this function
441
+ for (let i = 0; i < this.retryMessageQueue.length; i += 1) {
442
+ const { type, payload } = this.retryMessageQueue[i];
443
+ // sending the data to metroplex
444
+ // eslint-disable-next-line no-await-in-loop
445
+ yield this._sendSocketMessage(payload);
446
+ this.previousMessageType = type;
447
+ }
448
+ });
471
449
  }
472
450
  /** sets up the interval to empty the queue as we receive confirmation messages from metroplex */
473
451
  setupRetryMechanism() {
@@ -485,143 +463,149 @@ class MetroplexSocket {
485
463
  * will handle the final moments of a page being active. It
486
464
  * will try to empty both the queues with beacons.
487
465
  */
488
- async _handleUnload() {
489
- // closing the socket since the page is unloading
490
- this.close();
491
- // if we disable the client within the pagevisit, we do not
492
- // post anything during the unloading.
493
- if (ClientConfig.getInstance().isClientDisabled) {
494
- return;
495
- }
496
- // Don't send the final complete PV if the session has become inactive
497
- // we already sent the PV when went inactive
498
- if (ClientConfig.getInstance().isInactive()) {
499
- return;
500
- }
501
- await this.postFullPageVisit(MAX_BEACON_PAYLOAD_SIZE);
466
+ _handleUnload() {
467
+ return __awaiter(this, void 0, void 0, function* () {
468
+ // closing the socket since the page is unloading
469
+ this.close();
470
+ // if we disable the client within the pagevisit, we do not
471
+ // post anything during the unloading.
472
+ if (ClientConfig.getInstance().isClientDisabled) {
473
+ return;
474
+ }
475
+ // Don't send the final complete PV if the session has become inactive
476
+ // we already sent the PV when went inactive
477
+ if (ClientConfig.getInstance().isInactive()) {
478
+ return;
479
+ }
480
+ yield this.postFullPageVisit(MAX_BEACON_PAYLOAD_SIZE);
481
+ });
502
482
  }
503
483
  /**
504
484
  * will post full page visit to metroplex. It
505
485
  * will try to empty both the queues with beacons.
506
486
  */
507
- async postFullPageVisit(maxMessageSize) {
508
- if (this.retryMessageQueue.length === 0) {
509
- return;
510
- }
511
- // debug counters
512
- const postInfo = [];
513
- const numDropped = {
514
- [VIDEO_METROPLEX_TYPE]: 0,
515
- [PV_METROPLEX_TYPE]: 0,
516
- };
517
- let currentMsgPayloadSize = 0;
518
- let currentCompletePv = {
519
- [PAGE_VISIT_INFORMATION_ATT_NAME]: await this.getPageInformation(),
520
- [PAGE_VISIT_PART_ATT_NAME]: [],
521
- [PAGE_VISIT_VID_FRAG_ATT_NAME]: [],
522
- [PAGE_VISIT_HTTP_DATA_ATT_NAME]: [],
523
- [VIDEO_PART_COUNT_ATT_NAME]: this.connectionCount,
524
- };
525
- currentCompletePv[PAGE_VISIT_INFORMATION_ATT_NAME][IS_LAST_ATT_NAME] = true;
526
- const pageInfo = await this.getPageInformation();
527
- this.retryMessageQueue.forEach(msg => {
528
- // can't use two variables types in obj deconstruction
529
- // eslint-disable-next-line prefer-const
530
- let { type, payload } = msg;
531
- // If the message is larger than the beacon limit then skip to the next message
532
- const currentPayloadSize = new Blob([stringifyJSON(payload)]).size;
533
- if (currentPayloadSize > maxMessageSize) {
534
- // increment dropped count for this type
535
- numDropped[type] += 1;
487
+ postFullPageVisit(maxMessageSize) {
488
+ return __awaiter(this, void 0, void 0, function* () {
489
+ if (this.retryMessageQueue.length === 0) {
536
490
  return;
537
491
  }
538
- currentMsgPayloadSize += currentPayloadSize;
539
- if (currentMsgPayloadSize >= maxMessageSize) {
540
- this.postMessage(currentCompletePv);
541
- // add to post info
492
+ // debug counters
493
+ const postInfo = [];
494
+ const numDropped = {
495
+ [VIDEO_METROPLEX_TYPE]: 0,
496
+ [PV_METROPLEX_TYPE]: 0,
497
+ };
498
+ let currentMsgPayloadSize = 0;
499
+ let currentCompletePv = {
500
+ [PAGE_VISIT_INFORMATION_ATT_NAME]: yield this.getPageInformation(),
501
+ [PAGE_VISIT_PART_ATT_NAME]: [],
502
+ [PAGE_VISIT_VID_FRAG_ATT_NAME]: [],
503
+ [PAGE_VISIT_HTTP_DATA_ATT_NAME]: [],
504
+ [VIDEO_PART_COUNT_ATT_NAME]: this.connectionCount,
505
+ };
506
+ currentCompletePv[PAGE_VISIT_INFORMATION_ATT_NAME][IS_LAST_ATT_NAME] = true;
507
+ const pageInfo = yield this.getPageInformation();
508
+ this.retryMessageQueue.forEach(msg => {
509
+ // can't use two variables types in obj deconstruction
510
+ // eslint-disable-next-line prefer-const
511
+ let { type, payload } = msg;
512
+ // If the message is larger than the beacon limit then skip to the next message
513
+ const currentPayloadSize = new Blob([stringifyJSON(payload)]).size;
514
+ if (currentPayloadSize > maxMessageSize) {
515
+ // increment dropped count for this type
516
+ numDropped[type] += 1;
517
+ return;
518
+ }
519
+ currentMsgPayloadSize += currentPayloadSize;
520
+ if (currentMsgPayloadSize >= maxMessageSize) {
521
+ this.postMessage(currentCompletePv);
522
+ // add to post info
523
+ let postInfoMessage = `Vid: ${currentCompletePv[PAGE_VISIT_VID_FRAG_ATT_NAME].length}`;
524
+ postInfoMessage += ` PV: ${currentCompletePv[PAGE_VISIT_PART_ATT_NAME].length}`;
525
+ postInfoMessage += ` HTTP: ${currentCompletePv[PAGE_VISIT_HTTP_DATA_ATT_NAME].length},`;
526
+ postInfo.push(postInfoMessage);
527
+ // resetting currentCompletePv, since we need to keep adding
528
+ // events to a blank object to send to metroplex.
529
+ // retain the video part count, so we don't overwrite anything
530
+ currentCompletePv = {
531
+ [PAGE_VISIT_INFORMATION_ATT_NAME]: pageInfo,
532
+ [PAGE_VISIT_PART_ATT_NAME]: [],
533
+ [PAGE_VISIT_VID_FRAG_ATT_NAME]: [],
534
+ [PAGE_VISIT_HTTP_DATA_ATT_NAME]: [],
535
+ [VIDEO_PART_COUNT_ATT_NAME]: currentCompletePv[VIDEO_PART_COUNT_ATT_NAME],
536
+ };
537
+ currentCompletePv[PAGE_VISIT_INFORMATION_ATT_NAME][IS_LAST_ATT_NAME] =
538
+ true;
539
+ // resetting the message size based on what is being added
540
+ currentMsgPayloadSize = currentPayloadSize;
541
+ }
542
+ switch (type) {
543
+ case VIDEO_METROPLEX_TYPE:
544
+ currentCompletePv[PAGE_VISIT_VID_FRAG_ATT_NAME].push(payload[PAGE_VISIT_VID_FRAG_ATT_NAME]);
545
+ break;
546
+ case PV_METROPLEX_TYPE:
547
+ currentCompletePv[PAGE_VISIT_PART_ATT_NAME].push(payload[PAGE_VISIT_PART_ATT_NAME]);
548
+ break;
549
+ case HTTP_DATA_METROPLEX_TYPE:
550
+ currentCompletePv[PAGE_VISIT_HTTP_DATA_ATT_NAME].push(payload[PAGE_VISIT_HTTP_DATA_ATT_NAME]);
551
+ break;
552
+ }
553
+ });
554
+ this.postMessage(currentCompletePv);
555
+ // debug log if large retry message queue
556
+ if (this.retryMessageQueue.length > 100) {
542
557
  let postInfoMessage = `Vid: ${currentCompletePv[PAGE_VISIT_VID_FRAG_ATT_NAME].length}`;
543
558
  postInfoMessage += ` PV: ${currentCompletePv[PAGE_VISIT_PART_ATT_NAME].length}`;
544
559
  postInfoMessage += ` HTTP: ${currentCompletePv[PAGE_VISIT_HTTP_DATA_ATT_NAME].length},`;
545
560
  postInfo.push(postInfoMessage);
546
- // resetting currentCompletePv, since we need to keep adding
547
- // events to a blank object to send to metroplex.
548
- // retain the video part count, so we don't overwrite anything
549
- currentCompletePv = {
550
- [PAGE_VISIT_INFORMATION_ATT_NAME]: pageInfo,
551
- [PAGE_VISIT_PART_ATT_NAME]: [],
552
- [PAGE_VISIT_VID_FRAG_ATT_NAME]: [],
553
- [PAGE_VISIT_HTTP_DATA_ATT_NAME]: [],
554
- [VIDEO_PART_COUNT_ATT_NAME]: currentCompletePv[VIDEO_PART_COUNT_ATT_NAME],
555
- };
556
- currentCompletePv[PAGE_VISIT_INFORMATION_ATT_NAME][IS_LAST_ATT_NAME] =
557
- true;
558
- // resetting the message size based on what is being added
559
- currentMsgPayloadSize = currentPayloadSize;
560
- }
561
- switch (type) {
562
- case VIDEO_METROPLEX_TYPE:
563
- currentCompletePv[PAGE_VISIT_VID_FRAG_ATT_NAME].push(payload[PAGE_VISIT_VID_FRAG_ATT_NAME]);
564
- break;
565
- case PV_METROPLEX_TYPE:
566
- currentCompletePv[PAGE_VISIT_PART_ATT_NAME].push(payload[PAGE_VISIT_PART_ATT_NAME]);
567
- break;
568
- case HTTP_DATA_METROPLEX_TYPE:
569
- currentCompletePv[PAGE_VISIT_HTTP_DATA_ATT_NAME].push(payload[PAGE_VISIT_HTTP_DATA_ATT_NAME]);
570
- break;
561
+ // we completed posted the full pv, send the confirmation debug logs
562
+ // build the debug message
563
+ let message = 'POST Full PV complete';
564
+ // POST counts
565
+ message += `, POSTs count: ${postInfo.length}`;
566
+ message += `, POSTs info: ${stringifyJSON(postInfo)}`;
567
+ // Initial retry message queue size
568
+ message += `, Retry message queue size: ${this.retryMessageQueue.length}`;
569
+ // Num drops
570
+ if (numDropped[VIDEO_METROPLEX_TYPE] > 0) {
571
+ message += `, Video parts dropped: ${numDropped[VIDEO_METROPLEX_TYPE]}`;
572
+ }
573
+ if (numDropped[PV_METROPLEX_TYPE] > 0) {
574
+ message += `, Page visit parts dropped: ${numDropped[PV_METROPLEX_TYPE]}`;
575
+ }
576
+ if (numDropped[HTTP_DATA_METROPLEX_TYPE] > 0) {
577
+ message += `, HTTP data parts dropped: ${numDropped[HTTP_DATA_METROPLEX_TYPE]}`;
578
+ }
579
+ // Sequence info
580
+ message += `, Sequence Info: Latest ${this.messageSequenceNum}`;
581
+ message += ` Ack'd ${this.latestReceivedSeqNumStoredTime} ${this.latestReceivedSeqNumber}`;
582
+ // if client was disabled (due to inactive or otherwise) enable briefly so the
583
+ // debug message gets through
584
+ const clientDisabled = ClientConfig.getInstance().isClientDisabled;
585
+ ClientConfig.getInstance().isClientDisabled = false;
586
+ ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(message, clientDisabled, SEVERITY.warn);
571
587
  }
572
588
  });
573
- this.postMessage(currentCompletePv);
574
- // debug log if large retry message queue
575
- if (this.retryMessageQueue.length > 100) {
576
- let postInfoMessage = `Vid: ${currentCompletePv[PAGE_VISIT_VID_FRAG_ATT_NAME].length}`;
577
- postInfoMessage += ` PV: ${currentCompletePv[PAGE_VISIT_PART_ATT_NAME].length}`;
578
- postInfoMessage += ` HTTP: ${currentCompletePv[PAGE_VISIT_HTTP_DATA_ATT_NAME].length},`;
579
- postInfo.push(postInfoMessage);
580
- // we completed posted the full pv, send the confirmation debug logs
581
- // build the debug message
582
- let message = 'POST Full PV complete';
583
- // POST counts
584
- message += `, POSTs count: ${postInfo.length}`;
585
- message += `, POSTs info: ${stringifyJSON(postInfo)}`;
586
- // Initial retry message queue size
587
- message += `, Retry message queue size: ${this.retryMessageQueue.length}`;
588
- // Num drops
589
- if (numDropped[VIDEO_METROPLEX_TYPE] > 0) {
590
- message += `, Video parts dropped: ${numDropped[VIDEO_METROPLEX_TYPE]}`;
591
- }
592
- if (numDropped[PV_METROPLEX_TYPE] > 0) {
593
- message += `, Page visit parts dropped: ${numDropped[PV_METROPLEX_TYPE]}`;
594
- }
595
- if (numDropped[HTTP_DATA_METROPLEX_TYPE] > 0) {
596
- message += `, HTTP data parts dropped: ${numDropped[HTTP_DATA_METROPLEX_TYPE]}`;
597
- }
598
- // Sequence info
599
- message += `, Sequence Info: Latest ${this.messageSequenceNum}`;
600
- message += ` Ack'd ${this.latestReceivedSeqNumStoredTime} ${this.latestReceivedSeqNumber}`;
601
- // if client was disabled (due to inactive or otherwise) enable briefly so the
602
- // debug message gets through
603
- const clientDisabled = ClientConfig.getInstance().isClientDisabled;
604
- ClientConfig.getInstance().isClientDisabled = false;
605
- ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(message, clientDisabled, SEVERITY.warn);
606
- }
607
589
  }
608
590
  /**
609
591
  * will send a message to metroplex via a post request that will outlive the current page
610
592
  */
611
- async postMessage(msg) {
612
- const updatedMsg = msg;
613
- // ensure a unique video part number each call
614
- updatedMsg[VIDEO_PART_COUNT_ATT_NAME] += 1;
615
- // we send the remainder elements
616
- unwrapNoibuWrapped(fetch)(this.postURL, {
617
- method: 'POST',
618
- headers: {
619
- 'content-type': 'application/json',
620
- 'User-Agent': await getUserAgent(),
621
- },
622
- body: stringifyJSON(updatedMsg),
623
- // keep alive outlives the current page, its the same as beacon
624
- keepalive: true,
593
+ postMessage(msg) {
594
+ return __awaiter(this, void 0, void 0, function* () {
595
+ const updatedMsg = msg;
596
+ // ensure a unique video part number each call
597
+ updatedMsg[VIDEO_PART_COUNT_ATT_NAME] += 1;
598
+ // we send the remainder elements
599
+ unwrapNoibuWrapped(fetch)(this.postURL, {
600
+ method: 'POST',
601
+ headers: {
602
+ 'content-type': 'application/json',
603
+ 'User-Agent': yield getUserAgent(),
604
+ },
605
+ body: stringifyJSON(updatedMsg),
606
+ // keep alive outlives the current page, its the same as beacon
607
+ keepalive: true,
608
+ });
625
609
  });
626
610
  }
627
611
  /**
@@ -629,60 +613,66 @@ class MetroplexSocket {
629
613
  * is active and returns true. If inactive the session and socket are closed
630
614
  * and this method returns false.
631
615
  */
632
- async _sendSocketMessage(payload) {
633
- noibuLog('_sendSocketMessage');
634
- const closeIfInactive = await this.closeIfInactive();
635
- if (closeIfInactive) {
636
- noibuLog('_sendSocketMessage dropped due to', { closeIfInactive });
637
- return;
638
- }
639
- const payloadJson = stringifyJSON(payload);
640
- noibuLog(`_sendSocketMessage sending: ${payloadJson}`);
641
- if (this.socket) {
642
- this.socket.send(payloadJson);
643
- }
616
+ _sendSocketMessage(payload) {
617
+ return __awaiter(this, void 0, void 0, function* () {
618
+ noibuLog('_sendSocketMessage');
619
+ const closeIfInactive = yield this.closeIfInactive();
620
+ if (closeIfInactive) {
621
+ noibuLog('_sendSocketMessage dropped due to', { closeIfInactive });
622
+ return;
623
+ }
624
+ const payloadJson = stringifyJSON(payload);
625
+ noibuLog(`_sendSocketMessage sending: ${payloadJson}`);
626
+ if (this.socket) {
627
+ this.socket.send(payloadJson);
628
+ }
629
+ });
644
630
  }
645
631
  /**
646
632
  * Closes the socket connection if the session is inactive. Returns true if the
647
633
  * session is inactive
648
634
  */
649
- async closeIfInactive() {
650
- const inactive = ClientConfig.getInstance().isInactive();
651
- // if we weren't already inactive, go to inactive state
652
- if (inactive && !ClientConfig.getInstance().isClientDisabled) {
653
- // lock the client for 1 minute, since the lock expires
654
- // only on new page loads this will lock the client until
655
- // the next page is loaded.
656
- await ClientConfig.getInstance().lockClientUntilNextPage('Session is inactive, locking until next page');
657
- this.close();
658
- Promise.all([
659
- // post metrics now so we don't include events after going inactive
660
- StoredMetrics.getInstance().postMetrics(),
661
- // post retry queue now so we don't include event after going inactive
662
- this.postFullPageVisit(MAX_BEACON_PAYLOAD_SIZE),
663
- ]);
664
- }
665
- return inactive;
635
+ closeIfInactive() {
636
+ return __awaiter(this, void 0, void 0, function* () {
637
+ const inactive = ClientConfig.getInstance().isInactive();
638
+ // if we weren't already inactive, go to inactive state
639
+ if (inactive && !ClientConfig.getInstance().isClientDisabled) {
640
+ // lock the client for 1 minute, since the lock expires
641
+ // only on new page loads this will lock the client until
642
+ // the next page is loaded.
643
+ yield ClientConfig.getInstance().lockClientUntilNextPage('Session is inactive, locking until next page');
644
+ this.close();
645
+ Promise.all([
646
+ // post metrics now so we don't include events after going inactive
647
+ StoredMetrics.getInstance().postMetrics(),
648
+ // post retry queue now so we don't include event after going inactive
649
+ this.postFullPageVisit(MAX_BEACON_PAYLOAD_SIZE),
650
+ ]);
651
+ }
652
+ return inactive;
653
+ });
666
654
  }
667
655
  /** will get page information, calling this will increase the connection count */
668
- async getPageInformation() {
669
- return {
670
- [BROWSER_ID_ATT_NAME]: ClientConfig.getInstance().browserId,
671
- [PV_ID_ATT_NAME]: ClientConfig.getInstance().pageVisitId,
672
- [VER_ATT_NAME]: CURRENT_PV_VERSION,
673
- [PV_SEQ_ATT_NAME]: await ClientConfig.getInstance().getPageVisitSeq(),
674
- [ON_URL_ATT_NAME]: this._initialURL,
675
- [REF_URL_ATT_NAME]: this.initialReferingURL,
676
- [STARTED_AT_ATT_NAME]: this.sessionTimestamp.toISOString(),
677
- [CONN_COUNT_ATT_NAME]: this.connectionCount,
678
- [COLLECT_VER_ATT_NAME]: CURRENT_NOIBUJS_VERSION,
679
- [IS_LAST_ATT_NAME]: false,
680
- [SCRIPT_ID_ATT_NAME]: GET_SCRIPT_ID(),
681
- [SCRIPT_INSTANCE_ID_ATT_NAME]: this.scriptInstanceId,
682
- [METROPLEX_SOCKET_INSTANCE_ID_ATT_NAME]: this.instanceId,
683
- [SOCKET_INSTANCE_ID_ATT_NAME]: this.socketInstanceId,
684
- [VIDEO_RECORDER_ATT_NAME]: await getVideoRecorderType(),
685
- };
656
+ getPageInformation() {
657
+ return __awaiter(this, void 0, void 0, function* () {
658
+ return {
659
+ [BROWSER_ID_ATT_NAME]: ClientConfig.getInstance().browserId,
660
+ [PV_ID_ATT_NAME]: ClientConfig.getInstance().pageVisitId,
661
+ [VER_ATT_NAME]: CURRENT_PV_VERSION,
662
+ [PV_SEQ_ATT_NAME]: yield ClientConfig.getInstance().getPageVisitSeq(),
663
+ [ON_URL_ATT_NAME]: this._initialURL,
664
+ [REF_URL_ATT_NAME]: this.initialReferingURL,
665
+ [STARTED_AT_ATT_NAME]: this.sessionTimestamp.toISOString(),
666
+ [CONN_COUNT_ATT_NAME]: this.connectionCount,
667
+ [COLLECT_VER_ATT_NAME]: CURRENT_NOIBUJS_VERSION,
668
+ [IS_LAST_ATT_NAME]: false,
669
+ [SCRIPT_ID_ATT_NAME]: GET_SCRIPT_ID(),
670
+ [SCRIPT_INSTANCE_ID_ATT_NAME]: this.scriptInstanceId,
671
+ [METROPLEX_SOCKET_INSTANCE_ID_ATT_NAME]: this.instanceId,
672
+ [SOCKET_INSTANCE_ID_ATT_NAME]: this.socketInstanceId,
673
+ [VIDEO_RECORDER_ATT_NAME]: yield getVideoRecorderType(),
674
+ };
675
+ });
686
676
  }
687
677
  /**
688
678
  * Try to parse help code response and fire custom event