clarity-js 0.8.19 → 0.8.21

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.
@@ -1,8 +1,8 @@
1
1
  var dom = /*#__PURE__*/Object.freeze({
2
2
  __proto__: null,
3
- get add () { return add; },
3
+ get add () { return add$1; },
4
4
  get get () { return get; },
5
- get getId () { return getId; },
5
+ get getId () { return getId$1; },
6
6
  get getNode () { return getNode; },
7
7
  get getValue () { return getValue; },
8
8
  get has () { return has$1; },
@@ -164,24 +164,30 @@ function api(method) {
164
164
  }
165
165
 
166
166
  var startTime = 0;
167
+ function computeStartTime() {
168
+ return performance.now() + performance.timeOrigin;
169
+ }
167
170
  function start$I() {
168
- startTime = performance.now() + performance.timeOrigin;
171
+ startTime = computeStartTime();
169
172
  }
170
- // event.timestamp is number of milliseconds elapsed since the document was loaded
173
+ // event.timestamp is number of milliseconds elapsed since the document was loaded
171
174
  // since iframes can be loaded later the event timestamp is not the same as performance.now()
172
175
  // converting everything to absolute time by adding timeorigin of the event view
173
176
  // to synchronize times before calculating the difference with start time
174
177
  function time(event) {
175
178
  if (event === void 0) { event = null; }
179
+ // If startTime is 0, Clarity hasn't been started or has been stopped
180
+ // Use a local baseline to maintain relative timing semantics without affecting global state
181
+ var baseline = startTime === 0 ? computeStartTime() : startTime;
176
182
  var ts = event && event.timeStamp > 0 ? event.timeStamp : performance.now();
177
183
  var origin = event && event.view ? event.view.performance.timeOrigin : performance.timeOrigin;
178
- return Math.max(Math.round(ts + origin - startTime), 0);
184
+ return Math.max(Math.round(ts + origin - baseline), 0);
179
185
  }
180
186
  function stop$F() {
181
187
  startTime = 0;
182
188
  }
183
189
 
184
- var version$1 = "0.8.19";
190
+ var version$1 = "0.8.21";
185
191
 
186
192
  // tslint:disable: no-bitwise
187
193
  function hash (input, precision) {
@@ -653,7 +659,7 @@ function reset$r() {
653
659
  function setTimeout$1(handler, timeout, event) {
654
660
  return window.setTimeout(measure(handler), timeout, event);
655
661
  }
656
- function clearTimeout(handle) {
662
+ function clearTimeout$1(handle) {
657
663
  return window.clearTimeout(handle);
658
664
  }
659
665
 
@@ -667,7 +673,7 @@ function start$F() {
667
673
  }
668
674
  function reset$q() {
669
675
  if (timeout$7) {
670
- clearTimeout(timeout$7);
676
+ clearTimeout$1(timeout$7);
671
677
  }
672
678
  timeout$7 = setTimeout$1(ping, interval);
673
679
  last = time();
@@ -684,7 +690,7 @@ function ping() {
684
690
  }
685
691
  }
686
692
  function stop$C() {
687
- clearTimeout(timeout$7);
693
+ clearTimeout$1(timeout$7);
688
694
  last = 0;
689
695
  interval = 0;
690
696
  }
@@ -1251,7 +1257,7 @@ function recompute$8(evt) {
1251
1257
  var value = element.value;
1252
1258
  var checksum = value && value.length >= 5 /* Setting.WordLength */ && config$2.fraud && "password,secret,pass,social,ssn,code,hidden" /* Mask.Exclude */.indexOf(element.type) === -1 ? hash(value, 28 /* Setting.ChecksumPrecision */) : "" /* Constant.Empty */;
1253
1259
  state$a.push({ time: time(evt), event: 42 /* Event.Change */, data: { target: target(evt), type: element.type, value: value, checksum: checksum } });
1254
- schedule(encode$3.bind(this, 42 /* Event.Change */));
1260
+ schedule(encode$4.bind(this, 42 /* Event.Change */));
1255
1261
  }
1256
1262
  }
1257
1263
  function reset$m() {
@@ -1284,11 +1290,12 @@ function start$y() {
1284
1290
  }
1285
1291
  function observe$b(root) {
1286
1292
  bind(root, "click", handler$3.bind(this, 9 /* Event.Click */, root), true);
1293
+ bind(root, "contextmenu", handler$3.bind(this, 48 /* Event.ContextMenu */, root), true);
1287
1294
  }
1288
1295
  function handler$3(event, root, evt) {
1289
1296
  handler$3.dn = 6 /* FunctionNames.ClickHandler */;
1290
1297
  var frame = iframe(root);
1291
- var d = frame ? frame.contentDocument.documentElement : document.documentElement;
1298
+ var d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
1292
1299
  var x = "pageX" in evt ? Math.round(evt.pageX) : ("clientX" in evt ? Math.round(evt["clientX"] + d.scrollLeft) : null);
1293
1300
  var y = "pageY" in evt ? Math.round(evt.pageY) : ("clientY" in evt ? Math.round(evt["clientY"] + d.scrollTop) : null);
1294
1301
  // In case of iframe, we adjust (x,y) to be relative to top parent's origin
@@ -1334,7 +1341,7 @@ function handler$3(event, root, evt) {
1334
1341
  isFullText: textInfo.isFullText,
1335
1342
  }
1336
1343
  });
1337
- schedule(encode$3.bind(this, event));
1344
+ schedule(encode$4.bind(this, event));
1338
1345
  }
1339
1346
  }
1340
1347
  function link(node) {
@@ -1425,7 +1432,7 @@ function observe$a(root) {
1425
1432
  function recompute$7(action, evt) {
1426
1433
  recompute$7.dn = 7 /* FunctionNames.ClipboardRecompute */;
1427
1434
  state$8.push({ time: time(evt), event: 38 /* Event.Clipboard */, data: { target: target(evt), action: action } });
1428
- schedule(encode$3.bind(this, 38 /* Event.Clipboard */));
1435
+ schedule(encode$4.bind(this, 38 /* Event.Clipboard */));
1429
1436
  }
1430
1437
  function reset$k() {
1431
1438
  state$8 = [];
@@ -1461,18 +1468,18 @@ function recompute$6(evt) {
1461
1468
  state$7.pop();
1462
1469
  }
1463
1470
  state$7.push({ time: time(evt), event: 27 /* Event.Input */, data: data });
1464
- clearTimeout(timeout$6);
1471
+ clearTimeout$1(timeout$6);
1465
1472
  timeout$6 = setTimeout$1(process$7, 1000 /* Setting.InputLookAhead */, 27 /* Event.Input */);
1466
1473
  }
1467
1474
  }
1468
1475
  function process$7(event) {
1469
- schedule(encode$3.bind(this, event));
1476
+ schedule(encode$4.bind(this, event));
1470
1477
  }
1471
1478
  function reset$j() {
1472
1479
  state$7 = [];
1473
1480
  }
1474
1481
  function stop$u() {
1475
- clearTimeout(timeout$6);
1482
+ clearTimeout$1(timeout$6);
1476
1483
  reset$j();
1477
1484
  }
1478
1485
 
@@ -1498,7 +1505,7 @@ function observe$8(root) {
1498
1505
  function mouse(event, root, evt) {
1499
1506
  mouse.dn = 10 /* FunctionNames.PointerMouse */;
1500
1507
  var frame = iframe(root);
1501
- var d = frame ? frame.contentDocument.documentElement : document.documentElement;
1508
+ var d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
1502
1509
  var x = "pageX" in evt ? Math.round(evt.pageX) : ("clientX" in evt ? Math.round(evt["clientX"] + d.scrollLeft) : null);
1503
1510
  var y = "pageY" in evt ? Math.round(evt.pageY) : ("clientY" in evt ? Math.round(evt["clientY"] + d.scrollTop) : null);
1504
1511
  // In case of iframe, we adjust (x,y) to be relative to top parent's origin
@@ -1515,7 +1522,7 @@ function mouse(event, root, evt) {
1515
1522
  function touch(event, root, evt) {
1516
1523
  touch.dn = 11 /* FunctionNames.PointerTouch */;
1517
1524
  var frame = iframe(root);
1518
- var d = frame ? frame.contentDocument.documentElement : document.documentElement;
1525
+ var d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
1519
1526
  var touches = evt.changedTouches;
1520
1527
  var t = time(evt);
1521
1528
  if (touches) {
@@ -1567,7 +1574,7 @@ function handler$2(current) {
1567
1574
  state$6.pop();
1568
1575
  }
1569
1576
  state$6.push(current);
1570
- clearTimeout(timeout$5);
1577
+ clearTimeout$1(timeout$5);
1571
1578
  timeout$5 = setTimeout$1(process$6, 500 /* Setting.LookAhead */, current.event);
1572
1579
  break;
1573
1580
  default:
@@ -1577,7 +1584,7 @@ function handler$2(current) {
1577
1584
  }
1578
1585
  }
1579
1586
  function process$6(event) {
1580
- schedule(encode$3.bind(this, event));
1587
+ schedule(encode$4.bind(this, event));
1581
1588
  }
1582
1589
  function reset$i() {
1583
1590
  state$6 = [];
@@ -1592,7 +1599,7 @@ function similar$1(last, current) {
1592
1599
  return current.event === last.event && match && distance < 20 /* Setting.Distance */ && gap < 25 /* Setting.PointerInterval */ && sameId;
1593
1600
  }
1594
1601
  function stop$t() {
1595
- clearTimeout(timeout$5);
1602
+ clearTimeout$1(timeout$5);
1596
1603
  // Send out any pending pointer events in the pipeline
1597
1604
  if (state$6.length > 0) {
1598
1605
  process$6(state$6[state$6.length - 1].event);
@@ -1617,20 +1624,20 @@ function recompute$5() {
1617
1624
  height: de && "clientHeight" in de ? Math.min(de.clientHeight, window.innerHeight) : window.innerHeight,
1618
1625
  };
1619
1626
  if (initialStateLogged) {
1620
- clearTimeout(timeout$4);
1627
+ clearTimeout$1(timeout$4);
1621
1628
  timeout$4 = setTimeout$1(process$5, 500 /* Setting.LookAhead */, 11 /* Event.Resize */);
1622
1629
  }
1623
1630
  else {
1624
- encode$3(11 /* Event.Resize */);
1631
+ encode$4(11 /* Event.Resize */);
1625
1632
  initialStateLogged = true;
1626
1633
  }
1627
1634
  }
1628
1635
  function process$5(event) {
1629
- schedule(encode$3.bind(this, event));
1636
+ schedule(encode$4.bind(this, event));
1630
1637
  }
1631
1638
  function reset$h() {
1632
1639
  data$c = null;
1633
- clearTimeout(timeout$4);
1640
+ clearTimeout$1(timeout$4);
1634
1641
  }
1635
1642
  function stop$s() {
1636
1643
  reset$h();
@@ -1641,13 +1648,13 @@ function stop$s() {
1641
1648
  * every specified duration in milliseconds, ensuring the last event is not lost.
1642
1649
  * @param func - The function to throttle.
1643
1650
  * @param duration - The duration in milliseconds to wait before allowing the next execution.
1644
- * @returns A throttled version of the provided function.
1651
+ * @returns A throttled version of the provided function with a cleanup method.
1645
1652
  */
1646
1653
  function throttle(func, duration) {
1647
1654
  var lastExecutionTime = 0;
1648
1655
  var timeoutId = null;
1649
1656
  var lastArgs = null;
1650
- return function () {
1657
+ function throttledFunction() {
1651
1658
  var _this = this;
1652
1659
  var args = [];
1653
1660
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1672,7 +1679,16 @@ function throttle(func, duration) {
1672
1679
  lastExecutionTime = now;
1673
1680
  func.apply(this, args);
1674
1681
  }
1682
+ }
1683
+ // Add cleanup method to clear pending timeouts
1684
+ throttledFunction.cleanup = function () {
1685
+ if (timeoutId) {
1686
+ clearTimeout(timeoutId);
1687
+ timeoutId = null;
1688
+ lastArgs = null;
1689
+ }
1675
1690
  };
1691
+ return throttledFunction;
1676
1692
  }
1677
1693
 
1678
1694
  var state$5 = [];
@@ -1731,7 +1747,7 @@ function recompute$4(event) {
1731
1747
  state$5.pop();
1732
1748
  }
1733
1749
  state$5.push(current);
1734
- clearTimeout(timeout$3);
1750
+ clearTimeout$1(timeout$3);
1735
1751
  timeout$3 = setTimeout$1(process$4, 500 /* Setting.LookAhead */, 10 /* Event.Scroll */);
1736
1752
  }
1737
1753
  var throttledRecompute = throttle(recompute$4, 25 /* Setting.Throttle */);
@@ -1758,7 +1774,7 @@ function reset$g() {
1758
1774
  initialBottom = null;
1759
1775
  }
1760
1776
  function process$4(event) {
1761
- schedule(encode$3.bind(this, event));
1777
+ schedule(encode$4.bind(this, event));
1762
1778
  }
1763
1779
  function similar(last, current) {
1764
1780
  var dx = last.data.x - current.data.x;
@@ -1778,7 +1794,8 @@ function compute$8() {
1778
1794
  }
1779
1795
  }
1780
1796
  function stop$r() {
1781
- clearTimeout(timeout$3);
1797
+ clearTimeout$1(timeout$3);
1798
+ throttledRecompute.cleanup();
1782
1799
  state$5 = [];
1783
1800
  initialTop = null;
1784
1801
  initialBottom = null;
@@ -1812,7 +1829,7 @@ function recompute$3(root) {
1812
1829
  }
1813
1830
  var startNode = data$b.start ? data$b.start : null;
1814
1831
  if (previous !== null && data$b.start !== null && startNode !== current.anchorNode) {
1815
- clearTimeout(timeout$2);
1832
+ clearTimeout$1(timeout$2);
1816
1833
  process$3(21 /* Event.Selection */);
1817
1834
  }
1818
1835
  data$b = {
@@ -1822,11 +1839,11 @@ function recompute$3(root) {
1822
1839
  endOffset: current.focusOffset
1823
1840
  };
1824
1841
  previous = current;
1825
- clearTimeout(timeout$2);
1842
+ clearTimeout$1(timeout$2);
1826
1843
  timeout$2 = setTimeout$1(process$3, 500 /* Setting.LookAhead */, 21 /* Event.Selection */);
1827
1844
  }
1828
1845
  function process$3(event) {
1829
- schedule(encode$3.bind(this, event));
1846
+ schedule(encode$4.bind(this, event));
1830
1847
  }
1831
1848
  function reset$f() {
1832
1849
  previous = null;
@@ -1834,7 +1851,7 @@ function reset$f() {
1834
1851
  }
1835
1852
  function stop$q() {
1836
1853
  reset$f();
1837
- clearTimeout(timeout$2);
1854
+ clearTimeout$1(timeout$2);
1838
1855
  }
1839
1856
 
1840
1857
  var state$4 = [];
@@ -1847,7 +1864,7 @@ function observe$5(root) {
1847
1864
  function recompute$2(evt) {
1848
1865
  recompute$2.dn = 16 /* FunctionNames.SubmitRecompute */;
1849
1866
  state$4.push({ time: time(evt), event: 39 /* Event.Submit */, data: { target: target(evt) } });
1850
- schedule(encode$3.bind(this, 39 /* Event.Submit */));
1867
+ schedule(encode$4.bind(this, 39 /* Event.Submit */));
1851
1868
  }
1852
1869
  function reset$e() {
1853
1870
  state$4 = [];
@@ -1863,7 +1880,7 @@ function start$q() {
1863
1880
  function recompute$1(evt) {
1864
1881
  recompute$1.dn = 17 /* FunctionNames.UnloadRecompute */;
1865
1882
  data$a = { name: evt.type, persisted: evt.persisted ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */ };
1866
- encode$3(26 /* Event.Unload */, time(evt));
1883
+ encode$4(26 /* Event.Unload */, time(evt));
1867
1884
  stop();
1868
1885
  }
1869
1886
  function reset$d() {
@@ -1882,7 +1899,7 @@ function recompute(evt) {
1882
1899
  if (evt === void 0) { evt = null; }
1883
1900
  recompute.dn = 18 /* FunctionNames.VisibilityRecompute */;
1884
1901
  data$9 = { visible: "visibilityState" in document ? document.visibilityState : "default" };
1885
- encode$3(28 /* Event.Visibility */, time(evt));
1902
+ encode$4(28 /* Event.Visibility */, time(evt));
1886
1903
  }
1887
1904
  function reset$c() {
1888
1905
  data$9 = null;
@@ -2061,13 +2078,13 @@ function checkDocumentStyles(documentNode, timestamp) {
2061
2078
  }
2062
2079
  currentStyleSheets.push(styleSheet[styleSheetId]);
2063
2080
  }
2064
- var documentId = getId(documentNode, true);
2081
+ var documentId = getId$1(documentNode, true);
2065
2082
  if (!styleSheetMap[documentId]) {
2066
2083
  styleSheetMap[documentId] = [];
2067
2084
  }
2068
2085
  if (!arraysEqual(currentStyleSheets, styleSheetMap[documentId])) {
2069
2086
  // Using -1 to signify the root document node as we don't track that as part of our nodeMap
2070
- trackStyleAdoption(timestamp, documentNode == document ? -1 : getId(documentNode), 3 /* StyleSheetOperation.SetAdoptedStyles */, currentStyleSheets);
2087
+ trackStyleAdoption(timestamp, documentNode == document ? -1 : getId$1(documentNode), 3 /* StyleSheetOperation.SetAdoptedStyles */, currentStyleSheets);
2071
2088
  styleSheetMap[documentId] = currentStyleSheets;
2072
2089
  styleTimeMap[documentId] = timestamp;
2073
2090
  }
@@ -2075,7 +2092,7 @@ function checkDocumentStyles(documentNode, timestamp) {
2075
2092
  function compute$7() {
2076
2093
  for (var _i = 0, documentNodes_1 = documentNodes; _i < documentNodes_1.length; _i++) {
2077
2094
  var documentNode = documentNodes_1[_i];
2078
- var docId = documentNode == document ? -1 : getId(documentNode);
2095
+ var docId = documentNode == document ? -1 : getId$1(documentNode);
2079
2096
  var ts = docId in styleTimeMap ? styleTimeMap[docId] : null;
2080
2097
  checkDocumentStyles(documentNode, ts);
2081
2098
  }
@@ -2101,7 +2118,7 @@ function trackStyleChange(time, id, operation, cssRules) {
2101
2118
  cssRules: cssRules
2102
2119
  }
2103
2120
  });
2104
- encode$4(46 /* Event.StyleSheetUpdate */);
2121
+ encode$5(46 /* Event.StyleSheetUpdate */);
2105
2122
  }
2106
2123
  function trackStyleAdoption(time, id, operation, newIds) {
2107
2124
  sheetAdoptionState.push({
@@ -2113,7 +2130,7 @@ function trackStyleAdoption(time, id, operation, newIds) {
2113
2130
  newIds: newIds
2114
2131
  }
2115
2132
  });
2116
- encode$4(45 /* Event.StyleSheetAdoption */);
2133
+ encode$5(45 /* Event.StyleSheetAdoption */);
2117
2134
  }
2118
2135
  function arraysEqual(a, b) {
2119
2136
  if (a.length !== b.length) {
@@ -2185,7 +2202,7 @@ function track$6(time, id, operation, keyFrames, timing, targetId, timeline) {
2185
2202
  timeline: timeline
2186
2203
  }
2187
2204
  });
2188
- encode$4(44 /* Event.Animation */);
2205
+ encode$5(44 /* Event.Animation */);
2189
2206
  }
2190
2207
  function stop$k() {
2191
2208
  reset$a();
@@ -2202,7 +2219,7 @@ function overrideAnimationHelper(functionToOverride, name) {
2202
2219
  function trackAnimationOperation(animation, name) {
2203
2220
  if (active()) {
2204
2221
  var effect = animation.effect;
2205
- var target = (effect === null || effect === void 0 ? void 0 : effect.target) ? getId(effect.target) : null;
2222
+ var target = (effect === null || effect === void 0 ? void 0 : effect.target) ? getId$1(effect.target) : null;
2206
2223
  if (target !== null && effect.getKeyframes && effect.getTiming) {
2207
2224
  if (!animation[animationId]) {
2208
2225
  animation[animationId] = shortid();
@@ -2238,7 +2255,7 @@ function trackAnimationOperation(animation, name) {
2238
2255
  }
2239
2256
  }
2240
2257
 
2241
- function encode$4 (type, timer, ts) {
2258
+ function encode$5 (type, timer, ts) {
2242
2259
  if (timer === void 0) { timer = null; }
2243
2260
  if (ts === void 0) { ts = null; }
2244
2261
  return __awaiter(this, void 0, void 0, function () {
@@ -2363,7 +2380,7 @@ function encode$4 (type, timer, ts) {
2363
2380
  case "attributes":
2364
2381
  for (attr in data[key]) {
2365
2382
  if (data[key][attr] !== undefined) {
2366
- tokens.push(attribute(attr, data[key][attr], privacy));
2383
+ tokens.push(attribute$1(attr, data[key][attr], privacy));
2367
2384
  }
2368
2385
  }
2369
2386
  break;
@@ -2406,7 +2423,7 @@ function size(value) {
2406
2423
  function str(input) {
2407
2424
  return input.toString(36);
2408
2425
  }
2409
- function attribute(key, value, privacy) {
2426
+ function attribute$1(key, value, privacy) {
2410
2427
  return "".concat(key, "=").concat(text$1(value, key.indexOf("data-" /* Constant.DataAttribute */) === 0 ? "data-" /* Constant.DataAttribute */ : key, privacy));
2411
2428
  }
2412
2429
 
@@ -2439,14 +2456,14 @@ function compute$6() {
2439
2456
  // Check that width or height has changed from before, and also that width & height are not null values
2440
2457
  if ((data$8 === null || width !== data$8.width || height !== data$8.height) && width !== null && height !== null) {
2441
2458
  data$8 = { width: width, height: height };
2442
- encode$4(8 /* Event.Document */);
2459
+ encode$5(8 /* Event.Document */);
2443
2460
  }
2444
2461
  }
2445
2462
  function stop$j() {
2446
2463
  reset$9();
2447
2464
  }
2448
2465
 
2449
- function traverse (root, timer, source, timestamp) {
2466
+ function traverse$1 (root, timer, source, timestamp) {
2450
2467
  return __awaiter(this, void 0, void 0, function () {
2451
2468
  var queue, entry, next, state$1, subnode;
2452
2469
  return __generator(this, function (_a) {
@@ -2639,7 +2656,7 @@ function process$2() {
2639
2656
  case 4:
2640
2657
  _i++;
2641
2658
  return [3 /*break*/, 2];
2642
- case 5: return [4 /*yield*/, encode$4(6 /* Event.Mutation */, timer, record.time)];
2659
+ case 5: return [4 /*yield*/, encode$5(6 /* Event.Mutation */, timer, record.time)];
2643
2660
  case 6:
2644
2661
  _d.sent();
2645
2662
  return [3 /*break*/, 1];
@@ -2665,7 +2682,7 @@ function process$2() {
2665
2682
  processThrottledMutations();
2666
2683
  }
2667
2684
  if (!(Object.keys(throttledMutations).length === 0 && processedMutations)) return [3 /*break*/, 13];
2668
- return [4 /*yield*/, encode$4(6 /* Event.Mutation */, timer, time())];
2685
+ return [4 /*yield*/, encode$5(6 /* Event.Mutation */, timer, time())];
2669
2686
  case 12:
2670
2687
  _d.sent();
2671
2688
  _d.label = 13;
@@ -2752,7 +2769,7 @@ function processNodeList(list, source, timer, timestamp) {
2752
2769
  if (!(i < length)) return [3 /*break*/, 6];
2753
2770
  node = list[i];
2754
2771
  if (!(source === 1 /* Source.ChildListAdd */)) return [3 /*break*/, 2];
2755
- traverse(node, timer, source, timestamp);
2772
+ traverse$1(node, timer, source, timestamp);
2756
2773
  return [3 /*break*/, 5];
2757
2774
  case 2:
2758
2775
  state$1 = state(timer);
@@ -2777,7 +2794,7 @@ function processNodeList(list, source, timer, timestamp) {
2777
2794
  }
2778
2795
  function processThrottledMutations() {
2779
2796
  if (throttleDelay) {
2780
- clearTimeout(throttleDelay);
2797
+ clearTimeout$1(throttleDelay);
2781
2798
  }
2782
2799
  throttleDelay = setTimeout$1(function () {
2783
2800
  schedule(process$2, 1 /* Priority.High */);
@@ -2792,7 +2809,7 @@ function schedule$1(node) {
2792
2809
  // It's common for a webpage to call multiple synchronous "insertRule" / "deleteRule" calls.
2793
2810
  // And in those cases we do not wish to monitor changes multiple times for the same node.
2794
2811
  if (timeout$1) {
2795
- clearTimeout(timeout$1);
2812
+ clearTimeout$1(timeout$1);
2796
2813
  }
2797
2814
  timeout$1 = setTimeout$1(function () {
2798
2815
  trigger$1();
@@ -3038,7 +3055,7 @@ function processNode (node, source, timestamp) {
3038
3055
  case Node.ELEMENT_NODE:
3039
3056
  var element = node;
3040
3057
  var tag = element.tagName;
3041
- var attributes = getAttributes(element);
3058
+ var attributes = getAttributes$1(element);
3042
3059
  // In some cases, external libraries like vue-fragment, can modify parentNode property to not be in sync with the DOM
3043
3060
  // For correctness, we first look at parentElement and if it not present then fall back to using parentNode
3044
3061
  parent = node.parentElement ? node.parentElement : (node.parentNode ? node.parentNode : null);
@@ -3218,7 +3235,7 @@ function getCssRules(sheet) {
3218
3235
  }
3219
3236
  return value;
3220
3237
  }
3221
- function getAttributes(element) {
3238
+ function getAttributes$1(element) {
3222
3239
  var output = {};
3223
3240
  var attributes = element.attributes;
3224
3241
  if (attributes && attributes.length > 0) {
@@ -3330,9 +3347,9 @@ var selector = /*#__PURE__*/Object.freeze({
3330
3347
  reset: reset$8
3331
3348
  });
3332
3349
 
3333
- var index = 1;
3350
+ var index$1 = 1;
3334
3351
  var nodesMap = null; // Maps id => node to retrieve further node details using id.
3335
- var values = [];
3352
+ var values$1 = [];
3336
3353
  var updateMap = [];
3337
3354
  var hashMap = {};
3338
3355
  var override = [];
@@ -3342,7 +3359,7 @@ var maskExclude = [];
3342
3359
  var maskDisable = [];
3343
3360
  var maskTags = [];
3344
3361
  // The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced
3345
- var idMap = null; // Maps node => id.
3362
+ var idMap$1 = null; // Maps node => id.
3346
3363
  var iframeMap = null; // Maps iframe's contentDocument => parent iframe element
3347
3364
  var iframeContentMap = null; // Maps parent iframe element => iframe's contentDocument & contentWindow
3348
3365
  var privacyMap = null; // Maps node => Privacy (enum)
@@ -3355,8 +3372,8 @@ function stop$h() {
3355
3372
  reset$7();
3356
3373
  }
3357
3374
  function reset$7() {
3358
- index = 1;
3359
- values = [];
3375
+ index$1 = 1;
3376
+ values$1 = [];
3360
3377
  updateMap = [];
3361
3378
  hashMap = {};
3362
3379
  override = [];
@@ -3366,7 +3383,7 @@ function reset$7() {
3366
3383
  maskDisable = "radio,checkbox,range,button,reset,submit" /* Mask.Disable */.split("," /* Constant.Comma */);
3367
3384
  maskTags = "INPUT,SELECT,TEXTAREA" /* Mask.Tags */.split("," /* Constant.Comma */);
3368
3385
  nodesMap = new Map();
3369
- idMap = new WeakMap();
3386
+ idMap$1 = new WeakMap();
3370
3387
  iframeMap = new WeakMap();
3371
3388
  iframeContentMap = new WeakMap();
3372
3389
  privacyMap = new WeakMap();
@@ -3397,32 +3414,32 @@ function parse(root, init) {
3397
3414
  log$1(5 /* Code.Selector */, 1 /* Severity.Warning */, e ? e.name : null);
3398
3415
  }
3399
3416
  }
3400
- function getId(node, autogen) {
3417
+ function getId$1(node, autogen) {
3401
3418
  if (autogen === void 0) { autogen = false; }
3402
3419
  if (node === null) {
3403
3420
  return null;
3404
3421
  }
3405
- var id = idMap.get(node);
3422
+ var id = idMap$1.get(node);
3406
3423
  if (!id && autogen) {
3407
- id = index++;
3408
- idMap.set(node, id);
3424
+ id = index$1++;
3425
+ idMap$1.set(node, id);
3409
3426
  }
3410
3427
  return id ? id : null;
3411
3428
  }
3412
- function add(node, parent, data, source) {
3413
- var parentId = parent ? getId(parent) : null;
3429
+ function add$1(node, parent, data, source) {
3430
+ var parentId = parent ? getId$1(parent) : null;
3414
3431
  // Do not add detached nodes
3415
3432
  if ((!parent || !parentId) && node.host == null && node.nodeType !== Node.DOCUMENT_TYPE_NODE) {
3416
3433
  return;
3417
3434
  }
3418
- var id = getId(node, true);
3435
+ var id = getId$1(node, true);
3419
3436
  var previousId = getPreviousId(node);
3420
3437
  var parentValue = null;
3421
3438
  var regionId = exists(node) ? id : null;
3422
3439
  var fraudId = fraudMap.has(node) ? fraudMap.get(node) : null;
3423
3440
  var privacyId = config$2.content ? 1 /* Privacy.Sensitive */ : 3 /* Privacy.TextImage */;
3424
- if (parentId >= 0 && values[parentId]) {
3425
- parentValue = values[parentId];
3441
+ if (parentId >= 0 && values$1[parentId]) {
3442
+ parentValue = values$1[parentId];
3426
3443
  parentValue.children.push(id);
3427
3444
  regionId = regionId === null ? parentValue.region : regionId;
3428
3445
  fraudId = fraudId === null ? parentValue.metadata.fraud : fraudId;
@@ -3434,7 +3451,7 @@ function add(node, parent, data, source) {
3434
3451
  regionId = id;
3435
3452
  }
3436
3453
  nodesMap.set(id, node);
3437
- values[id] = {
3454
+ values$1[id] = {
3438
3455
  id: id,
3439
3456
  parent: parentId,
3440
3457
  previous: previousId,
@@ -3445,19 +3462,19 @@ function add(node, parent, data, source) {
3445
3462
  region: regionId,
3446
3463
  metadata: { active: true, suspend: false, privacy: privacyId, position: null, fraud: fraudId, size: null },
3447
3464
  };
3448
- privacy(node, values[id], parentValue);
3449
- updateSelector(values[id]);
3450
- updateImageSize(values[id]);
3465
+ privacy(node, values$1[id], parentValue);
3466
+ updateSelector(values$1[id]);
3467
+ updateImageSize(values$1[id]);
3451
3468
  track$4(id, source);
3452
3469
  }
3453
3470
  function update(node, parent, data, source) {
3454
- var id = getId(node);
3455
- var parentId = parent ? getId(parent) : null;
3471
+ var id = getId$1(node);
3472
+ var parentId = parent ? getId$1(parent) : null;
3456
3473
  var previousId = getPreviousId(node);
3457
3474
  var changed = false;
3458
3475
  var parentChanged = false;
3459
- if (id in values) {
3460
- var value = values[id];
3476
+ if (id in values$1) {
3477
+ var value = values$1[id];
3461
3478
  value.metadata.active = true;
3462
3479
  // Handle case where internal ordering may have changed
3463
3480
  if (value.previous !== previousId) {
@@ -3471,10 +3488,10 @@ function update(node, parent, data, source) {
3471
3488
  value.parent = parentId;
3472
3489
  // Move this node to the right location under new parent
3473
3490
  if (parentId !== null && parentId >= 0) {
3474
- var childIndex = previousId === null ? 0 : values[parentId].children.indexOf(previousId) + 1;
3475
- values[parentId].children.splice(childIndex, 0, id);
3491
+ var childIndex = previousId === null ? 0 : values$1[parentId].children.indexOf(previousId) + 1;
3492
+ values$1[parentId].children.splice(childIndex, 0, id);
3476
3493
  // Update region after the move
3477
- value.region = exists(node) ? id : values[parentId].region;
3494
+ value.region = exists(node) ? id : values$1[parentId].region;
3478
3495
  }
3479
3496
  else {
3480
3497
  // Mark this element as deleted if the parent has been updated to null
@@ -3482,9 +3499,9 @@ function update(node, parent, data, source) {
3482
3499
  }
3483
3500
  // Remove reference to this node from the old parent
3484
3501
  if (oldParentId !== null && oldParentId >= 0) {
3485
- var nodeIndex = values[oldParentId].children.indexOf(id);
3502
+ var nodeIndex = values$1[oldParentId].children.indexOf(id);
3486
3503
  if (nodeIndex >= 0) {
3487
- values[oldParentId].children.splice(nodeIndex, 1);
3504
+ values$1[oldParentId].children.splice(nodeIndex, 1);
3488
3505
  }
3489
3506
  }
3490
3507
  parentChanged = true;
@@ -3614,7 +3631,7 @@ function position(parent, child) {
3614
3631
  child.metadata.position = 1;
3615
3632
  var idx = parent ? parent.children.indexOf(child.id) : -1;
3616
3633
  while (idx-- > 0) {
3617
- var sibling = values[parent.children[idx]];
3634
+ var sibling = values$1[parent.children[idx]];
3618
3635
  if (child.data.tag === sibling.data.tag) {
3619
3636
  child.metadata.position = sibling.metadata.position + 1;
3620
3637
  break;
@@ -3623,7 +3640,7 @@ function position(parent, child) {
3623
3640
  return child.metadata.position;
3624
3641
  }
3625
3642
  function updateSelector(value) {
3626
- var parent = value.parent && value.parent in values ? values[value.parent] : null;
3643
+ var parent = value.parent && value.parent in values$1 ? values$1[value.parent] : null;
3627
3644
  var prefix = parent ? parent.selector : null;
3628
3645
  var d = value.data;
3629
3646
  var p = position(parent, value);
@@ -3641,35 +3658,35 @@ function getNode(id) {
3641
3658
  return nodesMap.has(id) ? nodesMap.get(id) : null;
3642
3659
  }
3643
3660
  function getValue(id) {
3644
- if (id in values) {
3645
- return values[id];
3661
+ if (id in values$1) {
3662
+ return values$1[id];
3646
3663
  }
3647
3664
  return null;
3648
3665
  }
3649
3666
  function get(node) {
3650
- var id = getId(node);
3651
- return id in values ? values[id] : null;
3667
+ var id = getId$1(node);
3668
+ return id in values$1 ? values$1[id] : null;
3652
3669
  }
3653
3670
  function lookup(hash) {
3654
3671
  return hash in hashMap ? hashMap[hash] : null;
3655
3672
  }
3656
3673
  function has$1(node) {
3657
- return nodesMap.has(getId(node));
3674
+ return nodesMap.has(getId$1(node));
3658
3675
  }
3659
3676
  function updates$2() {
3660
3677
  var output = [];
3661
3678
  for (var _i = 0, updateMap_1 = updateMap; _i < updateMap_1.length; _i++) {
3662
3679
  var id = updateMap_1[_i];
3663
- if (id in values) {
3664
- output.push(values[id]);
3680
+ if (id in values$1) {
3681
+ output.push(values$1[id]);
3665
3682
  }
3666
3683
  }
3667
3684
  updateMap = [];
3668
3685
  return output;
3669
3686
  }
3670
3687
  function remove(id, source) {
3671
- if (id in values) {
3672
- var value = values[id];
3688
+ if (id in values$1) {
3689
+ var value = values$1[id];
3673
3690
  value.metadata.active = false;
3674
3691
  value.parent = null;
3675
3692
  track$4(id, source);
@@ -3689,7 +3706,7 @@ function removeNodeFromNodesMap(id) {
3689
3706
  removeObserver(iframe_1);
3690
3707
  }
3691
3708
  nodesMap.delete(id);
3692
- var value = id in values ? values[id] : null;
3709
+ var value = id in values$1 ? values$1[id] : null;
3693
3710
  if (value && value.children) {
3694
3711
  for (var _i = 0, _a = value.children; _i < _a.length; _i++) {
3695
3712
  var childId = _a[_i];
@@ -3716,7 +3733,7 @@ function getPreviousId(node) {
3716
3733
  // Some nodes may not have an ID by design since Clarity skips over tags like SCRIPT, NOSCRIPT, META, COMMENTS, etc..
3717
3734
  // In that case, we keep going back and check for their sibling until we find a sibling with ID or no more sibling nodes are left.
3718
3735
  while (id === null && node.previousSibling) {
3719
- id = getId(node.previousSibling);
3736
+ id = getId$1(node.previousSibling);
3720
3737
  node = node.previousSibling;
3721
3738
  }
3722
3739
  return id;
@@ -3799,7 +3816,7 @@ function compute$5() {
3799
3816
  var q = [];
3800
3817
  for (var _i = 0, queue_1 = queue$1; _i < queue_1.length; _i++) {
3801
3818
  var r = queue_1[_i];
3802
- var id = getId(r.node);
3819
+ var id = getId$1(r.node);
3803
3820
  if (id) {
3804
3821
  r.state.data.id = id;
3805
3822
  regions[id] = r.state.data;
@@ -3812,7 +3829,7 @@ function compute$5() {
3812
3829
  queue$1 = q;
3813
3830
  // Schedule encode only when we have at least one valid data entry
3814
3831
  if (state$2.length > 0) {
3815
- encode$4(7 /* Event.Region */);
3832
+ encode$5(7 /* Event.Region */);
3816
3833
  }
3817
3834
  }
3818
3835
  function handler$1(entries) {
@@ -3827,7 +3844,7 @@ function handler$1(entries) {
3827
3844
  // like search box - one for desktop, and another for mobile. In those cases, CSS media queries determine which one should be visible.
3828
3845
  // Also, if these regions ever become non-zero width or height (through AJAX, user action or orientation change) - we will automatically start monitoring them from that point onwards
3829
3846
  if (regionMap.has(target) && rect.width + rect.height > 0 && viewport && viewport.width > 0 && viewport.height > 0) {
3830
- var id = target ? getId(target) : null;
3847
+ var id = target ? getId$1(target) : null;
3831
3848
  var data = id in regions ? regions[id] : { id: id, name: regionMap.get(target), interaction: 16 /* InteractionState.None */, visibility: 0 /* RegionVisibility.Rendered */ };
3832
3849
  // For regions that have relatively smaller area, we look at intersection ratio and see the overlap relative to element's area
3833
3850
  // However, for larger regions, area of regions could be bigger than viewport and therefore comparison is relative to visible area
@@ -3848,7 +3865,7 @@ function handler$1(entries) {
3848
3865
  }
3849
3866
  }
3850
3867
  if (state$2.length > 0) {
3851
- encode$4(7 /* Event.Region */);
3868
+ encode$5(7 /* Event.Region */);
3852
3869
  }
3853
3870
  }
3854
3871
  function process$1(n, d, s, v) {
@@ -3915,7 +3932,7 @@ function metadata$2(node, event, text) {
3915
3932
  return output;
3916
3933
  }
3917
3934
 
3918
- function encode$3 (type, ts) {
3935
+ function encode$4 (type, ts) {
3919
3936
  if (ts === void 0) { ts = null; }
3920
3937
  return __awaiter(this, void 0, void 0, function () {
3921
3938
  var t, tokens, _i, _a, entry, pTarget, _b, _c, entry, cTarget, cHash, _d, _e, entry, target, r, u, _f, _g, entry, iTarget, s, startTarget, endTarget, _h, _j, entry, sTarget, top_1, bottom, sTopHash, sBottomHash, _k, _l, entry, target, _m, _o, entry, target, _p, _q, entry, v;
@@ -3955,6 +3972,7 @@ function encode$3 (type, ts) {
3955
3972
  reset$i();
3956
3973
  break;
3957
3974
  case 9 /* Event.Click */:
3975
+ case 48 /* Event.ContextMenu */:
3958
3976
  for (_b = 0, _c = state$9; _b < _c.length; _b++) {
3959
3977
  entry = _c[_b];
3960
3978
  cTarget = metadata$2(entry.data.target, entry.event, entry.data.text);
@@ -4153,13 +4171,146 @@ function compute$4() {
4153
4171
  }
4154
4172
  }
4155
4173
  state$1 = temp; // Drop events less than the min time
4156
- encode$3(22 /* Event.Timeline */);
4174
+ encode$4(22 /* Event.Timeline */);
4157
4175
  }
4158
4176
  function stop$f() {
4159
4177
  state$1 = [];
4160
4178
  reset$5();
4161
4179
  }
4162
4180
 
4181
+ function encode$3 (type) {
4182
+ return __awaiter(this, void 0, void 0, function () {
4183
+ var eventTime, tokens, d, values$1, _i, values_1, value, privacy, data, _a, _b, key, attr;
4184
+ return __generator(this, function (_c) {
4185
+ eventTime = time();
4186
+ tokens = [eventTime, type];
4187
+ switch (type) {
4188
+ case 8 /* Event.Document */:
4189
+ d = data$8;
4190
+ tokens.push(d.width);
4191
+ tokens.push(d.height);
4192
+ track$8(type, d.width, d.height);
4193
+ queue(tokens);
4194
+ break;
4195
+ case 43 /* Event.Snapshot */:
4196
+ values$1 = values;
4197
+ // Only encode and queue DOM updates if we have valid updates to report back
4198
+ if (values$1.length > 0) {
4199
+ for (_i = 0, values_1 = values$1; _i < values_1.length; _i++) {
4200
+ value = values_1[_i];
4201
+ privacy = value.metadata.privacy;
4202
+ data = value.data;
4203
+ for (_a = 0, _b = ["tag", "attributes", "value"]; _a < _b.length; _a++) {
4204
+ key = _b[_a];
4205
+ if (data[key]) {
4206
+ switch (key) {
4207
+ case "tag":
4208
+ tokens.push(value.id);
4209
+ if (value.parent) {
4210
+ tokens.push(value.parent);
4211
+ }
4212
+ if (value.previous) {
4213
+ tokens.push(value.previous);
4214
+ }
4215
+ tokens.push(data[key]);
4216
+ break;
4217
+ case "attributes":
4218
+ for (attr in data[key]) {
4219
+ if (data[key][attr] !== undefined) {
4220
+ tokens.push(attribute(attr, data[key][attr], privacy));
4221
+ }
4222
+ }
4223
+ break;
4224
+ case "value":
4225
+ tokens.push(text$1(data[key], data.tag, privacy));
4226
+ break;
4227
+ }
4228
+ }
4229
+ }
4230
+ }
4231
+ queue(tokenize(tokens), true);
4232
+ }
4233
+ break;
4234
+ }
4235
+ return [2 /*return*/];
4236
+ });
4237
+ });
4238
+ }
4239
+ function attribute(key, value, privacy) {
4240
+ return "".concat(key, "=").concat(text$1(value, key.indexOf("data-" /* Constant.DataAttribute */) === 0 ? "data-" /* Constant.DataAttribute */ : key, privacy));
4241
+ }
4242
+
4243
+ var values = [];
4244
+ var index = 1;
4245
+ var idMap = null; // Maps node => id.
4246
+ function snapshot() {
4247
+ values = [];
4248
+ traverse(document);
4249
+ encode$3(43 /* Event.Snapshot */);
4250
+ }
4251
+ function traverse(root) {
4252
+ var queue = [root];
4253
+ while (queue.length > 0) {
4254
+ var attributes = null, tag = null, value = null;
4255
+ var node = queue.shift();
4256
+ var next = node.firstChild;
4257
+ var parent_1 = node.parentElement ? node.parentElement : (node.parentNode ? node.parentNode : null);
4258
+ while (next) {
4259
+ queue.push(next);
4260
+ next = next.nextSibling;
4261
+ }
4262
+ // Process the node
4263
+ var type = node.nodeType;
4264
+ switch (type) {
4265
+ case Node.DOCUMENT_TYPE_NODE:
4266
+ var doctype = node;
4267
+ tag = "*D" /* Constant.DocumentTag */;
4268
+ attributes = { name: doctype.name, publicId: doctype.publicId, systemId: doctype.systemId };
4269
+ break;
4270
+ case Node.TEXT_NODE:
4271
+ value = node.nodeValue;
4272
+ tag = idMap.get(parent_1) ? "*T" /* Constant.TextTag */ : tag;
4273
+ break;
4274
+ case Node.ELEMENT_NODE:
4275
+ var element = node;
4276
+ attributes = getAttributes(element);
4277
+ tag = ["NOSCRIPT", "SCRIPT", "STYLE"].indexOf(element.tagName) < 0 ? element.tagName : tag;
4278
+ break;
4279
+ }
4280
+ add(node, parent_1, { tag: tag, attributes: attributes, value: value });
4281
+ }
4282
+ }
4283
+ /* Helper Functions - Snapshot Traversal */
4284
+ function getAttributes(element) {
4285
+ var output = {};
4286
+ var attributes = element.attributes;
4287
+ if (attributes && attributes.length > 0) {
4288
+ for (var i = 0; i < attributes.length; i++) {
4289
+ output[attributes[i].name] = attributes[i].value;
4290
+ }
4291
+ }
4292
+ return output;
4293
+ }
4294
+ function getId(node) {
4295
+ if (node === null) {
4296
+ return null;
4297
+ }
4298
+ if (idMap.has(node)) {
4299
+ return idMap.get(node);
4300
+ }
4301
+ idMap.set(node, index);
4302
+ return index++;
4303
+ }
4304
+ function add(node, parent, data) {
4305
+ if (node && data && data.tag) {
4306
+ var id = getId(node);
4307
+ var parentId = parent ? idMap.get(parent) : null;
4308
+ var previous = node.previousSibling ? idMap.get(node.previousSibling) : null;
4309
+ var metadata_1 = { active: true, suspend: false, privacy: 5 /* Privacy.Snapshot */, position: null, fraud: null, size: null };
4310
+ values.push({ id: id, parent: parentId, previous: previous, children: [], data: data, selector: null, hash: null, region: null, metadata: metadata_1 });
4311
+ }
4312
+ }
4313
+
4163
4314
  var discoverBytes = 0;
4164
4315
  var playbackBytes = 0;
4165
4316
  var playback;
@@ -4224,7 +4375,7 @@ function queue(tokens, transmit) {
4224
4375
  // reset the timer. This allows Clarity to attempt an upload again.
4225
4376
  var gap = delay();
4226
4377
  if (now - queuedTime > (gap * 2)) {
4227
- clearTimeout(timeout);
4378
+ clearTimeout$1(timeout);
4228
4379
  timeout = null;
4229
4380
  }
4230
4381
  // Transmit Check: When transmit is set to true (default), it indicates that we should schedule an upload
@@ -4240,7 +4391,7 @@ function queue(tokens, transmit) {
4240
4391
  }
4241
4392
  }
4242
4393
  function stop$e() {
4243
- clearTimeout(timeout);
4394
+ clearTimeout$1(timeout);
4244
4395
  upload(true);
4245
4396
  discoverBytes = 0;
4246
4397
  playbackBytes = 0;
@@ -4310,6 +4461,7 @@ function stringify(encoded) {
4310
4461
  return encoded.p.length > 0 ? "{\"e\":".concat(encoded.e, ",\"a\":").concat(encoded.a, ",\"p\":").concat(encoded.p, "}") : "{\"e\":".concat(encoded.e, ",\"a\":").concat(encoded.a, "}");
4311
4462
  }
4312
4463
  function send(payload, zipped, sequence, beacon) {
4464
+ var _a;
4313
4465
  if (beacon === void 0) { beacon = false; }
4314
4466
  // Upload data if a valid URL is defined in the config
4315
4467
  if (typeof config$2.upload === "string" /* Constant.String */) {
@@ -4326,8 +4478,15 @@ function send(payload, zipped, sequence, beacon) {
4326
4478
  if (dispatched) {
4327
4479
  done(sequence);
4328
4480
  }
4481
+ else {
4482
+ // If sendBeacon fails, we report the error and continue with XHR upload
4483
+ report(new Error("".concat("BeaconError" /* Constant.BeaconError */, ": ").concat(payload.length)));
4484
+ }
4485
+ }
4486
+ catch (error) {
4487
+ // If sendBeacon fails, we report the error and continue with XHR upload
4488
+ report(new Error("".concat("BeaconError" /* Constant.BeaconError */, ": ").concat((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.substring(0, 50), " : ").concat(payload.length)));
4329
4489
  }
4330
- catch ( /* do nothing - and we will automatically fallback to XHR below */_a) { /* do nothing - and we will automatically fallback to XHR below */ }
4331
4490
  }
4332
4491
  // Before initiating XHR upload, we check if the data has already been uploaded using sendBeacon
4333
4492
  // There are two cases when dispatched could still be false:
@@ -4387,6 +4546,9 @@ function check$3(xhr, sequence) {
4387
4546
  if (xhr.status === 0) {
4388
4547
  config$2.upload = config$2.fallback ? config$2.fallback : config$2.upload;
4389
4548
  }
4549
+ // Capture the status code and number of attempts so we can report it back to the server
4550
+ track$1 = { sequence: sequence, attempts: transitData.attempts, status: xhr.status };
4551
+ encode$1(2 /* Event.Upload */);
4390
4552
  // In all other cases, re-attempt sending the same data
4391
4553
  // For retry we always fallback to string payload, even though we may have attempted
4392
4554
  // sending zipped payload earlier
@@ -4462,6 +4624,10 @@ function response(payload) {
4462
4624
  signalsEvent(parts[1]);
4463
4625
  }
4464
4626
  break;
4627
+ case "SNAPSHOT" /* Constant.Snapshot */:
4628
+ config$2.lean = false; // Disable lean mode to ensure we can send playback information to server.
4629
+ snapshot();
4630
+ break;
4465
4631
  }
4466
4632
  }
4467
4633
  }
@@ -4778,11 +4944,11 @@ function discover() {
4778
4944
  ts = time();
4779
4945
  timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
4780
4946
  start$d(timer);
4781
- return [4 /*yield*/, traverse(document, timer, 0 /* Source.Discover */, ts)];
4947
+ return [4 /*yield*/, traverse$1(document, timer, 0 /* Source.Discover */, ts)];
4782
4948
  case 1:
4783
4949
  _a.sent();
4784
4950
  checkDocumentStyles(document, ts);
4785
- return [4 /*yield*/, encode$4(5 /* Event.Discover */, timer, ts)];
4951
+ return [4 /*yield*/, encode$5(5 /* Event.Discover */, timer, ts)];
4786
4952
  case 2:
4787
4953
  _a.sent();
4788
4954
  stop$c(timer);
@@ -4832,7 +4998,7 @@ function encode$1 (event) {
4832
4998
  switch (event) {
4833
4999
  case 4 /* Event.Baseline */: {
4834
5000
  var b = state$b;
4835
- if (b) {
5001
+ if (b && b.data) {
4836
5002
  tokens = [b.time, b.event];
4837
5003
  tokens.push(b.data.visible);
4838
5004
  tokens.push(b.data.docWidth);
@@ -4946,7 +5112,7 @@ function encode$1 (event) {
4946
5112
  }
4947
5113
  case 40 /* Event.Extract */: {
4948
5114
  var extractKeys = keys;
4949
- extractKeys.forEach((function (e) {
5115
+ extractKeys.forEach(function (e) {
4950
5116
  tokens.push(e);
4951
5117
  var token = [];
4952
5118
  for (var d in data$e[e]) {
@@ -4955,7 +5121,7 @@ function encode$1 (event) {
4955
5121
  token.push(data$e[e][d]);
4956
5122
  }
4957
5123
  tokens.push(token);
4958
- }));
5124
+ });
4959
5125
  reset$n();
4960
5126
  queue(tokens, false);
4961
5127
  break;
@@ -5060,7 +5226,7 @@ function start$8() {
5060
5226
  var _a, _b, _c;
5061
5227
  rootDomain = null;
5062
5228
  var ua = navigator && "userAgent" in navigator ? navigator.userAgent : "" /* Constant.Empty */;
5063
- var timezone = (_c = (_b = (_a = Intl === null || Intl === void 0 ? void 0 : Intl.DateTimeFormat()) === null || _a === void 0 ? void 0 : _a.resolvedOptions()) === null || _b === void 0 ? void 0 : _b.timeZone) !== null && _c !== void 0 ? _c : '';
5229
+ var timezone = (_c = (typeof Intl !== 'undefined' && ((_b = (_a = Intl === null || Intl === void 0 ? void 0 : Intl.DateTimeFormat()) === null || _a === void 0 ? void 0 : _a.resolvedOptions()) === null || _b === void 0 ? void 0 : _b.timeZone))) !== null && _c !== void 0 ? _c : '';
5064
5230
  var timezoneOffset = new Date().getTimezoneOffset().toString();
5065
5231
  var ancestorOrigins = window.location.ancestorOrigins ? Array.from(window.location.ancestorOrigins).toString() : '';
5066
5232
  var title = document && document.title ? document.title : "" /* Constant.Empty */;
@@ -5902,7 +6068,7 @@ var observer;
5902
6068
  var types = ["navigation" /* Constant.Navigation */, "resource" /* Constant.Resource */, "longtask" /* Constant.LongTask */, "first-input" /* Constant.FID */, "layout-shift" /* Constant.CLS */, "largest-contentful-paint" /* Constant.LCP */, "event" /* Constant.PerformanceEventTiming */];
5903
6069
  function start$2() {
5904
6070
  // Capture connection properties, if available
5905
- if (navigator && "connection" in navigator) {
6071
+ if (navigator && navigator["connection"]) {
5906
6072
  log(27 /* Dimension.ConnectionType */, navigator["connection"]["effectiveType"]);
5907
6073
  }
5908
6074
  // Check the browser support performance observer as a pre-requisite for any performance measurement