clarity-js 0.6.34 → 0.6.35

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
@@ -62,7 +62,6 @@ var metadata$1 = /*#__PURE__*/Object.freeze({
62
62
  get data () { return data$2; },
63
63
  get callbacks () { return callbacks; },
64
64
  get start () { return start$9; },
65
- get userAgentData () { return userAgentData; },
66
65
  get stop () { return stop$8; },
67
66
  get metadata () { return metadata; },
68
67
  get id () { return id; },
@@ -89,6 +88,7 @@ var config$1 = {
89
88
  regions: [],
90
89
  extract: [],
91
90
  cookies: [],
91
+ fraud: [],
92
92
  report: null,
93
93
  upload: null,
94
94
  fallback: null,
@@ -111,11 +111,11 @@ function time(ts) {
111
111
  ts = ts ? ts : performance.now();
112
112
  return Math.max(Math.round(ts - startTime), 0);
113
113
  }
114
- function stop$C() {
114
+ function stop$B() {
115
115
  startTime = 0;
116
116
  }
117
117
 
118
- var version$1 = "0.6.34";
118
+ var version$1 = "0.6.35";
119
119
 
120
120
  // tslint:disable: no-bitwise
121
121
  function hash (input) {
@@ -142,9 +142,9 @@ var buffer = null;
142
142
  var update$2 = false;
143
143
  function start$E() {
144
144
  update$2 = false;
145
- reset$p();
145
+ reset$o();
146
146
  }
147
- function reset$p() {
147
+ function reset$o() {
148
148
  // Baseline state holds the previous values - if it is updated in the current payload,
149
149
  // reset the state to current value after sending the previous state
150
150
  if (update$2) {
@@ -206,25 +206,25 @@ function visibility(t, visible) {
206
206
  }
207
207
  update$2 = true;
208
208
  }
209
- function compute$d() {
209
+ function compute$c() {
210
210
  if (update$2) {
211
211
  encode$1(4 /* Baseline */);
212
212
  }
213
213
  }
214
- function stop$B() {
215
- reset$p();
214
+ function stop$A() {
215
+ reset$o();
216
216
  }
217
217
 
218
218
  var baseline = /*#__PURE__*/Object.freeze({
219
219
  __proto__: null,
220
220
  get state () { return state$9; },
221
221
  start: start$E,
222
- reset: reset$p,
222
+ reset: reset$o,
223
223
  track: track$7,
224
224
  activity: activity,
225
225
  visibility: visibility,
226
- compute: compute$d,
227
- stop: stop$B
226
+ compute: compute$c,
227
+ stop: stop$A
228
228
  });
229
229
 
230
230
  var data$j = null;
@@ -248,20 +248,19 @@ function start$D() {
248
248
  updates$3 = {};
249
249
  count$1(5 /* InvokeCount */);
250
250
  }
251
- function stop$A() {
251
+ function stop$z() {
252
252
  data$i = {};
253
253
  updates$3 = {};
254
254
  }
255
- function count$1(metric, increment) {
256
- if (increment === void 0) { increment = 1; }
255
+ function count$1(metric) {
257
256
  if (!(metric in data$i)) {
258
257
  data$i[metric] = 0;
259
258
  }
260
259
  if (!(metric in updates$3)) {
261
260
  updates$3[metric] = 0;
262
261
  }
263
- data$i[metric] += increment;
264
- updates$3[metric] += increment;
262
+ data$i[metric]++;
263
+ updates$3[metric]++;
265
264
  }
266
265
  function sum(metric, value) {
267
266
  if (value !== null) {
@@ -287,10 +286,10 @@ function max(metric, value) {
287
286
  }
288
287
  }
289
288
  }
290
- function compute$c() {
289
+ function compute$b() {
291
290
  encode$1(0 /* Metric */);
292
291
  }
293
- function reset$o() {
292
+ function reset$n() {
294
293
  updates$3 = {};
295
294
  }
296
295
 
@@ -309,7 +308,7 @@ function start$C() {
309
308
  interval = 60000 /* PingInterval */;
310
309
  last = 0;
311
310
  }
312
- function reset$n() {
311
+ function reset$m() {
313
312
  if (timeout$6) {
314
313
  clearTimeout(timeout$6);
315
314
  }
@@ -327,7 +326,7 @@ function ping() {
327
326
  suspend();
328
327
  }
329
328
  }
330
- function stop$z() {
329
+ function stop$y() {
331
330
  clearTimeout(timeout$6);
332
331
  last = 0;
333
332
  interval = 0;
@@ -337,15 +336,15 @@ var ping$1 = /*#__PURE__*/Object.freeze({
337
336
  __proto__: null,
338
337
  get data () { return data$h; },
339
338
  start: start$C,
340
- reset: reset$n,
341
- stop: stop$z
339
+ reset: reset$m,
340
+ stop: stop$y
342
341
  });
343
342
 
344
343
  var data$g = null;
345
344
  function start$B() {
346
345
  data$g = {};
347
346
  }
348
- function stop$y() {
347
+ function stop$x() {
349
348
  data$g = {};
350
349
  }
351
350
  function track$6(event, time) {
@@ -365,10 +364,10 @@ function track$6(event, time) {
365
364
  }
366
365
  }
367
366
  }
368
- function compute$b() {
367
+ function compute$a() {
369
368
  encode$1(36 /* Summary */);
370
369
  }
371
- function reset$m() {
370
+ function reset$l() {
372
371
  data$g = {};
373
372
  }
374
373
 
@@ -376,10 +375,10 @@ var summary = /*#__PURE__*/Object.freeze({
376
375
  __proto__: null,
377
376
  get data () { return data$g; },
378
377
  start: start$B,
379
- stop: stop$y,
378
+ stop: stop$x,
380
379
  track: track$6,
381
- compute: compute$b,
382
- reset: reset$m
380
+ compute: compute$a,
381
+ reset: reset$l
383
382
  });
384
383
 
385
384
  var data$f = null;
@@ -407,7 +406,7 @@ function upgrade(key) {
407
406
  encode$1(3 /* Upgrade */);
408
407
  }
409
408
  }
410
- function stop$x() {
409
+ function stop$w() {
411
410
  data$f = null;
412
411
  }
413
412
 
@@ -416,12 +415,12 @@ var upgrade$1 = /*#__PURE__*/Object.freeze({
416
415
  get data () { return data$f; },
417
416
  start: start$A,
418
417
  upgrade: upgrade,
419
- stop: stop$x
418
+ stop: stop$w
420
419
  });
421
420
 
422
421
  var data$e = null;
423
422
  function start$z() {
424
- reset$l();
423
+ reset$k();
425
424
  }
426
425
  function set(variable, value) {
427
426
  var values = typeof value === "string" /* String */ ? [value] : value;
@@ -449,14 +448,14 @@ function log$2(variable, value) {
449
448
  data$e[variable] = validValues;
450
449
  }
451
450
  }
452
- function compute$a() {
451
+ function compute$9() {
453
452
  encode$1(34 /* Variable */);
454
453
  }
455
- function reset$l() {
454
+ function reset$k() {
456
455
  data$e = {};
457
456
  }
458
- function stop$w() {
459
- reset$l();
457
+ function stop$v() {
458
+ reset$k();
460
459
  }
461
460
 
462
461
  var variable = /*#__PURE__*/Object.freeze({
@@ -465,9 +464,9 @@ var variable = /*#__PURE__*/Object.freeze({
465
464
  start: start$z,
466
465
  set: set,
467
466
  identify: identify,
468
- compute: compute$a,
469
- reset: reset$l,
470
- stop: stop$w
467
+ compute: compute$9,
468
+ reset: reset$k,
469
+ stop: stop$v
471
470
  });
472
471
 
473
472
  /*! *****************************************************************************
@@ -587,20 +586,20 @@ function start$y() {
587
586
  start$D();
588
587
  modules$1.forEach(function (x) { return measure(x.start)(); });
589
588
  }
590
- function stop$v() {
589
+ function stop$u() {
591
590
  // Stop modules in the reverse order of their initialization
592
591
  // The ordering below should respect inter-module dependency.
593
592
  // E.g. if upgrade depends on upload, then upgrade needs to end before upload.
594
593
  // Similarly, if upload depends on metadata, upload needs to end before metadata.
595
594
  modules$1.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
596
- stop$A();
595
+ stop$z();
597
596
  }
598
- function compute$9() {
599
- compute$a();
600
- compute$d();
601
- compute$2();
597
+ function compute$8() {
598
+ compute$9();
602
599
  compute$c();
600
+ compute$2();
603
601
  compute$b();
602
+ compute$a();
604
603
  compute$3();
605
604
  compute$4();
606
605
  }
@@ -650,7 +649,7 @@ function mangleText(value) {
650
649
  var index = value.indexOf(first);
651
650
  var prefix = value.substr(0, index);
652
651
  var suffix = value.substr(index + trimmed.length);
653
- return "" + prefix + trimmed.length.toString(36) + suffix;
652
+ return "".concat(prefix).concat(trimmed.length.toString(36)).concat(suffix);
654
653
  }
655
654
  return value;
656
655
  }
@@ -701,12 +700,30 @@ function mutate(array, start, end) {
701
700
  }
702
701
  }
703
702
 
703
+ var history$5 = [];
704
+ var data$d;
705
+ function start$x() {
706
+ history$5 = [];
707
+ max(26 /* Automation */, navigator.webdriver ? 1 /* True */ : 0 /* False */);
708
+ }
709
+ function check$4(id, target, input) {
710
+ // Compute hash for fraud detection. Hash is computed only if input meets the minimum length criteria
711
+ if (id !== null && input && input.length >= 5 /* WordLength */) {
712
+ data$d = { id: id, target: target, hash: hash(input) };
713
+ // Only encode this event if we haven't already reported this hash
714
+ if (history$5.indexOf(data$d.hash) < 0) {
715
+ history$5.push(data$d.hash);
716
+ encode$2(41 /* Fraud */);
717
+ }
718
+ }
719
+ }
720
+
704
721
  var TAGS = ["DIV", "TR", "P", "LI", "UL", "A", "BUTTON"];
705
722
  function selector (input, beta) {
706
723
  if (beta === void 0) { beta = false; }
707
724
  var a = input.attributes;
708
725
  var prefix = input.prefix ? input.prefix[beta ? 1 /* Beta */ : 0 /* Stable */] : null;
709
- var suffix = beta || ((a && !("class" /* Class */ in a)) || TAGS.indexOf(input.tag) >= 0) ? ":nth-of-type(" + input.position + ")" : "" /* Empty */;
726
+ var suffix = beta || ((a && !("class" /* Class */ in a)) || TAGS.indexOf(input.tag) >= 0) ? ":nth-of-type(".concat(input.position, ")") : "" /* Empty */;
710
727
  switch (input.tag) {
711
728
  case "STYLE":
712
729
  case "TITLE":
@@ -721,9 +738,9 @@ function selector (input, beta) {
721
738
  if (prefix === null) {
722
739
  return "" /* Empty */;
723
740
  }
724
- prefix = prefix + ">";
741
+ prefix = "".concat(prefix, ">");
725
742
  input.tag = input.tag.indexOf("svg:" /* SvgPrefix */) === 0 ? input.tag.substr("svg:" /* SvgPrefix */.length) : input.tag;
726
- var selector = "" + prefix + input.tag + suffix;
743
+ var selector = "".concat(prefix).concat(input.tag).concat(suffix);
727
744
  var classes = "class" /* Class */ in a && a["class" /* Class */].length > 0 ? a["class" /* Class */].trim().split(/\s+/) : null;
728
745
  if (beta) {
729
746
  // In beta mode, update selector to use "id" field when available. There are two exceptions:
@@ -731,19 +748,19 @@ function selector (input, beta) {
731
748
  // (2) if "id" appears inside a shadow DOM, in which case we continue to prefix up to shadow DOM to prevent conflicts
732
749
  var id = "id" /* Id */ in a && a["id" /* Id */].length > 0 ? a["id" /* Id */] : null;
733
750
  classes = input.tag !== "BODY" /* BodyTag */ && classes ? classes.filter(function (c) { return !hasDigits(c); }) : [];
734
- selector = classes.length > 0 ? "" + prefix + input.tag + "." + classes.join(".") + suffix : selector;
735
- selector = id && hasDigits(id) === false ? getDomPrefix(prefix) + "#" + id : selector;
751
+ selector = classes.length > 0 ? "".concat(prefix).concat(input.tag, ".").concat(classes.join(".")).concat(suffix) : selector;
752
+ selector = id && hasDigits(id) === false ? "".concat(getDomPrefix(prefix), "#").concat(id) : selector;
736
753
  }
737
754
  else {
738
755
  // Otherwise, fallback to stable mode, where we include class names as part of the selector
739
- selector = classes ? "" + prefix + input.tag + "." + classes.join(".") + suffix : selector;
756
+ selector = classes ? "".concat(prefix).concat(input.tag, ".").concat(classes.join(".")).concat(suffix) : selector;
740
757
  }
741
758
  return selector;
742
759
  }
743
760
  }
744
761
  function getDomPrefix(prefix) {
745
762
  var shadowDomStart = prefix.lastIndexOf("*S" /* ShadowDomTag */);
746
- var iframeDomStart = prefix.lastIndexOf("" + "iframe:" /* IFramePrefix */ + "HTML" /* HTML */);
763
+ var iframeDomStart = prefix.lastIndexOf("".concat("iframe:" /* IFramePrefix */).concat("HTML" /* HTML */));
747
764
  var domStart = Math.max(shadowDomStart, iframeDomStart);
748
765
  if (domStart < 0) {
749
766
  return "";
@@ -785,7 +802,7 @@ function resume$1() {
785
802
  }
786
803
  }
787
804
  }
788
- function reset$k() {
805
+ function reset$j() {
789
806
  tracker = {};
790
807
  queuedTasks = [];
791
808
  activeTask = null;
@@ -855,20 +872,20 @@ function state$8(timer) {
855
872
  // If this task is no longer being tracked, send stop message to the caller
856
873
  return 2 /* Stop */;
857
874
  }
858
- function start$x(timer) {
875
+ function start$w(timer) {
859
876
  tracker[key(timer)] = { start: performance.now(), calls: 0, yield: 30 /* LongTask */ };
860
877
  }
861
- function restart$1(timer) {
878
+ function restart$2(timer) {
862
879
  var id = key(timer);
863
880
  if (tracker && tracker[id]) {
864
881
  var c = tracker[id].calls;
865
882
  var y = tracker[id].yield;
866
- start$x(timer);
883
+ start$w(timer);
867
884
  tracker[id].calls = c + 1;
868
885
  tracker[id].yield = y;
869
886
  }
870
887
  }
871
- function stop$u(timer) {
888
+ function stop$t(timer) {
872
889
  var end = performance.now();
873
890
  var id = key(timer);
874
891
  var duration = end - tracker[id].start;
@@ -888,12 +905,12 @@ function suspend$1(timer) {
888
905
  case 0:
889
906
  id = key(timer);
890
907
  if (!(id in tracker)) return [3 /*break*/, 2];
891
- stop$u(timer);
908
+ stop$t(timer);
892
909
  _a = tracker[id];
893
910
  return [4 /*yield*/, wait()];
894
911
  case 1:
895
912
  _a.yield = (_b.sent()).timeRemaining();
896
- restart$1(timer);
913
+ restart$2(timer);
897
914
  _b.label = 2;
898
915
  case 2:
899
916
  // After we are done with suspending task, ensure that we are still operating in the right context
@@ -904,7 +921,7 @@ function suspend$1(timer) {
904
921
  });
905
922
  }
906
923
  function key(timer) {
907
- return timer.id + "." + timer.cost;
924
+ return "".concat(timer.id, ".").concat(timer.cost);
908
925
  }
909
926
  function wait() {
910
927
  return __awaiter(this, void 0, void 0, function () {
@@ -1000,91 +1017,13 @@ function tokenize (tokens) {
1000
1017
  return output;
1001
1018
  }
1002
1019
 
1003
- var data$d = [];
1004
- var enabled = false;
1005
- var observer$2 = null;
1006
- function start$w() {
1007
- reset$j();
1008
- observer$2 = null;
1009
- enabled = window["ResizeObserver"] ? true : false;
1010
- }
1011
- function compute$8(id) {
1012
- if (enabled === false) {
1013
- return;
1014
- }
1015
- observer$2 = observer$2 === null ? new ResizeObserver(handler$4) : observer$2;
1016
- if (observer$2) {
1017
- var value = getValue(id);
1018
- // If this is the first time computing size for this node, go ahead and wire up ResizeObserver
1019
- // In all other cases, value.metadata.size will be null or an array with two elements [width, height]
1020
- // And, in those cases, we will skip through the following section and not attach the observer
1021
- if (value && value.metadata.size !== null && value.metadata.size.length === 0) {
1022
- var node = getNode(id);
1023
- if (node && node.nodeType === Node.ELEMENT_NODE) {
1024
- var e = node;
1025
- var r = e.getBoundingClientRect();
1026
- value.metadata.size = [Math.floor(r.width * 100 /* BoxPrecision */), Math.floor(r.height * 100 /* BoxPrecision */)];
1027
- observer$2.observe(e);
1028
- }
1029
- }
1030
- }
1031
- }
1032
- function handler$4(entries) {
1033
- window.requestAnimationFrame(function () {
1034
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
1035
- var entry = entries_1[_i];
1036
- var target = entry.target;
1037
- var id = target ? getId(target) : null;
1038
- if (id) {
1039
- var v = getValue(id);
1040
- var s = v.metadata.size;
1041
- var b = entry.borderBoxSize;
1042
- var w = null;
1043
- var h = null;
1044
- // Check if browser supports borderBoxSize property on ResizeObserverEntry object
1045
- // Otherwise, fall back to using getBoundingClientRect() to be cross browser compatible
1046
- // Reference: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/borderBoxSize
1047
- if (b && b.length > 0) {
1048
- w = Math.floor(b[0].inlineSize * 100 /* BoxPrecision */);
1049
- h = Math.floor(b[0].blockSize * 100 /* BoxPrecision */);
1050
- }
1051
- else {
1052
- var r = target.getBoundingClientRect();
1053
- w = Math.floor(r.width * 100 /* BoxPrecision */);
1054
- h = Math.floor(r.height * 100 /* BoxPrecision */);
1055
- }
1056
- // Capture new width & height only if they are different from what we have in in-memory cache
1057
- if (w !== s[0] && h !== s[1]) {
1058
- s = [w, h];
1059
- data$d.push({ id: id, width: w, height: h });
1060
- }
1061
- }
1062
- }
1063
- // Schedule encode only when we have at least one valid data entry
1064
- if (data$d.length > 0) {
1065
- encode$4(37 /* Box */);
1066
- }
1067
- });
1068
- }
1069
- function reset$j() {
1070
- data$d = [];
1071
- }
1072
- function stop$t() {
1073
- reset$j();
1074
- if (observer$2) {
1075
- observer$2.disconnect();
1076
- observer$2 = null;
1077
- }
1078
- enabled = false;
1079
- }
1080
-
1081
1020
  function encode$4 (type, timer, ts) {
1082
1021
  if (timer === void 0) { timer = null; }
1083
1022
  if (ts === void 0) { ts = null; }
1084
1023
  return __awaiter(this, void 0, void 0, function () {
1085
- var eventTime, tokens, _a, d, _i, _b, r, b, _c, b_1, entry, values, _d, values_1, value, state, data, active, suspend, privacy, mangle, keys, _e, keys_1, key, size, factor, attr;
1086
- return __generator(this, function (_f) {
1087
- switch (_f.label) {
1024
+ var eventTime, tokens, _a, d, _i, _b, r, values, _c, values_1, value, state, data, active, suspend, privacy, mangle, keys, _d, keys_1, key, box, factor, attr;
1025
+ return __generator(this, function (_e) {
1026
+ switch (_e.label) {
1088
1027
  case 0:
1089
1028
  eventTime = ts || time();
1090
1029
  tokens = [eventTime, type];
@@ -1092,18 +1031,17 @@ function encode$4 (type, timer, ts) {
1092
1031
  switch (_a) {
1093
1032
  case 8 /* Document */: return [3 /*break*/, 1];
1094
1033
  case 7 /* Region */: return [3 /*break*/, 2];
1095
- case 37 /* Box */: return [3 /*break*/, 3];
1096
- case 5 /* Discover */: return [3 /*break*/, 4];
1097
- case 6 /* Mutation */: return [3 /*break*/, 4];
1034
+ case 5 /* Discover */: return [3 /*break*/, 3];
1035
+ case 6 /* Mutation */: return [3 /*break*/, 3];
1098
1036
  }
1099
- return [3 /*break*/, 11];
1037
+ return [3 /*break*/, 10];
1100
1038
  case 1:
1101
1039
  d = data$c;
1102
1040
  tokens.push(d.width);
1103
1041
  tokens.push(d.height);
1104
1042
  track$7(type, d.width, d.height);
1105
1043
  queue(tokens);
1106
- return [3 /*break*/, 11];
1044
+ return [3 /*break*/, 10];
1107
1045
  case 2:
1108
1046
  for (_i = 0, _b = state$1; _i < _b.length; _i++) {
1109
1047
  r = _b[_i];
@@ -1115,39 +1053,28 @@ function encode$4 (type, timer, ts) {
1115
1053
  queue(tokens);
1116
1054
  }
1117
1055
  reset$6();
1118
- return [3 /*break*/, 11];
1056
+ return [3 /*break*/, 10];
1119
1057
  case 3:
1120
- b = data$d;
1121
- for (_c = 0, b_1 = b; _c < b_1.length; _c++) {
1122
- entry = b_1[_c];
1123
- tokens.push(entry.id);
1124
- tokens.push(entry.width);
1125
- tokens.push(entry.height);
1126
- }
1127
- reset$j();
1128
- queue(tokens);
1129
- return [3 /*break*/, 11];
1130
- case 4:
1131
1058
  // Check if we are operating within the context of the current page
1132
1059
  if (state$8(timer) === 2 /* Stop */) {
1133
- return [3 /*break*/, 11];
1060
+ return [3 /*break*/, 10];
1134
1061
  }
1135
1062
  values = updates$2();
1136
- if (!(values.length > 0)) return [3 /*break*/, 10];
1137
- _d = 0, values_1 = values;
1138
- _f.label = 5;
1139
- case 5:
1140
- if (!(_d < values_1.length)) return [3 /*break*/, 9];
1141
- value = values_1[_d];
1063
+ if (!(values.length > 0)) return [3 /*break*/, 9];
1064
+ _c = 0, values_1 = values;
1065
+ _e.label = 4;
1066
+ case 4:
1067
+ if (!(_c < values_1.length)) return [3 /*break*/, 8];
1068
+ value = values_1[_c];
1142
1069
  state = state$8(timer);
1143
- if (!(state === 0 /* Wait */)) return [3 /*break*/, 7];
1070
+ if (!(state === 0 /* Wait */)) return [3 /*break*/, 6];
1144
1071
  return [4 /*yield*/, suspend$1(timer)];
1072
+ case 5:
1073
+ state = _e.sent();
1074
+ _e.label = 6;
1145
1075
  case 6:
1146
- state = _f.sent();
1147
- _f.label = 7;
1148
- case 7:
1149
1076
  if (state === 2 /* Stop */) {
1150
- return [3 /*break*/, 9];
1077
+ return [3 /*break*/, 8];
1151
1078
  }
1152
1079
  data = value.data;
1153
1080
  active = value.metadata.active;
@@ -1155,13 +1082,12 @@ function encode$4 (type, timer, ts) {
1155
1082
  privacy = value.metadata.privacy;
1156
1083
  mangle = shouldMangle(value);
1157
1084
  keys = active ? ["tag", "attributes", "value"] : ["tag"];
1158
- compute$8(value.id);
1159
- for (_e = 0, keys_1 = keys; _e < keys_1.length; _e++) {
1160
- key = keys_1[_e];
1085
+ for (_d = 0, keys_1 = keys; _d < keys_1.length; _d++) {
1086
+ key = keys_1[_d];
1161
1087
  if (data[key]) {
1162
1088
  switch (key) {
1163
1089
  case "tag":
1164
- size = value.metadata.size;
1090
+ box = size$1(value);
1165
1091
  factor = mangle ? -1 : 1;
1166
1092
  tokens.push(value.id * factor);
1167
1093
  if (value.parent && active) {
@@ -1171,8 +1097,8 @@ function encode$4 (type, timer, ts) {
1171
1097
  tokens.push(value.previous);
1172
1098
  }
1173
1099
  tokens.push(suspend ? "*M" /* SuspendMutationTag */ : data[key]);
1174
- if (size && size.length === 2) {
1175
- tokens.push("" + "#" /* Box */ + str$1(size[0]) + "." + str$1(size[1]));
1100
+ if (box && box.length === 2) {
1101
+ tokens.push("".concat("#" /* Box */).concat(str$1(box[0]), ".").concat(str$1(box[1])));
1176
1102
  }
1177
1103
  break;
1178
1104
  case "attributes":
@@ -1183,23 +1109,24 @@ function encode$4 (type, timer, ts) {
1183
1109
  }
1184
1110
  break;
1185
1111
  case "value":
1112
+ check$4(value.metadata.fraud, value.id, data[key]);
1186
1113
  tokens.push(scrub(data[key], data.tag, privacy, mangle));
1187
1114
  break;
1188
1115
  }
1189
1116
  }
1190
1117
  }
1191
- _f.label = 8;
1118
+ _e.label = 7;
1119
+ case 7:
1120
+ _c++;
1121
+ return [3 /*break*/, 4];
1192
1122
  case 8:
1193
- _d++;
1194
- return [3 /*break*/, 5];
1195
- case 9:
1196
1123
  if (type === 6 /* Mutation */) {
1197
1124
  activity(eventTime);
1198
1125
  }
1199
1126
  queue(tokenize(tokens), !config$1.lean);
1200
- _f.label = 10;
1201
- case 10: return [3 /*break*/, 11];
1202
- case 11: return [2 /*return*/];
1127
+ _e.label = 9;
1128
+ case 9: return [3 /*break*/, 10];
1129
+ case 10: return [2 /*return*/];
1203
1130
  }
1204
1131
  });
1205
1132
  });
@@ -1208,11 +1135,20 @@ function shouldMangle(value) {
1208
1135
  var privacy = value.metadata.privacy;
1209
1136
  return value.data.tag === "*T" /* TextTag */ && !(privacy === 0 /* None */ || privacy === 1 /* Sensitive */);
1210
1137
  }
1138
+ function size$1(value) {
1139
+ if (value.metadata.size !== null && value.metadata.size.length === 0) {
1140
+ var img = getNode(value.id);
1141
+ if (img) {
1142
+ return [Math.floor(img.offsetWidth * 100 /* BoxPrecision */), Math.floor(img.offsetHeight * 100 /* BoxPrecision */)];
1143
+ }
1144
+ }
1145
+ return value.metadata.size;
1146
+ }
1211
1147
  function str$1(input) {
1212
1148
  return input.toString(36);
1213
1149
  }
1214
1150
  function attribute(key, value, privacy) {
1215
- return key + "=" + scrub(value, key, privacy);
1151
+ return "".concat(key, "=").concat(scrub(value, key, privacy));
1216
1152
  }
1217
1153
 
1218
1154
  var data$c;
@@ -1316,7 +1252,8 @@ function handler$3(event, root, evt) {
1316
1252
  context: context(a),
1317
1253
  text: text(t),
1318
1254
  link: a ? a.href : null,
1319
- hash: null
1255
+ hash: null,
1256
+ trust: evt.isTrusted ? 1 /* True */ : 0 /* False */
1320
1257
  }
1321
1258
  });
1322
1259
  schedule$1(encode$3.bind(this, event));
@@ -1415,18 +1352,12 @@ function recompute$6(evt) {
1415
1352
  var input = target(evt);
1416
1353
  var value = get(input);
1417
1354
  if (input && input.type && value) {
1418
- var v = void 0;
1355
+ var v = input.value;
1419
1356
  switch (input.type) {
1420
1357
  case "radio":
1421
1358
  case "checkbox":
1422
1359
  v = input.checked ? "true" : "false";
1423
1360
  break;
1424
- case "range":
1425
- v = input.value;
1426
- break;
1427
- default:
1428
- v = scrub(input.value, "input", value.metadata.privacy);
1429
- break;
1430
1361
  }
1431
1362
  var data = { target: input, value: v };
1432
1363
  // If last entry in the queue is for the same target node as the current one, remove it so we can later swap it with current data.
@@ -2202,7 +2133,7 @@ function process$2() {
2202
2133
  switch (_b.label) {
2203
2134
  case 0:
2204
2135
  timer = { id: id(), cost: 3 /* LayoutCost */ };
2205
- start$x(timer);
2136
+ start$w(timer);
2206
2137
  _b.label = 1;
2207
2138
  case 1:
2208
2139
  if (!(mutations.length > 0)) return [3 /*break*/, 8];
@@ -2257,7 +2188,7 @@ function process$2() {
2257
2188
  _b.sent();
2258
2189
  return [3 /*break*/, 1];
2259
2190
  case 8:
2260
- stop$u(timer);
2191
+ stop$t(timer);
2261
2192
  return [2 /*return*/];
2262
2193
  }
2263
2194
  });
@@ -2384,10 +2315,6 @@ function generate(target, type) {
2384
2315
  }
2385
2316
 
2386
2317
  var index = 1;
2387
- // Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#%3Cinput%3E_types
2388
- var DISALLOWED_TYPES = ["password", "hidden", "email", "tel"];
2389
- var DISALLOWED_NAMES = ["addr", "cell", "code", "dob", "email", "mob", "name", "phone", "secret", "social", "ssn", "tel", "zip", "pass", "card", "account", "cvv", "ccv"];
2390
- var DISALLOWED_MATCH = ["address", "password", "contact"];
2391
2318
  var nodes = [];
2392
2319
  var values = [];
2393
2320
  var updateMap = [];
@@ -2395,10 +2322,13 @@ var hashMap = {};
2395
2322
  var override = [];
2396
2323
  var unmask = [];
2397
2324
  var updatedFragments = {};
2325
+ var maskText = [];
2326
+ var maskDisable = [];
2398
2327
  // The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced
2399
2328
  var idMap = null; // Maps node => id.
2400
2329
  var iframeMap = null; // Maps iframe's contentDocument => parent iframe element
2401
2330
  var privacyMap = null; // Maps node => Privacy (enum)
2331
+ var fraudMap = null; // Maps node => FraudId (number)
2402
2332
  function start$i() {
2403
2333
  reset$7();
2404
2334
  parse$1(document, true);
@@ -2414,9 +2344,12 @@ function reset$7() {
2414
2344
  hashMap = {};
2415
2345
  override = [];
2416
2346
  unmask = [];
2347
+ maskText = "password,secret,pass,social,ssn,name,code,dob,cell,mob,contact,hidden,account,cvv,ccv,email,tel,phone,address,addr,card,zip" /* Text */.split("," /* Comma */);
2348
+ maskDisable = "radio,checkbox,range,button,reset,submit" /* Disable */.split("," /* Comma */);
2417
2349
  idMap = new WeakMap();
2418
2350
  iframeMap = new WeakMap();
2419
2351
  privacyMap = new WeakMap();
2352
+ fraudMap = new WeakMap();
2420
2353
  }
2421
2354
  // We parse new root nodes for any regions or masked nodes in the beginning (document) and
2422
2355
  // later whenever there are new additions or modifications to DOM (mutations)
@@ -2432,8 +2365,9 @@ function parse$1(root, init) {
2432
2365
  // Since mutations may happen on leaf nodes too, e.g. text nodes, which may not support all selector APIs.
2433
2366
  // We ensure that the root note supports querySelectorAll API before executing the code below to identify new regions.
2434
2367
  if ("querySelectorAll" in root) {
2435
- config$1.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "" + x[0]); }); }); // Regions
2368
+ config$1.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "".concat(x[0])); }); }); // Regions
2436
2369
  config$1.mask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 3 /* TextImage */); }); }); // Masked Elements
2370
+ config$1.fraud.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Check
2437
2371
  unmask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 0 /* None */); }); }); // Unmasked Elements
2438
2372
  }
2439
2373
  }
@@ -2457,19 +2391,18 @@ function add(node, parent, data, source) {
2457
2391
  var id = getId(node, true);
2458
2392
  var parentId = parent ? getId(parent) : null;
2459
2393
  var previousId = getPreviousId(node);
2460
- var privacy = config$1.content ? 1 /* Sensitive */ : 2 /* Text */;
2461
2394
  var parentValue = null;
2462
2395
  var regionId = exists(node) ? id : null;
2463
2396
  var fragmentId = null;
2397
+ var fraudId = fraudMap.has(node) ? fraudMap.get(node) : null;
2398
+ var privacyId = config$1.content ? 1 /* Sensitive */ : 2 /* Text */;
2464
2399
  if (parentId >= 0 && values[parentId]) {
2465
2400
  parentValue = values[parentId];
2466
2401
  parentValue.children.push(id);
2467
2402
  regionId = regionId === null ? parentValue.region : regionId;
2468
2403
  fragmentId = parentValue.fragment;
2469
- privacy = parentValue.metadata.privacy;
2404
+ fraudId = fraudId === null ? parentValue.metadata.fraud : fraudId;
2470
2405
  }
2471
- // Check to see if this particular node should be masked or not
2472
- privacy = getPrivacy(node, data, parentValue, privacy);
2473
2406
  // If there's an explicit region attribute set on the element, use it to mark a region on the page
2474
2407
  if (data.attributes && "data-clarity-region" /* RegionData */ in data.attributes) {
2475
2408
  observe$1(node, data.attributes["data-clarity-region" /* RegionData */]);
@@ -2485,11 +2418,12 @@ function add(node, parent, data, source) {
2485
2418
  selector: null,
2486
2419
  hash: null,
2487
2420
  region: regionId,
2488
- metadata: { active: true, suspend: false, privacy: privacy, position: null, size: null },
2421
+ metadata: { active: true, suspend: false, privacy: privacyId, position: null, fraud: fraudId, size: null },
2489
2422
  fragment: fragmentId,
2490
2423
  };
2424
+ privacy(node, values[id], parentValue);
2491
2425
  updateSelector(values[id]);
2492
- size(values[id], parentValue);
2426
+ size(values[id]);
2493
2427
  track$4(id, source, values[id].fragment);
2494
2428
  }
2495
2429
  function update$1(node, parent, data, source) {
@@ -2569,75 +2503,61 @@ function iframe(node) {
2569
2503
  var doc = node.nodeType === Node.DOCUMENT_NODE ? node : null;
2570
2504
  return doc && iframeMap.has(doc) ? iframeMap.get(doc) : null;
2571
2505
  }
2572
- function getPrivacy(node, data, parent, privacy) {
2573
- var attributes = data.attributes;
2506
+ function privacy(node, value, parent) {
2507
+ var data = value.data;
2508
+ var metadata = value.metadata;
2509
+ var current = metadata.privacy;
2510
+ var attributes = data.attributes || {};
2574
2511
  var tag = data.tag.toUpperCase();
2575
- // If this node was explicitly configured to contain sensitive content, use that information and return the value
2576
- if (privacyMap.has(node)) {
2577
- return privacyMap.get(node);
2578
- }
2579
- // If it's a text node belonging to a STYLE or TITLE tag;
2580
- // Or, the text node belongs to one of SCRUB_EXCEPTIONS
2581
- // then reset the privacy setting to ensure we capture the content
2582
- if (tag === "*T" /* TextTag */ && parent && parent.data) {
2583
- var path = parent.selector ? parent.selector[0 /* Stable */] : "" /* Empty */;
2584
- privacy = parent.data.tag === "STYLE" /* StyleTag */ || parent.data.tag === "TITLE" /* TitleTag */ ? 0 /* None */ : privacy;
2585
- for (var _i = 0, override_1 = override; _i < override_1.length; _i++) {
2586
- var entry = override_1[_i];
2587
- if (path.indexOf(entry) >= 0) {
2588
- privacy = 0 /* None */;
2589
- break;
2590
- }
2591
- }
2592
- }
2593
- // Do not proceed if attributes are missing for the node
2594
- if (attributes === null || attributes === undefined) {
2595
- return privacy;
2596
- }
2597
- // Look up for sensitive fields
2598
- if ("class" /* Class */ in attributes && privacy === 1 /* Sensitive */) {
2599
- for (var _a = 0, DISALLOWED_MATCH_1 = DISALLOWED_MATCH; _a < DISALLOWED_MATCH_1.length; _a++) {
2600
- var match = DISALLOWED_MATCH_1[_a];
2601
- if (attributes["class" /* Class */].indexOf(match) >= 0) {
2602
- privacy = 2 /* Text */;
2603
- break;
2604
- }
2605
- }
2606
- }
2607
- // Check for disallowed list of fields (e.g. address, phone, etc.) only if the input node is not already masked
2608
- if (tag === "INPUT" /* InputTag */) {
2609
- if (privacy === 0 /* None */) {
2610
- var field = "" /* Empty */;
2611
- // Be aggressive in looking up any attribute (id, class, name, etc.) for disallowed names
2612
- for (var _b = 0, _c = Object.keys(attributes); _b < _c.length; _b++) {
2613
- var attribute = _c[_b];
2614
- field += attributes[attribute].toLowerCase();
2615
- }
2616
- for (var _d = 0, DISALLOWED_NAMES_1 = DISALLOWED_NAMES; _d < DISALLOWED_NAMES_1.length; _d++) {
2617
- var name_1 = DISALLOWED_NAMES_1[_d];
2618
- if (field.indexOf(name_1) >= 0) {
2619
- privacy = 2 /* Text */;
2620
- break;
2621
- }
2622
- }
2623
- }
2624
- else if (privacy === 1 /* Sensitive */) {
2625
- // Mask all input fields with an exception of type=submit; since they do not accept user input
2626
- privacy = attributes && attributes["type" /* Type */] === "submit" /* Submit */ ? 0 /* None */ : 2 /* Text */;
2627
- }
2628
- }
2629
- // Check for disallowed list of types (e.g. password, email, etc.) and set the masked property appropriately
2630
- if ("type" /* Type */ in attributes && DISALLOWED_TYPES.indexOf(attributes["type" /* Type */]) >= 0) {
2631
- privacy = 2 /* Text */;
2632
- }
2633
- // Following two conditions supersede any of the above. If there are explicit instructions to mask / unmask a field, we honor that.
2634
- if ("data-clarity-mask" /* MaskData */ in attributes) {
2635
- privacy = 3 /* TextImage */;
2512
+ switch (true) {
2513
+ case "data-clarity-mask" /* MaskData */ in attributes:
2514
+ metadata.privacy = 3 /* TextImage */;
2515
+ break;
2516
+ case "data-clarity-unmask" /* UnmaskData */ in attributes:
2517
+ metadata.privacy = 0 /* None */;
2518
+ break;
2519
+ case privacyMap.has(node):
2520
+ // If this node was explicitly configured to contain sensitive content, honor that privacy setting
2521
+ metadata.privacy = privacyMap.get(node);
2522
+ break;
2523
+ case fraudMap.has(node):
2524
+ // If this node was explicitly configured to be evaluated for fraud, then also mask content
2525
+ metadata.privacy = 2 /* Text */;
2526
+ break;
2527
+ case tag === "*T" /* TextTag */:
2528
+ // If it's a text node belonging to a STYLE or TITLE tag or one of SCRUB_EXCEPTIONS, then capture content
2529
+ var pTag = parent && parent.data ? parent.data.tag : "" /* Empty */;
2530
+ var pSelector_1 = parent && parent.selector ? parent.selector[0 /* Stable */] : "" /* Empty */;
2531
+ metadata.privacy = pTag === "STYLE" /* StyleTag */ || pTag === "TITLE" /* TitleTag */ || override.some(function (x) { return pSelector_1.indexOf(x) >= 0; }) ? 0 /* None */ : current;
2532
+ break;
2533
+ case "type" /* Type */ in attributes:
2534
+ // If this node has an explicit type assigned to it, go through masking rules to determine right privacy setting
2535
+ metadata.privacy = inspect(attributes["type" /* Type */], metadata);
2536
+ break;
2537
+ case tag === "INPUT" /* InputTag */ && current === 0 /* None */:
2538
+ // If even default privacy setting is to not mask, we still scan through input fields for any sensitive information
2539
+ var field_1 = "" /* Empty */;
2540
+ Object.keys(attributes).forEach(function (x) { return field_1 += attributes[x].toLowerCase(); });
2541
+ metadata.privacy = inspect(field_1, metadata);
2542
+ break;
2543
+ case current === 1 /* Sensitive */ && tag === "INPUT" /* InputTag */:
2544
+ // If it's a button or an input option, make an exception to disable masking
2545
+ metadata.privacy = maskDisable.indexOf(attributes["type" /* Type */]) >= 0 ? 0 /* None */ : current;
2546
+ break;
2547
+ case current === 1 /* Sensitive */:
2548
+ // In a mode where we mask sensitive information by default, look through class names to aggressively mask content
2549
+ metadata.privacy = inspect(attributes["class" /* Class */], metadata);
2550
+ break;
2551
+ default:
2552
+ metadata.privacy = parent ? parent.metadata.privacy : metadata.privacy;
2553
+ break;
2636
2554
  }
2637
- if ("data-clarity-unmask" /* UnmaskData */ in attributes) {
2638
- privacy = 0 /* None */;
2555
+ }
2556
+ function inspect(input, metadata) {
2557
+ if (input && maskText.some(function (x) { return input.indexOf(x) >= 0; })) {
2558
+ return 2 /* Text */;
2639
2559
  }
2640
- return privacy;
2560
+ return metadata.privacy;
2641
2561
  }
2642
2562
  function diff(a, b, field) {
2643
2563
  if (typeof a[field] === "object" && typeof b[field] === "object") {
@@ -2725,17 +2645,9 @@ function remove(id, source) {
2725
2645
  track$4(id, source);
2726
2646
  }
2727
2647
  }
2728
- function size(value, parent) {
2729
- var data = value.data;
2730
- var tag = data.tag;
2731
- // If this element is a text node, is masked, and longer than configured length, then track box model for the parent element
2732
- var isLongText = tag === "*T" /* TextTag */ && data.value && data.value.length > 15 /* ResizeObserverThreshold */;
2733
- var isMasked = value.metadata.privacy === 2 /* Text */ || value.metadata.privacy === 3 /* TextImage */;
2734
- if (isLongText && isMasked && parent && parent.metadata.size === null) {
2735
- parent.metadata.size = [];
2736
- }
2648
+ function size(value) {
2737
2649
  // If this element is a image node, and is masked, then track box model for the current element
2738
- if (data.tag === "IMG" /* ImageTag */ && value.metadata.privacy === 3 /* TextImage */) {
2650
+ if (value.data.tag === "IMG" /* ImageTag */ && value.metadata.privacy === 3 /* TextImage */) {
2739
2651
  value.metadata.size = [];
2740
2652
  }
2741
2653
  }
@@ -2944,18 +2856,23 @@ function link(node) {
2944
2856
  }
2945
2857
  return null;
2946
2858
  }
2947
- function metadata$2(node, event) {
2859
+ function metadata$2(node, event, text) {
2860
+ if (text === void 0) { text = null; }
2948
2861
  // If the node is null, we return a reserved value for id: 0. Valid assignment of id begins from 1+.
2949
2862
  var output = { id: 0, hash: null, privacy: 2 /* Text */, node: node };
2950
2863
  if (node) {
2951
2864
  var value = get(node);
2952
2865
  if (value !== null) {
2866
+ var metadata_1 = value.metadata;
2953
2867
  output.id = value.id;
2954
2868
  output.hash = value.hash;
2955
- output.privacy = value.metadata.privacy;
2869
+ output.privacy = metadata_1.privacy;
2956
2870
  if (value.region) {
2957
2871
  track$3(value.region, event);
2958
2872
  }
2873
+ if (metadata_1.fraud) {
2874
+ check$4(metadata_1.fraud, value.id, text || value.data.value);
2875
+ }
2959
2876
  }
2960
2877
  }
2961
2878
  return output;
@@ -2994,7 +2911,7 @@ function encode$3 (type) {
2994
2911
  case 9 /* Click */:
2995
2912
  for (_b = 0, _c = state$7; _b < _c.length; _b++) {
2996
2913
  entry = _c[_b];
2997
- cTarget = metadata$2(entry.data.target, entry.event);
2914
+ cTarget = metadata$2(entry.data.target, entry.event, entry.data.text);
2998
2915
  tokens = [entry.time, entry.event];
2999
2916
  cHash = cTarget.hash.join("." /* Dot */);
3000
2917
  tokens.push(cTarget.id);
@@ -3008,6 +2925,7 @@ function encode$3 (type) {
3008
2925
  tokens.push(scrub(entry.data.text, "click", cTarget.privacy));
3009
2926
  tokens.push(entry.data.link);
3010
2927
  tokens.push(cHash);
2928
+ tokens.push(entry.data.trust);
3011
2929
  queue(tokens);
3012
2930
  track$2(entry.time, entry.event, cHash, entry.data.x, entry.data.y, entry.data.reaction, entry.data.context);
3013
2931
  }
@@ -3043,10 +2961,10 @@ function encode$3 (type) {
3043
2961
  case 27 /* Input */:
3044
2962
  for (_f = 0, _g = state$5; _f < _g.length; _f++) {
3045
2963
  entry = _g[_f];
3046
- iTarget = metadata$2(entry.data.target, entry.event);
2964
+ iTarget = metadata$2(entry.data.target, entry.event, entry.data.value);
3047
2965
  tokens = [entry.time, entry.event];
3048
2966
  tokens.push(iTarget.id);
3049
- tokens.push(entry.data.value);
2967
+ tokens.push(scrub(entry.data.value, "input", iTarget.privacy));
3050
2968
  queue(tokens);
3051
2969
  }
3052
2970
  reset$f();
@@ -3221,7 +3139,7 @@ function queue(tokens, transmit) {
3221
3139
  // We enrich the data going out with the existing upload. In these cases, call to upload comes with 'transmit' set to false.
3222
3140
  if (transmit && timeout === null) {
3223
3141
  if (type !== 25 /* Ping */) {
3224
- reset$n();
3142
+ reset$m();
3225
3143
  }
3226
3144
  timeout = setTimeout(upload, gap);
3227
3145
  queuedTime = now;
@@ -3257,11 +3175,11 @@ function upload(final) {
3257
3175
  // Otherwise you run a risk of infinite loop.
3258
3176
  compute$6();
3259
3177
  compute$5();
3260
- compute$9();
3178
+ compute$8();
3261
3179
  last = final === true;
3262
3180
  e = JSON.stringify(envelope(last));
3263
- a = "[" + analysis.join() + "]";
3264
- p = sendPlaybackBytes ? "[" + playback.join() + "]" : "" /* Empty */;
3181
+ a = "[".concat(analysis.join(), "]");
3182
+ p = sendPlaybackBytes ? "[".concat(playback.join(), "]") : "" /* Empty */;
3265
3183
  encoded = { e: e, a: a, p: p };
3266
3184
  payload = stringify(encoded);
3267
3185
  if (!last) return [3 /*break*/, 1];
@@ -3288,7 +3206,7 @@ function upload(final) {
3288
3206
  });
3289
3207
  }
3290
3208
  function stringify(encoded) {
3291
- return encoded.p.length > 0 ? "{\"e\":" + encoded.e + ",\"a\":" + encoded.a + ",\"p\":" + encoded.p + "}" : "{\"e\":" + encoded.e + ",\"a\":" + encoded.a + "}";
3209
+ 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, "}");
3292
3210
  }
3293
3211
  function send(payload, zipped, sequence, beacon) {
3294
3212
  if (beacon === void 0) { beacon = false; }
@@ -3449,14 +3367,6 @@ function handler(error) {
3449
3367
  stack: e.stack,
3450
3368
  source: error["filename"]
3451
3369
  };
3452
- // In certain cases, ResizeObserver could lead to flood of benign errors - especially when video element is involved.
3453
- // Reference Chromium issue: https://bugs.chromium.org/p/chromium/issues/detail?id=809574
3454
- // Even though it doesn't impact user experience, or show up in console, it can still flood error reporting through on error
3455
- // To mitigate that, we turn off Clarity's ResizeObserver on getting the first instance of this error
3456
- if (e.message.indexOf("ResizeObserver" /* ResizeObserver */) >= 0) {
3457
- stop$t();
3458
- return false;
3459
- }
3460
3370
  encode$2(31 /* ScriptError */);
3461
3371
  }
3462
3372
  return true;
@@ -3486,6 +3396,14 @@ function encode$2 (type) {
3486
3396
  queue(tokens, false);
3487
3397
  }
3488
3398
  break;
3399
+ case 41 /* Fraud */:
3400
+ if (data$d) {
3401
+ tokens.push(data$d.id);
3402
+ tokens.push(data$d.target);
3403
+ tokens.push(data$d.hash);
3404
+ queue(tokens, false);
3405
+ }
3406
+ break;
3489
3407
  }
3490
3408
  return [2 /*return*/];
3491
3409
  });
@@ -3501,7 +3419,7 @@ function log$1(code, severity, name, message, stack) {
3501
3419
  if (name === void 0) { name = null; }
3502
3420
  if (message === void 0) { message = null; }
3503
3421
  if (stack === void 0) { stack = null; }
3504
- var key = name ? name + "|" + message : "";
3422
+ var key = name ? "".concat(name, "|").concat(message) : "";
3505
3423
  // While rare, it's possible for code to fail repeatedly during the lifetime of the same page
3506
3424
  // In those cases, we only want to log the failure once and not spam logs with redundant information.
3507
3425
  if (code in history$2 && history$2[code].indexOf(key) >= 0) {
@@ -3676,7 +3594,7 @@ function encode$1 (event) {
3676
3594
  tokens.push(b.data.activityTime);
3677
3595
  queue(tokens, false);
3678
3596
  }
3679
- reset$p();
3597
+ reset$o();
3680
3598
  break;
3681
3599
  case 25 /* Ping */:
3682
3600
  tokens.push(data$h.gap);
@@ -3709,7 +3627,7 @@ function encode$1 (event) {
3709
3627
  tokens.push(v);
3710
3628
  tokens.push(data$e[v]);
3711
3629
  }
3712
- reset$l();
3630
+ reset$k();
3713
3631
  queue(tokens, false);
3714
3632
  }
3715
3633
  break;
@@ -3724,7 +3642,7 @@ function encode$1 (event) {
3724
3642
  // However, for data over the wire, we round it off to milliseconds precision.
3725
3643
  tokens.push(Math.round(updates$3[m]));
3726
3644
  }
3727
- reset$o();
3645
+ reset$n();
3728
3646
  queue(tokens, false);
3729
3647
  }
3730
3648
  break;
@@ -3750,7 +3668,7 @@ function encode$1 (event) {
3750
3668
  tokens.push(key);
3751
3669
  tokens.push([].concat.apply([], data$g[e]));
3752
3670
  }
3753
- reset$m();
3671
+ reset$l();
3754
3672
  queue(tokens, false);
3755
3673
  }
3756
3674
  break;
@@ -3809,7 +3727,7 @@ function log(dimension, value) {
3809
3727
  // Check valid value before moving ahead
3810
3728
  if (value) {
3811
3729
  // Ensure received value is casted into a string if it wasn't a string to begin with
3812
- value = "" + value;
3730
+ value = "".concat(value);
3813
3731
  if (!(dimension in data$3)) {
3814
3732
  data$3[dimension] = [];
3815
3733
  }
@@ -3864,7 +3782,6 @@ function start$9() {
3864
3782
  log(17 /* DocumentDirection */, document.dir);
3865
3783
  if (navigator) {
3866
3784
  log(9 /* Language */, navigator.userLanguage || navigator.language);
3867
- max(26 /* Automation */, navigator.webdriver ? 1 /* True */ : 0 /* False */);
3868
3785
  userAgentData();
3869
3786
  }
3870
3787
  // Metrics
@@ -3992,7 +3909,7 @@ function session() {
3992
3909
  output.session = parts[0];
3993
3910
  output.count = num(parts[2]) + 1;
3994
3911
  output.upgrade = num(parts[3]);
3995
- output.upload = parts.length >= 6 ? "" + "https://" /* HTTPS */ + parts[5] + "/" + parts[4] : "" + "https://" /* HTTPS */ + parts[4];
3912
+ output.upload = parts.length >= 6 ? "".concat("https://" /* HTTPS */).concat(parts[5], "/").concat(parts[4]) : "".concat("https://" /* HTTPS */).concat(parts[4]);
3996
3913
  }
3997
3914
  }
3998
3915
  return output;
@@ -4017,11 +3934,11 @@ function user() {
4017
3934
  // Check if we either got version-less cookie value or saw multiple copies of the user cookie crumbs
4018
3935
  // In both these cases, we go ahead and delete the existing cookie set on current domain
4019
3936
  if (parts.length === 1 || count > 1) {
4020
- var deleted = "" + ";" /* Semicolon */ + "expires=" /* Expires */ + (new Date(0)).toUTCString() + ";path=/" /* Path */;
3937
+ var deleted = "".concat(";" /* Semicolon */).concat("expires=" /* Expires */).concat((new Date(0)).toUTCString()).concat(";path=/" /* Path */);
4021
3938
  // First, delete current user cookie which might be set on current sub-domain vs. root domain
4022
- document.cookie = "_clck" /* CookieKey */ + "=" + deleted;
3939
+ document.cookie = "".concat("_clck" /* CookieKey */, "=").concat(deleted);
4023
3940
  // Second, same thing for current session cookie so it can be re-written later with the root domain
4024
- document.cookie = "_clsk" /* SessionKey */ + "=" + deleted;
3941
+ document.cookie = "".concat("_clsk" /* SessionKey */, "=").concat(deleted);
4025
3942
  }
4026
3943
  // End code for backward compatibility
4027
3944
  // Read version information and timestamp from cookie, if available
@@ -4058,19 +3975,19 @@ function setCookie(key, value, time) {
4058
3975
  var expiry = new Date();
4059
3976
  expiry.setDate(expiry.getDate() + time);
4060
3977
  var expires = expiry ? "expires=" /* Expires */ + expiry.toUTCString() : "" /* Empty */;
4061
- var cookie = key + "=" + value + ";" /* Semicolon */ + expires + ";path=/" /* Path */;
3978
+ var cookie = "".concat(key, "=").concat(value).concat(";" /* Semicolon */).concat(expires).concat(";path=/" /* Path */);
4062
3979
  try {
4063
3980
  // Attempt to get the root domain only once and fall back to writing cookie on the current domain.
4064
3981
  if (rootDomain === null) {
4065
3982
  var hostname = location.hostname ? location.hostname.split("." /* Dot */) : [];
4066
3983
  // Walk backwards on a domain and attempt to set a cookie, until successful
4067
3984
  for (var i = hostname.length - 1; i >= 0; i--) {
4068
- rootDomain = "." + hostname[i] + (rootDomain ? rootDomain : "" /* Empty */);
3985
+ rootDomain = ".".concat(hostname[i]).concat(rootDomain ? rootDomain : "" /* Empty */);
4069
3986
  // We do not wish to attempt writing a cookie on the absolute last part of the domain, e.g. .com or .net.
4070
3987
  // So we start attempting after second-last part, e.g. .domain.com (PASS) or .co.uk (FAIL)
4071
3988
  if (i < hostname.length - 1) {
4072
3989
  // Write the cookie on the current computed top level domain
4073
- document.cookie = "" + cookie + ";" /* Semicolon */ + "domain=" /* Domain */ + rootDomain;
3990
+ document.cookie = "".concat(cookie).concat(";" /* Semicolon */).concat("domain=" /* Domain */).concat(rootDomain);
4074
3991
  // Once written, check if the cookie exists and its value matches exactly with what we intended to set
4075
3992
  // Checking for exact value match helps us eliminate a corner case where the cookie may already be present with a different value
4076
3993
  // If the check is successful, no more action is required and we can return from the function since rootDomain cookie is already set
@@ -4088,7 +4005,7 @@ function setCookie(key, value, time) {
4088
4005
  catch (_a) {
4089
4006
  rootDomain = "" /* Empty */;
4090
4007
  }
4091
- document.cookie = rootDomain ? "" + cookie + ";" /* Semicolon */ + "domain=" /* Domain */ + rootDomain : cookie;
4008
+ document.cookie = rootDomain ? "".concat(cookie).concat(";" /* Semicolon */).concat("domain=" /* Domain */).concat(rootDomain) : cookie;
4092
4009
  }
4093
4010
  }
4094
4011
 
@@ -4243,9 +4160,13 @@ function compute$1() {
4243
4160
  if (url !== getCurrentUrl()) {
4244
4161
  // If the url changed, start tracking it as a new page
4245
4162
  stop();
4246
- window.setTimeout(start, 250 /* RestartDelay */);
4163
+ window.setTimeout(restart$1, 250 /* RestartDelay */);
4247
4164
  }
4248
4165
  }
4166
+ function restart$1() {
4167
+ start();
4168
+ max(29 /* SinglePage */, 1 /* True */);
4169
+ }
4249
4170
  function getCurrentUrl() {
4250
4171
  return location.href ? location.href.replace(location.hash, "" /* Empty */) : location.href;
4251
4172
  }
@@ -4258,7 +4179,7 @@ var status = false;
4258
4179
  function start$6() {
4259
4180
  status = true;
4260
4181
  start$F();
4261
- reset$k();
4182
+ reset$j();
4262
4183
  reset$1();
4263
4184
  reset$2();
4264
4185
  start$7();
@@ -4267,8 +4188,8 @@ function stop$5() {
4267
4188
  stop$6();
4268
4189
  reset$2();
4269
4190
  reset$1();
4270
- reset$k();
4271
- stop$C();
4191
+ reset$j();
4192
+ stop$B();
4272
4193
  status = false;
4273
4194
  }
4274
4195
  function active() {
@@ -4322,6 +4243,7 @@ function restart() {
4322
4243
  }
4323
4244
 
4324
4245
  function start$5() {
4246
+ start$x();
4325
4247
  start$e();
4326
4248
  start$d();
4327
4249
  }
@@ -4349,14 +4271,14 @@ function discover() {
4349
4271
  case 0:
4350
4272
  ts = time();
4351
4273
  timer = { id: id(), cost: 3 /* LayoutCost */ };
4352
- start$x(timer);
4274
+ start$w(timer);
4353
4275
  return [4 /*yield*/, traverse(document, timer, 0 /* Discover */)];
4354
4276
  case 1:
4355
4277
  _a.sent();
4356
4278
  return [4 /*yield*/, encode$4(5 /* Discover */, timer, ts)];
4357
4279
  case 2:
4358
4280
  _a.sent();
4359
- stop$u(timer);
4281
+ stop$t(timer);
4360
4282
  return [2 /*return*/];
4361
4283
  }
4362
4284
  });
@@ -4371,13 +4293,11 @@ function start$3() {
4371
4293
  start$i();
4372
4294
  start$j();
4373
4295
  start$4();
4374
- start$w();
4375
4296
  }
4376
4297
  function stop$3() {
4377
4298
  stop$f();
4378
4299
  stop$g();
4379
4300
  stop$h();
4380
- stop$t();
4381
4301
  end();
4382
4302
  }
4383
4303
 
@@ -4505,7 +4425,11 @@ function process(entries) {
4505
4425
  compute(entry);
4506
4426
  break;
4507
4427
  case "resource" /* Resource */:
4508
- log(4 /* NetworkHosts */, host(entry.name));
4428
+ var name_1 = entry.name;
4429
+ log(4 /* NetworkHosts */, host(name_1));
4430
+ if (name_1 === config$1.upload || name_1 === config$1.fallback) {
4431
+ max(28 /* UploadTime */, entry.duration);
4432
+ }
4509
4433
  break;
4510
4434
  case "longtask" /* LongTask */:
4511
4435
  count$1(7 /* LongTaskCount */);
@@ -4528,6 +4452,11 @@ function process(entries) {
4528
4452
  break;
4529
4453
  }
4530
4454
  }
4455
+ if (performance && "memory" /* Memory */ in performance && performance["memory" /* Memory */].usedJSHeapSize) {
4456
+ // Track consumed memory (MBs) where "memory" API is available
4457
+ // Reference: https://developer.mozilla.org/en-US/docs/Web/API/Performance/memory
4458
+ max(30 /* UsedMemory */, Math.abs(performance["memory" /* Memory */].usedJSHeapSize / 1048576 /* MegaByte */));
4459
+ }
4531
4460
  }
4532
4461
  function stop$2() {
4533
4462
  if (observer) {
@@ -4589,7 +4518,7 @@ function stop() {
4589
4518
  if (active()) {
4590
4519
  // Stop modules in the reverse order of their initialization
4591
4520
  modules.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
4592
- stop$v();
4521
+ stop$u();
4593
4522
  stop$5();
4594
4523
  }
4595
4524
  }