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.
@@ -58,7 +58,6 @@ var metadata$1 = /*#__PURE__*/Object.freeze({
58
58
  get data () { return data$2; },
59
59
  get callbacks () { return callbacks; },
60
60
  get start () { return start$9; },
61
- get userAgentData () { return userAgentData; },
62
61
  get stop () { return stop$8; },
63
62
  get metadata () { return metadata; },
64
63
  get id () { return id; },
@@ -85,6 +84,7 @@ var config$1 = {
85
84
  regions: [],
86
85
  extract: [],
87
86
  cookies: [],
87
+ fraud: [],
88
88
  report: null,
89
89
  upload: null,
90
90
  fallback: null,
@@ -107,11 +107,11 @@ function time(ts) {
107
107
  ts = ts ? ts : performance.now();
108
108
  return Math.max(Math.round(ts - startTime), 0);
109
109
  }
110
- function stop$C() {
110
+ function stop$B() {
111
111
  startTime = 0;
112
112
  }
113
113
 
114
- var version$1 = "0.6.34";
114
+ var version$1 = "0.6.35";
115
115
 
116
116
  // tslint:disable: no-bitwise
117
117
  function hash (input) {
@@ -138,9 +138,9 @@ var buffer = null;
138
138
  var update$2 = false;
139
139
  function start$E() {
140
140
  update$2 = false;
141
- reset$p();
141
+ reset$o();
142
142
  }
143
- function reset$p() {
143
+ function reset$o() {
144
144
  // Baseline state holds the previous values - if it is updated in the current payload,
145
145
  // reset the state to current value after sending the previous state
146
146
  if (update$2) {
@@ -202,25 +202,25 @@ function visibility(t, visible) {
202
202
  }
203
203
  update$2 = true;
204
204
  }
205
- function compute$d() {
205
+ function compute$c() {
206
206
  if (update$2) {
207
207
  encode$1(4 /* Baseline */);
208
208
  }
209
209
  }
210
- function stop$B() {
211
- reset$p();
210
+ function stop$A() {
211
+ reset$o();
212
212
  }
213
213
 
214
214
  var baseline = /*#__PURE__*/Object.freeze({
215
215
  __proto__: null,
216
216
  get state () { return state$9; },
217
217
  start: start$E,
218
- reset: reset$p,
218
+ reset: reset$o,
219
219
  track: track$7,
220
220
  activity: activity,
221
221
  visibility: visibility,
222
- compute: compute$d,
223
- stop: stop$B
222
+ compute: compute$c,
223
+ stop: stop$A
224
224
  });
225
225
 
226
226
  var data$j = null;
@@ -244,20 +244,19 @@ function start$D() {
244
244
  updates$3 = {};
245
245
  count$1(5 /* InvokeCount */);
246
246
  }
247
- function stop$A() {
247
+ function stop$z() {
248
248
  data$i = {};
249
249
  updates$3 = {};
250
250
  }
251
- function count$1(metric, increment) {
252
- if (increment === void 0) { increment = 1; }
251
+ function count$1(metric) {
253
252
  if (!(metric in data$i)) {
254
253
  data$i[metric] = 0;
255
254
  }
256
255
  if (!(metric in updates$3)) {
257
256
  updates$3[metric] = 0;
258
257
  }
259
- data$i[metric] += increment;
260
- updates$3[metric] += increment;
258
+ data$i[metric]++;
259
+ updates$3[metric]++;
261
260
  }
262
261
  function sum(metric, value) {
263
262
  if (value !== null) {
@@ -283,10 +282,10 @@ function max(metric, value) {
283
282
  }
284
283
  }
285
284
  }
286
- function compute$c() {
285
+ function compute$b() {
287
286
  encode$1(0 /* Metric */);
288
287
  }
289
- function reset$o() {
288
+ function reset$n() {
290
289
  updates$3 = {};
291
290
  }
292
291
 
@@ -305,7 +304,7 @@ function start$C() {
305
304
  interval = 60000 /* PingInterval */;
306
305
  last = 0;
307
306
  }
308
- function reset$n() {
307
+ function reset$m() {
309
308
  if (timeout$6) {
310
309
  clearTimeout(timeout$6);
311
310
  }
@@ -323,7 +322,7 @@ function ping() {
323
322
  suspend();
324
323
  }
325
324
  }
326
- function stop$z() {
325
+ function stop$y() {
327
326
  clearTimeout(timeout$6);
328
327
  last = 0;
329
328
  interval = 0;
@@ -333,15 +332,15 @@ var ping$1 = /*#__PURE__*/Object.freeze({
333
332
  __proto__: null,
334
333
  get data () { return data$h; },
335
334
  start: start$C,
336
- reset: reset$n,
337
- stop: stop$z
335
+ reset: reset$m,
336
+ stop: stop$y
338
337
  });
339
338
 
340
339
  var data$g = null;
341
340
  function start$B() {
342
341
  data$g = {};
343
342
  }
344
- function stop$y() {
343
+ function stop$x() {
345
344
  data$g = {};
346
345
  }
347
346
  function track$6(event, time) {
@@ -361,10 +360,10 @@ function track$6(event, time) {
361
360
  }
362
361
  }
363
362
  }
364
- function compute$b() {
363
+ function compute$a() {
365
364
  encode$1(36 /* Summary */);
366
365
  }
367
- function reset$m() {
366
+ function reset$l() {
368
367
  data$g = {};
369
368
  }
370
369
 
@@ -372,10 +371,10 @@ var summary = /*#__PURE__*/Object.freeze({
372
371
  __proto__: null,
373
372
  get data () { return data$g; },
374
373
  start: start$B,
375
- stop: stop$y,
374
+ stop: stop$x,
376
375
  track: track$6,
377
- compute: compute$b,
378
- reset: reset$m
376
+ compute: compute$a,
377
+ reset: reset$l
379
378
  });
380
379
 
381
380
  var data$f = null;
@@ -403,7 +402,7 @@ function upgrade(key) {
403
402
  encode$1(3 /* Upgrade */);
404
403
  }
405
404
  }
406
- function stop$x() {
405
+ function stop$w() {
407
406
  data$f = null;
408
407
  }
409
408
 
@@ -412,12 +411,12 @@ var upgrade$1 = /*#__PURE__*/Object.freeze({
412
411
  get data () { return data$f; },
413
412
  start: start$A,
414
413
  upgrade: upgrade,
415
- stop: stop$x
414
+ stop: stop$w
416
415
  });
417
416
 
418
417
  var data$e = null;
419
418
  function start$z() {
420
- reset$l();
419
+ reset$k();
421
420
  }
422
421
  function set(variable, value) {
423
422
  var values = typeof value === "string" /* String */ ? [value] : value;
@@ -445,14 +444,14 @@ function log$2(variable, value) {
445
444
  data$e[variable] = validValues;
446
445
  }
447
446
  }
448
- function compute$a() {
447
+ function compute$9() {
449
448
  encode$1(34 /* Variable */);
450
449
  }
451
- function reset$l() {
450
+ function reset$k() {
452
451
  data$e = {};
453
452
  }
454
- function stop$w() {
455
- reset$l();
453
+ function stop$v() {
454
+ reset$k();
456
455
  }
457
456
 
458
457
  var variable = /*#__PURE__*/Object.freeze({
@@ -461,9 +460,9 @@ var variable = /*#__PURE__*/Object.freeze({
461
460
  start: start$z,
462
461
  set: set,
463
462
  identify: identify,
464
- compute: compute$a,
465
- reset: reset$l,
466
- stop: stop$w
463
+ compute: compute$9,
464
+ reset: reset$k,
465
+ stop: stop$v
467
466
  });
468
467
 
469
468
  /*! *****************************************************************************
@@ -583,20 +582,20 @@ function start$y() {
583
582
  start$D();
584
583
  modules$1.forEach(function (x) { return measure(x.start)(); });
585
584
  }
586
- function stop$v() {
585
+ function stop$u() {
587
586
  // Stop modules in the reverse order of their initialization
588
587
  // The ordering below should respect inter-module dependency.
589
588
  // E.g. if upgrade depends on upload, then upgrade needs to end before upload.
590
589
  // Similarly, if upload depends on metadata, upload needs to end before metadata.
591
590
  modules$1.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
592
- stop$A();
591
+ stop$z();
593
592
  }
594
- function compute$9() {
595
- compute$a();
596
- compute$d();
597
- compute$2();
593
+ function compute$8() {
594
+ compute$9();
598
595
  compute$c();
596
+ compute$2();
599
597
  compute$b();
598
+ compute$a();
600
599
  compute$3();
601
600
  compute$4();
602
601
  }
@@ -646,7 +645,7 @@ function mangleText(value) {
646
645
  var index = value.indexOf(first);
647
646
  var prefix = value.substr(0, index);
648
647
  var suffix = value.substr(index + trimmed.length);
649
- return "" + prefix + trimmed.length.toString(36) + suffix;
648
+ return "".concat(prefix).concat(trimmed.length.toString(36)).concat(suffix);
650
649
  }
651
650
  return value;
652
651
  }
@@ -697,12 +696,30 @@ function mutate(array, start, end) {
697
696
  }
698
697
  }
699
698
 
699
+ var history$5 = [];
700
+ var data$d;
701
+ function start$x() {
702
+ history$5 = [];
703
+ max(26 /* Automation */, navigator.webdriver ? 1 /* True */ : 0 /* False */);
704
+ }
705
+ function check$4(id, target, input) {
706
+ // Compute hash for fraud detection. Hash is computed only if input meets the minimum length criteria
707
+ if (id !== null && input && input.length >= 5 /* WordLength */) {
708
+ data$d = { id: id, target: target, hash: hash(input) };
709
+ // Only encode this event if we haven't already reported this hash
710
+ if (history$5.indexOf(data$d.hash) < 0) {
711
+ history$5.push(data$d.hash);
712
+ encode$2(41 /* Fraud */);
713
+ }
714
+ }
715
+ }
716
+
700
717
  var TAGS = ["DIV", "TR", "P", "LI", "UL", "A", "BUTTON"];
701
718
  function selector (input, beta) {
702
719
  if (beta === void 0) { beta = false; }
703
720
  var a = input.attributes;
704
721
  var prefix = input.prefix ? input.prefix[beta ? 1 /* Beta */ : 0 /* Stable */] : null;
705
- var suffix = beta || ((a && !("class" /* Class */ in a)) || TAGS.indexOf(input.tag) >= 0) ? ":nth-of-type(" + input.position + ")" : "" /* Empty */;
722
+ var suffix = beta || ((a && !("class" /* Class */ in a)) || TAGS.indexOf(input.tag) >= 0) ? ":nth-of-type(".concat(input.position, ")") : "" /* Empty */;
706
723
  switch (input.tag) {
707
724
  case "STYLE":
708
725
  case "TITLE":
@@ -717,9 +734,9 @@ function selector (input, beta) {
717
734
  if (prefix === null) {
718
735
  return "" /* Empty */;
719
736
  }
720
- prefix = prefix + ">";
737
+ prefix = "".concat(prefix, ">");
721
738
  input.tag = input.tag.indexOf("svg:" /* SvgPrefix */) === 0 ? input.tag.substr("svg:" /* SvgPrefix */.length) : input.tag;
722
- var selector = "" + prefix + input.tag + suffix;
739
+ var selector = "".concat(prefix).concat(input.tag).concat(suffix);
723
740
  var classes = "class" /* Class */ in a && a["class" /* Class */].length > 0 ? a["class" /* Class */].trim().split(/\s+/) : null;
724
741
  if (beta) {
725
742
  // In beta mode, update selector to use "id" field when available. There are two exceptions:
@@ -727,19 +744,19 @@ function selector (input, beta) {
727
744
  // (2) if "id" appears inside a shadow DOM, in which case we continue to prefix up to shadow DOM to prevent conflicts
728
745
  var id = "id" /* Id */ in a && a["id" /* Id */].length > 0 ? a["id" /* Id */] : null;
729
746
  classes = input.tag !== "BODY" /* BodyTag */ && classes ? classes.filter(function (c) { return !hasDigits(c); }) : [];
730
- selector = classes.length > 0 ? "" + prefix + input.tag + "." + classes.join(".") + suffix : selector;
731
- selector = id && hasDigits(id) === false ? getDomPrefix(prefix) + "#" + id : selector;
747
+ selector = classes.length > 0 ? "".concat(prefix).concat(input.tag, ".").concat(classes.join(".")).concat(suffix) : selector;
748
+ selector = id && hasDigits(id) === false ? "".concat(getDomPrefix(prefix), "#").concat(id) : selector;
732
749
  }
733
750
  else {
734
751
  // Otherwise, fallback to stable mode, where we include class names as part of the selector
735
- selector = classes ? "" + prefix + input.tag + "." + classes.join(".") + suffix : selector;
752
+ selector = classes ? "".concat(prefix).concat(input.tag, ".").concat(classes.join(".")).concat(suffix) : selector;
736
753
  }
737
754
  return selector;
738
755
  }
739
756
  }
740
757
  function getDomPrefix(prefix) {
741
758
  var shadowDomStart = prefix.lastIndexOf("*S" /* ShadowDomTag */);
742
- var iframeDomStart = prefix.lastIndexOf("" + "iframe:" /* IFramePrefix */ + "HTML" /* HTML */);
759
+ var iframeDomStart = prefix.lastIndexOf("".concat("iframe:" /* IFramePrefix */).concat("HTML" /* HTML */));
743
760
  var domStart = Math.max(shadowDomStart, iframeDomStart);
744
761
  if (domStart < 0) {
745
762
  return "";
@@ -781,7 +798,7 @@ function resume$1() {
781
798
  }
782
799
  }
783
800
  }
784
- function reset$k() {
801
+ function reset$j() {
785
802
  tracker = {};
786
803
  queuedTasks = [];
787
804
  activeTask = null;
@@ -851,20 +868,20 @@ function state$8(timer) {
851
868
  // If this task is no longer being tracked, send stop message to the caller
852
869
  return 2 /* Stop */;
853
870
  }
854
- function start$x(timer) {
871
+ function start$w(timer) {
855
872
  tracker[key(timer)] = { start: performance.now(), calls: 0, yield: 30 /* LongTask */ };
856
873
  }
857
- function restart$1(timer) {
874
+ function restart$2(timer) {
858
875
  var id = key(timer);
859
876
  if (tracker && tracker[id]) {
860
877
  var c = tracker[id].calls;
861
878
  var y = tracker[id].yield;
862
- start$x(timer);
879
+ start$w(timer);
863
880
  tracker[id].calls = c + 1;
864
881
  tracker[id].yield = y;
865
882
  }
866
883
  }
867
- function stop$u(timer) {
884
+ function stop$t(timer) {
868
885
  var end = performance.now();
869
886
  var id = key(timer);
870
887
  var duration = end - tracker[id].start;
@@ -884,12 +901,12 @@ function suspend$1(timer) {
884
901
  case 0:
885
902
  id = key(timer);
886
903
  if (!(id in tracker)) return [3 /*break*/, 2];
887
- stop$u(timer);
904
+ stop$t(timer);
888
905
  _a = tracker[id];
889
906
  return [4 /*yield*/, wait()];
890
907
  case 1:
891
908
  _a.yield = (_b.sent()).timeRemaining();
892
- restart$1(timer);
909
+ restart$2(timer);
893
910
  _b.label = 2;
894
911
  case 2:
895
912
  // After we are done with suspending task, ensure that we are still operating in the right context
@@ -900,7 +917,7 @@ function suspend$1(timer) {
900
917
  });
901
918
  }
902
919
  function key(timer) {
903
- return timer.id + "." + timer.cost;
920
+ return "".concat(timer.id, ".").concat(timer.cost);
904
921
  }
905
922
  function wait() {
906
923
  return __awaiter(this, void 0, void 0, function () {
@@ -996,91 +1013,13 @@ function tokenize (tokens) {
996
1013
  return output;
997
1014
  }
998
1015
 
999
- var data$d = [];
1000
- var enabled = false;
1001
- var observer$2 = null;
1002
- function start$w() {
1003
- reset$j();
1004
- observer$2 = null;
1005
- enabled = window["ResizeObserver"] ? true : false;
1006
- }
1007
- function compute$8(id) {
1008
- if (enabled === false) {
1009
- return;
1010
- }
1011
- observer$2 = observer$2 === null ? new ResizeObserver(handler$4) : observer$2;
1012
- if (observer$2) {
1013
- var value = getValue(id);
1014
- // If this is the first time computing size for this node, go ahead and wire up ResizeObserver
1015
- // In all other cases, value.metadata.size will be null or an array with two elements [width, height]
1016
- // And, in those cases, we will skip through the following section and not attach the observer
1017
- if (value && value.metadata.size !== null && value.metadata.size.length === 0) {
1018
- var node = getNode(id);
1019
- if (node && node.nodeType === Node.ELEMENT_NODE) {
1020
- var e = node;
1021
- var r = e.getBoundingClientRect();
1022
- value.metadata.size = [Math.floor(r.width * 100 /* BoxPrecision */), Math.floor(r.height * 100 /* BoxPrecision */)];
1023
- observer$2.observe(e);
1024
- }
1025
- }
1026
- }
1027
- }
1028
- function handler$4(entries) {
1029
- window.requestAnimationFrame(function () {
1030
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
1031
- var entry = entries_1[_i];
1032
- var target = entry.target;
1033
- var id = target ? getId(target) : null;
1034
- if (id) {
1035
- var v = getValue(id);
1036
- var s = v.metadata.size;
1037
- var b = entry.borderBoxSize;
1038
- var w = null;
1039
- var h = null;
1040
- // Check if browser supports borderBoxSize property on ResizeObserverEntry object
1041
- // Otherwise, fall back to using getBoundingClientRect() to be cross browser compatible
1042
- // Reference: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/borderBoxSize
1043
- if (b && b.length > 0) {
1044
- w = Math.floor(b[0].inlineSize * 100 /* BoxPrecision */);
1045
- h = Math.floor(b[0].blockSize * 100 /* BoxPrecision */);
1046
- }
1047
- else {
1048
- var r = target.getBoundingClientRect();
1049
- w = Math.floor(r.width * 100 /* BoxPrecision */);
1050
- h = Math.floor(r.height * 100 /* BoxPrecision */);
1051
- }
1052
- // Capture new width & height only if they are different from what we have in in-memory cache
1053
- if (w !== s[0] && h !== s[1]) {
1054
- s = [w, h];
1055
- data$d.push({ id: id, width: w, height: h });
1056
- }
1057
- }
1058
- }
1059
- // Schedule encode only when we have at least one valid data entry
1060
- if (data$d.length > 0) {
1061
- encode$4(37 /* Box */);
1062
- }
1063
- });
1064
- }
1065
- function reset$j() {
1066
- data$d = [];
1067
- }
1068
- function stop$t() {
1069
- reset$j();
1070
- if (observer$2) {
1071
- observer$2.disconnect();
1072
- observer$2 = null;
1073
- }
1074
- enabled = false;
1075
- }
1076
-
1077
1016
  function encode$4 (type, timer, ts) {
1078
1017
  if (timer === void 0) { timer = null; }
1079
1018
  if (ts === void 0) { ts = null; }
1080
1019
  return __awaiter(this, void 0, void 0, function () {
1081
- 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;
1082
- return __generator(this, function (_f) {
1083
- switch (_f.label) {
1020
+ 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;
1021
+ return __generator(this, function (_e) {
1022
+ switch (_e.label) {
1084
1023
  case 0:
1085
1024
  eventTime = ts || time();
1086
1025
  tokens = [eventTime, type];
@@ -1088,18 +1027,17 @@ function encode$4 (type, timer, ts) {
1088
1027
  switch (_a) {
1089
1028
  case 8 /* Document */: return [3 /*break*/, 1];
1090
1029
  case 7 /* Region */: return [3 /*break*/, 2];
1091
- case 37 /* Box */: return [3 /*break*/, 3];
1092
- case 5 /* Discover */: return [3 /*break*/, 4];
1093
- case 6 /* Mutation */: return [3 /*break*/, 4];
1030
+ case 5 /* Discover */: return [3 /*break*/, 3];
1031
+ case 6 /* Mutation */: return [3 /*break*/, 3];
1094
1032
  }
1095
- return [3 /*break*/, 11];
1033
+ return [3 /*break*/, 10];
1096
1034
  case 1:
1097
1035
  d = data$c;
1098
1036
  tokens.push(d.width);
1099
1037
  tokens.push(d.height);
1100
1038
  track$7(type, d.width, d.height);
1101
1039
  queue(tokens);
1102
- return [3 /*break*/, 11];
1040
+ return [3 /*break*/, 10];
1103
1041
  case 2:
1104
1042
  for (_i = 0, _b = state$1; _i < _b.length; _i++) {
1105
1043
  r = _b[_i];
@@ -1111,39 +1049,28 @@ function encode$4 (type, timer, ts) {
1111
1049
  queue(tokens);
1112
1050
  }
1113
1051
  reset$6();
1114
- return [3 /*break*/, 11];
1052
+ return [3 /*break*/, 10];
1115
1053
  case 3:
1116
- b = data$d;
1117
- for (_c = 0, b_1 = b; _c < b_1.length; _c++) {
1118
- entry = b_1[_c];
1119
- tokens.push(entry.id);
1120
- tokens.push(entry.width);
1121
- tokens.push(entry.height);
1122
- }
1123
- reset$j();
1124
- queue(tokens);
1125
- return [3 /*break*/, 11];
1126
- case 4:
1127
1054
  // Check if we are operating within the context of the current page
1128
1055
  if (state$8(timer) === 2 /* Stop */) {
1129
- return [3 /*break*/, 11];
1056
+ return [3 /*break*/, 10];
1130
1057
  }
1131
1058
  values = updates$2();
1132
- if (!(values.length > 0)) return [3 /*break*/, 10];
1133
- _d = 0, values_1 = values;
1134
- _f.label = 5;
1135
- case 5:
1136
- if (!(_d < values_1.length)) return [3 /*break*/, 9];
1137
- value = values_1[_d];
1059
+ if (!(values.length > 0)) return [3 /*break*/, 9];
1060
+ _c = 0, values_1 = values;
1061
+ _e.label = 4;
1062
+ case 4:
1063
+ if (!(_c < values_1.length)) return [3 /*break*/, 8];
1064
+ value = values_1[_c];
1138
1065
  state = state$8(timer);
1139
- if (!(state === 0 /* Wait */)) return [3 /*break*/, 7];
1066
+ if (!(state === 0 /* Wait */)) return [3 /*break*/, 6];
1140
1067
  return [4 /*yield*/, suspend$1(timer)];
1068
+ case 5:
1069
+ state = _e.sent();
1070
+ _e.label = 6;
1141
1071
  case 6:
1142
- state = _f.sent();
1143
- _f.label = 7;
1144
- case 7:
1145
1072
  if (state === 2 /* Stop */) {
1146
- return [3 /*break*/, 9];
1073
+ return [3 /*break*/, 8];
1147
1074
  }
1148
1075
  data = value.data;
1149
1076
  active = value.metadata.active;
@@ -1151,13 +1078,12 @@ function encode$4 (type, timer, ts) {
1151
1078
  privacy = value.metadata.privacy;
1152
1079
  mangle = shouldMangle(value);
1153
1080
  keys = active ? ["tag", "attributes", "value"] : ["tag"];
1154
- compute$8(value.id);
1155
- for (_e = 0, keys_1 = keys; _e < keys_1.length; _e++) {
1156
- key = keys_1[_e];
1081
+ for (_d = 0, keys_1 = keys; _d < keys_1.length; _d++) {
1082
+ key = keys_1[_d];
1157
1083
  if (data[key]) {
1158
1084
  switch (key) {
1159
1085
  case "tag":
1160
- size = value.metadata.size;
1086
+ box = size$1(value);
1161
1087
  factor = mangle ? -1 : 1;
1162
1088
  tokens.push(value.id * factor);
1163
1089
  if (value.parent && active) {
@@ -1167,8 +1093,8 @@ function encode$4 (type, timer, ts) {
1167
1093
  tokens.push(value.previous);
1168
1094
  }
1169
1095
  tokens.push(suspend ? "*M" /* SuspendMutationTag */ : data[key]);
1170
- if (size && size.length === 2) {
1171
- tokens.push("" + "#" /* Box */ + str$1(size[0]) + "." + str$1(size[1]));
1096
+ if (box && box.length === 2) {
1097
+ tokens.push("".concat("#" /* Box */).concat(str$1(box[0]), ".").concat(str$1(box[1])));
1172
1098
  }
1173
1099
  break;
1174
1100
  case "attributes":
@@ -1179,23 +1105,24 @@ function encode$4 (type, timer, ts) {
1179
1105
  }
1180
1106
  break;
1181
1107
  case "value":
1108
+ check$4(value.metadata.fraud, value.id, data[key]);
1182
1109
  tokens.push(scrub(data[key], data.tag, privacy, mangle));
1183
1110
  break;
1184
1111
  }
1185
1112
  }
1186
1113
  }
1187
- _f.label = 8;
1114
+ _e.label = 7;
1115
+ case 7:
1116
+ _c++;
1117
+ return [3 /*break*/, 4];
1188
1118
  case 8:
1189
- _d++;
1190
- return [3 /*break*/, 5];
1191
- case 9:
1192
1119
  if (type === 6 /* Mutation */) {
1193
1120
  activity(eventTime);
1194
1121
  }
1195
1122
  queue(tokenize(tokens), !config$1.lean);
1196
- _f.label = 10;
1197
- case 10: return [3 /*break*/, 11];
1198
- case 11: return [2 /*return*/];
1123
+ _e.label = 9;
1124
+ case 9: return [3 /*break*/, 10];
1125
+ case 10: return [2 /*return*/];
1199
1126
  }
1200
1127
  });
1201
1128
  });
@@ -1204,11 +1131,20 @@ function shouldMangle(value) {
1204
1131
  var privacy = value.metadata.privacy;
1205
1132
  return value.data.tag === "*T" /* TextTag */ && !(privacy === 0 /* None */ || privacy === 1 /* Sensitive */);
1206
1133
  }
1134
+ function size$1(value) {
1135
+ if (value.metadata.size !== null && value.metadata.size.length === 0) {
1136
+ var img = getNode(value.id);
1137
+ if (img) {
1138
+ return [Math.floor(img.offsetWidth * 100 /* BoxPrecision */), Math.floor(img.offsetHeight * 100 /* BoxPrecision */)];
1139
+ }
1140
+ }
1141
+ return value.metadata.size;
1142
+ }
1207
1143
  function str$1(input) {
1208
1144
  return input.toString(36);
1209
1145
  }
1210
1146
  function attribute(key, value, privacy) {
1211
- return key + "=" + scrub(value, key, privacy);
1147
+ return "".concat(key, "=").concat(scrub(value, key, privacy));
1212
1148
  }
1213
1149
 
1214
1150
  var data$c;
@@ -1312,7 +1248,8 @@ function handler$3(event, root, evt) {
1312
1248
  context: context(a),
1313
1249
  text: text(t),
1314
1250
  link: a ? a.href : null,
1315
- hash: null
1251
+ hash: null,
1252
+ trust: evt.isTrusted ? 1 /* True */ : 0 /* False */
1316
1253
  }
1317
1254
  });
1318
1255
  schedule$1(encode$3.bind(this, event));
@@ -1411,18 +1348,12 @@ function recompute$6(evt) {
1411
1348
  var input = target(evt);
1412
1349
  var value = get(input);
1413
1350
  if (input && input.type && value) {
1414
- var v = void 0;
1351
+ var v = input.value;
1415
1352
  switch (input.type) {
1416
1353
  case "radio":
1417
1354
  case "checkbox":
1418
1355
  v = input.checked ? "true" : "false";
1419
1356
  break;
1420
- case "range":
1421
- v = input.value;
1422
- break;
1423
- default:
1424
- v = scrub(input.value, "input", value.metadata.privacy);
1425
- break;
1426
1357
  }
1427
1358
  var data = { target: input, value: v };
1428
1359
  // 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.
@@ -2198,7 +2129,7 @@ function process$2() {
2198
2129
  switch (_b.label) {
2199
2130
  case 0:
2200
2131
  timer = { id: id(), cost: 3 /* LayoutCost */ };
2201
- start$x(timer);
2132
+ start$w(timer);
2202
2133
  _b.label = 1;
2203
2134
  case 1:
2204
2135
  if (!(mutations.length > 0)) return [3 /*break*/, 8];
@@ -2253,7 +2184,7 @@ function process$2() {
2253
2184
  _b.sent();
2254
2185
  return [3 /*break*/, 1];
2255
2186
  case 8:
2256
- stop$u(timer);
2187
+ stop$t(timer);
2257
2188
  return [2 /*return*/];
2258
2189
  }
2259
2190
  });
@@ -2380,10 +2311,6 @@ function generate(target, type) {
2380
2311
  }
2381
2312
 
2382
2313
  var index = 1;
2383
- // Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#%3Cinput%3E_types
2384
- var DISALLOWED_TYPES = ["password", "hidden", "email", "tel"];
2385
- var DISALLOWED_NAMES = ["addr", "cell", "code", "dob", "email", "mob", "name", "phone", "secret", "social", "ssn", "tel", "zip", "pass", "card", "account", "cvv", "ccv"];
2386
- var DISALLOWED_MATCH = ["address", "password", "contact"];
2387
2314
  var nodes = [];
2388
2315
  var values = [];
2389
2316
  var updateMap = [];
@@ -2391,10 +2318,13 @@ var hashMap = {};
2391
2318
  var override = [];
2392
2319
  var unmask = [];
2393
2320
  var updatedFragments = {};
2321
+ var maskText = [];
2322
+ var maskDisable = [];
2394
2323
  // The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced
2395
2324
  var idMap = null; // Maps node => id.
2396
2325
  var iframeMap = null; // Maps iframe's contentDocument => parent iframe element
2397
2326
  var privacyMap = null; // Maps node => Privacy (enum)
2327
+ var fraudMap = null; // Maps node => FraudId (number)
2398
2328
  function start$i() {
2399
2329
  reset$7();
2400
2330
  parse$1(document, true);
@@ -2410,9 +2340,12 @@ function reset$7() {
2410
2340
  hashMap = {};
2411
2341
  override = [];
2412
2342
  unmask = [];
2343
+ 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 */);
2344
+ maskDisable = "radio,checkbox,range,button,reset,submit" /* Disable */.split("," /* Comma */);
2413
2345
  idMap = new WeakMap();
2414
2346
  iframeMap = new WeakMap();
2415
2347
  privacyMap = new WeakMap();
2348
+ fraudMap = new WeakMap();
2416
2349
  }
2417
2350
  // We parse new root nodes for any regions or masked nodes in the beginning (document) and
2418
2351
  // later whenever there are new additions or modifications to DOM (mutations)
@@ -2428,8 +2361,9 @@ function parse$1(root, init) {
2428
2361
  // Since mutations may happen on leaf nodes too, e.g. text nodes, which may not support all selector APIs.
2429
2362
  // We ensure that the root note supports querySelectorAll API before executing the code below to identify new regions.
2430
2363
  if ("querySelectorAll" in root) {
2431
- config$1.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "" + x[0]); }); }); // Regions
2364
+ config$1.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "".concat(x[0])); }); }); // Regions
2432
2365
  config$1.mask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 3 /* TextImage */); }); }); // Masked Elements
2366
+ config$1.fraud.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Check
2433
2367
  unmask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 0 /* None */); }); }); // Unmasked Elements
2434
2368
  }
2435
2369
  }
@@ -2453,19 +2387,18 @@ function add(node, parent, data, source) {
2453
2387
  var id = getId(node, true);
2454
2388
  var parentId = parent ? getId(parent) : null;
2455
2389
  var previousId = getPreviousId(node);
2456
- var privacy = config$1.content ? 1 /* Sensitive */ : 2 /* Text */;
2457
2390
  var parentValue = null;
2458
2391
  var regionId = exists(node) ? id : null;
2459
2392
  var fragmentId = null;
2393
+ var fraudId = fraudMap.has(node) ? fraudMap.get(node) : null;
2394
+ var privacyId = config$1.content ? 1 /* Sensitive */ : 2 /* Text */;
2460
2395
  if (parentId >= 0 && values[parentId]) {
2461
2396
  parentValue = values[parentId];
2462
2397
  parentValue.children.push(id);
2463
2398
  regionId = regionId === null ? parentValue.region : regionId;
2464
2399
  fragmentId = parentValue.fragment;
2465
- privacy = parentValue.metadata.privacy;
2400
+ fraudId = fraudId === null ? parentValue.metadata.fraud : fraudId;
2466
2401
  }
2467
- // Check to see if this particular node should be masked or not
2468
- privacy = getPrivacy(node, data, parentValue, privacy);
2469
2402
  // If there's an explicit region attribute set on the element, use it to mark a region on the page
2470
2403
  if (data.attributes && "data-clarity-region" /* RegionData */ in data.attributes) {
2471
2404
  observe$1(node, data.attributes["data-clarity-region" /* RegionData */]);
@@ -2481,11 +2414,12 @@ function add(node, parent, data, source) {
2481
2414
  selector: null,
2482
2415
  hash: null,
2483
2416
  region: regionId,
2484
- metadata: { active: true, suspend: false, privacy: privacy, position: null, size: null },
2417
+ metadata: { active: true, suspend: false, privacy: privacyId, position: null, fraud: fraudId, size: null },
2485
2418
  fragment: fragmentId,
2486
2419
  };
2420
+ privacy(node, values[id], parentValue);
2487
2421
  updateSelector(values[id]);
2488
- size(values[id], parentValue);
2422
+ size(values[id]);
2489
2423
  track$4(id, source, values[id].fragment);
2490
2424
  }
2491
2425
  function update$1(node, parent, data, source) {
@@ -2565,75 +2499,61 @@ function iframe(node) {
2565
2499
  var doc = node.nodeType === Node.DOCUMENT_NODE ? node : null;
2566
2500
  return doc && iframeMap.has(doc) ? iframeMap.get(doc) : null;
2567
2501
  }
2568
- function getPrivacy(node, data, parent, privacy) {
2569
- var attributes = data.attributes;
2502
+ function privacy(node, value, parent) {
2503
+ var data = value.data;
2504
+ var metadata = value.metadata;
2505
+ var current = metadata.privacy;
2506
+ var attributes = data.attributes || {};
2570
2507
  var tag = data.tag.toUpperCase();
2571
- // If this node was explicitly configured to contain sensitive content, use that information and return the value
2572
- if (privacyMap.has(node)) {
2573
- return privacyMap.get(node);
2574
- }
2575
- // If it's a text node belonging to a STYLE or TITLE tag;
2576
- // Or, the text node belongs to one of SCRUB_EXCEPTIONS
2577
- // then reset the privacy setting to ensure we capture the content
2578
- if (tag === "*T" /* TextTag */ && parent && parent.data) {
2579
- var path = parent.selector ? parent.selector[0 /* Stable */] : "" /* Empty */;
2580
- privacy = parent.data.tag === "STYLE" /* StyleTag */ || parent.data.tag === "TITLE" /* TitleTag */ ? 0 /* None */ : privacy;
2581
- for (var _i = 0, override_1 = override; _i < override_1.length; _i++) {
2582
- var entry = override_1[_i];
2583
- if (path.indexOf(entry) >= 0) {
2584
- privacy = 0 /* None */;
2585
- break;
2586
- }
2587
- }
2588
- }
2589
- // Do not proceed if attributes are missing for the node
2590
- if (attributes === null || attributes === undefined) {
2591
- return privacy;
2592
- }
2593
- // Look up for sensitive fields
2594
- if ("class" /* Class */ in attributes && privacy === 1 /* Sensitive */) {
2595
- for (var _a = 0, DISALLOWED_MATCH_1 = DISALLOWED_MATCH; _a < DISALLOWED_MATCH_1.length; _a++) {
2596
- var match = DISALLOWED_MATCH_1[_a];
2597
- if (attributes["class" /* Class */].indexOf(match) >= 0) {
2598
- privacy = 2 /* Text */;
2599
- break;
2600
- }
2601
- }
2602
- }
2603
- // Check for disallowed list of fields (e.g. address, phone, etc.) only if the input node is not already masked
2604
- if (tag === "INPUT" /* InputTag */) {
2605
- if (privacy === 0 /* None */) {
2606
- var field = "" /* Empty */;
2607
- // Be aggressive in looking up any attribute (id, class, name, etc.) for disallowed names
2608
- for (var _b = 0, _c = Object.keys(attributes); _b < _c.length; _b++) {
2609
- var attribute = _c[_b];
2610
- field += attributes[attribute].toLowerCase();
2611
- }
2612
- for (var _d = 0, DISALLOWED_NAMES_1 = DISALLOWED_NAMES; _d < DISALLOWED_NAMES_1.length; _d++) {
2613
- var name_1 = DISALLOWED_NAMES_1[_d];
2614
- if (field.indexOf(name_1) >= 0) {
2615
- privacy = 2 /* Text */;
2616
- break;
2617
- }
2618
- }
2619
- }
2620
- else if (privacy === 1 /* Sensitive */) {
2621
- // Mask all input fields with an exception of type=submit; since they do not accept user input
2622
- privacy = attributes && attributes["type" /* Type */] === "submit" /* Submit */ ? 0 /* None */ : 2 /* Text */;
2623
- }
2624
- }
2625
- // Check for disallowed list of types (e.g. password, email, etc.) and set the masked property appropriately
2626
- if ("type" /* Type */ in attributes && DISALLOWED_TYPES.indexOf(attributes["type" /* Type */]) >= 0) {
2627
- privacy = 2 /* Text */;
2628
- }
2629
- // Following two conditions supersede any of the above. If there are explicit instructions to mask / unmask a field, we honor that.
2630
- if ("data-clarity-mask" /* MaskData */ in attributes) {
2631
- privacy = 3 /* TextImage */;
2508
+ switch (true) {
2509
+ case "data-clarity-mask" /* MaskData */ in attributes:
2510
+ metadata.privacy = 3 /* TextImage */;
2511
+ break;
2512
+ case "data-clarity-unmask" /* UnmaskData */ in attributes:
2513
+ metadata.privacy = 0 /* None */;
2514
+ break;
2515
+ case privacyMap.has(node):
2516
+ // If this node was explicitly configured to contain sensitive content, honor that privacy setting
2517
+ metadata.privacy = privacyMap.get(node);
2518
+ break;
2519
+ case fraudMap.has(node):
2520
+ // If this node was explicitly configured to be evaluated for fraud, then also mask content
2521
+ metadata.privacy = 2 /* Text */;
2522
+ break;
2523
+ case tag === "*T" /* TextTag */:
2524
+ // If it's a text node belonging to a STYLE or TITLE tag or one of SCRUB_EXCEPTIONS, then capture content
2525
+ var pTag = parent && parent.data ? parent.data.tag : "" /* Empty */;
2526
+ var pSelector_1 = parent && parent.selector ? parent.selector[0 /* Stable */] : "" /* Empty */;
2527
+ metadata.privacy = pTag === "STYLE" /* StyleTag */ || pTag === "TITLE" /* TitleTag */ || override.some(function (x) { return pSelector_1.indexOf(x) >= 0; }) ? 0 /* None */ : current;
2528
+ break;
2529
+ case "type" /* Type */ in attributes:
2530
+ // If this node has an explicit type assigned to it, go through masking rules to determine right privacy setting
2531
+ metadata.privacy = inspect(attributes["type" /* Type */], metadata);
2532
+ break;
2533
+ case tag === "INPUT" /* InputTag */ && current === 0 /* None */:
2534
+ // If even default privacy setting is to not mask, we still scan through input fields for any sensitive information
2535
+ var field_1 = "" /* Empty */;
2536
+ Object.keys(attributes).forEach(function (x) { return field_1 += attributes[x].toLowerCase(); });
2537
+ metadata.privacy = inspect(field_1, metadata);
2538
+ break;
2539
+ case current === 1 /* Sensitive */ && tag === "INPUT" /* InputTag */:
2540
+ // If it's a button or an input option, make an exception to disable masking
2541
+ metadata.privacy = maskDisable.indexOf(attributes["type" /* Type */]) >= 0 ? 0 /* None */ : current;
2542
+ break;
2543
+ case current === 1 /* Sensitive */:
2544
+ // In a mode where we mask sensitive information by default, look through class names to aggressively mask content
2545
+ metadata.privacy = inspect(attributes["class" /* Class */], metadata);
2546
+ break;
2547
+ default:
2548
+ metadata.privacy = parent ? parent.metadata.privacy : metadata.privacy;
2549
+ break;
2632
2550
  }
2633
- if ("data-clarity-unmask" /* UnmaskData */ in attributes) {
2634
- privacy = 0 /* None */;
2551
+ }
2552
+ function inspect(input, metadata) {
2553
+ if (input && maskText.some(function (x) { return input.indexOf(x) >= 0; })) {
2554
+ return 2 /* Text */;
2635
2555
  }
2636
- return privacy;
2556
+ return metadata.privacy;
2637
2557
  }
2638
2558
  function diff(a, b, field) {
2639
2559
  if (typeof a[field] === "object" && typeof b[field] === "object") {
@@ -2721,17 +2641,9 @@ function remove(id, source) {
2721
2641
  track$4(id, source);
2722
2642
  }
2723
2643
  }
2724
- function size(value, parent) {
2725
- var data = value.data;
2726
- var tag = data.tag;
2727
- // If this element is a text node, is masked, and longer than configured length, then track box model for the parent element
2728
- var isLongText = tag === "*T" /* TextTag */ && data.value && data.value.length > 15 /* ResizeObserverThreshold */;
2729
- var isMasked = value.metadata.privacy === 2 /* Text */ || value.metadata.privacy === 3 /* TextImage */;
2730
- if (isLongText && isMasked && parent && parent.metadata.size === null) {
2731
- parent.metadata.size = [];
2732
- }
2644
+ function size(value) {
2733
2645
  // If this element is a image node, and is masked, then track box model for the current element
2734
- if (data.tag === "IMG" /* ImageTag */ && value.metadata.privacy === 3 /* TextImage */) {
2646
+ if (value.data.tag === "IMG" /* ImageTag */ && value.metadata.privacy === 3 /* TextImage */) {
2735
2647
  value.metadata.size = [];
2736
2648
  }
2737
2649
  }
@@ -2940,18 +2852,23 @@ function link(node) {
2940
2852
  }
2941
2853
  return null;
2942
2854
  }
2943
- function metadata$2(node, event) {
2855
+ function metadata$2(node, event, text) {
2856
+ if (text === void 0) { text = null; }
2944
2857
  // If the node is null, we return a reserved value for id: 0. Valid assignment of id begins from 1+.
2945
2858
  var output = { id: 0, hash: null, privacy: 2 /* Text */, node: node };
2946
2859
  if (node) {
2947
2860
  var value = get(node);
2948
2861
  if (value !== null) {
2862
+ var metadata_1 = value.metadata;
2949
2863
  output.id = value.id;
2950
2864
  output.hash = value.hash;
2951
- output.privacy = value.metadata.privacy;
2865
+ output.privacy = metadata_1.privacy;
2952
2866
  if (value.region) {
2953
2867
  track$3(value.region, event);
2954
2868
  }
2869
+ if (metadata_1.fraud) {
2870
+ check$4(metadata_1.fraud, value.id, text || value.data.value);
2871
+ }
2955
2872
  }
2956
2873
  }
2957
2874
  return output;
@@ -2990,7 +2907,7 @@ function encode$3 (type) {
2990
2907
  case 9 /* Click */:
2991
2908
  for (_b = 0, _c = state$7; _b < _c.length; _b++) {
2992
2909
  entry = _c[_b];
2993
- cTarget = metadata$2(entry.data.target, entry.event);
2910
+ cTarget = metadata$2(entry.data.target, entry.event, entry.data.text);
2994
2911
  tokens = [entry.time, entry.event];
2995
2912
  cHash = cTarget.hash.join("." /* Dot */);
2996
2913
  tokens.push(cTarget.id);
@@ -3004,6 +2921,7 @@ function encode$3 (type) {
3004
2921
  tokens.push(scrub(entry.data.text, "click", cTarget.privacy));
3005
2922
  tokens.push(entry.data.link);
3006
2923
  tokens.push(cHash);
2924
+ tokens.push(entry.data.trust);
3007
2925
  queue(tokens);
3008
2926
  track$2(entry.time, entry.event, cHash, entry.data.x, entry.data.y, entry.data.reaction, entry.data.context);
3009
2927
  }
@@ -3039,10 +2957,10 @@ function encode$3 (type) {
3039
2957
  case 27 /* Input */:
3040
2958
  for (_f = 0, _g = state$5; _f < _g.length; _f++) {
3041
2959
  entry = _g[_f];
3042
- iTarget = metadata$2(entry.data.target, entry.event);
2960
+ iTarget = metadata$2(entry.data.target, entry.event, entry.data.value);
3043
2961
  tokens = [entry.time, entry.event];
3044
2962
  tokens.push(iTarget.id);
3045
- tokens.push(entry.data.value);
2963
+ tokens.push(scrub(entry.data.value, "input", iTarget.privacy));
3046
2964
  queue(tokens);
3047
2965
  }
3048
2966
  reset$f();
@@ -3217,7 +3135,7 @@ function queue(tokens, transmit) {
3217
3135
  // We enrich the data going out with the existing upload. In these cases, call to upload comes with 'transmit' set to false.
3218
3136
  if (transmit && timeout === null) {
3219
3137
  if (type !== 25 /* Ping */) {
3220
- reset$n();
3138
+ reset$m();
3221
3139
  }
3222
3140
  timeout = setTimeout(upload, gap);
3223
3141
  queuedTime = now;
@@ -3253,11 +3171,11 @@ function upload(final) {
3253
3171
  // Otherwise you run a risk of infinite loop.
3254
3172
  compute$6();
3255
3173
  compute$5();
3256
- compute$9();
3174
+ compute$8();
3257
3175
  last = final === true;
3258
3176
  e = JSON.stringify(envelope(last));
3259
- a = "[" + analysis.join() + "]";
3260
- p = sendPlaybackBytes ? "[" + playback.join() + "]" : "" /* Empty */;
3177
+ a = "[".concat(analysis.join(), "]");
3178
+ p = sendPlaybackBytes ? "[".concat(playback.join(), "]") : "" /* Empty */;
3261
3179
  encoded = { e: e, a: a, p: p };
3262
3180
  payload = stringify(encoded);
3263
3181
  if (!last) return [3 /*break*/, 1];
@@ -3284,7 +3202,7 @@ function upload(final) {
3284
3202
  });
3285
3203
  }
3286
3204
  function stringify(encoded) {
3287
- return encoded.p.length > 0 ? "{\"e\":" + encoded.e + ",\"a\":" + encoded.a + ",\"p\":" + encoded.p + "}" : "{\"e\":" + encoded.e + ",\"a\":" + encoded.a + "}";
3205
+ 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, "}");
3288
3206
  }
3289
3207
  function send(payload, zipped, sequence, beacon) {
3290
3208
  if (beacon === void 0) { beacon = false; }
@@ -3445,14 +3363,6 @@ function handler(error) {
3445
3363
  stack: e.stack,
3446
3364
  source: error["filename"]
3447
3365
  };
3448
- // In certain cases, ResizeObserver could lead to flood of benign errors - especially when video element is involved.
3449
- // Reference Chromium issue: https://bugs.chromium.org/p/chromium/issues/detail?id=809574
3450
- // Even though it doesn't impact user experience, or show up in console, it can still flood error reporting through on error
3451
- // To mitigate that, we turn off Clarity's ResizeObserver on getting the first instance of this error
3452
- if (e.message.indexOf("ResizeObserver" /* ResizeObserver */) >= 0) {
3453
- stop$t();
3454
- return false;
3455
- }
3456
3366
  encode$2(31 /* ScriptError */);
3457
3367
  }
3458
3368
  return true;
@@ -3482,6 +3392,14 @@ function encode$2 (type) {
3482
3392
  queue(tokens, false);
3483
3393
  }
3484
3394
  break;
3395
+ case 41 /* Fraud */:
3396
+ if (data$d) {
3397
+ tokens.push(data$d.id);
3398
+ tokens.push(data$d.target);
3399
+ tokens.push(data$d.hash);
3400
+ queue(tokens, false);
3401
+ }
3402
+ break;
3485
3403
  }
3486
3404
  return [2 /*return*/];
3487
3405
  });
@@ -3497,7 +3415,7 @@ function log$1(code, severity, name, message, stack) {
3497
3415
  if (name === void 0) { name = null; }
3498
3416
  if (message === void 0) { message = null; }
3499
3417
  if (stack === void 0) { stack = null; }
3500
- var key = name ? name + "|" + message : "";
3418
+ var key = name ? "".concat(name, "|").concat(message) : "";
3501
3419
  // While rare, it's possible for code to fail repeatedly during the lifetime of the same page
3502
3420
  // In those cases, we only want to log the failure once and not spam logs with redundant information.
3503
3421
  if (code in history$2 && history$2[code].indexOf(key) >= 0) {
@@ -3672,7 +3590,7 @@ function encode$1 (event) {
3672
3590
  tokens.push(b.data.activityTime);
3673
3591
  queue(tokens, false);
3674
3592
  }
3675
- reset$p();
3593
+ reset$o();
3676
3594
  break;
3677
3595
  case 25 /* Ping */:
3678
3596
  tokens.push(data$h.gap);
@@ -3705,7 +3623,7 @@ function encode$1 (event) {
3705
3623
  tokens.push(v);
3706
3624
  tokens.push(data$e[v]);
3707
3625
  }
3708
- reset$l();
3626
+ reset$k();
3709
3627
  queue(tokens, false);
3710
3628
  }
3711
3629
  break;
@@ -3720,7 +3638,7 @@ function encode$1 (event) {
3720
3638
  // However, for data over the wire, we round it off to milliseconds precision.
3721
3639
  tokens.push(Math.round(updates$3[m]));
3722
3640
  }
3723
- reset$o();
3641
+ reset$n();
3724
3642
  queue(tokens, false);
3725
3643
  }
3726
3644
  break;
@@ -3746,7 +3664,7 @@ function encode$1 (event) {
3746
3664
  tokens.push(key);
3747
3665
  tokens.push([].concat.apply([], data$g[e]));
3748
3666
  }
3749
- reset$m();
3667
+ reset$l();
3750
3668
  queue(tokens, false);
3751
3669
  }
3752
3670
  break;
@@ -3805,7 +3723,7 @@ function log(dimension, value) {
3805
3723
  // Check valid value before moving ahead
3806
3724
  if (value) {
3807
3725
  // Ensure received value is casted into a string if it wasn't a string to begin with
3808
- value = "" + value;
3726
+ value = "".concat(value);
3809
3727
  if (!(dimension in data$3)) {
3810
3728
  data$3[dimension] = [];
3811
3729
  }
@@ -3860,7 +3778,6 @@ function start$9() {
3860
3778
  log(17 /* DocumentDirection */, document.dir);
3861
3779
  if (navigator) {
3862
3780
  log(9 /* Language */, navigator.userLanguage || navigator.language);
3863
- max(26 /* Automation */, navigator.webdriver ? 1 /* True */ : 0 /* False */);
3864
3781
  userAgentData();
3865
3782
  }
3866
3783
  // Metrics
@@ -3988,7 +3905,7 @@ function session() {
3988
3905
  output.session = parts[0];
3989
3906
  output.count = num(parts[2]) + 1;
3990
3907
  output.upgrade = num(parts[3]);
3991
- output.upload = parts.length >= 6 ? "" + "https://" /* HTTPS */ + parts[5] + "/" + parts[4] : "" + "https://" /* HTTPS */ + parts[4];
3908
+ output.upload = parts.length >= 6 ? "".concat("https://" /* HTTPS */).concat(parts[5], "/").concat(parts[4]) : "".concat("https://" /* HTTPS */).concat(parts[4]);
3992
3909
  }
3993
3910
  }
3994
3911
  return output;
@@ -4013,11 +3930,11 @@ function user() {
4013
3930
  // Check if we either got version-less cookie value or saw multiple copies of the user cookie crumbs
4014
3931
  // In both these cases, we go ahead and delete the existing cookie set on current domain
4015
3932
  if (parts.length === 1 || count > 1) {
4016
- var deleted = "" + ";" /* Semicolon */ + "expires=" /* Expires */ + (new Date(0)).toUTCString() + ";path=/" /* Path */;
3933
+ var deleted = "".concat(";" /* Semicolon */).concat("expires=" /* Expires */).concat((new Date(0)).toUTCString()).concat(";path=/" /* Path */);
4017
3934
  // First, delete current user cookie which might be set on current sub-domain vs. root domain
4018
- document.cookie = "_clck" /* CookieKey */ + "=" + deleted;
3935
+ document.cookie = "".concat("_clck" /* CookieKey */, "=").concat(deleted);
4019
3936
  // Second, same thing for current session cookie so it can be re-written later with the root domain
4020
- document.cookie = "_clsk" /* SessionKey */ + "=" + deleted;
3937
+ document.cookie = "".concat("_clsk" /* SessionKey */, "=").concat(deleted);
4021
3938
  }
4022
3939
  // End code for backward compatibility
4023
3940
  // Read version information and timestamp from cookie, if available
@@ -4054,19 +3971,19 @@ function setCookie(key, value, time) {
4054
3971
  var expiry = new Date();
4055
3972
  expiry.setDate(expiry.getDate() + time);
4056
3973
  var expires = expiry ? "expires=" /* Expires */ + expiry.toUTCString() : "" /* Empty */;
4057
- var cookie = key + "=" + value + ";" /* Semicolon */ + expires + ";path=/" /* Path */;
3974
+ var cookie = "".concat(key, "=").concat(value).concat(";" /* Semicolon */).concat(expires).concat(";path=/" /* Path */);
4058
3975
  try {
4059
3976
  // Attempt to get the root domain only once and fall back to writing cookie on the current domain.
4060
3977
  if (rootDomain === null) {
4061
3978
  var hostname = location.hostname ? location.hostname.split("." /* Dot */) : [];
4062
3979
  // Walk backwards on a domain and attempt to set a cookie, until successful
4063
3980
  for (var i = hostname.length - 1; i >= 0; i--) {
4064
- rootDomain = "." + hostname[i] + (rootDomain ? rootDomain : "" /* Empty */);
3981
+ rootDomain = ".".concat(hostname[i]).concat(rootDomain ? rootDomain : "" /* Empty */);
4065
3982
  // We do not wish to attempt writing a cookie on the absolute last part of the domain, e.g. .com or .net.
4066
3983
  // So we start attempting after second-last part, e.g. .domain.com (PASS) or .co.uk (FAIL)
4067
3984
  if (i < hostname.length - 1) {
4068
3985
  // Write the cookie on the current computed top level domain
4069
- document.cookie = "" + cookie + ";" /* Semicolon */ + "domain=" /* Domain */ + rootDomain;
3986
+ document.cookie = "".concat(cookie).concat(";" /* Semicolon */).concat("domain=" /* Domain */).concat(rootDomain);
4070
3987
  // Once written, check if the cookie exists and its value matches exactly with what we intended to set
4071
3988
  // Checking for exact value match helps us eliminate a corner case where the cookie may already be present with a different value
4072
3989
  // If the check is successful, no more action is required and we can return from the function since rootDomain cookie is already set
@@ -4084,7 +4001,7 @@ function setCookie(key, value, time) {
4084
4001
  catch (_a) {
4085
4002
  rootDomain = "" /* Empty */;
4086
4003
  }
4087
- document.cookie = rootDomain ? "" + cookie + ";" /* Semicolon */ + "domain=" /* Domain */ + rootDomain : cookie;
4004
+ document.cookie = rootDomain ? "".concat(cookie).concat(";" /* Semicolon */).concat("domain=" /* Domain */).concat(rootDomain) : cookie;
4088
4005
  }
4089
4006
  }
4090
4007
 
@@ -4239,9 +4156,13 @@ function compute$1() {
4239
4156
  if (url !== getCurrentUrl()) {
4240
4157
  // If the url changed, start tracking it as a new page
4241
4158
  stop();
4242
- window.setTimeout(start, 250 /* RestartDelay */);
4159
+ window.setTimeout(restart$1, 250 /* RestartDelay */);
4243
4160
  }
4244
4161
  }
4162
+ function restart$1() {
4163
+ start();
4164
+ max(29 /* SinglePage */, 1 /* True */);
4165
+ }
4245
4166
  function getCurrentUrl() {
4246
4167
  return location.href ? location.href.replace(location.hash, "" /* Empty */) : location.href;
4247
4168
  }
@@ -4254,7 +4175,7 @@ var status = false;
4254
4175
  function start$6() {
4255
4176
  status = true;
4256
4177
  start$F();
4257
- reset$k();
4178
+ reset$j();
4258
4179
  reset$1();
4259
4180
  reset$2();
4260
4181
  start$7();
@@ -4263,8 +4184,8 @@ function stop$5() {
4263
4184
  stop$6();
4264
4185
  reset$2();
4265
4186
  reset$1();
4266
- reset$k();
4267
- stop$C();
4187
+ reset$j();
4188
+ stop$B();
4268
4189
  status = false;
4269
4190
  }
4270
4191
  function active() {
@@ -4318,6 +4239,7 @@ function restart() {
4318
4239
  }
4319
4240
 
4320
4241
  function start$5() {
4242
+ start$x();
4321
4243
  start$e();
4322
4244
  start$d();
4323
4245
  }
@@ -4345,14 +4267,14 @@ function discover() {
4345
4267
  case 0:
4346
4268
  ts = time();
4347
4269
  timer = { id: id(), cost: 3 /* LayoutCost */ };
4348
- start$x(timer);
4270
+ start$w(timer);
4349
4271
  return [4 /*yield*/, traverse(document, timer, 0 /* Discover */)];
4350
4272
  case 1:
4351
4273
  _a.sent();
4352
4274
  return [4 /*yield*/, encode$4(5 /* Discover */, timer, ts)];
4353
4275
  case 2:
4354
4276
  _a.sent();
4355
- stop$u(timer);
4277
+ stop$t(timer);
4356
4278
  return [2 /*return*/];
4357
4279
  }
4358
4280
  });
@@ -4367,13 +4289,11 @@ function start$3() {
4367
4289
  start$i();
4368
4290
  start$j();
4369
4291
  start$4();
4370
- start$w();
4371
4292
  }
4372
4293
  function stop$3() {
4373
4294
  stop$f();
4374
4295
  stop$g();
4375
4296
  stop$h();
4376
- stop$t();
4377
4297
  end();
4378
4298
  }
4379
4299
 
@@ -4501,7 +4421,11 @@ function process(entries) {
4501
4421
  compute(entry);
4502
4422
  break;
4503
4423
  case "resource" /* Resource */:
4504
- log(4 /* NetworkHosts */, host(entry.name));
4424
+ var name_1 = entry.name;
4425
+ log(4 /* NetworkHosts */, host(name_1));
4426
+ if (name_1 === config$1.upload || name_1 === config$1.fallback) {
4427
+ max(28 /* UploadTime */, entry.duration);
4428
+ }
4505
4429
  break;
4506
4430
  case "longtask" /* LongTask */:
4507
4431
  count$1(7 /* LongTaskCount */);
@@ -4524,6 +4448,11 @@ function process(entries) {
4524
4448
  break;
4525
4449
  }
4526
4450
  }
4451
+ if (performance && "memory" /* Memory */ in performance && performance["memory" /* Memory */].usedJSHeapSize) {
4452
+ // Track consumed memory (MBs) where "memory" API is available
4453
+ // Reference: https://developer.mozilla.org/en-US/docs/Web/API/Performance/memory
4454
+ max(30 /* UsedMemory */, Math.abs(performance["memory" /* Memory */].usedJSHeapSize / 1048576 /* MegaByte */));
4455
+ }
4527
4456
  }
4528
4457
  function stop$2() {
4529
4458
  if (observer) {
@@ -4585,7 +4514,7 @@ function stop() {
4585
4514
  if (active()) {
4586
4515
  // Stop modules in the reverse order of their initialization
4587
4516
  modules.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
4588
- stop$v();
4517
+ stop$u();
4589
4518
  stop$5();
4590
4519
  }
4591
4520
  }