clarity-js 0.8.48 → 0.8.50-beta

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
@@ -173,6 +173,7 @@ var config$2 = {
173
173
  throttleDom: true,
174
174
  conversions: false,
175
175
  includeSubdomains: true,
176
+ modules: [],
176
177
  };
177
178
 
178
179
  function api(method) {
@@ -186,7 +187,7 @@ var startTime = 0;
186
187
  function computeStartTime() {
187
188
  return performance.now() + performance.timeOrigin;
188
189
  }
189
- function start$N() {
190
+ function start$O() {
190
191
  startTime = computeStartTime();
191
192
  }
192
193
  // event.timestamp is number of milliseconds elapsed since the document was loaded
@@ -206,7 +207,7 @@ function stop$K() {
206
207
  startTime = 0;
207
208
  }
208
209
 
209
- var version$1 = "0.8.48";
210
+ var version$1 = "0.8.50-beta";
210
211
 
211
212
  // tslint:disable: no-bitwise
212
213
  function hash (input, precision) {
@@ -429,7 +430,7 @@ function redact$1(value) {
429
430
  var state$b = null;
430
431
  var buffer = null;
431
432
  var update$2 = false;
432
- function start$M() {
433
+ function start$N() {
433
434
  update$2 = false;
434
435
  reset$u();
435
436
  }
@@ -582,7 +583,7 @@ var baseline = /*#__PURE__*/Object.freeze({
582
583
  compute: compute$g,
583
584
  dynamic: dynamic$1,
584
585
  reset: reset$u,
585
- start: start$M,
586
+ start: start$N,
586
587
  get state () { return state$b; },
587
588
  stop: stop$J,
588
589
  track: track$8,
@@ -609,7 +610,7 @@ function event$1(a, b) {
609
610
 
610
611
  var data$k = null;
611
612
  var updates$3 = null;
612
- function start$L() {
613
+ function start$M() {
613
614
  data$k = {};
614
615
  updates$3 = {};
615
616
  count$1(5 /* Metric.InvokeCount */);
@@ -670,7 +671,7 @@ var data$j;
670
671
  var last = 0;
671
672
  var interval = 0;
672
673
  var timeout$7 = null;
673
- function start$K() {
674
+ function start$L() {
674
675
  interval = 60000 /* Setting.PingInterval */;
675
676
  last = 0;
676
677
  }
@@ -702,12 +703,12 @@ var ping$1 = /*#__PURE__*/Object.freeze({
702
703
  __proto__: null,
703
704
  get data () { return data$j; },
704
705
  reset: reset$s,
705
- start: start$K,
706
+ start: start$L,
706
707
  stop: stop$H
707
708
  });
708
709
 
709
710
  var data$i = null;
710
- function start$J() {
711
+ function start$K() {
711
712
  data$i = {};
712
713
  }
713
714
  function stop$G() {
@@ -742,7 +743,7 @@ var summary = /*#__PURE__*/Object.freeze({
742
743
  compute: compute$e,
743
744
  get data () { return data$i; },
744
745
  reset: reset$r,
745
- start: start$J,
746
+ start: start$K,
746
747
  stop: stop$G,
747
748
  track: track$7
748
749
  });
@@ -861,7 +862,7 @@ function read(stream) {
861
862
  }
862
863
 
863
864
  var data$h = null;
864
- function start$I() {
865
+ function start$J() {
865
866
  reset$q();
866
867
  }
867
868
  function set(variable, value) {
@@ -963,7 +964,7 @@ var variable = /*#__PURE__*/Object.freeze({
963
964
  identify: identify,
964
965
  reset: reset$q,
965
966
  set: set,
966
- start: start$I,
967
+ start: start$J,
967
968
  stop: stop$F
968
969
  });
969
970
 
@@ -973,7 +974,7 @@ var variables = {};
973
974
  var selectors = {};
974
975
  var hashes = {};
975
976
  var validation = {};
976
- function start$H() {
977
+ function start$I() {
977
978
  reset$p();
978
979
  }
979
980
  // Input string is of the following form:
@@ -1162,7 +1163,7 @@ var extract = /*#__PURE__*/Object.freeze({
1162
1163
  data: data$g,
1163
1164
  keys: keys,
1164
1165
  reset: reset$p,
1165
- start: start$H,
1166
+ start: start$I,
1166
1167
  stop: stop$E,
1167
1168
  trigger: trigger$2,
1168
1169
  update: update$1
@@ -1191,7 +1192,7 @@ function decodeCookieValue(value) {
1191
1192
 
1192
1193
  var rootDomain = null;
1193
1194
  var COOKIE_SEP = "^" /* Constant.Caret */;
1194
- function start$G() {
1195
+ function start$H() {
1195
1196
  rootDomain = null;
1196
1197
  }
1197
1198
  function stop$D() {
@@ -1276,7 +1277,7 @@ var cookie = /*#__PURE__*/Object.freeze({
1276
1277
  COOKIE_SEP: COOKIE_SEP,
1277
1278
  getCookie: getCookie,
1278
1279
  setCookie: setCookie,
1279
- start: start$G,
1280
+ start: start$H,
1280
1281
  stop: stop$D
1281
1282
  });
1282
1283
 
@@ -1309,9 +1310,9 @@ function signalsEvent(signalsPayload) {
1309
1310
  }
1310
1311
 
1311
1312
  var modules$2 = [baseline, dimension, variable, limit, summary, cookie, consent$2, metadata$1, envelope$1, upload$1, ping$1, upgrade$1, extract];
1312
- function start$F() {
1313
+ function start$G() {
1313
1314
  // Metric needs to be initialized before we can start measuring. so metric is not wrapped in measure
1314
- start$L();
1315
+ start$M();
1315
1316
  modules$2.forEach(function (x) { return measure(x.start)(); });
1316
1317
  }
1317
1318
  function stop$C() {
@@ -1335,7 +1336,7 @@ function compute$b() {
1335
1336
 
1336
1337
  var history$5 = [];
1337
1338
  var data$f;
1338
- function start$E() {
1339
+ function start$F() {
1339
1340
  history$5 = [];
1340
1341
  max(26 /* Metric.Automation */, navigator.webdriver ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */);
1341
1342
  try {
@@ -1359,7 +1360,7 @@ function check$5(id, target, input) {
1359
1360
  }
1360
1361
 
1361
1362
  var state$a = [];
1362
- function start$D() {
1363
+ function start$E() {
1363
1364
  reset$o();
1364
1365
  }
1365
1366
  function observe$c(root) {
@@ -1399,14 +1400,14 @@ function offset(element) {
1399
1400
 
1400
1401
  var UserInputTags = ["input", "textarea", "radio", "button", "canvas", "select"];
1401
1402
  var state$9 = [];
1402
- function start$C() {
1403
+ function start$D() {
1403
1404
  reset$n();
1404
1405
  }
1405
1406
  function observe$b(root) {
1406
- bind(root, "click", handler$3.bind(this, 9 /* Event.Click */, root), true);
1407
- bind(root, "contextmenu", handler$3.bind(this, 48 /* Event.ContextMenu */, root), true);
1407
+ bind(root, "click", handler$4.bind(this, 9 /* Event.Click */, root), true);
1408
+ bind(root, "contextmenu", handler$4.bind(this, 48 /* Event.ContextMenu */, root), true);
1408
1409
  }
1409
- function handler$3(event, root, evt) {
1410
+ function handler$4(event, root, evt) {
1410
1411
  var frame = iframe(root);
1411
1412
  var d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
1412
1413
  var x = "pageX" in evt ? Math.round(evt.pageX) : ("clientX" in evt ? Math.round(evt["clientX"] + d.scrollLeft) : null);
@@ -1457,6 +1458,7 @@ function handler$3(event, root, evt) {
1457
1458
  tag: getElementAttribute(t, "tagName").substring(0, 10 /* Setting.ClickTag */),
1458
1459
  class: getElementAttribute(t, "className").substring(0, 50 /* Setting.ClickClass */),
1459
1460
  id: getElementAttribute(t, "id").substring(0, 25 /* Setting.ClickId */),
1461
+ source: evt.isTrusted ? 0 /* ClickSource.Undefined */ : source()
1460
1462
  }
1461
1463
  });
1462
1464
  schedule(encode$4.bind(this, event));
@@ -1537,6 +1539,28 @@ function context(a) {
1537
1539
  }
1538
1540
  return 0 /* BrowsingContext.Self */;
1539
1541
  }
1542
+ function source() {
1543
+ try {
1544
+ var stack = new Error().stack || "";
1545
+ var origin_1 = location.origin;
1546
+ var result = 4 /* ClickSource.Unknown */;
1547
+ for (var _i = 0, _a = stack.split("\n"); _i < _a.length; _i++) {
1548
+ var line = _a[_i];
1549
+ if (line.indexOf("://") >= 0) {
1550
+ result = line.indexOf("extension") < 0 && line.indexOf(origin_1) >= 0
1551
+ ? 1 /* ClickSource.FirstParty */
1552
+ : 2 /* ClickSource.ThirdParty */;
1553
+ }
1554
+ else if (line.indexOf("eval") >= 0 || line.indexOf("Function") >= 0 || line.indexOf("<a") >= 0 || /VM\d/.test(line)) {
1555
+ result = 3 /* ClickSource.Eval */;
1556
+ }
1557
+ }
1558
+ return result;
1559
+ }
1560
+ catch (_b) {
1561
+ return 4 /* ClickSource.Unknown */;
1562
+ }
1563
+ }
1540
1564
  function reset$n() {
1541
1565
  state$9 = [];
1542
1566
  }
@@ -1545,7 +1569,7 @@ function stop$A() {
1545
1569
  }
1546
1570
 
1547
1571
  var state$8 = [];
1548
- function start$B() {
1572
+ function start$C() {
1549
1573
  reset$m();
1550
1574
  }
1551
1575
  function observe$a(root) {
@@ -1566,7 +1590,7 @@ function stop$z() {
1566
1590
 
1567
1591
  var timeout$6 = null;
1568
1592
  var state$7 = [];
1569
- function start$A() {
1593
+ function start$B() {
1570
1594
  reset$l();
1571
1595
  }
1572
1596
  function observe$9(root) {
@@ -1610,7 +1634,7 @@ var timeout$5 = null;
1610
1634
  var hasPrimaryTouch = false;
1611
1635
  var primaryTouchId = 0;
1612
1636
  var activeTouchPointIds = new Set();
1613
- function start$z() {
1637
+ function start$A() {
1614
1638
  reset$k();
1615
1639
  }
1616
1640
  function observe$8(root) {
@@ -1637,7 +1661,7 @@ function mouse(event, root, evt) {
1637
1661
  }
1638
1662
  // Check for null values before processing this event
1639
1663
  if (x !== null && y !== null) {
1640
- handler$2({ time: time(evt), event: event, data: { target: target(evt), x: x, y: y } });
1664
+ handler$3({ time: time(evt), event: event, data: { target: target(evt), x: x, y: y } });
1641
1665
  }
1642
1666
  }
1643
1667
  function touch(event, root, evt) {
@@ -1672,7 +1696,7 @@ function touch(event, root, evt) {
1672
1696
  var isPrimary = hasPrimaryTouch && primaryTouchId === id;
1673
1697
  // Check for null values before processing this event
1674
1698
  if (x !== null && y !== null) {
1675
- handler$2({ time: t, event: event, data: { target: target(evt), x: x, y: y, id: id, isPrimary: isPrimary } });
1699
+ handler$3({ time: t, event: event, data: { target: target(evt), x: x, y: y, id: id, isPrimary: isPrimary } });
1676
1700
  }
1677
1701
  // Reset primary touch point id once touch event ends
1678
1702
  if (event === 20 /* Event.TouchCancel */ || event === 18 /* Event.TouchEnd */) {
@@ -1683,7 +1707,7 @@ function touch(event, root, evt) {
1683
1707
  }
1684
1708
  }
1685
1709
  }
1686
- function handler$2(current) {
1710
+ function handler$3(current) {
1687
1711
  switch (current.event) {
1688
1712
  case 12 /* Event.MouseMove */:
1689
1713
  case 15 /* Event.MouseWheel */:
@@ -1778,7 +1802,7 @@ var data$e;
1778
1802
  var timeout$4 = null;
1779
1803
  var initialStateLogged = false;
1780
1804
  var throttledRecompute$1 = throttle(recompute$5, 500 /* Setting.LookAhead */);
1781
- function start$y() {
1805
+ function start$z() {
1782
1806
  initialStateLogged = false;
1783
1807
  bind(window, "resize", throttledRecompute$1);
1784
1808
  recompute$5();
@@ -1816,7 +1840,7 @@ var state$5 = [];
1816
1840
  var initialTop = null;
1817
1841
  var initialBottom = null;
1818
1842
  var timeout$3 = null;
1819
- function start$x() {
1843
+ function start$y() {
1820
1844
  state$5 = [];
1821
1845
  recompute$4();
1822
1846
  }
@@ -1854,7 +1878,8 @@ function recompute$4(event) {
1854
1878
  var endYPosition = height - yOffset;
1855
1879
  var top = getPositionNode(xPosition, startYPosition);
1856
1880
  var bottom = getPositionNode(xPosition, endYPosition);
1857
- var current = { time: time(event), event: 10 /* Event.Scroll */, data: { target: element, x: x, y: y, top: top, bottom: bottom } };
1881
+ var trust = event && event.isTrusted ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */;
1882
+ var current = { time: time(event), event: 10 /* Event.Scroll */, data: { target: element, x: x, y: y, top: top, bottom: bottom, trust: trust } };
1858
1883
  // We don't send any scroll events if this is the first event and the current position is top (0,0)
1859
1884
  if ((event === null && x === 0 && y === 0) || (x === null || y === null)) {
1860
1885
  initialTop = top;
@@ -1923,7 +1948,7 @@ function stop$v() {
1923
1948
  var data$d = null;
1924
1949
  var previous = null;
1925
1950
  var timeout$2 = null;
1926
- function start$w() {
1951
+ function start$x() {
1927
1952
  reset$h();
1928
1953
  }
1929
1954
  function observe$6(root) {
@@ -1973,7 +1998,7 @@ function stop$u() {
1973
1998
  }
1974
1999
 
1975
2000
  var state$4 = [];
1976
- function start$v() {
2001
+ function start$w() {
1977
2002
  reset$g();
1978
2003
  }
1979
2004
  function observe$5(root) {
@@ -1991,7 +2016,7 @@ function stop$t() {
1991
2016
  }
1992
2017
 
1993
2018
  var data$c;
1994
- function start$u() {
2019
+ function start$v() {
1995
2020
  bind(window, "pagehide", recompute$1);
1996
2021
  }
1997
2022
  function recompute$1(evt) {
@@ -2007,7 +2032,7 @@ function stop$s() {
2007
2032
  }
2008
2033
 
2009
2034
  var data$b;
2010
- function start$t() {
2035
+ function start$u() {
2011
2036
  bind(document, "visibilitychange", recompute);
2012
2037
  recompute();
2013
2038
  }
@@ -2027,7 +2052,7 @@ function stop$r() {
2027
2052
  }
2028
2053
 
2029
2054
  var data$a;
2030
- function start$s() {
2055
+ function start$t() {
2031
2056
  bind(window, "focus", function () { return compute$9(1 /* BooleanFlag.True */); });
2032
2057
  bind(window, "blur", function () { return compute$9(0 /* BooleanFlag.False */); });
2033
2058
  }
@@ -2042,20 +2067,44 @@ function compute$9(focus) {
2042
2067
  encode$4(50 /* Event.Focus */);
2043
2068
  }
2044
2069
 
2070
+ var bound = false;
2071
+ function start$s() {
2072
+ // Only bind once - this listener must persist even when Clarity stops
2073
+ // to detect when the page is restored from bfcache
2074
+ if (!bound) {
2075
+ try {
2076
+ window[api("addEventListener" /* Constant.AddEventListener */)]("pageshow", measure(handler$2), { capture: false, passive: true });
2077
+ bound = true;
2078
+ }
2079
+ catch (_a) {
2080
+ /* do nothing */
2081
+ }
2082
+ }
2083
+ }
2084
+ function handler$2(evt) {
2085
+ // The persisted property indicates if the page was loaded from bfcache
2086
+ if (evt && evt.persisted) {
2087
+ // Restart Clarity since it was stopped when the page entered bfcache
2088
+ start();
2089
+ log$1(11 /* Code.BFCache */, 0 /* Severity.Info */);
2090
+ }
2091
+ }
2092
+
2045
2093
  function start$r() {
2046
2094
  start$j();
2095
+ start$D();
2047
2096
  start$C();
2097
+ start$A();
2048
2098
  start$B();
2049
2099
  start$z();
2050
- start$A();
2051
- start$y();
2100
+ start$u();
2052
2101
  start$t();
2053
2102
  start$s();
2103
+ start$y();
2054
2104
  start$x();
2105
+ start$E();
2055
2106
  start$w();
2056
- start$D();
2057
2107
  start$v();
2058
- start$u();
2059
2108
  }
2060
2109
  function stop$p() {
2061
2110
  stop$h();
@@ -4171,6 +4220,7 @@ function encode$4 (type, ts) {
4171
4220
  tokens.push(entry.data.tag);
4172
4221
  tokens.push(entry.data.class);
4173
4222
  tokens.push(entry.data.id);
4223
+ tokens.push(entry.data.source);
4174
4224
  queue(tokens);
4175
4225
  track$2(entry.time, entry.event, cHash, entry.data.x, entry.data.y, entry.data.reaction, entry.data.context);
4176
4226
  }
@@ -4244,6 +4294,7 @@ function encode$4 (type, ts) {
4244
4294
  tokens.push(entry.data.y);
4245
4295
  tokens.push(sTopHash);
4246
4296
  tokens.push(sBottomHash);
4297
+ tokens.push(entry.data.trust);
4247
4298
  queue(tokens);
4248
4299
  track$8(entry.event, entry.data.x, entry.data.y, entry.time);
4249
4300
  }
@@ -4505,6 +4556,9 @@ var modules$1 = null;
4505
4556
  function start$i() {
4506
4557
  active$2 = true;
4507
4558
  modules$1 = new Set();
4559
+ if (config$2.modules && config$2.modules.length > 0) {
4560
+ config$2.modules.forEach(function (m) { event(m); });
4561
+ }
4508
4562
  }
4509
4563
  function stop$g() {
4510
4564
  stopCallbacks.reverse().forEach(function (callback) {
@@ -6031,7 +6085,7 @@ function stop$6() {
6031
6085
  var status = false;
6032
6086
  function start$5() {
6033
6087
  status = true;
6034
- start$N();
6088
+ start$O();
6035
6089
  reset$4();
6036
6090
  reset$1();
6037
6091
  reset$2();
@@ -6098,7 +6152,7 @@ function restart() {
6098
6152
  }
6099
6153
 
6100
6154
  function start$4() {
6101
- start$E();
6155
+ start$F();
6102
6156
  start$g();
6103
6157
  start$f();
6104
6158
  }
@@ -6440,7 +6494,7 @@ function start(config$1) {
6440
6494
  if (check()) {
6441
6495
  config(config$1);
6442
6496
  start$5();
6443
- start$F();
6497
+ start$G();
6444
6498
  modules.forEach(function (x) { return measure(x.start)(); });
6445
6499
  // If it's an internal call to start, without explicit configuration,
6446
6500
  // re-process any newly accumulated items in the queue