clarity-js 0.8.20 → 0.8.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/clarity.js CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  var dom = /*#__PURE__*/Object.freeze({
4
4
  __proto__: null,
5
- get add () { return add; },
5
+ get add () { return add$1; },
6
6
  get get () { return get; },
7
- get getId () { return getId; },
7
+ get getId () { return getId$1; },
8
8
  get getNode () { return getNode; },
9
9
  get getValue () { return getValue; },
10
10
  get has () { return has$1; },
@@ -189,7 +189,7 @@ function stop$F() {
189
189
  startTime = 0;
190
190
  }
191
191
 
192
- var version$1 = "0.8.20";
192
+ var version$1 = "0.8.22";
193
193
 
194
194
  // tslint:disable: no-bitwise
195
195
  function hash (input, precision) {
@@ -1259,7 +1259,7 @@ function recompute$8(evt) {
1259
1259
  var value = element.value;
1260
1260
  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 */;
1261
1261
  state$a.push({ time: time(evt), event: 42 /* Event.Change */, data: { target: target(evt), type: element.type, value: value, checksum: checksum } });
1262
- schedule(encode$3.bind(this, 42 /* Event.Change */));
1262
+ schedule(encode$4.bind(this, 42 /* Event.Change */));
1263
1263
  }
1264
1264
  }
1265
1265
  function reset$m() {
@@ -1297,7 +1297,7 @@ function observe$b(root) {
1297
1297
  function handler$3(event, root, evt) {
1298
1298
  handler$3.dn = 6 /* FunctionNames.ClickHandler */;
1299
1299
  var frame = iframe(root);
1300
- var d = frame ? frame.contentDocument.documentElement : document.documentElement;
1300
+ var d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
1301
1301
  var x = "pageX" in evt ? Math.round(evt.pageX) : ("clientX" in evt ? Math.round(evt["clientX"] + d.scrollLeft) : null);
1302
1302
  var y = "pageY" in evt ? Math.round(evt.pageY) : ("clientY" in evt ? Math.round(evt["clientY"] + d.scrollTop) : null);
1303
1303
  // In case of iframe, we adjust (x,y) to be relative to top parent's origin
@@ -1343,7 +1343,7 @@ function handler$3(event, root, evt) {
1343
1343
  isFullText: textInfo.isFullText,
1344
1344
  }
1345
1345
  });
1346
- schedule(encode$3.bind(this, event));
1346
+ schedule(encode$4.bind(this, event));
1347
1347
  }
1348
1348
  }
1349
1349
  function link(node) {
@@ -1434,7 +1434,7 @@ function observe$a(root) {
1434
1434
  function recompute$7(action, evt) {
1435
1435
  recompute$7.dn = 7 /* FunctionNames.ClipboardRecompute */;
1436
1436
  state$8.push({ time: time(evt), event: 38 /* Event.Clipboard */, data: { target: target(evt), action: action } });
1437
- schedule(encode$3.bind(this, 38 /* Event.Clipboard */));
1437
+ schedule(encode$4.bind(this, 38 /* Event.Clipboard */));
1438
1438
  }
1439
1439
  function reset$k() {
1440
1440
  state$8 = [];
@@ -1475,7 +1475,7 @@ function recompute$6(evt) {
1475
1475
  }
1476
1476
  }
1477
1477
  function process$7(event) {
1478
- schedule(encode$3.bind(this, event));
1478
+ schedule(encode$4.bind(this, event));
1479
1479
  }
1480
1480
  function reset$j() {
1481
1481
  state$7 = [];
@@ -1507,7 +1507,7 @@ function observe$8(root) {
1507
1507
  function mouse(event, root, evt) {
1508
1508
  mouse.dn = 10 /* FunctionNames.PointerMouse */;
1509
1509
  var frame = iframe(root);
1510
- var d = frame ? frame.contentDocument.documentElement : document.documentElement;
1510
+ var d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
1511
1511
  var x = "pageX" in evt ? Math.round(evt.pageX) : ("clientX" in evt ? Math.round(evt["clientX"] + d.scrollLeft) : null);
1512
1512
  var y = "pageY" in evt ? Math.round(evt.pageY) : ("clientY" in evt ? Math.round(evt["clientY"] + d.scrollTop) : null);
1513
1513
  // In case of iframe, we adjust (x,y) to be relative to top parent's origin
@@ -1524,7 +1524,7 @@ function mouse(event, root, evt) {
1524
1524
  function touch(event, root, evt) {
1525
1525
  touch.dn = 11 /* FunctionNames.PointerTouch */;
1526
1526
  var frame = iframe(root);
1527
- var d = frame ? frame.contentDocument.documentElement : document.documentElement;
1527
+ var d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
1528
1528
  var touches = evt.changedTouches;
1529
1529
  var t = time(evt);
1530
1530
  if (touches) {
@@ -1586,7 +1586,7 @@ function handler$2(current) {
1586
1586
  }
1587
1587
  }
1588
1588
  function process$6(event) {
1589
- schedule(encode$3.bind(this, event));
1589
+ schedule(encode$4.bind(this, event));
1590
1590
  }
1591
1591
  function reset$i() {
1592
1592
  state$6 = [];
@@ -1608,43 +1608,6 @@ function stop$t() {
1608
1608
  }
1609
1609
  }
1610
1610
 
1611
- var data$c;
1612
- var timeout$4 = null;
1613
- var initialStateLogged = false;
1614
- function start$u() {
1615
- initialStateLogged = false;
1616
- bind(window, "resize", recompute$5);
1617
- recompute$5();
1618
- }
1619
- function recompute$5() {
1620
- recompute$5.dn = 12 /* FunctionNames.ResizeRecompute */;
1621
- var de = document.documentElement;
1622
- // window.innerWidth includes width of the scrollbar and is not a true representation of the viewport width.
1623
- // Therefore, when possible, use documentElement's clientWidth property.
1624
- data$c = {
1625
- width: de && "clientWidth" in de ? Math.min(de.clientWidth, window.innerWidth) : window.innerWidth,
1626
- height: de && "clientHeight" in de ? Math.min(de.clientHeight, window.innerHeight) : window.innerHeight,
1627
- };
1628
- if (initialStateLogged) {
1629
- clearTimeout$1(timeout$4);
1630
- timeout$4 = setTimeout$1(process$5, 500 /* Setting.LookAhead */, 11 /* Event.Resize */);
1631
- }
1632
- else {
1633
- encode$3(11 /* Event.Resize */);
1634
- initialStateLogged = true;
1635
- }
1636
- }
1637
- function process$5(event) {
1638
- schedule(encode$3.bind(this, event));
1639
- }
1640
- function reset$h() {
1641
- data$c = null;
1642
- clearTimeout$1(timeout$4);
1643
- }
1644
- function stop$s() {
1645
- reset$h();
1646
- }
1647
-
1648
1611
  /**
1649
1612
  * Creates a throttled version of the provided function that only executes at most once
1650
1613
  * every specified duration in milliseconds, ensuring the last event is not lost.
@@ -1693,6 +1656,45 @@ function throttle(func, duration) {
1693
1656
  return throttledFunction;
1694
1657
  }
1695
1658
 
1659
+ var data$c;
1660
+ var timeout$4 = null;
1661
+ var initialStateLogged = false;
1662
+ var throttledRecompute$1 = throttle(recompute$5, 500 /* Setting.LookAhead */);
1663
+ function start$u() {
1664
+ initialStateLogged = false;
1665
+ bind(window, "resize", throttledRecompute$1);
1666
+ recompute$5();
1667
+ }
1668
+ function recompute$5() {
1669
+ recompute$5.dn = 12 /* FunctionNames.ResizeRecompute */;
1670
+ var de = document.documentElement;
1671
+ // window.innerWidth includes width of the scrollbar and is not a true representation of the viewport width.
1672
+ // Therefore, when possible, use documentElement's clientWidth property.
1673
+ data$c = {
1674
+ width: de && "clientWidth" in de ? Math.min(de.clientWidth, window.innerWidth) : window.innerWidth,
1675
+ height: de && "clientHeight" in de ? Math.min(de.clientHeight, window.innerHeight) : window.innerHeight,
1676
+ };
1677
+ if (initialStateLogged) {
1678
+ clearTimeout$1(timeout$4);
1679
+ timeout$4 = setTimeout$1(process$5, 500 /* Setting.LookAhead */, 11 /* Event.Resize */);
1680
+ }
1681
+ else {
1682
+ encode$4(11 /* Event.Resize */);
1683
+ initialStateLogged = true;
1684
+ }
1685
+ }
1686
+ function process$5(event) {
1687
+ schedule(encode$4.bind(this, event));
1688
+ }
1689
+ function reset$h() {
1690
+ data$c = null;
1691
+ clearTimeout$1(timeout$4);
1692
+ throttledRecompute$1.cleanup();
1693
+ }
1694
+ function stop$s() {
1695
+ reset$h();
1696
+ }
1697
+
1696
1698
  var state$5 = [];
1697
1699
  var initialTop = null;
1698
1700
  var initialBottom = null;
@@ -1776,7 +1778,7 @@ function reset$g() {
1776
1778
  initialBottom = null;
1777
1779
  }
1778
1780
  function process$4(event) {
1779
- schedule(encode$3.bind(this, event));
1781
+ schedule(encode$4.bind(this, event));
1780
1782
  }
1781
1783
  function similar(last, current) {
1782
1784
  var dx = last.data.x - current.data.x;
@@ -1845,7 +1847,7 @@ function recompute$3(root) {
1845
1847
  timeout$2 = setTimeout$1(process$3, 500 /* Setting.LookAhead */, 21 /* Event.Selection */);
1846
1848
  }
1847
1849
  function process$3(event) {
1848
- schedule(encode$3.bind(this, event));
1850
+ schedule(encode$4.bind(this, event));
1849
1851
  }
1850
1852
  function reset$f() {
1851
1853
  previous = null;
@@ -1866,7 +1868,7 @@ function observe$5(root) {
1866
1868
  function recompute$2(evt) {
1867
1869
  recompute$2.dn = 16 /* FunctionNames.SubmitRecompute */;
1868
1870
  state$4.push({ time: time(evt), event: 39 /* Event.Submit */, data: { target: target(evt) } });
1869
- schedule(encode$3.bind(this, 39 /* Event.Submit */));
1871
+ schedule(encode$4.bind(this, 39 /* Event.Submit */));
1870
1872
  }
1871
1873
  function reset$e() {
1872
1874
  state$4 = [];
@@ -1882,7 +1884,7 @@ function start$q() {
1882
1884
  function recompute$1(evt) {
1883
1885
  recompute$1.dn = 17 /* FunctionNames.UnloadRecompute */;
1884
1886
  data$a = { name: evt.type, persisted: evt.persisted ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */ };
1885
- encode$3(26 /* Event.Unload */, time(evt));
1887
+ encode$4(26 /* Event.Unload */, time(evt));
1886
1888
  stop();
1887
1889
  }
1888
1890
  function reset$d() {
@@ -1901,7 +1903,7 @@ function recompute(evt) {
1901
1903
  if (evt === void 0) { evt = null; }
1902
1904
  recompute.dn = 18 /* FunctionNames.VisibilityRecompute */;
1903
1905
  data$9 = { visible: "visibilityState" in document ? document.visibilityState : "default" };
1904
- encode$3(28 /* Event.Visibility */, time(evt));
1906
+ encode$4(28 /* Event.Visibility */, time(evt));
1905
1907
  }
1906
1908
  function reset$c() {
1907
1909
  data$9 = null;
@@ -2080,13 +2082,13 @@ function checkDocumentStyles(documentNode, timestamp) {
2080
2082
  }
2081
2083
  currentStyleSheets.push(styleSheet[styleSheetId]);
2082
2084
  }
2083
- var documentId = getId(documentNode, true);
2085
+ var documentId = getId$1(documentNode, true);
2084
2086
  if (!styleSheetMap[documentId]) {
2085
2087
  styleSheetMap[documentId] = [];
2086
2088
  }
2087
2089
  if (!arraysEqual(currentStyleSheets, styleSheetMap[documentId])) {
2088
2090
  // Using -1 to signify the root document node as we don't track that as part of our nodeMap
2089
- trackStyleAdoption(timestamp, documentNode == document ? -1 : getId(documentNode), 3 /* StyleSheetOperation.SetAdoptedStyles */, currentStyleSheets);
2091
+ trackStyleAdoption(timestamp, documentNode == document ? -1 : getId$1(documentNode), 3 /* StyleSheetOperation.SetAdoptedStyles */, currentStyleSheets);
2090
2092
  styleSheetMap[documentId] = currentStyleSheets;
2091
2093
  styleTimeMap[documentId] = timestamp;
2092
2094
  }
@@ -2094,7 +2096,7 @@ function checkDocumentStyles(documentNode, timestamp) {
2094
2096
  function compute$7() {
2095
2097
  for (var _i = 0, documentNodes_1 = documentNodes; _i < documentNodes_1.length; _i++) {
2096
2098
  var documentNode = documentNodes_1[_i];
2097
- var docId = documentNode == document ? -1 : getId(documentNode);
2099
+ var docId = documentNode == document ? -1 : getId$1(documentNode);
2098
2100
  var ts = docId in styleTimeMap ? styleTimeMap[docId] : null;
2099
2101
  checkDocumentStyles(documentNode, ts);
2100
2102
  }
@@ -2120,7 +2122,7 @@ function trackStyleChange(time, id, operation, cssRules) {
2120
2122
  cssRules: cssRules
2121
2123
  }
2122
2124
  });
2123
- encode$4(46 /* Event.StyleSheetUpdate */);
2125
+ encode$5(46 /* Event.StyleSheetUpdate */);
2124
2126
  }
2125
2127
  function trackStyleAdoption(time, id, operation, newIds) {
2126
2128
  sheetAdoptionState.push({
@@ -2132,7 +2134,7 @@ function trackStyleAdoption(time, id, operation, newIds) {
2132
2134
  newIds: newIds
2133
2135
  }
2134
2136
  });
2135
- encode$4(45 /* Event.StyleSheetAdoption */);
2137
+ encode$5(45 /* Event.StyleSheetAdoption */);
2136
2138
  }
2137
2139
  function arraysEqual(a, b) {
2138
2140
  if (a.length !== b.length) {
@@ -2204,7 +2206,7 @@ function track$6(time, id, operation, keyFrames, timing, targetId, timeline) {
2204
2206
  timeline: timeline
2205
2207
  }
2206
2208
  });
2207
- encode$4(44 /* Event.Animation */);
2209
+ encode$5(44 /* Event.Animation */);
2208
2210
  }
2209
2211
  function stop$k() {
2210
2212
  reset$a();
@@ -2221,7 +2223,7 @@ function overrideAnimationHelper(functionToOverride, name) {
2221
2223
  function trackAnimationOperation(animation, name) {
2222
2224
  if (active()) {
2223
2225
  var effect = animation.effect;
2224
- var target = (effect === null || effect === void 0 ? void 0 : effect.target) ? getId(effect.target) : null;
2226
+ var target = (effect === null || effect === void 0 ? void 0 : effect.target) ? getId$1(effect.target) : null;
2225
2227
  if (target !== null && effect.getKeyframes && effect.getTiming) {
2226
2228
  if (!animation[animationId]) {
2227
2229
  animation[animationId] = shortid();
@@ -2257,7 +2259,7 @@ function trackAnimationOperation(animation, name) {
2257
2259
  }
2258
2260
  }
2259
2261
 
2260
- function encode$4 (type, timer, ts) {
2262
+ function encode$5 (type, timer, ts) {
2261
2263
  if (timer === void 0) { timer = null; }
2262
2264
  if (ts === void 0) { ts = null; }
2263
2265
  return __awaiter(this, void 0, void 0, function () {
@@ -2382,7 +2384,7 @@ function encode$4 (type, timer, ts) {
2382
2384
  case "attributes":
2383
2385
  for (attr in data[key]) {
2384
2386
  if (data[key][attr] !== undefined) {
2385
- tokens.push(attribute(attr, data[key][attr], privacy));
2387
+ tokens.push(attribute$1(attr, data[key][attr], privacy));
2386
2388
  }
2387
2389
  }
2388
2390
  break;
@@ -2425,7 +2427,7 @@ function size(value) {
2425
2427
  function str(input) {
2426
2428
  return input.toString(36);
2427
2429
  }
2428
- function attribute(key, value, privacy) {
2430
+ function attribute$1(key, value, privacy) {
2429
2431
  return "".concat(key, "=").concat(text$1(value, key.indexOf("data-" /* Constant.DataAttribute */) === 0 ? "data-" /* Constant.DataAttribute */ : key, privacy));
2430
2432
  }
2431
2433
 
@@ -2458,14 +2460,14 @@ function compute$6() {
2458
2460
  // Check that width or height has changed from before, and also that width & height are not null values
2459
2461
  if ((data$8 === null || width !== data$8.width || height !== data$8.height) && width !== null && height !== null) {
2460
2462
  data$8 = { width: width, height: height };
2461
- encode$4(8 /* Event.Document */);
2463
+ encode$5(8 /* Event.Document */);
2462
2464
  }
2463
2465
  }
2464
2466
  function stop$j() {
2465
2467
  reset$9();
2466
2468
  }
2467
2469
 
2468
- function traverse (root, timer, source, timestamp) {
2470
+ function traverse$1 (root, timer, source, timestamp) {
2469
2471
  return __awaiter(this, void 0, void 0, function () {
2470
2472
  var queue, entry, next, state$1, subnode;
2471
2473
  return __generator(this, function (_a) {
@@ -2658,7 +2660,7 @@ function process$2() {
2658
2660
  case 4:
2659
2661
  _i++;
2660
2662
  return [3 /*break*/, 2];
2661
- case 5: return [4 /*yield*/, encode$4(6 /* Event.Mutation */, timer, record.time)];
2663
+ case 5: return [4 /*yield*/, encode$5(6 /* Event.Mutation */, timer, record.time)];
2662
2664
  case 6:
2663
2665
  _d.sent();
2664
2666
  return [3 /*break*/, 1];
@@ -2684,7 +2686,7 @@ function process$2() {
2684
2686
  processThrottledMutations();
2685
2687
  }
2686
2688
  if (!(Object.keys(throttledMutations).length === 0 && processedMutations)) return [3 /*break*/, 13];
2687
- return [4 /*yield*/, encode$4(6 /* Event.Mutation */, timer, time())];
2689
+ return [4 /*yield*/, encode$5(6 /* Event.Mutation */, timer, time())];
2688
2690
  case 12:
2689
2691
  _d.sent();
2690
2692
  _d.label = 13;
@@ -2771,7 +2773,7 @@ function processNodeList(list, source, timer, timestamp) {
2771
2773
  if (!(i < length)) return [3 /*break*/, 6];
2772
2774
  node = list[i];
2773
2775
  if (!(source === 1 /* Source.ChildListAdd */)) return [3 /*break*/, 2];
2774
- traverse(node, timer, source, timestamp);
2776
+ traverse$1(node, timer, source, timestamp);
2775
2777
  return [3 /*break*/, 5];
2776
2778
  case 2:
2777
2779
  state$1 = state(timer);
@@ -3057,7 +3059,7 @@ function processNode (node, source, timestamp) {
3057
3059
  case Node.ELEMENT_NODE:
3058
3060
  var element = node;
3059
3061
  var tag = element.tagName;
3060
- var attributes = getAttributes(element);
3062
+ var attributes = getAttributes$1(element);
3061
3063
  // In some cases, external libraries like vue-fragment, can modify parentNode property to not be in sync with the DOM
3062
3064
  // For correctness, we first look at parentElement and if it not present then fall back to using parentNode
3063
3065
  parent = node.parentElement ? node.parentElement : (node.parentNode ? node.parentNode : null);
@@ -3237,7 +3239,7 @@ function getCssRules(sheet) {
3237
3239
  }
3238
3240
  return value;
3239
3241
  }
3240
- function getAttributes(element) {
3242
+ function getAttributes$1(element) {
3241
3243
  var output = {};
3242
3244
  var attributes = element.attributes;
3243
3245
  if (attributes && attributes.length > 0) {
@@ -3349,9 +3351,9 @@ var selector = /*#__PURE__*/Object.freeze({
3349
3351
  reset: reset$8
3350
3352
  });
3351
3353
 
3352
- var index = 1;
3354
+ var index$1 = 1;
3353
3355
  var nodesMap = null; // Maps id => node to retrieve further node details using id.
3354
- var values = [];
3356
+ var values$1 = [];
3355
3357
  var updateMap = [];
3356
3358
  var hashMap = {};
3357
3359
  var override = [];
@@ -3361,7 +3363,7 @@ var maskExclude = [];
3361
3363
  var maskDisable = [];
3362
3364
  var maskTags = [];
3363
3365
  // The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced
3364
- var idMap = null; // Maps node => id.
3366
+ var idMap$1 = null; // Maps node => id.
3365
3367
  var iframeMap = null; // Maps iframe's contentDocument => parent iframe element
3366
3368
  var iframeContentMap = null; // Maps parent iframe element => iframe's contentDocument & contentWindow
3367
3369
  var privacyMap = null; // Maps node => Privacy (enum)
@@ -3374,8 +3376,8 @@ function stop$h() {
3374
3376
  reset$7();
3375
3377
  }
3376
3378
  function reset$7() {
3377
- index = 1;
3378
- values = [];
3379
+ index$1 = 1;
3380
+ values$1 = [];
3379
3381
  updateMap = [];
3380
3382
  hashMap = {};
3381
3383
  override = [];
@@ -3385,7 +3387,7 @@ function reset$7() {
3385
3387
  maskDisable = "radio,checkbox,range,button,reset,submit" /* Mask.Disable */.split("," /* Constant.Comma */);
3386
3388
  maskTags = "INPUT,SELECT,TEXTAREA" /* Mask.Tags */.split("," /* Constant.Comma */);
3387
3389
  nodesMap = new Map();
3388
- idMap = new WeakMap();
3390
+ idMap$1 = new WeakMap();
3389
3391
  iframeMap = new WeakMap();
3390
3392
  iframeContentMap = new WeakMap();
3391
3393
  privacyMap = new WeakMap();
@@ -3416,32 +3418,32 @@ function parse(root, init) {
3416
3418
  log$1(5 /* Code.Selector */, 1 /* Severity.Warning */, e ? e.name : null);
3417
3419
  }
3418
3420
  }
3419
- function getId(node, autogen) {
3421
+ function getId$1(node, autogen) {
3420
3422
  if (autogen === void 0) { autogen = false; }
3421
3423
  if (node === null) {
3422
3424
  return null;
3423
3425
  }
3424
- var id = idMap.get(node);
3426
+ var id = idMap$1.get(node);
3425
3427
  if (!id && autogen) {
3426
- id = index++;
3427
- idMap.set(node, id);
3428
+ id = index$1++;
3429
+ idMap$1.set(node, id);
3428
3430
  }
3429
3431
  return id ? id : null;
3430
3432
  }
3431
- function add(node, parent, data, source) {
3432
- var parentId = parent ? getId(parent) : null;
3433
+ function add$1(node, parent, data, source) {
3434
+ var parentId = parent ? getId$1(parent) : null;
3433
3435
  // Do not add detached nodes
3434
3436
  if ((!parent || !parentId) && node.host == null && node.nodeType !== Node.DOCUMENT_TYPE_NODE) {
3435
3437
  return;
3436
3438
  }
3437
- var id = getId(node, true);
3439
+ var id = getId$1(node, true);
3438
3440
  var previousId = getPreviousId(node);
3439
3441
  var parentValue = null;
3440
3442
  var regionId = exists(node) ? id : null;
3441
3443
  var fraudId = fraudMap.has(node) ? fraudMap.get(node) : null;
3442
3444
  var privacyId = config$2.content ? 1 /* Privacy.Sensitive */ : 3 /* Privacy.TextImage */;
3443
- if (parentId >= 0 && values[parentId]) {
3444
- parentValue = values[parentId];
3445
+ if (parentId >= 0 && values$1[parentId]) {
3446
+ parentValue = values$1[parentId];
3445
3447
  parentValue.children.push(id);
3446
3448
  regionId = regionId === null ? parentValue.region : regionId;
3447
3449
  fraudId = fraudId === null ? parentValue.metadata.fraud : fraudId;
@@ -3453,7 +3455,7 @@ function add(node, parent, data, source) {
3453
3455
  regionId = id;
3454
3456
  }
3455
3457
  nodesMap.set(id, node);
3456
- values[id] = {
3458
+ values$1[id] = {
3457
3459
  id: id,
3458
3460
  parent: parentId,
3459
3461
  previous: previousId,
@@ -3464,19 +3466,19 @@ function add(node, parent, data, source) {
3464
3466
  region: regionId,
3465
3467
  metadata: { active: true, suspend: false, privacy: privacyId, position: null, fraud: fraudId, size: null },
3466
3468
  };
3467
- privacy(node, values[id], parentValue);
3468
- updateSelector(values[id]);
3469
- updateImageSize(values[id]);
3469
+ privacy(node, values$1[id], parentValue);
3470
+ updateSelector(values$1[id]);
3471
+ updateImageSize(values$1[id]);
3470
3472
  track$4(id, source);
3471
3473
  }
3472
3474
  function update(node, parent, data, source) {
3473
- var id = getId(node);
3474
- var parentId = parent ? getId(parent) : null;
3475
+ var id = getId$1(node);
3476
+ var parentId = parent ? getId$1(parent) : null;
3475
3477
  var previousId = getPreviousId(node);
3476
3478
  var changed = false;
3477
3479
  var parentChanged = false;
3478
- if (id in values) {
3479
- var value = values[id];
3480
+ if (id in values$1) {
3481
+ var value = values$1[id];
3480
3482
  value.metadata.active = true;
3481
3483
  // Handle case where internal ordering may have changed
3482
3484
  if (value.previous !== previousId) {
@@ -3490,10 +3492,10 @@ function update(node, parent, data, source) {
3490
3492
  value.parent = parentId;
3491
3493
  // Move this node to the right location under new parent
3492
3494
  if (parentId !== null && parentId >= 0) {
3493
- var childIndex = previousId === null ? 0 : values[parentId].children.indexOf(previousId) + 1;
3494
- values[parentId].children.splice(childIndex, 0, id);
3495
+ var childIndex = previousId === null ? 0 : values$1[parentId].children.indexOf(previousId) + 1;
3496
+ values$1[parentId].children.splice(childIndex, 0, id);
3495
3497
  // Update region after the move
3496
- value.region = exists(node) ? id : values[parentId].region;
3498
+ value.region = exists(node) ? id : values$1[parentId].region;
3497
3499
  }
3498
3500
  else {
3499
3501
  // Mark this element as deleted if the parent has been updated to null
@@ -3501,9 +3503,9 @@ function update(node, parent, data, source) {
3501
3503
  }
3502
3504
  // Remove reference to this node from the old parent
3503
3505
  if (oldParentId !== null && oldParentId >= 0) {
3504
- var nodeIndex = values[oldParentId].children.indexOf(id);
3506
+ var nodeIndex = values$1[oldParentId].children.indexOf(id);
3505
3507
  if (nodeIndex >= 0) {
3506
- values[oldParentId].children.splice(nodeIndex, 1);
3508
+ values$1[oldParentId].children.splice(nodeIndex, 1);
3507
3509
  }
3508
3510
  }
3509
3511
  parentChanged = true;
@@ -3633,7 +3635,7 @@ function position(parent, child) {
3633
3635
  child.metadata.position = 1;
3634
3636
  var idx = parent ? parent.children.indexOf(child.id) : -1;
3635
3637
  while (idx-- > 0) {
3636
- var sibling = values[parent.children[idx]];
3638
+ var sibling = values$1[parent.children[idx]];
3637
3639
  if (child.data.tag === sibling.data.tag) {
3638
3640
  child.metadata.position = sibling.metadata.position + 1;
3639
3641
  break;
@@ -3642,7 +3644,7 @@ function position(parent, child) {
3642
3644
  return child.metadata.position;
3643
3645
  }
3644
3646
  function updateSelector(value) {
3645
- var parent = value.parent && value.parent in values ? values[value.parent] : null;
3647
+ var parent = value.parent && value.parent in values$1 ? values$1[value.parent] : null;
3646
3648
  var prefix = parent ? parent.selector : null;
3647
3649
  var d = value.data;
3648
3650
  var p = position(parent, value);
@@ -3660,35 +3662,35 @@ function getNode(id) {
3660
3662
  return nodesMap.has(id) ? nodesMap.get(id) : null;
3661
3663
  }
3662
3664
  function getValue(id) {
3663
- if (id in values) {
3664
- return values[id];
3665
+ if (id in values$1) {
3666
+ return values$1[id];
3665
3667
  }
3666
3668
  return null;
3667
3669
  }
3668
3670
  function get(node) {
3669
- var id = getId(node);
3670
- return id in values ? values[id] : null;
3671
+ var id = getId$1(node);
3672
+ return id in values$1 ? values$1[id] : null;
3671
3673
  }
3672
3674
  function lookup(hash) {
3673
3675
  return hash in hashMap ? hashMap[hash] : null;
3674
3676
  }
3675
3677
  function has$1(node) {
3676
- return nodesMap.has(getId(node));
3678
+ return nodesMap.has(getId$1(node));
3677
3679
  }
3678
3680
  function updates$2() {
3679
3681
  var output = [];
3680
3682
  for (var _i = 0, updateMap_1 = updateMap; _i < updateMap_1.length; _i++) {
3681
3683
  var id = updateMap_1[_i];
3682
- if (id in values) {
3683
- output.push(values[id]);
3684
+ if (id in values$1) {
3685
+ output.push(values$1[id]);
3684
3686
  }
3685
3687
  }
3686
3688
  updateMap = [];
3687
3689
  return output;
3688
3690
  }
3689
3691
  function remove(id, source) {
3690
- if (id in values) {
3691
- var value = values[id];
3692
+ if (id in values$1) {
3693
+ var value = values$1[id];
3692
3694
  value.metadata.active = false;
3693
3695
  value.parent = null;
3694
3696
  track$4(id, source);
@@ -3708,7 +3710,7 @@ function removeNodeFromNodesMap(id) {
3708
3710
  removeObserver(iframe_1);
3709
3711
  }
3710
3712
  nodesMap.delete(id);
3711
- var value = id in values ? values[id] : null;
3713
+ var value = id in values$1 ? values$1[id] : null;
3712
3714
  if (value && value.children) {
3713
3715
  for (var _i = 0, _a = value.children; _i < _a.length; _i++) {
3714
3716
  var childId = _a[_i];
@@ -3735,7 +3737,7 @@ function getPreviousId(node) {
3735
3737
  // Some nodes may not have an ID by design since Clarity skips over tags like SCRIPT, NOSCRIPT, META, COMMENTS, etc..
3736
3738
  // 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.
3737
3739
  while (id === null && node.previousSibling) {
3738
- id = getId(node.previousSibling);
3740
+ id = getId$1(node.previousSibling);
3739
3741
  node = node.previousSibling;
3740
3742
  }
3741
3743
  return id;
@@ -3818,7 +3820,7 @@ function compute$5() {
3818
3820
  var q = [];
3819
3821
  for (var _i = 0, queue_1 = queue$1; _i < queue_1.length; _i++) {
3820
3822
  var r = queue_1[_i];
3821
- var id = getId(r.node);
3823
+ var id = getId$1(r.node);
3822
3824
  if (id) {
3823
3825
  r.state.data.id = id;
3824
3826
  regions[id] = r.state.data;
@@ -3831,7 +3833,7 @@ function compute$5() {
3831
3833
  queue$1 = q;
3832
3834
  // Schedule encode only when we have at least one valid data entry
3833
3835
  if (state$2.length > 0) {
3834
- encode$4(7 /* Event.Region */);
3836
+ encode$5(7 /* Event.Region */);
3835
3837
  }
3836
3838
  }
3837
3839
  function handler$1(entries) {
@@ -3846,7 +3848,7 @@ function handler$1(entries) {
3846
3848
  // like search box - one for desktop, and another for mobile. In those cases, CSS media queries determine which one should be visible.
3847
3849
  // 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
3848
3850
  if (regionMap.has(target) && rect.width + rect.height > 0 && viewport && viewport.width > 0 && viewport.height > 0) {
3849
- var id = target ? getId(target) : null;
3851
+ var id = target ? getId$1(target) : null;
3850
3852
  var data = id in regions ? regions[id] : { id: id, name: regionMap.get(target), interaction: 16 /* InteractionState.None */, visibility: 0 /* RegionVisibility.Rendered */ };
3851
3853
  // For regions that have relatively smaller area, we look at intersection ratio and see the overlap relative to element's area
3852
3854
  // However, for larger regions, area of regions could be bigger than viewport and therefore comparison is relative to visible area
@@ -3867,7 +3869,7 @@ function handler$1(entries) {
3867
3869
  }
3868
3870
  }
3869
3871
  if (state$2.length > 0) {
3870
- encode$4(7 /* Event.Region */);
3872
+ encode$5(7 /* Event.Region */);
3871
3873
  }
3872
3874
  }
3873
3875
  function process$1(n, d, s, v) {
@@ -3934,7 +3936,7 @@ function metadata$2(node, event, text) {
3934
3936
  return output;
3935
3937
  }
3936
3938
 
3937
- function encode$3 (type, ts) {
3939
+ function encode$4 (type, ts) {
3938
3940
  if (ts === void 0) { ts = null; }
3939
3941
  return __awaiter(this, void 0, void 0, function () {
3940
3942
  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;
@@ -4173,13 +4175,146 @@ function compute$4() {
4173
4175
  }
4174
4176
  }
4175
4177
  state$1 = temp; // Drop events less than the min time
4176
- encode$3(22 /* Event.Timeline */);
4178
+ encode$4(22 /* Event.Timeline */);
4177
4179
  }
4178
4180
  function stop$f() {
4179
4181
  state$1 = [];
4180
4182
  reset$5();
4181
4183
  }
4182
4184
 
4185
+ function encode$3 (type) {
4186
+ return __awaiter(this, void 0, void 0, function () {
4187
+ var eventTime, tokens, d, values$1, _i, values_1, value, privacy, data, _a, _b, key, attr;
4188
+ return __generator(this, function (_c) {
4189
+ eventTime = time();
4190
+ tokens = [eventTime, type];
4191
+ switch (type) {
4192
+ case 8 /* Event.Document */:
4193
+ d = data$8;
4194
+ tokens.push(d.width);
4195
+ tokens.push(d.height);
4196
+ track$8(type, d.width, d.height);
4197
+ queue(tokens);
4198
+ break;
4199
+ case 43 /* Event.Snapshot */:
4200
+ values$1 = values;
4201
+ // Only encode and queue DOM updates if we have valid updates to report back
4202
+ if (values$1.length > 0) {
4203
+ for (_i = 0, values_1 = values$1; _i < values_1.length; _i++) {
4204
+ value = values_1[_i];
4205
+ privacy = value.metadata.privacy;
4206
+ data = value.data;
4207
+ for (_a = 0, _b = ["tag", "attributes", "value"]; _a < _b.length; _a++) {
4208
+ key = _b[_a];
4209
+ if (data[key]) {
4210
+ switch (key) {
4211
+ case "tag":
4212
+ tokens.push(value.id);
4213
+ if (value.parent) {
4214
+ tokens.push(value.parent);
4215
+ }
4216
+ if (value.previous) {
4217
+ tokens.push(value.previous);
4218
+ }
4219
+ tokens.push(data[key]);
4220
+ break;
4221
+ case "attributes":
4222
+ for (attr in data[key]) {
4223
+ if (data[key][attr] !== undefined) {
4224
+ tokens.push(attribute(attr, data[key][attr], privacy));
4225
+ }
4226
+ }
4227
+ break;
4228
+ case "value":
4229
+ tokens.push(text$1(data[key], data.tag, privacy));
4230
+ break;
4231
+ }
4232
+ }
4233
+ }
4234
+ }
4235
+ queue(tokenize(tokens), true);
4236
+ }
4237
+ break;
4238
+ }
4239
+ return [2 /*return*/];
4240
+ });
4241
+ });
4242
+ }
4243
+ function attribute(key, value, privacy) {
4244
+ return "".concat(key, "=").concat(text$1(value, key.indexOf("data-" /* Constant.DataAttribute */) === 0 ? "data-" /* Constant.DataAttribute */ : key, privacy));
4245
+ }
4246
+
4247
+ var values = [];
4248
+ var index = 1;
4249
+ var idMap = null; // Maps node => id.
4250
+ function snapshot() {
4251
+ values = [];
4252
+ traverse(document);
4253
+ encode$3(43 /* Event.Snapshot */);
4254
+ }
4255
+ function traverse(root) {
4256
+ var queue = [root];
4257
+ while (queue.length > 0) {
4258
+ var attributes = null, tag = null, value = null;
4259
+ var node = queue.shift();
4260
+ var next = node.firstChild;
4261
+ var parent_1 = node.parentElement ? node.parentElement : (node.parentNode ? node.parentNode : null);
4262
+ while (next) {
4263
+ queue.push(next);
4264
+ next = next.nextSibling;
4265
+ }
4266
+ // Process the node
4267
+ var type = node.nodeType;
4268
+ switch (type) {
4269
+ case Node.DOCUMENT_TYPE_NODE:
4270
+ var doctype = node;
4271
+ tag = "*D" /* Constant.DocumentTag */;
4272
+ attributes = { name: doctype.name, publicId: doctype.publicId, systemId: doctype.systemId };
4273
+ break;
4274
+ case Node.TEXT_NODE:
4275
+ value = node.nodeValue;
4276
+ tag = idMap.get(parent_1) ? "*T" /* Constant.TextTag */ : tag;
4277
+ break;
4278
+ case Node.ELEMENT_NODE:
4279
+ var element = node;
4280
+ attributes = getAttributes(element);
4281
+ tag = ["NOSCRIPT", "SCRIPT", "STYLE"].indexOf(element.tagName) < 0 ? element.tagName : tag;
4282
+ break;
4283
+ }
4284
+ add(node, parent_1, { tag: tag, attributes: attributes, value: value });
4285
+ }
4286
+ }
4287
+ /* Helper Functions - Snapshot Traversal */
4288
+ function getAttributes(element) {
4289
+ var output = {};
4290
+ var attributes = element.attributes;
4291
+ if (attributes && attributes.length > 0) {
4292
+ for (var i = 0; i < attributes.length; i++) {
4293
+ output[attributes[i].name] = attributes[i].value;
4294
+ }
4295
+ }
4296
+ return output;
4297
+ }
4298
+ function getId(node) {
4299
+ if (node === null) {
4300
+ return null;
4301
+ }
4302
+ if (idMap.has(node)) {
4303
+ return idMap.get(node);
4304
+ }
4305
+ idMap.set(node, index);
4306
+ return index++;
4307
+ }
4308
+ function add(node, parent, data) {
4309
+ if (node && data && data.tag) {
4310
+ var id = getId(node);
4311
+ var parentId = parent ? idMap.get(parent) : null;
4312
+ var previous = node.previousSibling ? idMap.get(node.previousSibling) : null;
4313
+ var metadata_1 = { active: true, suspend: false, privacy: 5 /* Privacy.Snapshot */, position: null, fraud: null, size: null };
4314
+ values.push({ id: id, parent: parentId, previous: previous, children: [], data: data, selector: null, hash: null, region: null, metadata: metadata_1 });
4315
+ }
4316
+ }
4317
+
4183
4318
  var discoverBytes = 0;
4184
4319
  var playbackBytes = 0;
4185
4320
  var playback;
@@ -4330,6 +4465,7 @@ function stringify(encoded) {
4330
4465
  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, "}");
4331
4466
  }
4332
4467
  function send(payload, zipped, sequence, beacon) {
4468
+ var _a;
4333
4469
  if (beacon === void 0) { beacon = false; }
4334
4470
  // Upload data if a valid URL is defined in the config
4335
4471
  if (typeof config$2.upload === "string" /* Constant.String */) {
@@ -4339,15 +4475,22 @@ function send(payload, zipped, sequence, beacon) {
4339
4475
  // The advantage to using sendBeacon is that browser can decide to upload asynchronously, improving chances of success
4340
4476
  // However, we don't want to rely on it for every payload, since we have no ability to retry if the upload failed.
4341
4477
  // Also, in case of sendBeacon, we do not have a way to alter HTTP headers and therefore can't send compressed payload
4342
- if (beacon && "sendBeacon" in navigator) {
4478
+ if (beacon && navigator && navigator["sendBeacon"]) {
4343
4479
  try {
4344
4480
  // Navigator needs to be bound to sendBeacon before it is used to avoid errors in some browsers
4345
4481
  dispatched = navigator.sendBeacon.bind(navigator)(url_1, payload);
4346
4482
  if (dispatched) {
4347
4483
  done(sequence);
4348
4484
  }
4485
+ else {
4486
+ // If sendBeacon fails, we report the error and continue with XHR upload
4487
+ report(new Error("".concat("BeaconError" /* Constant.BeaconError */, ": ").concat(payload.length)));
4488
+ }
4489
+ }
4490
+ catch (error) {
4491
+ // If sendBeacon fails, we report the error and continue with XHR upload
4492
+ 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)));
4349
4493
  }
4350
- catch ( /* do nothing - and we will automatically fallback to XHR below */_a) { /* do nothing - and we will automatically fallback to XHR below */ }
4351
4494
  }
4352
4495
  // Before initiating XHR upload, we check if the data has already been uploaded using sendBeacon
4353
4496
  // There are two cases when dispatched could still be false:
@@ -4407,6 +4550,9 @@ function check$3(xhr, sequence) {
4407
4550
  if (xhr.status === 0) {
4408
4551
  config$2.upload = config$2.fallback ? config$2.fallback : config$2.upload;
4409
4552
  }
4553
+ // Capture the status code and number of attempts so we can report it back to the server
4554
+ track$1 = { sequence: sequence, attempts: transitData.attempts, status: xhr.status };
4555
+ encode$1(2 /* Event.Upload */);
4410
4556
  // In all other cases, re-attempt sending the same data
4411
4557
  // For retry we always fallback to string payload, even though we may have attempted
4412
4558
  // sending zipped payload earlier
@@ -4482,6 +4628,10 @@ function response(payload) {
4482
4628
  signalsEvent(parts[1]);
4483
4629
  }
4484
4630
  break;
4631
+ case "SNAPSHOT" /* Constant.Snapshot */:
4632
+ config$2.lean = false; // Disable lean mode to ensure we can send playback information to server.
4633
+ snapshot();
4634
+ break;
4485
4635
  }
4486
4636
  }
4487
4637
  }
@@ -4798,11 +4948,11 @@ function discover() {
4798
4948
  ts = time();
4799
4949
  timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
4800
4950
  start$d(timer);
4801
- return [4 /*yield*/, traverse(document, timer, 0 /* Source.Discover */, ts)];
4951
+ return [4 /*yield*/, traverse$1(document, timer, 0 /* Source.Discover */, ts)];
4802
4952
  case 1:
4803
4953
  _a.sent();
4804
4954
  checkDocumentStyles(document, ts);
4805
- return [4 /*yield*/, encode$4(5 /* Event.Discover */, timer, ts)];
4955
+ return [4 /*yield*/, encode$5(5 /* Event.Discover */, timer, ts)];
4806
4956
  case 2:
4807
4957
  _a.sent();
4808
4958
  stop$c(timer);
@@ -5080,7 +5230,7 @@ function start$8() {
5080
5230
  var _a, _b, _c;
5081
5231
  rootDomain = null;
5082
5232
  var ua = navigator && "userAgent" in navigator ? navigator.userAgent : "" /* Constant.Empty */;
5083
- 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 : '';
5233
+ 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 : '';
5084
5234
  var timezoneOffset = new Date().getTimezoneOffset().toString();
5085
5235
  var ancestorOrigins = window.location.ancestorOrigins ? Array.from(window.location.ancestorOrigins).toString() : '';
5086
5236
  var title = document && document.title ? document.title : "" /* Constant.Empty */;
@@ -5922,7 +6072,7 @@ var observer;
5922
6072
  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 */];
5923
6073
  function start$2() {
5924
6074
  // Capture connection properties, if available
5925
- if (navigator && "connection" in navigator) {
6075
+ if (navigator && navigator["connection"]) {
5926
6076
  log(27 /* Dimension.ConnectionType */, navigator["connection"]["effectiveType"]);
5927
6077
  }
5928
6078
  // Check the browser support performance observer as a pre-requisite for any performance measurement