clarity-js 0.6.43 → 0.7.0

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.
@@ -80,12 +80,14 @@ var config$1 = {
80
80
  lean: false,
81
81
  track: true,
82
82
  content: true,
83
+ drop: [],
83
84
  mask: [],
84
85
  unmask: [],
85
86
  regions: [],
86
87
  extract: [],
87
88
  cookies: [],
88
- fraud: [],
89
+ fraud: true,
90
+ checksum: [],
89
91
  report: null,
90
92
  upload: null,
91
93
  fallback: null,
@@ -101,22 +103,23 @@ function api(method) {
101
103
  }
102
104
 
103
105
  var startTime = 0;
104
- function start$F() {
106
+ function start$G() {
105
107
  startTime = performance.now();
106
108
  }
107
- function time(ts) {
108
- if (ts === void 0) { ts = null; }
109
- ts = ts ? ts : performance.now();
109
+ function time(event) {
110
+ if (event === void 0) { event = null; }
111
+ var ts = event && event.timeStamp > 0 ? event.timeStamp : performance.now();
110
112
  return Math.max(Math.round(ts - startTime), 0);
111
113
  }
112
- function stop$B() {
114
+ function stop$C() {
113
115
  startTime = 0;
114
116
  }
115
117
 
116
- var version$1 = "0.6.43";
118
+ var version$1 = "0.7.0";
117
119
 
118
120
  // tslint:disable: no-bitwise
119
- function hash (input) {
121
+ function hash (input, precision) {
122
+ if (precision === void 0) { precision = null; }
120
123
  // Code inspired from C# GetHashCode: https://github.com/Microsoft/referencesource/blob/master/mscorlib/system/string.cs
121
124
  var hash = 0;
122
125
  var hashOne = 5381;
@@ -132,21 +135,164 @@ function hash (input) {
132
135
  // Replace the magic number from C# implementation (1566083941) with a smaller prime number (11579)
133
136
  // This ensures we don't hit integer overflow and prevent collisions
134
137
  hash = Math.abs(hashOne + (hashTwo * 11579));
135
- return hash.toString(36);
138
+ return (precision ? hash % Math.pow(2, precision) : hash).toString(36);
139
+ }
140
+
141
+ var catchallRegex = /\S/gi;
142
+ var unicodeRegex = true;
143
+ var digitRegex = null;
144
+ var letterRegex = null;
145
+ var currencyRegex = null;
146
+ function text$1(value, hint, privacy, mangle) {
147
+ if (mangle === void 0) { mangle = false; }
148
+ if (value) {
149
+ switch (privacy) {
150
+ case 0 /* Privacy.None */:
151
+ return value;
152
+ case 1 /* Privacy.Sensitive */:
153
+ switch (hint) {
154
+ case "*T" /* Layout.Constant.TextTag */:
155
+ case "value":
156
+ case "placeholder":
157
+ case "click":
158
+ return redact(value);
159
+ case "input":
160
+ case "change":
161
+ return mangleToken(value);
162
+ }
163
+ return value;
164
+ case 2 /* Privacy.Text */:
165
+ case 3 /* Privacy.TextImage */:
166
+ switch (hint) {
167
+ case "*T" /* Layout.Constant.TextTag */:
168
+ return mangle ? mangleText(value) : mask(value);
169
+ case "src":
170
+ case "srcset":
171
+ case "title":
172
+ case "alt":
173
+ return privacy === 3 /* Privacy.TextImage */ ? "" /* Data.Constant.Empty */ : value;
174
+ case "value":
175
+ case "click":
176
+ case "input":
177
+ case "change":
178
+ return mangleToken(value);
179
+ case "placeholder":
180
+ return mask(value);
181
+ }
182
+ break;
183
+ case 4 /* Privacy.Exclude */:
184
+ switch (hint) {
185
+ case "value":
186
+ case "input":
187
+ case "click":
188
+ case "change":
189
+ return Array(5 /* Data.Setting.WordLength */).join("\u2022" /* Data.Constant.Mask */);
190
+ case "checksum":
191
+ return "" /* Data.Constant.Empty */;
192
+ }
193
+ }
194
+ }
195
+ return value;
196
+ }
197
+ function url$1(input) {
198
+ var drop = config$1.drop;
199
+ if (drop && drop.length > 0 && input && input.indexOf("?") > 0) {
200
+ var _a = input.split("?"), path = _a[0], query = _a[1];
201
+ var swap_1 = "*na*" /* Data.Constant.Dropped */;
202
+ return path + "?" + query.split("&").map(function (p) { return drop.some(function (x) { return p.indexOf("".concat(x, "=")) === 0; }) ? "".concat(p.split("=")[0], "=").concat(swap_1) : p; }).join("&");
203
+ }
204
+ return input;
205
+ }
206
+ function mangleText(value) {
207
+ var trimmed = value.trim();
208
+ if (trimmed.length > 0) {
209
+ var first = trimmed[0];
210
+ var index = value.indexOf(first);
211
+ var prefix = value.substr(0, index);
212
+ var suffix = value.substr(index + trimmed.length);
213
+ return "".concat(prefix).concat(trimmed.length.toString(36)).concat(suffix);
214
+ }
215
+ return value;
216
+ }
217
+ function mask(value) {
218
+ return value.replace(catchallRegex, "\u2022" /* Data.Constant.Mask */);
219
+ }
220
+ function mangleToken(value) {
221
+ var length = ((Math.floor(value.length / 5 /* Data.Setting.WordLength */) + 1) * 5 /* Data.Setting.WordLength */);
222
+ var output = "" /* Layout.Constant.Empty */;
223
+ for (var i = 0; i < length; i++) {
224
+ output += i > 0 && i % 5 /* Data.Setting.WordLength */ === 0 ? " " /* Data.Constant.Space */ : "\u2022" /* Data.Constant.Mask */;
225
+ }
226
+ return output;
227
+ }
228
+ function redact(value) {
229
+ var spaceIndex = -1;
230
+ var gap = 0;
231
+ var hasDigit = false;
232
+ var hasEmail = false;
233
+ var hasWhitespace = false;
234
+ var array = null;
235
+ // Initialize unicode regex, if supported by the browser
236
+ // Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes
237
+ if (unicodeRegex && digitRegex === null) {
238
+ try {
239
+ digitRegex = new RegExp("\\p{N}", "gu");
240
+ letterRegex = new RegExp("\\p{L}", "gu");
241
+ currencyRegex = new RegExp("\\p{Sc}", "gu");
242
+ }
243
+ catch (_a) {
244
+ unicodeRegex = false;
245
+ }
246
+ }
247
+ for (var i = 0; i < value.length; i++) {
248
+ var c = value.charCodeAt(i);
249
+ hasDigit = hasDigit || (c >= 48 /* Data.Character.Zero */ && c <= 57 /* Data.Character.Nine */); // Check for digits in the current word
250
+ hasEmail = hasEmail || c === 64 /* Data.Character.At */; // Check for @ sign anywhere within the current word
251
+ hasWhitespace = c === 9 /* Data.Character.Tab */ || c === 10 /* Data.Character.NewLine */ || c === 13 /* Data.Character.Return */ || c === 32 /* Data.Character.Blank */;
252
+ // Process each word as an individual token to redact any sensitive information
253
+ if (i === 0 || i === value.length - 1 || hasWhitespace) {
254
+ // Performance optimization: Lazy load string -> array conversion only when required
255
+ if (hasDigit || hasEmail) {
256
+ if (array === null) {
257
+ array = value.split("" /* Data.Constant.Empty */);
258
+ }
259
+ // Work on a token at a time so we don't have to apply regex to a larger string
260
+ var token = value.substring(spaceIndex + 1, hasWhitespace ? i : i + 1);
261
+ // Check if unicode regex is supported, otherwise fallback to calling mask function on this token
262
+ if (unicodeRegex && currencyRegex !== null) {
263
+ // Do not redact information if the token contains a currency symbol
264
+ token = token.match(currencyRegex) ? token : token.replace(letterRegex, "\u25AA" /* Data.Constant.Letter */).replace(digitRegex, "\u25AB" /* Data.Constant.Digit */);
265
+ }
266
+ else {
267
+ token = mask(token);
268
+ }
269
+ // Merge token back into array at the right place
270
+ array.splice(spaceIndex + 1 - gap, token.length, token);
271
+ gap += token.length - 1;
272
+ }
273
+ // Reset digit and email flags after every word boundary, except the beginning of string
274
+ if (hasWhitespace) {
275
+ hasDigit = false;
276
+ hasEmail = false;
277
+ spaceIndex = i;
278
+ }
279
+ }
280
+ }
281
+ return array ? array.join("" /* Data.Constant.Empty */) : value;
136
282
  }
137
283
 
138
- var state$9 = null;
284
+ var state$a = null;
139
285
  var buffer = null;
140
286
  var update$2 = false;
141
- function start$E() {
287
+ function start$F() {
142
288
  update$2 = false;
143
- reset$p();
289
+ reset$q();
144
290
  }
145
- function reset$p() {
291
+ function reset$q() {
146
292
  // Baseline state holds the previous values - if it is updated in the current payload,
147
293
  // reset the state to current value after sending the previous state
148
294
  if (update$2) {
149
- state$9 = { time: time(), event: 4 /* Event.Baseline */, data: {
295
+ state$a = { time: time(), event: 4 /* Event.Baseline */, data: {
150
296
  visible: buffer.visible,
151
297
  docWidth: buffer.docWidth,
152
298
  docHeight: buffer.docHeight,
@@ -209,20 +355,20 @@ function compute$c() {
209
355
  encode$1(4 /* Event.Baseline */);
210
356
  }
211
357
  }
212
- function stop$A() {
213
- reset$p();
358
+ function stop$B() {
359
+ reset$q();
214
360
  }
215
361
 
216
362
  var baseline = /*#__PURE__*/Object.freeze({
217
363
  __proto__: null,
218
- get state () { return state$9; },
219
- start: start$E,
220
- reset: reset$p,
364
+ get state () { return state$a; },
365
+ start: start$F,
366
+ reset: reset$q,
221
367
  track: track$7,
222
368
  activity: activity,
223
369
  visibility: visibility,
224
370
  compute: compute$c,
225
- stop: stop$A
371
+ stop: stop$B
226
372
  });
227
373
 
228
374
  var data$j = null;
@@ -241,12 +387,12 @@ function event(key, value) {
241
387
 
242
388
  var data$i = null;
243
389
  var updates$3 = null;
244
- function start$D() {
390
+ function start$E() {
245
391
  data$i = {};
246
392
  updates$3 = {};
247
393
  count$1(5 /* Metric.InvokeCount */);
248
394
  }
249
- function stop$z() {
395
+ function stop$A() {
250
396
  data$i = {};
251
397
  updates$3 = {};
252
398
  }
@@ -287,7 +433,7 @@ function max(metric, value) {
287
433
  function compute$b() {
288
434
  encode$1(0 /* Event.Metric */);
289
435
  }
290
- function reset$o() {
436
+ function reset$p() {
291
437
  updates$3 = {};
292
438
  }
293
439
 
@@ -302,11 +448,11 @@ var data$h;
302
448
  var last = 0;
303
449
  var interval = 0;
304
450
  var timeout$6 = null;
305
- function start$C() {
451
+ function start$D() {
306
452
  interval = 60000 /* Setting.PingInterval */;
307
453
  last = 0;
308
454
  }
309
- function reset$n() {
455
+ function reset$o() {
310
456
  if (timeout$6) {
311
457
  clearTimeout(timeout$6);
312
458
  }
@@ -324,7 +470,7 @@ function ping() {
324
470
  suspend();
325
471
  }
326
472
  }
327
- function stop$y() {
473
+ function stop$z() {
328
474
  clearTimeout(timeout$6);
329
475
  last = 0;
330
476
  interval = 0;
@@ -333,16 +479,16 @@ function stop$y() {
333
479
  var ping$1 = /*#__PURE__*/Object.freeze({
334
480
  __proto__: null,
335
481
  get data () { return data$h; },
336
- start: start$C,
337
- reset: reset$n,
338
- stop: stop$y
482
+ start: start$D,
483
+ reset: reset$o,
484
+ stop: stop$z
339
485
  });
340
486
 
341
487
  var data$g = null;
342
- function start$B() {
488
+ function start$C() {
343
489
  data$g = {};
344
490
  }
345
- function stop$x() {
491
+ function stop$y() {
346
492
  data$g = {};
347
493
  }
348
494
  function track$6(event, time) {
@@ -365,22 +511,22 @@ function track$6(event, time) {
365
511
  function compute$a() {
366
512
  encode$1(36 /* Event.Summary */);
367
513
  }
368
- function reset$m() {
514
+ function reset$n() {
369
515
  data$g = {};
370
516
  }
371
517
 
372
518
  var summary = /*#__PURE__*/Object.freeze({
373
519
  __proto__: null,
374
520
  get data () { return data$g; },
375
- start: start$B,
376
- stop: stop$x,
521
+ start: start$C,
522
+ stop: stop$y,
377
523
  track: track$6,
378
524
  compute: compute$a,
379
- reset: reset$m
525
+ reset: reset$n
380
526
  });
381
527
 
382
528
  var data$f = null;
383
- function start$A() {
529
+ function start$B() {
384
530
  if (!config$1.lean && config$1.upgrade) {
385
531
  config$1.upgrade("Config" /* Constant.Config */);
386
532
  }
@@ -404,21 +550,21 @@ function upgrade(key) {
404
550
  encode$1(3 /* Event.Upgrade */);
405
551
  }
406
552
  }
407
- function stop$w() {
553
+ function stop$x() {
408
554
  data$f = null;
409
555
  }
410
556
 
411
557
  var upgrade$1 = /*#__PURE__*/Object.freeze({
412
558
  __proto__: null,
413
559
  get data () { return data$f; },
414
- start: start$A,
560
+ start: start$B,
415
561
  upgrade: upgrade,
416
- stop: stop$w
562
+ stop: stop$x
417
563
  });
418
564
 
419
565
  var data$e = null;
420
- function start$z() {
421
- reset$l();
566
+ function start$A() {
567
+ reset$m();
422
568
  }
423
569
  function set(variable, value) {
424
570
  var values = typeof value === "string" /* Constant.String */ ? [value] : value;
@@ -449,22 +595,22 @@ function log$2(variable, value) {
449
595
  function compute$9() {
450
596
  encode$1(34 /* Event.Variable */);
451
597
  }
452
- function reset$l() {
598
+ function reset$m() {
453
599
  data$e = {};
454
600
  }
455
- function stop$v() {
456
- reset$l();
601
+ function stop$w() {
602
+ reset$m();
457
603
  }
458
604
 
459
605
  var variable = /*#__PURE__*/Object.freeze({
460
606
  __proto__: null,
461
607
  get data () { return data$e; },
462
- start: start$z,
608
+ start: start$A,
463
609
  set: set,
464
610
  identify: identify,
465
611
  compute: compute$9,
466
- reset: reset$l,
467
- stop: stop$v
612
+ reset: reset$m,
613
+ stop: stop$w
468
614
  });
469
615
 
470
616
  /******************************************************************************
@@ -579,18 +725,18 @@ function read(stream) {
579
725
  }
580
726
 
581
727
  var modules$1 = [baseline, dimension, variable, limit, summary, metadata$1, envelope$1, upload$1, ping$1, upgrade$1, extract];
582
- function start$y() {
728
+ function start$z() {
583
729
  // Metric needs to be initialized before we can start measuring. so metric is not wrapped in measure
584
- start$D();
730
+ start$E();
585
731
  modules$1.forEach(function (x) { return measure(x.start)(); });
586
732
  }
587
- function stop$u() {
733
+ function stop$v() {
588
734
  // Stop modules in the reverse order of their initialization
589
735
  // The ordering below should respect inter-module dependency.
590
736
  // E.g. if upgrade depends on upload, then upgrade needs to end before upload.
591
737
  // Similarly, if upload depends on metadata, upload needs to end before metadata.
592
738
  modules$1.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
593
- stop$z();
739
+ stop$A();
594
740
  }
595
741
  function compute$8() {
596
742
  compute$9();
@@ -602,130 +748,9 @@ function compute$8() {
602
748
  compute$4();
603
749
  }
604
750
 
605
- var catchallRegex = /\S/gi;
606
- var unicodeRegex = true;
607
- var digitRegex = null;
608
- var letterRegex = null;
609
- var currencyRegex = null;
610
- function scrub (value, hint, privacy, mangle) {
611
- if (mangle === void 0) { mangle = false; }
612
- if (value) {
613
- switch (privacy) {
614
- case 0 /* Privacy.None */:
615
- return value;
616
- case 1 /* Privacy.Sensitive */:
617
- switch (hint) {
618
- case "*T" /* Layout.Constant.TextTag */:
619
- case "value":
620
- case "placeholder":
621
- case "click":
622
- case "input":
623
- return redact(value);
624
- }
625
- return value;
626
- case 2 /* Privacy.Text */:
627
- case 3 /* Privacy.TextImage */:
628
- switch (hint) {
629
- case "*T" /* Layout.Constant.TextTag */:
630
- return mangle ? mangleText(value) : mask(value);
631
- case "src":
632
- case "srcset":
633
- case "title":
634
- case "alt":
635
- return privacy === 3 /* Privacy.TextImage */ ? "" /* Data.Constant.Empty */ : value;
636
- case "value":
637
- case "click":
638
- case "input":
639
- return mangleToken(value);
640
- case "placeholder":
641
- return mask(value);
642
- }
643
- break;
644
- }
645
- }
646
- return value;
647
- }
648
- function mangleText(value) {
649
- var trimmed = value.trim();
650
- if (trimmed.length > 0) {
651
- var first = trimmed[0];
652
- var index = value.indexOf(first);
653
- var prefix = value.substr(0, index);
654
- var suffix = value.substr(index + trimmed.length);
655
- return "".concat(prefix).concat(trimmed.length.toString(36)).concat(suffix);
656
- }
657
- return value;
658
- }
659
- function mask(value) {
660
- return value.replace(catchallRegex, "\u2022" /* Data.Constant.Mask */);
661
- }
662
- function mangleToken(value) {
663
- var length = ((Math.floor(value.length / 5 /* Data.Setting.WordLength */) + 1) * 5 /* Data.Setting.WordLength */);
664
- var output = "" /* Layout.Constant.Empty */;
665
- for (var i = 0; i < length; i++) {
666
- output += i > 0 && i % 5 /* Data.Setting.WordLength */ === 0 ? " " /* Data.Constant.Space */ : "\u2022" /* Data.Constant.Mask */;
667
- }
668
- return output;
669
- }
670
- function redact(value) {
671
- var spaceIndex = -1;
672
- var gap = 0;
673
- var hasDigit = false;
674
- var hasEmail = false;
675
- var hasWhitespace = false;
676
- var array = null;
677
- // Initialize unicode regex, if supported by the browser
678
- // Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes
679
- if (unicodeRegex && digitRegex === null) {
680
- try {
681
- digitRegex = new RegExp("\\p{N}", "gu");
682
- letterRegex = new RegExp("\\p{L}", "gu");
683
- currencyRegex = new RegExp("\\p{Sc}", "gu");
684
- }
685
- catch (_a) {
686
- unicodeRegex = false;
687
- }
688
- }
689
- for (var i = 0; i < value.length; i++) {
690
- var c = value.charCodeAt(i);
691
- hasDigit = hasDigit || (c >= 48 /* Data.Character.Zero */ && c <= 57 /* Data.Character.Nine */); // Check for digits in the current word
692
- hasEmail = hasEmail || c === 64 /* Data.Character.At */; // Check for @ sign anywhere within the current word
693
- hasWhitespace = c === 9 /* Data.Character.Tab */ || c === 10 /* Data.Character.NewLine */ || c === 13 /* Data.Character.Return */ || c === 32 /* Data.Character.Blank */;
694
- // Process each word as an individual token to redact any sensitive information
695
- if (i === 0 || i === value.length - 1 || hasWhitespace) {
696
- // Performance optimization: Lazy load string -> array conversion only when required
697
- if (hasDigit || hasEmail) {
698
- if (array === null) {
699
- array = value.split("" /* Data.Constant.Empty */);
700
- }
701
- // Work on a token at a time so we don't have to apply regex to a larger string
702
- var token = value.substring(spaceIndex + 1, hasWhitespace ? i : i + 1);
703
- // Check if unicode regex is supported, otherwise fallback to calling mask function on this token
704
- if (unicodeRegex && currencyRegex !== null) {
705
- // Do not redact information if the token contains a currency symbol
706
- token = token.match(currencyRegex) ? token : token.replace(letterRegex, "\u25AA" /* Data.Constant.Letter */).replace(digitRegex, "\u25AB" /* Data.Constant.Digit */);
707
- }
708
- else {
709
- token = mask(token);
710
- }
711
- // Merge token back into array at the right place
712
- array.splice(spaceIndex + 1 - gap, token.length, token);
713
- gap += token.length - 1;
714
- }
715
- // Reset digit and email flags after every word boundary, except the beginning of string
716
- if (hasWhitespace) {
717
- hasDigit = false;
718
- hasEmail = false;
719
- spaceIndex = i;
720
- }
721
- }
722
- }
723
- return array ? array.join("" /* Data.Constant.Empty */) : value;
724
- }
725
-
726
751
  var history$5 = [];
727
752
  var data$d;
728
- function start$x() {
753
+ function start$y() {
729
754
  history$5 = [];
730
755
  max(26 /* Metric.Automation */, navigator.webdriver ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */);
731
756
  try {
@@ -736,12 +761,12 @@ function start$x() {
736
761
  }
737
762
  }
738
763
  function check$4(id, target, input) {
739
- // Compute hash for fraud detection. Hash is computed only if input meets the minimum length criteria
740
- if (id !== null && input && input.length >= 5 /* Setting.WordLength */) {
741
- data$d = { id: id, target: target, hash: hash(input) };
764
+ // Compute hash for fraud detection, if enabled. Hash is computed only if input meets the minimum length criteria
765
+ if (config$1.fraud && id !== null && input && input.length >= 5 /* Setting.WordLength */) {
766
+ data$d = { id: id, target: target, checksum: hash(input, 24 /* Setting.ChecksumPrecision */) };
742
767
  // Only encode this event if we haven't already reported this hash
743
- if (history$5.indexOf(data$d.hash) < 0) {
744
- history$5.push(data$d.hash);
768
+ if (history$5.indexOf(data$d.checksum) < 0) {
769
+ history$5.push(data$d.checksum);
745
770
  encode$2(41 /* Event.Fraud */);
746
771
  }
747
772
  }
@@ -749,7 +774,7 @@ function check$4(id, target, input) {
749
774
 
750
775
  var excludeClassNames = "load,active,fixed,visible,focus,show,collaps,animat" /* Constant.ExcludeClassNames */.split("," /* Constant.Comma */);
751
776
  var selectorMap = {};
752
- function reset$k() {
777
+ function reset$l() {
753
778
  selectorMap = {};
754
779
  }
755
780
  function get$1(input, type) {
@@ -837,7 +862,7 @@ function filter(value) {
837
862
 
838
863
  var selector = /*#__PURE__*/Object.freeze({
839
864
  __proto__: null,
840
- reset: reset$k,
865
+ reset: reset$l,
841
866
  get: get$1
842
867
  });
843
868
 
@@ -864,7 +889,7 @@ function resume$1() {
864
889
  }
865
890
  }
866
891
  }
867
- function reset$j() {
892
+ function reset$k() {
868
893
  tracker = {};
869
894
  queuedTasks = [];
870
895
  activeTask = null;
@@ -925,7 +950,7 @@ function run() {
925
950
  });
926
951
  }
927
952
  }
928
- function state$8(timer) {
953
+ function state$9(timer) {
929
954
  var id = key(timer);
930
955
  if (id in tracker) {
931
956
  var elapsed = performance.now() - tracker[id].start;
@@ -934,7 +959,7 @@ function state$8(timer) {
934
959
  // If this task is no longer being tracked, send stop message to the caller
935
960
  return 2 /* Task.Stop */;
936
961
  }
937
- function start$w(timer) {
962
+ function start$x(timer) {
938
963
  tracker[key(timer)] = { start: performance.now(), calls: 0, yield: 30 /* Setting.LongTask */ };
939
964
  }
940
965
  function restart$2(timer) {
@@ -942,12 +967,12 @@ function restart$2(timer) {
942
967
  if (tracker && tracker[id]) {
943
968
  var c = tracker[id].calls;
944
969
  var y = tracker[id].yield;
945
- start$w(timer);
970
+ start$x(timer);
946
971
  tracker[id].calls = c + 1;
947
972
  tracker[id].yield = y;
948
973
  }
949
974
  }
950
- function stop$t(timer) {
975
+ function stop$u(timer) {
951
976
  var end = performance.now();
952
977
  var id = key(timer);
953
978
  var duration = end - tracker[id].start;
@@ -967,7 +992,7 @@ function suspend$1(timer) {
967
992
  case 0:
968
993
  id = key(timer);
969
994
  if (!(id in tracker)) return [3 /*break*/, 2];
970
- stop$t(timer);
995
+ stop$u(timer);
971
996
  _a = tracker[id];
972
997
  return [4 /*yield*/, wait()];
973
998
  case 1:
@@ -1118,7 +1143,7 @@ function encode$4 (type, timer, ts) {
1118
1143
  return [3 /*break*/, 10];
1119
1144
  case 3:
1120
1145
  // Check if we are operating within the context of the current page
1121
- if (state$8(timer) === 2 /* Task.Stop */) {
1146
+ if (state$9(timer) === 2 /* Task.Stop */) {
1122
1147
  return [3 /*break*/, 10];
1123
1148
  }
1124
1149
  values = updates$2();
@@ -1128,7 +1153,7 @@ function encode$4 (type, timer, ts) {
1128
1153
  case 4:
1129
1154
  if (!(_c < values_1.length)) return [3 /*break*/, 8];
1130
1155
  value = values_1[_c];
1131
- state = state$8(timer);
1156
+ state = state$9(timer);
1132
1157
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 6];
1133
1158
  return [4 /*yield*/, suspend$1(timer)];
1134
1159
  case 5:
@@ -1172,7 +1197,7 @@ function encode$4 (type, timer, ts) {
1172
1197
  break;
1173
1198
  case "value":
1174
1199
  check$4(value.metadata.fraud, value.id, data[key]);
1175
- tokens.push(scrub(data[key], data.tag, privacy, mangle));
1200
+ tokens.push(text$1(data[key], data.tag, privacy, mangle));
1176
1201
  break;
1177
1202
  }
1178
1203
  }
@@ -1210,15 +1235,15 @@ function str$1(input) {
1210
1235
  return input.toString(36);
1211
1236
  }
1212
1237
  function attribute(key, value, privacy) {
1213
- return "".concat(key, "=").concat(scrub(value, key, privacy));
1238
+ return "".concat(key, "=").concat(text$1(value, key, privacy));
1214
1239
  }
1215
1240
 
1216
1241
  var data$c;
1217
- function reset$i() {
1242
+ function reset$j() {
1218
1243
  data$c = null;
1219
1244
  }
1220
- function start$v() {
1221
- reset$i();
1245
+ function start$w() {
1246
+ reset$j();
1222
1247
  compute$7();
1223
1248
  }
1224
1249
  function compute$7() {
@@ -1245,6 +1270,29 @@ function compute$7() {
1245
1270
  }
1246
1271
  }
1247
1272
  function end() {
1273
+ reset$j();
1274
+ }
1275
+
1276
+ var state$8 = [];
1277
+ function start$v() {
1278
+ reset$i();
1279
+ }
1280
+ function observe$c(root) {
1281
+ bind(root, "change", recompute$8, true);
1282
+ }
1283
+ function recompute$8(evt) {
1284
+ var element = target(evt);
1285
+ if (element) {
1286
+ var value = element.value;
1287
+ var checksum = value && value.length >= 5 /* Setting.WordLength */ && config$1.fraud ? hash(value, 24 /* Setting.ChecksumPrecision */) : "" /* Constant.Empty */;
1288
+ state$8.push({ time: time(evt), event: 42 /* Event.Change */, data: { target: target(evt), type: element.type, value: value, checksum: checksum } });
1289
+ schedule$1(encode$3.bind(this, 42 /* Event.Change */));
1290
+ }
1291
+ }
1292
+ function reset$i() {
1293
+ state$8 = [];
1294
+ }
1295
+ function stop$t() {
1248
1296
  reset$i();
1249
1297
  }
1250
1298
 
@@ -1301,7 +1349,7 @@ function handler$3(event, root, evt) {
1301
1349
  // Check for null values before processing this event
1302
1350
  if (x !== null && y !== null) {
1303
1351
  state$7.push({
1304
- time: time(),
1352
+ time: time(evt),
1305
1353
  event: event,
1306
1354
  data: {
1307
1355
  target: t,
@@ -1392,7 +1440,7 @@ function observe$a(root) {
1392
1440
  bind(root, "paste", recompute$7.bind(this, 2 /* Clipboard.Paste */), true);
1393
1441
  }
1394
1442
  function recompute$7(action, evt) {
1395
- state$6.push({ time: time(), event: 38 /* Event.Clipboard */, data: { target: target(evt), action: action } });
1443
+ state$6.push({ time: time(evt), event: 38 /* Event.Clipboard */, data: { target: target(evt), action: action } });
1396
1444
  schedule$1(encode$3.bind(this, 38 /* Event.Clipboard */));
1397
1445
  }
1398
1446
  function reset$g() {
@@ -1426,9 +1474,9 @@ function recompute$6(evt) {
1426
1474
  if (state$5.length > 0 && (state$5[state$5.length - 1].data.target === data.target)) {
1427
1475
  state$5.pop();
1428
1476
  }
1429
- state$5.push({ time: time(), event: 27 /* Event.Input */, data: data });
1477
+ state$5.push({ time: time(evt), event: 27 /* Event.Input */, data: data });
1430
1478
  clearTimeout(timeout$5);
1431
- timeout$5 = setTimeout(process$6, 500 /* Setting.LookAhead */, 27 /* Event.Input */);
1479
+ timeout$5 = setTimeout(process$6, 1000 /* Setting.InputLookAhead */, 27 /* Event.Input */);
1432
1480
  }
1433
1481
  }
1434
1482
  function process$6(event) {
@@ -1471,14 +1519,14 @@ function mouse(event, root, evt) {
1471
1519
  }
1472
1520
  // Check for null values before processing this event
1473
1521
  if (x !== null && y !== null) {
1474
- handler$2({ time: time(), event: event, data: { target: target(evt), x: x, y: y } });
1522
+ handler$2({ time: time(evt), event: event, data: { target: target(evt), x: x, y: y } });
1475
1523
  }
1476
1524
  }
1477
1525
  function touch(event, root, evt) {
1478
1526
  var frame = iframe(root);
1479
1527
  var d = frame ? frame.contentDocument.documentElement : document.documentElement;
1480
1528
  var touches = evt.changedTouches;
1481
- var t = time();
1529
+ var t = time(evt);
1482
1530
  if (touches) {
1483
1531
  for (var i = 0; i < touches.length; i++) {
1484
1532
  var entry = touches[i];
@@ -1584,7 +1632,7 @@ function recompute$4(event) {
1584
1632
  // And, if for some reason that is not available, fall back to looking up scrollTop on document.documentElement.
1585
1633
  var x = element === de && "pageXOffset" in w ? Math.round(w.pageXOffset) : Math.round(element.scrollLeft);
1586
1634
  var y = element === de && "pageYOffset" in w ? Math.round(w.pageYOffset) : Math.round(element.scrollTop);
1587
- var current = { time: time(), event: 10 /* Event.Scroll */, data: { target: element, x: x, y: y } };
1635
+ var current = { time: time(event), event: 10 /* Event.Scroll */, data: { target: element, x: x, y: y } };
1588
1636
  // We don't send any scroll events if this is the first event and the current position is top (0,0)
1589
1637
  if ((event === null && x === 0 && y === 0) || (x === null || y === null)) {
1590
1638
  return;
@@ -1674,7 +1722,7 @@ function observe$5(root) {
1674
1722
  bind(root, "submit", recompute$2, true);
1675
1723
  }
1676
1724
  function recompute$2(evt) {
1677
- state$2.push({ time: time(), event: 39 /* Event.Submit */, data: { target: target(evt) } });
1725
+ state$2.push({ time: time(evt), event: 39 /* Event.Submit */, data: { target: target(evt) } });
1678
1726
  schedule$1(encode$3.bind(this, 39 /* Event.Submit */));
1679
1727
  }
1680
1728
  function reset$a() {
@@ -1690,7 +1738,7 @@ function start$m() {
1690
1738
  }
1691
1739
  function recompute$1(evt) {
1692
1740
  data$9 = { name: evt.type };
1693
- encode$3(26 /* Event.Unload */);
1741
+ encode$3(26 /* Event.Unload */, time(evt));
1694
1742
  stop();
1695
1743
  }
1696
1744
  function reset$9() {
@@ -1705,9 +1753,10 @@ function start$l() {
1705
1753
  bind(document, "visibilitychange", recompute);
1706
1754
  recompute();
1707
1755
  }
1708
- function recompute() {
1756
+ function recompute(evt) {
1757
+ if (evt === void 0) { evt = null; }
1709
1758
  data$8 = { visible: "visibilityState" in document ? document.visibilityState : "default" };
1710
- encode$3(28 /* Event.Visibility */);
1759
+ encode$3(28 /* Event.Visibility */, time(evt));
1711
1760
  }
1712
1761
  function reset$8() {
1713
1762
  data$8 = null;
@@ -1726,6 +1775,7 @@ function start$k() {
1726
1775
  start$l();
1727
1776
  start$p();
1728
1777
  start$o();
1778
+ start$v();
1729
1779
  start$n();
1730
1780
  start$m();
1731
1781
  }
@@ -1739,6 +1789,7 @@ function stop$i() {
1739
1789
  stop$j();
1740
1790
  stop$n();
1741
1791
  stop$m();
1792
+ stop$t();
1742
1793
  stop$l();
1743
1794
  stop$k();
1744
1795
  }
@@ -1752,6 +1803,7 @@ function observe$4(root) {
1752
1803
  observe$8(root);
1753
1804
  observe$9(root);
1754
1805
  observe$6(root);
1806
+ observe$c(root);
1755
1807
  observe$5(root);
1756
1808
  }
1757
1809
  }
@@ -1832,6 +1884,7 @@ function num$1(input, scale) {
1832
1884
  var IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last"];
1833
1885
  var newlineRegex = /[\r\n]+/g;
1834
1886
  function processNode (node, source) {
1887
+ var _a;
1835
1888
  var child = null;
1836
1889
  // Do not track this change if we are attempting to remove a node before discovering it
1837
1890
  if (source === 2 /* Source.ChildListRemove */ && has(node) === false) {
@@ -1928,7 +1981,7 @@ function processNode (node, source) {
1928
1981
  try {
1929
1982
  ld(JSON.parse(element.text.replace(newlineRegex, "" /* Constant.Empty */)));
1930
1983
  }
1931
- catch ( /* do nothing */_a) { /* do nothing */ }
1984
+ catch ( /* do nothing */_b) { /* do nothing */ }
1932
1985
  }
1933
1986
  break;
1934
1987
  case "NOSCRIPT":
@@ -1954,11 +2007,20 @@ function processNode (node, source) {
1954
2007
  break;
1955
2008
  case "HEAD":
1956
2009
  var head = { tag: tag, attributes: attributes };
1957
- if (location) {
1958
- head.attributes["*B" /* Constant.Base */] = location.protocol + "//" + location.hostname;
1959
- }
2010
+ var l = insideFrame && ((_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.location) ? node.ownerDocument.location : location;
2011
+ head.attributes["*B" /* Constant.Base */] = l.protocol + "//" + l.hostname + l.pathname;
1960
2012
  dom[call](node, parent, head, source);
1961
2013
  break;
2014
+ case "BASE":
2015
+ // Override the auto detected base path to explicit value specified in this tag
2016
+ var baseHead = get(node.parentElement);
2017
+ if (baseHead) {
2018
+ // We create "a" element so we can generate protocol and hostname for relative paths like "/path/"
2019
+ var a = document.createElement("a");
2020
+ a.href = attributes["href"];
2021
+ baseHead.data.attributes["*B" /* Constant.Base */] = a.protocol + "//" + a.hostname + a.pathname;
2022
+ }
2023
+ break;
1962
2024
  case "STYLE":
1963
2025
  var styleData = { tag: tag, attributes: attributes, value: getStyleValue(element) };
1964
2026
  dom[call](node, parent, styleData, source);
@@ -2058,7 +2120,7 @@ function traverse (root, timer, source) {
2058
2120
  queue.push(next);
2059
2121
  next = next.nextSibling;
2060
2122
  }
2061
- state = state$8(timer);
2123
+ state = state$9(timer);
2062
2124
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 3];
2063
2125
  return [4 /*yield*/, suspend$1(timer)];
2064
2126
  case 2:
@@ -2195,7 +2257,7 @@ function process$2() {
2195
2257
  switch (_b.label) {
2196
2258
  case 0:
2197
2259
  timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
2198
- start$w(timer);
2260
+ start$x(timer);
2199
2261
  _b.label = 1;
2200
2262
  case 1:
2201
2263
  if (!(mutations.length > 0)) return [3 /*break*/, 8];
@@ -2205,7 +2267,7 @@ function process$2() {
2205
2267
  case 2:
2206
2268
  if (!(_i < _a.length)) return [3 /*break*/, 6];
2207
2269
  mutation = _a[_i];
2208
- state = state$8(timer);
2270
+ state = state$9(timer);
2209
2271
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 4];
2210
2272
  return [4 /*yield*/, suspend$1(timer)];
2211
2273
  case 3:
@@ -2250,7 +2312,7 @@ function process$2() {
2250
2312
  _b.sent();
2251
2313
  return [3 /*break*/, 1];
2252
2314
  case 8:
2253
- stop$t(timer);
2315
+ stop$u(timer);
2254
2316
  return [2 /*return*/];
2255
2317
  }
2256
2318
  });
@@ -2312,7 +2374,7 @@ function processNodeList(list, source, timer) {
2312
2374
  traverse(list[i], timer, source);
2313
2375
  return [3 /*break*/, 5];
2314
2376
  case 2:
2315
- state = state$8(timer);
2377
+ state = state$9(timer);
2316
2378
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 4];
2317
2379
  return [4 /*yield*/, suspend$1(timer)];
2318
2380
  case 3:
@@ -2385,8 +2447,9 @@ var override = [];
2385
2447
  var unmask = [];
2386
2448
  var updatedFragments = {};
2387
2449
  var maskText = [];
2388
- var maskInput = [];
2450
+ var maskExclude = [];
2389
2451
  var maskDisable = [];
2452
+ var maskTags = [];
2390
2453
  // The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced
2391
2454
  var idMap = null; // Maps node => id.
2392
2455
  var iframeMap = null; // Maps iframe's contentDocument => parent iframe element
@@ -2408,13 +2471,14 @@ function reset$7() {
2408
2471
  override = [];
2409
2472
  unmask = [];
2410
2473
  maskText = "address,password,contact" /* Mask.Text */.split("," /* Constant.Comma */);
2411
- maskInput = "password,secret,pass,social,ssn,name,code,dob,cell,mob,contact,hidden,account,cvv,ccv,email,tel,phone,address,addr,card,zip" /* Mask.Input */.split("," /* Constant.Comma */);
2474
+ maskExclude = "password,secret,pass,social,ssn,code,hidden" /* Mask.Exclude */.split("," /* Constant.Comma */);
2412
2475
  maskDisable = "radio,checkbox,range,button,reset,submit" /* Mask.Disable */.split("," /* Constant.Comma */);
2476
+ maskTags = "INPUT,SELECT,TEXTAREA" /* Mask.Tags */.split("," /* Constant.Comma */);
2413
2477
  idMap = new WeakMap();
2414
2478
  iframeMap = new WeakMap();
2415
2479
  privacyMap = new WeakMap();
2416
2480
  fraudMap = new WeakMap();
2417
- reset$k();
2481
+ reset$l();
2418
2482
  }
2419
2483
  // We parse new root nodes for any regions or masked nodes in the beginning (document) and
2420
2484
  // later whenever there are new additions or modifications to DOM (mutations)
@@ -2432,7 +2496,7 @@ function parse$1(root, init) {
2432
2496
  if ("querySelectorAll" in root) {
2433
2497
  config$1.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "".concat(x[0])); }); }); // Regions
2434
2498
  config$1.mask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 3 /* Privacy.TextImage */); }); }); // Masked Elements
2435
- config$1.fraud.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Check
2499
+ config$1.checksum.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Checksum Check
2436
2500
  unmask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 0 /* Privacy.None */); }); }); // Unmasked Elements
2437
2501
  }
2438
2502
  }
@@ -2576,6 +2640,16 @@ function privacy(node, value, parent) {
2576
2640
  var attributes = data.attributes || {};
2577
2641
  var tag = data.tag.toUpperCase();
2578
2642
  switch (true) {
2643
+ case maskTags.indexOf(tag) >= 0:
2644
+ var type = attributes["type" /* Constant.Type */];
2645
+ var meta_1 = "" /* Constant.Empty */;
2646
+ Object.keys(attributes).forEach(function (x) { return meta_1 += attributes[x].toLowerCase(); });
2647
+ var exclude = maskExclude.some(function (x) { return meta_1.indexOf(x) >= 0; });
2648
+ // Regardless of privacy mode, always mask off user input from input boxes or drop downs with two exceptions:
2649
+ // (1) The node is detected to be one of the excluded fields, in which case we drop everything
2650
+ // (2) The node's type is one of the allowed types (like checkboxes)
2651
+ metadata.privacy = tag === "INPUT" /* Constant.InputTag */ && maskDisable.indexOf(type) >= 0 ? current : (exclude ? 4 /* Privacy.Exclude */ : 2 /* Privacy.Text */);
2652
+ break;
2579
2653
  case "data-clarity-mask" /* Constant.MaskData */ in attributes:
2580
2654
  metadata.privacy = 3 /* Privacy.TextImage */;
2581
2655
  break;
@@ -2597,20 +2671,6 @@ function privacy(node, value, parent) {
2597
2671
  var tags = ["STYLE" /* Constant.StyleTag */, "TITLE" /* Constant.TitleTag */, "svg:style" /* Constant.SvgStyle */];
2598
2672
  metadata.privacy = tags.includes(pTag) || override.some(function (x) { return pSelector_1.indexOf(x) >= 0; }) ? 0 /* Privacy.None */ : current;
2599
2673
  break;
2600
- case tag === "INPUT" /* Constant.InputTag */ && current === 0 /* Privacy.None */:
2601
- // If even default privacy setting is to not mask, we still scan through input fields for any sensitive information
2602
- var field_1 = "" /* Constant.Empty */;
2603
- Object.keys(attributes).forEach(function (x) { return field_1 += attributes[x].toLowerCase(); });
2604
- metadata.privacy = inspect(field_1, maskInput, metadata);
2605
- break;
2606
- case tag === "INPUT" /* Constant.InputTag */ && current === 1 /* Privacy.Sensitive */:
2607
- // Look through class names to aggressively mask content
2608
- metadata.privacy = inspect(attributes["class" /* Constant.Class */], maskText, metadata);
2609
- // If this node has an explicit type assigned to it, go through masking rules to determine right privacy setting
2610
- metadata.privacy = inspect(attributes["type" /* Constant.Type */], maskInput, metadata);
2611
- // If it's a button or an input option, make an exception to disable masking in sensitive mode
2612
- metadata.privacy = maskDisable.indexOf(attributes["type" /* Constant.Type */]) >= 0 ? 0 /* Privacy.None */ : metadata.privacy;
2613
- break;
2614
2674
  case current === 1 /* Privacy.Sensitive */:
2615
2675
  // In a mode where we mask sensitive information by default, look through class names to aggressively mask content
2616
2676
  metadata.privacy = inspect(attributes["class" /* Constant.Class */], maskText, metadata);
@@ -2948,11 +3008,12 @@ function metadata$2(node, event, text) {
2948
3008
  return output;
2949
3009
  }
2950
3010
 
2951
- function encode$3 (type) {
3011
+ function encode$3 (type, ts) {
3012
+ if (ts === void 0) { ts = null; }
2952
3013
  return __awaiter(this, void 0, void 0, function () {
2953
- var t, tokens, _i, _a, entry, pTarget, _b, _c, entry, cTarget, cHash, _d, _e, entry, target, r, u, _f, _g, entry, iTarget, s, startTarget, endTarget, _h, _j, entry, sTarget, _k, _l, entry, target, _m, _o, entry, v;
2954
- return __generator(this, function (_p) {
2955
- t = time();
3014
+ var t, tokens, _i, _a, entry, pTarget, _b, _c, entry, cTarget, cHash, _d, _e, entry, target, r, u, _f, _g, entry, iTarget, s, startTarget, endTarget, _h, _j, entry, sTarget, _k, _l, entry, target, _m, _o, entry, target, _p, _q, entry, v;
3015
+ return __generator(this, function (_r) {
3016
+ t = ts || time();
2956
3017
  tokens = [t, type];
2957
3018
  switch (type) {
2958
3019
  case 13 /* Event.MouseDown */:
@@ -2992,8 +3053,8 @@ function encode$3 (type) {
2992
3053
  tokens.push(entry.data.button);
2993
3054
  tokens.push(entry.data.reaction);
2994
3055
  tokens.push(entry.data.context);
2995
- tokens.push(scrub(entry.data.text, "click", cTarget.privacy));
2996
- tokens.push(entry.data.link);
3056
+ tokens.push(text$1(entry.data.text, "click", cTarget.privacy));
3057
+ tokens.push(url$1(entry.data.link));
2997
3058
  tokens.push(cHash);
2998
3059
  tokens.push(entry.data.trust);
2999
3060
  queue(tokens);
@@ -3034,7 +3095,7 @@ function encode$3 (type) {
3034
3095
  iTarget = metadata$2(entry.data.target, entry.event, entry.data.value);
3035
3096
  tokens = [entry.time, entry.event];
3036
3097
  tokens.push(iTarget.id);
3037
- tokens.push(scrub(entry.data.value, "input", iTarget.privacy));
3098
+ tokens.push(text$1(entry.data.value, "input", iTarget.privacy));
3038
3099
  queue(tokens);
3039
3100
  }
3040
3101
  reset$f();
@@ -3067,11 +3128,27 @@ function encode$3 (type) {
3067
3128
  }
3068
3129
  reset$c();
3069
3130
  break;
3070
- case 39 /* Event.Submit */:
3071
- for (_k = 0, _l = state$2; _k < _l.length; _k++) {
3131
+ case 42 /* Event.Change */:
3132
+ for (_k = 0, _l = state$8; _k < _l.length; _k++) {
3072
3133
  entry = _l[_k];
3073
3134
  tokens = [entry.time, entry.event];
3074
3135
  target = metadata$2(entry.data.target, entry.event);
3136
+ if (target.id > 0) {
3137
+ tokens = [entry.time, entry.event];
3138
+ tokens.push(target.id);
3139
+ tokens.push(entry.data.type);
3140
+ tokens.push(text$1(entry.data.value, "change", target.privacy));
3141
+ tokens.push(text$1(entry.data.checksum, "checksum", target.privacy));
3142
+ queue(tokens);
3143
+ }
3144
+ }
3145
+ reset$i();
3146
+ break;
3147
+ case 39 /* Event.Submit */:
3148
+ for (_m = 0, _o = state$2; _m < _o.length; _m++) {
3149
+ entry = _o[_m];
3150
+ tokens = [entry.time, entry.event];
3151
+ target = metadata$2(entry.data.target, entry.event);
3075
3152
  if (target.id > 0) {
3076
3153
  tokens.push(target.id);
3077
3154
  queue(tokens);
@@ -3080,8 +3157,8 @@ function encode$3 (type) {
3080
3157
  reset$a();
3081
3158
  break;
3082
3159
  case 22 /* Event.Timeline */:
3083
- for (_m = 0, _o = updates$1; _m < _o.length; _m++) {
3084
- entry = _o[_m];
3160
+ for (_p = 0, _q = updates$1; _p < _q.length; _p++) {
3161
+ entry = _q[_p];
3085
3162
  tokens = [entry.time, entry.event];
3086
3163
  tokens.push(entry.data.type);
3087
3164
  tokens.push(entry.data.hash);
@@ -3209,7 +3286,7 @@ function queue(tokens, transmit) {
3209
3286
  // We enrich the data going out with the existing upload. In these cases, call to upload comes with 'transmit' set to false.
3210
3287
  if (transmit && timeout === null) {
3211
3288
  if (type !== 25 /* Event.Ping */) {
3212
- reset$n();
3289
+ reset$o();
3213
3290
  }
3214
3291
  timeout = setTimeout(upload, gap);
3215
3292
  queuedTime = now;
@@ -3459,7 +3536,7 @@ function encode$2 (type) {
3459
3536
  tokens.push(data$7.line);
3460
3537
  tokens.push(data$7.column);
3461
3538
  tokens.push(data$7.stack);
3462
- tokens.push(data$7.source);
3539
+ tokens.push(url$1(data$7.source));
3463
3540
  queue(tokens);
3464
3541
  break;
3465
3542
  case 33 /* Event.Log */:
@@ -3476,7 +3553,7 @@ function encode$2 (type) {
3476
3553
  if (data$d) {
3477
3554
  tokens.push(data$d.id);
3478
3555
  tokens.push(data$d.target);
3479
- tokens.push(data$d.hash);
3556
+ tokens.push(data$d.checksum);
3480
3557
  queue(tokens, false);
3481
3558
  }
3482
3559
  break;
@@ -3655,7 +3732,7 @@ function encode$1 (event) {
3655
3732
  var tokens = [t, event];
3656
3733
  switch (event) {
3657
3734
  case 4 /* Event.Baseline */:
3658
- var b = state$9;
3735
+ var b = state$a;
3659
3736
  if (b) {
3660
3737
  tokens = [b.time, b.event];
3661
3738
  tokens.push(b.data.visible);
@@ -3670,7 +3747,7 @@ function encode$1 (event) {
3670
3747
  tokens.push(b.data.activityTime);
3671
3748
  queue(tokens, false);
3672
3749
  }
3673
- reset$p();
3750
+ reset$q();
3674
3751
  break;
3675
3752
  case 25 /* Event.Ping */:
3676
3753
  tokens.push(data$h.gap);
@@ -3703,7 +3780,7 @@ function encode$1 (event) {
3703
3780
  tokens.push(v);
3704
3781
  tokens.push(data$e[v]);
3705
3782
  }
3706
- reset$l();
3783
+ reset$m();
3707
3784
  queue(tokens, false);
3708
3785
  }
3709
3786
  break;
@@ -3718,7 +3795,7 @@ function encode$1 (event) {
3718
3795
  // However, for data over the wire, we round it off to milliseconds precision.
3719
3796
  tokens.push(Math.round(updates$3[m]));
3720
3797
  }
3721
- reset$o();
3798
+ reset$p();
3722
3799
  queue(tokens, false);
3723
3800
  }
3724
3801
  break;
@@ -3744,7 +3821,7 @@ function encode$1 (event) {
3744
3821
  tokens.push(key);
3745
3822
  tokens.push([].concat.apply([], data$g[e]));
3746
3823
  }
3747
- reset$m();
3824
+ reset$n();
3748
3825
  queue(tokens, false);
3749
3826
  }
3750
3827
  break;
@@ -3839,30 +3916,31 @@ function start$9() {
3839
3916
  // Populate ids for this page
3840
3917
  var s = session();
3841
3918
  var u = user();
3842
- data$2 = {
3843
- projectId: config$1.projectId || hash(location.host),
3844
- userId: u.id,
3845
- sessionId: s.session,
3846
- pageNum: s.count
3847
- };
3919
+ var projectId = config$1.projectId || hash(location.host);
3920
+ data$2 = { projectId: projectId, userId: u.id, sessionId: s.session, pageNum: s.count };
3848
3921
  // Override configuration based on what's in the session storage, unless it is blank (e.g. using upload callback, like in devtools)
3849
3922
  config$1.lean = config$1.track && s.upgrade !== null ? s.upgrade === 0 /* BooleanFlag.False */ : config$1.lean;
3850
3923
  config$1.upload = config$1.track && typeof config$1.upload === "string" /* Constant.String */ && s.upload && s.upload.length > "https://" /* Constant.HTTPS */.length ? s.upload : config$1.upload;
3851
- // Log dimensions
3924
+ // Log page metadata as dimensions
3852
3925
  log(0 /* Dimension.UserAgent */, ua);
3853
3926
  log(3 /* Dimension.PageTitle */, title);
3854
- log(1 /* Dimension.Url */, location.href);
3927
+ log(1 /* Dimension.Url */, url$1(location.href));
3855
3928
  log(2 /* Dimension.Referrer */, document.referrer);
3856
3929
  log(15 /* Dimension.TabId */, tab());
3857
3930
  log(16 /* Dimension.PageLanguage */, document.documentElement.lang);
3858
3931
  log(17 /* Dimension.DocumentDirection */, document.dir);
3932
+ log(26 /* Dimension.DevicePixelRatio */, "".concat(window.devicePixelRatio));
3933
+ // Capture additional metadata as metrics
3934
+ max(0 /* Metric.ClientTimestamp */, s.ts);
3935
+ max(1 /* Metric.Playback */, 0 /* BooleanFlag.False */);
3936
+ // Capture navigator specific dimensions
3859
3937
  if (navigator) {
3860
- log(9 /* Dimension.Language */, navigator.userLanguage || navigator.language);
3938
+ log(9 /* Dimension.Language */, navigator.language);
3939
+ max(33 /* Metric.HardwareConcurrency */, navigator.hardwareConcurrency);
3940
+ max(32 /* Metric.MaxTouchPoints */, navigator.maxTouchPoints);
3941
+ max(34 /* Metric.DeviceMemory */, Math.round(navigator.deviceMemory));
3861
3942
  userAgentData();
3862
3943
  }
3863
- // Metrics
3864
- max(0 /* Metric.ClientTimestamp */, s.ts);
3865
- max(1 /* Metric.Playback */, 0 /* BooleanFlag.False */);
3866
3944
  if (screen) {
3867
3945
  max(14 /* Metric.ScreenWidth */, Math.round(screen.width));
3868
3946
  max(15 /* Metric.ScreenHeight */, Math.round(screen.height));
@@ -3880,22 +3958,20 @@ function start$9() {
3880
3958
  track(u);
3881
3959
  }
3882
3960
  function userAgentData() {
3883
- if (navigator["userAgentData"] && navigator["userAgentData"].getHighEntropyValues) {
3884
- navigator["userAgentData"].getHighEntropyValues(["model",
3885
- "platform",
3886
- "platformVersion",
3887
- "uaFullVersion"])
3888
- .then(function (ua) {
3961
+ var uaData = navigator["userAgentData"];
3962
+ if (uaData && uaData.getHighEntropyValues) {
3963
+ uaData.getHighEntropyValues(["model", "platform", "platformVersion", "uaFullVersion"]).then(function (ua) {
3889
3964
  var _a;
3890
3965
  log(22 /* Dimension.Platform */, ua.platform);
3891
3966
  log(23 /* Dimension.PlatformVersion */, ua.platformVersion);
3892
- (_a = ua.brands) === null || _a === void 0 ? void 0 : _a.forEach(function (brand) {
3893
- log(24 /* Dimension.Brand */, brand.name + "~" /* Constant.Tilde */ + brand.version);
3894
- });
3967
+ (_a = ua.brands) === null || _a === void 0 ? void 0 : _a.forEach(function (brand) { log(24 /* Dimension.Brand */, brand.name + "~" /* Constant.Tilde */ + brand.version); });
3895
3968
  log(25 /* Dimension.Model */, ua.model);
3896
3969
  max(27 /* Metric.Mobile */, ua.mobile ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */);
3897
3970
  });
3898
3971
  }
3972
+ else {
3973
+ log(22 /* Dimension.Platform */, navigator.platform);
3974
+ }
3899
3975
  }
3900
3976
  function stop$8() {
3901
3977
  rootDomain = null;
@@ -4254,8 +4330,8 @@ function stop$6() {
4254
4330
  var status = false;
4255
4331
  function start$6() {
4256
4332
  status = true;
4257
- start$F();
4258
- reset$j();
4333
+ start$G();
4334
+ reset$k();
4259
4335
  reset$1();
4260
4336
  reset$2();
4261
4337
  start$7();
@@ -4264,8 +4340,8 @@ function stop$5() {
4264
4340
  stop$6();
4265
4341
  reset$2();
4266
4342
  reset$1();
4267
- reset$j();
4268
- stop$B();
4343
+ reset$k();
4344
+ stop$C();
4269
4345
  status = false;
4270
4346
  }
4271
4347
  function active() {
@@ -4319,7 +4395,7 @@ function restart() {
4319
4395
  }
4320
4396
 
4321
4397
  function start$5() {
4322
- start$x();
4398
+ start$y();
4323
4399
  start$e();
4324
4400
  start$d();
4325
4401
  }
@@ -4347,14 +4423,14 @@ function discover() {
4347
4423
  case 0:
4348
4424
  ts = time();
4349
4425
  timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
4350
- start$w(timer);
4426
+ start$x(timer);
4351
4427
  return [4 /*yield*/, traverse(document, timer, 0 /* Source.Discover */)];
4352
4428
  case 1:
4353
4429
  _a.sent();
4354
4430
  return [4 /*yield*/, encode$4(5 /* Event.Discover */, timer, ts)];
4355
4431
  case 2:
4356
4432
  _a.sent();
4357
- stop$t(timer);
4433
+ stop$u(timer);
4358
4434
  return [2 /*return*/];
4359
4435
  }
4360
4436
  });
@@ -4364,7 +4440,7 @@ function discover() {
4364
4440
  function start$3() {
4365
4441
  // The order below is important
4366
4442
  // and is determined by interdependencies of modules
4367
- start$v();
4443
+ start$w();
4368
4444
  start$h();
4369
4445
  start$i();
4370
4446
  start$j();
@@ -4446,6 +4522,10 @@ function compute(entry) {
4446
4522
  var observer;
4447
4523
  var types = ["navigation" /* Constant.Navigation */, "resource" /* Constant.Resource */, "longtask" /* Constant.LongTask */, "first-input" /* Constant.FID */, "layout-shift" /* Constant.CLS */, "largest-contentful-paint" /* Constant.LCP */];
4448
4524
  function start$2() {
4525
+ // Capture connection properties, if available
4526
+ if (navigator && "connection" in navigator) {
4527
+ log(27 /* Dimension.ConnectionType */, navigator["connection"]["effectiveType"]);
4528
+ }
4449
4529
  // Check the browser support performance observer as a pre-requisite for any performance measurement
4450
4530
  if (window["PerformanceObserver"] && PerformanceObserver.supportedEntryTypes) {
4451
4531
  // Start monitoring performance data after page has finished loading.
@@ -4569,7 +4649,7 @@ function start(config$1) {
4569
4649
  if (check()) {
4570
4650
  config(config$1);
4571
4651
  start$6();
4572
- start$y();
4652
+ start$z();
4573
4653
  modules.forEach(function (x) { return measure(x.start)(); });
4574
4654
  }
4575
4655
  }
@@ -4595,7 +4675,7 @@ function stop() {
4595
4675
  if (active()) {
4596
4676
  // Stop modules in the reverse order of their initialization
4597
4677
  modules.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
4598
- stop$u();
4678
+ stop$v();
4599
4679
  stop$5();
4600
4680
  }
4601
4681
  }