clarity-js 0.6.43 → 0.7.1

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.1";
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,166 @@ 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);
136
139
  }
137
140
 
138
- var state$9 = null;
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 "*T" /* Layout.Constant.TextTag */:
186
+ return mangle ? mangleText(value) : mask(value);
187
+ case "value":
188
+ case "input":
189
+ case "click":
190
+ case "change":
191
+ return Array(5 /* Data.Setting.WordLength */).join("\u2022" /* Data.Constant.Mask */);
192
+ case "checksum":
193
+ return "" /* Data.Constant.Empty */;
194
+ }
195
+ }
196
+ }
197
+ return value;
198
+ }
199
+ function url$1(input) {
200
+ var drop = config$1.drop;
201
+ if (drop && drop.length > 0 && input && input.indexOf("?") > 0) {
202
+ var _a = input.split("?"), path = _a[0], query = _a[1];
203
+ var swap_1 = "*na*" /* Data.Constant.Dropped */;
204
+ 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("&");
205
+ }
206
+ return input;
207
+ }
208
+ function mangleText(value) {
209
+ var trimmed = value.trim();
210
+ if (trimmed.length > 0) {
211
+ var first = trimmed[0];
212
+ var index = value.indexOf(first);
213
+ var prefix = value.substr(0, index);
214
+ var suffix = value.substr(index + trimmed.length);
215
+ return "".concat(prefix).concat(trimmed.length.toString(36)).concat(suffix);
216
+ }
217
+ return value;
218
+ }
219
+ function mask(value) {
220
+ return value.replace(catchallRegex, "\u2022" /* Data.Constant.Mask */);
221
+ }
222
+ function mangleToken(value) {
223
+ var length = ((Math.floor(value.length / 5 /* Data.Setting.WordLength */) + 1) * 5 /* Data.Setting.WordLength */);
224
+ var output = "" /* Layout.Constant.Empty */;
225
+ for (var i = 0; i < length; i++) {
226
+ output += i > 0 && i % 5 /* Data.Setting.WordLength */ === 0 ? " " /* Data.Constant.Space */ : "\u2022" /* Data.Constant.Mask */;
227
+ }
228
+ return output;
229
+ }
230
+ function redact(value) {
231
+ var spaceIndex = -1;
232
+ var gap = 0;
233
+ var hasDigit = false;
234
+ var hasEmail = false;
235
+ var hasWhitespace = false;
236
+ var array = null;
237
+ // Initialize unicode regex, if supported by the browser
238
+ // Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes
239
+ if (unicodeRegex && digitRegex === null) {
240
+ try {
241
+ digitRegex = new RegExp("\\p{N}", "gu");
242
+ letterRegex = new RegExp("\\p{L}", "gu");
243
+ currencyRegex = new RegExp("\\p{Sc}", "gu");
244
+ }
245
+ catch (_a) {
246
+ unicodeRegex = false;
247
+ }
248
+ }
249
+ for (var i = 0; i < value.length; i++) {
250
+ var c = value.charCodeAt(i);
251
+ hasDigit = hasDigit || (c >= 48 /* Data.Character.Zero */ && c <= 57 /* Data.Character.Nine */); // Check for digits in the current word
252
+ hasEmail = hasEmail || c === 64 /* Data.Character.At */; // Check for @ sign anywhere within the current word
253
+ hasWhitespace = c === 9 /* Data.Character.Tab */ || c === 10 /* Data.Character.NewLine */ || c === 13 /* Data.Character.Return */ || c === 32 /* Data.Character.Blank */;
254
+ // Process each word as an individual token to redact any sensitive information
255
+ if (i === 0 || i === value.length - 1 || hasWhitespace) {
256
+ // Performance optimization: Lazy load string -> array conversion only when required
257
+ if (hasDigit || hasEmail) {
258
+ if (array === null) {
259
+ array = value.split("" /* Data.Constant.Empty */);
260
+ }
261
+ // Work on a token at a time so we don't have to apply regex to a larger string
262
+ var token = value.substring(spaceIndex + 1, hasWhitespace ? i : i + 1);
263
+ // Check if unicode regex is supported, otherwise fallback to calling mask function on this token
264
+ if (unicodeRegex && currencyRegex !== null) {
265
+ // Do not redact information if the token contains a currency symbol
266
+ token = token.match(currencyRegex) ? token : token.replace(letterRegex, "\u25AA" /* Data.Constant.Letter */).replace(digitRegex, "\u25AB" /* Data.Constant.Digit */);
267
+ }
268
+ else {
269
+ token = mask(token);
270
+ }
271
+ // Merge token back into array at the right place
272
+ array.splice(spaceIndex + 1 - gap, token.length, token);
273
+ gap += token.length - 1;
274
+ }
275
+ // Reset digit and email flags after every word boundary, except the beginning of string
276
+ if (hasWhitespace) {
277
+ hasDigit = false;
278
+ hasEmail = false;
279
+ spaceIndex = i;
280
+ }
281
+ }
282
+ }
283
+ return array ? array.join("" /* Data.Constant.Empty */) : value;
284
+ }
285
+
286
+ var state$a = null;
139
287
  var buffer = null;
140
288
  var update$2 = false;
141
- function start$E() {
289
+ function start$F() {
142
290
  update$2 = false;
143
- reset$p();
291
+ reset$q();
144
292
  }
145
- function reset$p() {
293
+ function reset$q() {
146
294
  // Baseline state holds the previous values - if it is updated in the current payload,
147
295
  // reset the state to current value after sending the previous state
148
296
  if (update$2) {
149
- state$9 = { time: time(), event: 4 /* Event.Baseline */, data: {
297
+ state$a = { time: time(), event: 4 /* Event.Baseline */, data: {
150
298
  visible: buffer.visible,
151
299
  docWidth: buffer.docWidth,
152
300
  docHeight: buffer.docHeight,
@@ -209,20 +357,20 @@ function compute$c() {
209
357
  encode$1(4 /* Event.Baseline */);
210
358
  }
211
359
  }
212
- function stop$A() {
213
- reset$p();
360
+ function stop$B() {
361
+ reset$q();
214
362
  }
215
363
 
216
364
  var baseline = /*#__PURE__*/Object.freeze({
217
365
  __proto__: null,
218
- get state () { return state$9; },
219
- start: start$E,
220
- reset: reset$p,
366
+ get state () { return state$a; },
367
+ start: start$F,
368
+ reset: reset$q,
221
369
  track: track$7,
222
370
  activity: activity,
223
371
  visibility: visibility,
224
372
  compute: compute$c,
225
- stop: stop$A
373
+ stop: stop$B
226
374
  });
227
375
 
228
376
  var data$j = null;
@@ -241,12 +389,12 @@ function event(key, value) {
241
389
 
242
390
  var data$i = null;
243
391
  var updates$3 = null;
244
- function start$D() {
392
+ function start$E() {
245
393
  data$i = {};
246
394
  updates$3 = {};
247
395
  count$1(5 /* Metric.InvokeCount */);
248
396
  }
249
- function stop$z() {
397
+ function stop$A() {
250
398
  data$i = {};
251
399
  updates$3 = {};
252
400
  }
@@ -287,7 +435,7 @@ function max(metric, value) {
287
435
  function compute$b() {
288
436
  encode$1(0 /* Event.Metric */);
289
437
  }
290
- function reset$o() {
438
+ function reset$p() {
291
439
  updates$3 = {};
292
440
  }
293
441
 
@@ -302,11 +450,11 @@ var data$h;
302
450
  var last = 0;
303
451
  var interval = 0;
304
452
  var timeout$6 = null;
305
- function start$C() {
453
+ function start$D() {
306
454
  interval = 60000 /* Setting.PingInterval */;
307
455
  last = 0;
308
456
  }
309
- function reset$n() {
457
+ function reset$o() {
310
458
  if (timeout$6) {
311
459
  clearTimeout(timeout$6);
312
460
  }
@@ -324,7 +472,7 @@ function ping() {
324
472
  suspend();
325
473
  }
326
474
  }
327
- function stop$y() {
475
+ function stop$z() {
328
476
  clearTimeout(timeout$6);
329
477
  last = 0;
330
478
  interval = 0;
@@ -333,16 +481,16 @@ function stop$y() {
333
481
  var ping$1 = /*#__PURE__*/Object.freeze({
334
482
  __proto__: null,
335
483
  get data () { return data$h; },
336
- start: start$C,
337
- reset: reset$n,
338
- stop: stop$y
484
+ start: start$D,
485
+ reset: reset$o,
486
+ stop: stop$z
339
487
  });
340
488
 
341
489
  var data$g = null;
342
- function start$B() {
490
+ function start$C() {
343
491
  data$g = {};
344
492
  }
345
- function stop$x() {
493
+ function stop$y() {
346
494
  data$g = {};
347
495
  }
348
496
  function track$6(event, time) {
@@ -365,22 +513,22 @@ function track$6(event, time) {
365
513
  function compute$a() {
366
514
  encode$1(36 /* Event.Summary */);
367
515
  }
368
- function reset$m() {
516
+ function reset$n() {
369
517
  data$g = {};
370
518
  }
371
519
 
372
520
  var summary = /*#__PURE__*/Object.freeze({
373
521
  __proto__: null,
374
522
  get data () { return data$g; },
375
- start: start$B,
376
- stop: stop$x,
523
+ start: start$C,
524
+ stop: stop$y,
377
525
  track: track$6,
378
526
  compute: compute$a,
379
- reset: reset$m
527
+ reset: reset$n
380
528
  });
381
529
 
382
530
  var data$f = null;
383
- function start$A() {
531
+ function start$B() {
384
532
  if (!config$1.lean && config$1.upgrade) {
385
533
  config$1.upgrade("Config" /* Constant.Config */);
386
534
  }
@@ -404,21 +552,21 @@ function upgrade(key) {
404
552
  encode$1(3 /* Event.Upgrade */);
405
553
  }
406
554
  }
407
- function stop$w() {
555
+ function stop$x() {
408
556
  data$f = null;
409
557
  }
410
558
 
411
559
  var upgrade$1 = /*#__PURE__*/Object.freeze({
412
560
  __proto__: null,
413
561
  get data () { return data$f; },
414
- start: start$A,
562
+ start: start$B,
415
563
  upgrade: upgrade,
416
- stop: stop$w
564
+ stop: stop$x
417
565
  });
418
566
 
419
567
  var data$e = null;
420
- function start$z() {
421
- reset$l();
568
+ function start$A() {
569
+ reset$m();
422
570
  }
423
571
  function set(variable, value) {
424
572
  var values = typeof value === "string" /* Constant.String */ ? [value] : value;
@@ -449,22 +597,22 @@ function log$2(variable, value) {
449
597
  function compute$9() {
450
598
  encode$1(34 /* Event.Variable */);
451
599
  }
452
- function reset$l() {
600
+ function reset$m() {
453
601
  data$e = {};
454
602
  }
455
- function stop$v() {
456
- reset$l();
603
+ function stop$w() {
604
+ reset$m();
457
605
  }
458
606
 
459
607
  var variable = /*#__PURE__*/Object.freeze({
460
608
  __proto__: null,
461
609
  get data () { return data$e; },
462
- start: start$z,
610
+ start: start$A,
463
611
  set: set,
464
612
  identify: identify,
465
613
  compute: compute$9,
466
- reset: reset$l,
467
- stop: stop$v
614
+ reset: reset$m,
615
+ stop: stop$w
468
616
  });
469
617
 
470
618
  /******************************************************************************
@@ -579,18 +727,18 @@ function read(stream) {
579
727
  }
580
728
 
581
729
  var modules$1 = [baseline, dimension, variable, limit, summary, metadata$1, envelope$1, upload$1, ping$1, upgrade$1, extract];
582
- function start$y() {
730
+ function start$z() {
583
731
  // Metric needs to be initialized before we can start measuring. so metric is not wrapped in measure
584
- start$D();
732
+ start$E();
585
733
  modules$1.forEach(function (x) { return measure(x.start)(); });
586
734
  }
587
- function stop$u() {
735
+ function stop$v() {
588
736
  // Stop modules in the reverse order of their initialization
589
737
  // The ordering below should respect inter-module dependency.
590
738
  // E.g. if upgrade depends on upload, then upgrade needs to end before upload.
591
739
  // Similarly, if upload depends on metadata, upload needs to end before metadata.
592
740
  modules$1.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
593
- stop$z();
741
+ stop$A();
594
742
  }
595
743
  function compute$8() {
596
744
  compute$9();
@@ -602,130 +750,9 @@ function compute$8() {
602
750
  compute$4();
603
751
  }
604
752
 
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
753
  var history$5 = [];
727
754
  var data$d;
728
- function start$x() {
755
+ function start$y() {
729
756
  history$5 = [];
730
757
  max(26 /* Metric.Automation */, navigator.webdriver ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */);
731
758
  try {
@@ -736,12 +763,12 @@ function start$x() {
736
763
  }
737
764
  }
738
765
  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) };
766
+ // Compute hash for fraud detection, if enabled. Hash is computed only if input meets the minimum length criteria
767
+ if (config$1.fraud && id !== null && input && input.length >= 5 /* Setting.WordLength */) {
768
+ data$d = { id: id, target: target, checksum: hash(input, 24 /* Setting.ChecksumPrecision */) };
742
769
  // 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);
770
+ if (history$5.indexOf(data$d.checksum) < 0) {
771
+ history$5.push(data$d.checksum);
745
772
  encode$2(41 /* Event.Fraud */);
746
773
  }
747
774
  }
@@ -749,7 +776,7 @@ function check$4(id, target, input) {
749
776
 
750
777
  var excludeClassNames = "load,active,fixed,visible,focus,show,collaps,animat" /* Constant.ExcludeClassNames */.split("," /* Constant.Comma */);
751
778
  var selectorMap = {};
752
- function reset$k() {
779
+ function reset$l() {
753
780
  selectorMap = {};
754
781
  }
755
782
  function get$1(input, type) {
@@ -837,7 +864,7 @@ function filter(value) {
837
864
 
838
865
  var selector = /*#__PURE__*/Object.freeze({
839
866
  __proto__: null,
840
- reset: reset$k,
867
+ reset: reset$l,
841
868
  get: get$1
842
869
  });
843
870
 
@@ -864,7 +891,7 @@ function resume$1() {
864
891
  }
865
892
  }
866
893
  }
867
- function reset$j() {
894
+ function reset$k() {
868
895
  tracker = {};
869
896
  queuedTasks = [];
870
897
  activeTask = null;
@@ -925,7 +952,7 @@ function run() {
925
952
  });
926
953
  }
927
954
  }
928
- function state$8(timer) {
955
+ function state$9(timer) {
929
956
  var id = key(timer);
930
957
  if (id in tracker) {
931
958
  var elapsed = performance.now() - tracker[id].start;
@@ -934,7 +961,7 @@ function state$8(timer) {
934
961
  // If this task is no longer being tracked, send stop message to the caller
935
962
  return 2 /* Task.Stop */;
936
963
  }
937
- function start$w(timer) {
964
+ function start$x(timer) {
938
965
  tracker[key(timer)] = { start: performance.now(), calls: 0, yield: 30 /* Setting.LongTask */ };
939
966
  }
940
967
  function restart$2(timer) {
@@ -942,12 +969,12 @@ function restart$2(timer) {
942
969
  if (tracker && tracker[id]) {
943
970
  var c = tracker[id].calls;
944
971
  var y = tracker[id].yield;
945
- start$w(timer);
972
+ start$x(timer);
946
973
  tracker[id].calls = c + 1;
947
974
  tracker[id].yield = y;
948
975
  }
949
976
  }
950
- function stop$t(timer) {
977
+ function stop$u(timer) {
951
978
  var end = performance.now();
952
979
  var id = key(timer);
953
980
  var duration = end - tracker[id].start;
@@ -967,7 +994,7 @@ function suspend$1(timer) {
967
994
  case 0:
968
995
  id = key(timer);
969
996
  if (!(id in tracker)) return [3 /*break*/, 2];
970
- stop$t(timer);
997
+ stop$u(timer);
971
998
  _a = tracker[id];
972
999
  return [4 /*yield*/, wait()];
973
1000
  case 1:
@@ -1118,7 +1145,7 @@ function encode$4 (type, timer, ts) {
1118
1145
  return [3 /*break*/, 10];
1119
1146
  case 3:
1120
1147
  // Check if we are operating within the context of the current page
1121
- if (state$8(timer) === 2 /* Task.Stop */) {
1148
+ if (state$9(timer) === 2 /* Task.Stop */) {
1122
1149
  return [3 /*break*/, 10];
1123
1150
  }
1124
1151
  values = updates$2();
@@ -1128,7 +1155,7 @@ function encode$4 (type, timer, ts) {
1128
1155
  case 4:
1129
1156
  if (!(_c < values_1.length)) return [3 /*break*/, 8];
1130
1157
  value = values_1[_c];
1131
- state = state$8(timer);
1158
+ state = state$9(timer);
1132
1159
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 6];
1133
1160
  return [4 /*yield*/, suspend$1(timer)];
1134
1161
  case 5:
@@ -1172,7 +1199,7 @@ function encode$4 (type, timer, ts) {
1172
1199
  break;
1173
1200
  case "value":
1174
1201
  check$4(value.metadata.fraud, value.id, data[key]);
1175
- tokens.push(scrub(data[key], data.tag, privacy, mangle));
1202
+ tokens.push(text$1(data[key], data.tag, privacy, mangle));
1176
1203
  break;
1177
1204
  }
1178
1205
  }
@@ -1210,15 +1237,15 @@ function str$1(input) {
1210
1237
  return input.toString(36);
1211
1238
  }
1212
1239
  function attribute(key, value, privacy) {
1213
- return "".concat(key, "=").concat(scrub(value, key, privacy));
1240
+ return "".concat(key, "=").concat(text$1(value, key, privacy));
1214
1241
  }
1215
1242
 
1216
1243
  var data$c;
1217
- function reset$i() {
1244
+ function reset$j() {
1218
1245
  data$c = null;
1219
1246
  }
1220
- function start$v() {
1221
- reset$i();
1247
+ function start$w() {
1248
+ reset$j();
1222
1249
  compute$7();
1223
1250
  }
1224
1251
  function compute$7() {
@@ -1245,6 +1272,29 @@ function compute$7() {
1245
1272
  }
1246
1273
  }
1247
1274
  function end() {
1275
+ reset$j();
1276
+ }
1277
+
1278
+ var state$8 = [];
1279
+ function start$v() {
1280
+ reset$i();
1281
+ }
1282
+ function observe$c(root) {
1283
+ bind(root, "change", recompute$8, true);
1284
+ }
1285
+ function recompute$8(evt) {
1286
+ var element = target(evt);
1287
+ if (element) {
1288
+ var value = element.value;
1289
+ var checksum = value && value.length >= 5 /* Setting.WordLength */ && config$1.fraud ? hash(value, 24 /* Setting.ChecksumPrecision */) : "" /* Constant.Empty */;
1290
+ state$8.push({ time: time(evt), event: 42 /* Event.Change */, data: { target: target(evt), type: element.type, value: value, checksum: checksum } });
1291
+ schedule$1(encode$3.bind(this, 42 /* Event.Change */));
1292
+ }
1293
+ }
1294
+ function reset$i() {
1295
+ state$8 = [];
1296
+ }
1297
+ function stop$t() {
1248
1298
  reset$i();
1249
1299
  }
1250
1300
 
@@ -1301,7 +1351,7 @@ function handler$3(event, root, evt) {
1301
1351
  // Check for null values before processing this event
1302
1352
  if (x !== null && y !== null) {
1303
1353
  state$7.push({
1304
- time: time(),
1354
+ time: time(evt),
1305
1355
  event: event,
1306
1356
  data: {
1307
1357
  target: t,
@@ -1392,7 +1442,7 @@ function observe$a(root) {
1392
1442
  bind(root, "paste", recompute$7.bind(this, 2 /* Clipboard.Paste */), true);
1393
1443
  }
1394
1444
  function recompute$7(action, evt) {
1395
- state$6.push({ time: time(), event: 38 /* Event.Clipboard */, data: { target: target(evt), action: action } });
1445
+ state$6.push({ time: time(evt), event: 38 /* Event.Clipboard */, data: { target: target(evt), action: action } });
1396
1446
  schedule$1(encode$3.bind(this, 38 /* Event.Clipboard */));
1397
1447
  }
1398
1448
  function reset$g() {
@@ -1426,9 +1476,9 @@ function recompute$6(evt) {
1426
1476
  if (state$5.length > 0 && (state$5[state$5.length - 1].data.target === data.target)) {
1427
1477
  state$5.pop();
1428
1478
  }
1429
- state$5.push({ time: time(), event: 27 /* Event.Input */, data: data });
1479
+ state$5.push({ time: time(evt), event: 27 /* Event.Input */, data: data });
1430
1480
  clearTimeout(timeout$5);
1431
- timeout$5 = setTimeout(process$6, 500 /* Setting.LookAhead */, 27 /* Event.Input */);
1481
+ timeout$5 = setTimeout(process$6, 1000 /* Setting.InputLookAhead */, 27 /* Event.Input */);
1432
1482
  }
1433
1483
  }
1434
1484
  function process$6(event) {
@@ -1471,14 +1521,14 @@ function mouse(event, root, evt) {
1471
1521
  }
1472
1522
  // Check for null values before processing this event
1473
1523
  if (x !== null && y !== null) {
1474
- handler$2({ time: time(), event: event, data: { target: target(evt), x: x, y: y } });
1524
+ handler$2({ time: time(evt), event: event, data: { target: target(evt), x: x, y: y } });
1475
1525
  }
1476
1526
  }
1477
1527
  function touch(event, root, evt) {
1478
1528
  var frame = iframe(root);
1479
1529
  var d = frame ? frame.contentDocument.documentElement : document.documentElement;
1480
1530
  var touches = evt.changedTouches;
1481
- var t = time();
1531
+ var t = time(evt);
1482
1532
  if (touches) {
1483
1533
  for (var i = 0; i < touches.length; i++) {
1484
1534
  var entry = touches[i];
@@ -1584,7 +1634,7 @@ function recompute$4(event) {
1584
1634
  // And, if for some reason that is not available, fall back to looking up scrollTop on document.documentElement.
1585
1635
  var x = element === de && "pageXOffset" in w ? Math.round(w.pageXOffset) : Math.round(element.scrollLeft);
1586
1636
  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 } };
1637
+ var current = { time: time(event), event: 10 /* Event.Scroll */, data: { target: element, x: x, y: y } };
1588
1638
  // We don't send any scroll events if this is the first event and the current position is top (0,0)
1589
1639
  if ((event === null && x === 0 && y === 0) || (x === null || y === null)) {
1590
1640
  return;
@@ -1674,7 +1724,7 @@ function observe$5(root) {
1674
1724
  bind(root, "submit", recompute$2, true);
1675
1725
  }
1676
1726
  function recompute$2(evt) {
1677
- state$2.push({ time: time(), event: 39 /* Event.Submit */, data: { target: target(evt) } });
1727
+ state$2.push({ time: time(evt), event: 39 /* Event.Submit */, data: { target: target(evt) } });
1678
1728
  schedule$1(encode$3.bind(this, 39 /* Event.Submit */));
1679
1729
  }
1680
1730
  function reset$a() {
@@ -1690,7 +1740,7 @@ function start$m() {
1690
1740
  }
1691
1741
  function recompute$1(evt) {
1692
1742
  data$9 = { name: evt.type };
1693
- encode$3(26 /* Event.Unload */);
1743
+ encode$3(26 /* Event.Unload */, time(evt));
1694
1744
  stop();
1695
1745
  }
1696
1746
  function reset$9() {
@@ -1705,9 +1755,10 @@ function start$l() {
1705
1755
  bind(document, "visibilitychange", recompute);
1706
1756
  recompute();
1707
1757
  }
1708
- function recompute() {
1758
+ function recompute(evt) {
1759
+ if (evt === void 0) { evt = null; }
1709
1760
  data$8 = { visible: "visibilityState" in document ? document.visibilityState : "default" };
1710
- encode$3(28 /* Event.Visibility */);
1761
+ encode$3(28 /* Event.Visibility */, time(evt));
1711
1762
  }
1712
1763
  function reset$8() {
1713
1764
  data$8 = null;
@@ -1726,6 +1777,7 @@ function start$k() {
1726
1777
  start$l();
1727
1778
  start$p();
1728
1779
  start$o();
1780
+ start$v();
1729
1781
  start$n();
1730
1782
  start$m();
1731
1783
  }
@@ -1739,6 +1791,7 @@ function stop$i() {
1739
1791
  stop$j();
1740
1792
  stop$n();
1741
1793
  stop$m();
1794
+ stop$t();
1742
1795
  stop$l();
1743
1796
  stop$k();
1744
1797
  }
@@ -1752,6 +1805,7 @@ function observe$4(root) {
1752
1805
  observe$8(root);
1753
1806
  observe$9(root);
1754
1807
  observe$6(root);
1808
+ observe$c(root);
1755
1809
  observe$5(root);
1756
1810
  }
1757
1811
  }
@@ -1832,6 +1886,7 @@ function num$1(input, scale) {
1832
1886
  var IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last"];
1833
1887
  var newlineRegex = /[\r\n]+/g;
1834
1888
  function processNode (node, source) {
1889
+ var _a;
1835
1890
  var child = null;
1836
1891
  // Do not track this change if we are attempting to remove a node before discovering it
1837
1892
  if (source === 2 /* Source.ChildListRemove */ && has(node) === false) {
@@ -1928,7 +1983,7 @@ function processNode (node, source) {
1928
1983
  try {
1929
1984
  ld(JSON.parse(element.text.replace(newlineRegex, "" /* Constant.Empty */)));
1930
1985
  }
1931
- catch ( /* do nothing */_a) { /* do nothing */ }
1986
+ catch ( /* do nothing */_b) { /* do nothing */ }
1932
1987
  }
1933
1988
  break;
1934
1989
  case "NOSCRIPT":
@@ -1954,11 +2009,20 @@ function processNode (node, source) {
1954
2009
  break;
1955
2010
  case "HEAD":
1956
2011
  var head = { tag: tag, attributes: attributes };
1957
- if (location) {
1958
- head.attributes["*B" /* Constant.Base */] = location.protocol + "//" + location.hostname;
1959
- }
2012
+ var l = insideFrame && ((_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.location) ? node.ownerDocument.location : location;
2013
+ head.attributes["*B" /* Constant.Base */] = l.protocol + "//" + l.hostname + l.pathname;
1960
2014
  dom[call](node, parent, head, source);
1961
2015
  break;
2016
+ case "BASE":
2017
+ // Override the auto detected base path to explicit value specified in this tag
2018
+ var baseHead = get(node.parentElement);
2019
+ if (baseHead) {
2020
+ // We create "a" element so we can generate protocol and hostname for relative paths like "/path/"
2021
+ var a = document.createElement("a");
2022
+ a.href = attributes["href"];
2023
+ baseHead.data.attributes["*B" /* Constant.Base */] = a.protocol + "//" + a.hostname + a.pathname;
2024
+ }
2025
+ break;
1962
2026
  case "STYLE":
1963
2027
  var styleData = { tag: tag, attributes: attributes, value: getStyleValue(element) };
1964
2028
  dom[call](node, parent, styleData, source);
@@ -2058,7 +2122,7 @@ function traverse (root, timer, source) {
2058
2122
  queue.push(next);
2059
2123
  next = next.nextSibling;
2060
2124
  }
2061
- state = state$8(timer);
2125
+ state = state$9(timer);
2062
2126
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 3];
2063
2127
  return [4 /*yield*/, suspend$1(timer)];
2064
2128
  case 2:
@@ -2195,7 +2259,7 @@ function process$2() {
2195
2259
  switch (_b.label) {
2196
2260
  case 0:
2197
2261
  timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
2198
- start$w(timer);
2262
+ start$x(timer);
2199
2263
  _b.label = 1;
2200
2264
  case 1:
2201
2265
  if (!(mutations.length > 0)) return [3 /*break*/, 8];
@@ -2205,7 +2269,7 @@ function process$2() {
2205
2269
  case 2:
2206
2270
  if (!(_i < _a.length)) return [3 /*break*/, 6];
2207
2271
  mutation = _a[_i];
2208
- state = state$8(timer);
2272
+ state = state$9(timer);
2209
2273
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 4];
2210
2274
  return [4 /*yield*/, suspend$1(timer)];
2211
2275
  case 3:
@@ -2250,7 +2314,7 @@ function process$2() {
2250
2314
  _b.sent();
2251
2315
  return [3 /*break*/, 1];
2252
2316
  case 8:
2253
- stop$t(timer);
2317
+ stop$u(timer);
2254
2318
  return [2 /*return*/];
2255
2319
  }
2256
2320
  });
@@ -2312,7 +2376,7 @@ function processNodeList(list, source, timer) {
2312
2376
  traverse(list[i], timer, source);
2313
2377
  return [3 /*break*/, 5];
2314
2378
  case 2:
2315
- state = state$8(timer);
2379
+ state = state$9(timer);
2316
2380
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 4];
2317
2381
  return [4 /*yield*/, suspend$1(timer)];
2318
2382
  case 3:
@@ -2385,8 +2449,9 @@ var override = [];
2385
2449
  var unmask = [];
2386
2450
  var updatedFragments = {};
2387
2451
  var maskText = [];
2388
- var maskInput = [];
2452
+ var maskExclude = [];
2389
2453
  var maskDisable = [];
2454
+ var maskTags = [];
2390
2455
  // The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced
2391
2456
  var idMap = null; // Maps node => id.
2392
2457
  var iframeMap = null; // Maps iframe's contentDocument => parent iframe element
@@ -2408,13 +2473,14 @@ function reset$7() {
2408
2473
  override = [];
2409
2474
  unmask = [];
2410
2475
  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 */);
2476
+ maskExclude = "password,secret,pass,social,ssn,code,hidden" /* Mask.Exclude */.split("," /* Constant.Comma */);
2412
2477
  maskDisable = "radio,checkbox,range,button,reset,submit" /* Mask.Disable */.split("," /* Constant.Comma */);
2478
+ maskTags = "INPUT,SELECT,TEXTAREA" /* Mask.Tags */.split("," /* Constant.Comma */);
2413
2479
  idMap = new WeakMap();
2414
2480
  iframeMap = new WeakMap();
2415
2481
  privacyMap = new WeakMap();
2416
2482
  fraudMap = new WeakMap();
2417
- reset$k();
2483
+ reset$l();
2418
2484
  }
2419
2485
  // We parse new root nodes for any regions or masked nodes in the beginning (document) and
2420
2486
  // later whenever there are new additions or modifications to DOM (mutations)
@@ -2432,7 +2498,7 @@ function parse$1(root, init) {
2432
2498
  if ("querySelectorAll" in root) {
2433
2499
  config$1.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "".concat(x[0])); }); }); // Regions
2434
2500
  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
2501
+ config$1.checksum.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Checksum Check
2436
2502
  unmask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 0 /* Privacy.None */); }); }); // Unmasked Elements
2437
2503
  }
2438
2504
  }
@@ -2576,6 +2642,16 @@ function privacy(node, value, parent) {
2576
2642
  var attributes = data.attributes || {};
2577
2643
  var tag = data.tag.toUpperCase();
2578
2644
  switch (true) {
2645
+ case maskTags.indexOf(tag) >= 0:
2646
+ var type = attributes["type" /* Constant.Type */];
2647
+ var meta_1 = "" /* Constant.Empty */;
2648
+ Object.keys(attributes).forEach(function (x) { return meta_1 += attributes[x].toLowerCase(); });
2649
+ var exclude = maskExclude.some(function (x) { return meta_1.indexOf(x) >= 0; });
2650
+ // Regardless of privacy mode, always mask off user input from input boxes or drop downs with two exceptions:
2651
+ // (1) The node is detected to be one of the excluded fields, in which case we drop everything
2652
+ // (2) The node's type is one of the allowed types (like checkboxes)
2653
+ metadata.privacy = tag === "INPUT" /* Constant.InputTag */ && maskDisable.indexOf(type) >= 0 ? current : (exclude ? 4 /* Privacy.Exclude */ : 2 /* Privacy.Text */);
2654
+ break;
2579
2655
  case "data-clarity-mask" /* Constant.MaskData */ in attributes:
2580
2656
  metadata.privacy = 3 /* Privacy.TextImage */;
2581
2657
  break;
@@ -2597,20 +2673,6 @@ function privacy(node, value, parent) {
2597
2673
  var tags = ["STYLE" /* Constant.StyleTag */, "TITLE" /* Constant.TitleTag */, "svg:style" /* Constant.SvgStyle */];
2598
2674
  metadata.privacy = tags.includes(pTag) || override.some(function (x) { return pSelector_1.indexOf(x) >= 0; }) ? 0 /* Privacy.None */ : current;
2599
2675
  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
2676
  case current === 1 /* Privacy.Sensitive */:
2615
2677
  // In a mode where we mask sensitive information by default, look through class names to aggressively mask content
2616
2678
  metadata.privacy = inspect(attributes["class" /* Constant.Class */], maskText, metadata);
@@ -2948,11 +3010,12 @@ function metadata$2(node, event, text) {
2948
3010
  return output;
2949
3011
  }
2950
3012
 
2951
- function encode$3 (type) {
3013
+ function encode$3 (type, ts) {
3014
+ if (ts === void 0) { ts = null; }
2952
3015
  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();
3016
+ 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;
3017
+ return __generator(this, function (_r) {
3018
+ t = ts || time();
2956
3019
  tokens = [t, type];
2957
3020
  switch (type) {
2958
3021
  case 13 /* Event.MouseDown */:
@@ -2992,8 +3055,8 @@ function encode$3 (type) {
2992
3055
  tokens.push(entry.data.button);
2993
3056
  tokens.push(entry.data.reaction);
2994
3057
  tokens.push(entry.data.context);
2995
- tokens.push(scrub(entry.data.text, "click", cTarget.privacy));
2996
- tokens.push(entry.data.link);
3058
+ tokens.push(text$1(entry.data.text, "click", cTarget.privacy));
3059
+ tokens.push(url$1(entry.data.link));
2997
3060
  tokens.push(cHash);
2998
3061
  tokens.push(entry.data.trust);
2999
3062
  queue(tokens);
@@ -3034,7 +3097,7 @@ function encode$3 (type) {
3034
3097
  iTarget = metadata$2(entry.data.target, entry.event, entry.data.value);
3035
3098
  tokens = [entry.time, entry.event];
3036
3099
  tokens.push(iTarget.id);
3037
- tokens.push(scrub(entry.data.value, "input", iTarget.privacy));
3100
+ tokens.push(text$1(entry.data.value, "input", iTarget.privacy));
3038
3101
  queue(tokens);
3039
3102
  }
3040
3103
  reset$f();
@@ -3067,11 +3130,27 @@ function encode$3 (type) {
3067
3130
  }
3068
3131
  reset$c();
3069
3132
  break;
3070
- case 39 /* Event.Submit */:
3071
- for (_k = 0, _l = state$2; _k < _l.length; _k++) {
3133
+ case 42 /* Event.Change */:
3134
+ for (_k = 0, _l = state$8; _k < _l.length; _k++) {
3072
3135
  entry = _l[_k];
3073
3136
  tokens = [entry.time, entry.event];
3074
3137
  target = metadata$2(entry.data.target, entry.event);
3138
+ if (target.id > 0) {
3139
+ tokens = [entry.time, entry.event];
3140
+ tokens.push(target.id);
3141
+ tokens.push(entry.data.type);
3142
+ tokens.push(text$1(entry.data.value, "change", target.privacy));
3143
+ tokens.push(text$1(entry.data.checksum, "checksum", target.privacy));
3144
+ queue(tokens);
3145
+ }
3146
+ }
3147
+ reset$i();
3148
+ break;
3149
+ case 39 /* Event.Submit */:
3150
+ for (_m = 0, _o = state$2; _m < _o.length; _m++) {
3151
+ entry = _o[_m];
3152
+ tokens = [entry.time, entry.event];
3153
+ target = metadata$2(entry.data.target, entry.event);
3075
3154
  if (target.id > 0) {
3076
3155
  tokens.push(target.id);
3077
3156
  queue(tokens);
@@ -3080,8 +3159,8 @@ function encode$3 (type) {
3080
3159
  reset$a();
3081
3160
  break;
3082
3161
  case 22 /* Event.Timeline */:
3083
- for (_m = 0, _o = updates$1; _m < _o.length; _m++) {
3084
- entry = _o[_m];
3162
+ for (_p = 0, _q = updates$1; _p < _q.length; _p++) {
3163
+ entry = _q[_p];
3085
3164
  tokens = [entry.time, entry.event];
3086
3165
  tokens.push(entry.data.type);
3087
3166
  tokens.push(entry.data.hash);
@@ -3209,7 +3288,7 @@ function queue(tokens, transmit) {
3209
3288
  // We enrich the data going out with the existing upload. In these cases, call to upload comes with 'transmit' set to false.
3210
3289
  if (transmit && timeout === null) {
3211
3290
  if (type !== 25 /* Event.Ping */) {
3212
- reset$n();
3291
+ reset$o();
3213
3292
  }
3214
3293
  timeout = setTimeout(upload, gap);
3215
3294
  queuedTime = now;
@@ -3459,7 +3538,7 @@ function encode$2 (type) {
3459
3538
  tokens.push(data$7.line);
3460
3539
  tokens.push(data$7.column);
3461
3540
  tokens.push(data$7.stack);
3462
- tokens.push(data$7.source);
3541
+ tokens.push(url$1(data$7.source));
3463
3542
  queue(tokens);
3464
3543
  break;
3465
3544
  case 33 /* Event.Log */:
@@ -3476,7 +3555,7 @@ function encode$2 (type) {
3476
3555
  if (data$d) {
3477
3556
  tokens.push(data$d.id);
3478
3557
  tokens.push(data$d.target);
3479
- tokens.push(data$d.hash);
3558
+ tokens.push(data$d.checksum);
3480
3559
  queue(tokens, false);
3481
3560
  }
3482
3561
  break;
@@ -3655,7 +3734,7 @@ function encode$1 (event) {
3655
3734
  var tokens = [t, event];
3656
3735
  switch (event) {
3657
3736
  case 4 /* Event.Baseline */:
3658
- var b = state$9;
3737
+ var b = state$a;
3659
3738
  if (b) {
3660
3739
  tokens = [b.time, b.event];
3661
3740
  tokens.push(b.data.visible);
@@ -3670,7 +3749,7 @@ function encode$1 (event) {
3670
3749
  tokens.push(b.data.activityTime);
3671
3750
  queue(tokens, false);
3672
3751
  }
3673
- reset$p();
3752
+ reset$q();
3674
3753
  break;
3675
3754
  case 25 /* Event.Ping */:
3676
3755
  tokens.push(data$h.gap);
@@ -3703,7 +3782,7 @@ function encode$1 (event) {
3703
3782
  tokens.push(v);
3704
3783
  tokens.push(data$e[v]);
3705
3784
  }
3706
- reset$l();
3785
+ reset$m();
3707
3786
  queue(tokens, false);
3708
3787
  }
3709
3788
  break;
@@ -3718,7 +3797,7 @@ function encode$1 (event) {
3718
3797
  // However, for data over the wire, we round it off to milliseconds precision.
3719
3798
  tokens.push(Math.round(updates$3[m]));
3720
3799
  }
3721
- reset$o();
3800
+ reset$p();
3722
3801
  queue(tokens, false);
3723
3802
  }
3724
3803
  break;
@@ -3744,7 +3823,7 @@ function encode$1 (event) {
3744
3823
  tokens.push(key);
3745
3824
  tokens.push([].concat.apply([], data$g[e]));
3746
3825
  }
3747
- reset$m();
3826
+ reset$n();
3748
3827
  queue(tokens, false);
3749
3828
  }
3750
3829
  break;
@@ -3839,30 +3918,31 @@ function start$9() {
3839
3918
  // Populate ids for this page
3840
3919
  var s = session();
3841
3920
  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
- };
3921
+ var projectId = config$1.projectId || hash(location.host);
3922
+ data$2 = { projectId: projectId, userId: u.id, sessionId: s.session, pageNum: s.count };
3848
3923
  // Override configuration based on what's in the session storage, unless it is blank (e.g. using upload callback, like in devtools)
3849
3924
  config$1.lean = config$1.track && s.upgrade !== null ? s.upgrade === 0 /* BooleanFlag.False */ : config$1.lean;
3850
3925
  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
3926
+ // Log page metadata as dimensions
3852
3927
  log(0 /* Dimension.UserAgent */, ua);
3853
3928
  log(3 /* Dimension.PageTitle */, title);
3854
- log(1 /* Dimension.Url */, location.href);
3929
+ log(1 /* Dimension.Url */, url$1(location.href));
3855
3930
  log(2 /* Dimension.Referrer */, document.referrer);
3856
3931
  log(15 /* Dimension.TabId */, tab());
3857
3932
  log(16 /* Dimension.PageLanguage */, document.documentElement.lang);
3858
3933
  log(17 /* Dimension.DocumentDirection */, document.dir);
3934
+ log(26 /* Dimension.DevicePixelRatio */, "".concat(window.devicePixelRatio));
3935
+ // Capture additional metadata as metrics
3936
+ max(0 /* Metric.ClientTimestamp */, s.ts);
3937
+ max(1 /* Metric.Playback */, 0 /* BooleanFlag.False */);
3938
+ // Capture navigator specific dimensions
3859
3939
  if (navigator) {
3860
- log(9 /* Dimension.Language */, navigator.userLanguage || navigator.language);
3940
+ log(9 /* Dimension.Language */, navigator.language);
3941
+ max(33 /* Metric.HardwareConcurrency */, navigator.hardwareConcurrency);
3942
+ max(32 /* Metric.MaxTouchPoints */, navigator.maxTouchPoints);
3943
+ max(34 /* Metric.DeviceMemory */, Math.round(navigator.deviceMemory));
3861
3944
  userAgentData();
3862
3945
  }
3863
- // Metrics
3864
- max(0 /* Metric.ClientTimestamp */, s.ts);
3865
- max(1 /* Metric.Playback */, 0 /* BooleanFlag.False */);
3866
3946
  if (screen) {
3867
3947
  max(14 /* Metric.ScreenWidth */, Math.round(screen.width));
3868
3948
  max(15 /* Metric.ScreenHeight */, Math.round(screen.height));
@@ -3880,22 +3960,20 @@ function start$9() {
3880
3960
  track(u);
3881
3961
  }
3882
3962
  function userAgentData() {
3883
- if (navigator["userAgentData"] && navigator["userAgentData"].getHighEntropyValues) {
3884
- navigator["userAgentData"].getHighEntropyValues(["model",
3885
- "platform",
3886
- "platformVersion",
3887
- "uaFullVersion"])
3888
- .then(function (ua) {
3963
+ var uaData = navigator["userAgentData"];
3964
+ if (uaData && uaData.getHighEntropyValues) {
3965
+ uaData.getHighEntropyValues(["model", "platform", "platformVersion", "uaFullVersion"]).then(function (ua) {
3889
3966
  var _a;
3890
3967
  log(22 /* Dimension.Platform */, ua.platform);
3891
3968
  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
- });
3969
+ (_a = ua.brands) === null || _a === void 0 ? void 0 : _a.forEach(function (brand) { log(24 /* Dimension.Brand */, brand.name + "~" /* Constant.Tilde */ + brand.version); });
3895
3970
  log(25 /* Dimension.Model */, ua.model);
3896
3971
  max(27 /* Metric.Mobile */, ua.mobile ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */);
3897
3972
  });
3898
3973
  }
3974
+ else {
3975
+ log(22 /* Dimension.Platform */, navigator.platform);
3976
+ }
3899
3977
  }
3900
3978
  function stop$8() {
3901
3979
  rootDomain = null;
@@ -4254,8 +4332,8 @@ function stop$6() {
4254
4332
  var status = false;
4255
4333
  function start$6() {
4256
4334
  status = true;
4257
- start$F();
4258
- reset$j();
4335
+ start$G();
4336
+ reset$k();
4259
4337
  reset$1();
4260
4338
  reset$2();
4261
4339
  start$7();
@@ -4264,8 +4342,8 @@ function stop$5() {
4264
4342
  stop$6();
4265
4343
  reset$2();
4266
4344
  reset$1();
4267
- reset$j();
4268
- stop$B();
4345
+ reset$k();
4346
+ stop$C();
4269
4347
  status = false;
4270
4348
  }
4271
4349
  function active() {
@@ -4319,7 +4397,7 @@ function restart() {
4319
4397
  }
4320
4398
 
4321
4399
  function start$5() {
4322
- start$x();
4400
+ start$y();
4323
4401
  start$e();
4324
4402
  start$d();
4325
4403
  }
@@ -4347,14 +4425,14 @@ function discover() {
4347
4425
  case 0:
4348
4426
  ts = time();
4349
4427
  timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
4350
- start$w(timer);
4428
+ start$x(timer);
4351
4429
  return [4 /*yield*/, traverse(document, timer, 0 /* Source.Discover */)];
4352
4430
  case 1:
4353
4431
  _a.sent();
4354
4432
  return [4 /*yield*/, encode$4(5 /* Event.Discover */, timer, ts)];
4355
4433
  case 2:
4356
4434
  _a.sent();
4357
- stop$t(timer);
4435
+ stop$u(timer);
4358
4436
  return [2 /*return*/];
4359
4437
  }
4360
4438
  });
@@ -4364,7 +4442,7 @@ function discover() {
4364
4442
  function start$3() {
4365
4443
  // The order below is important
4366
4444
  // and is determined by interdependencies of modules
4367
- start$v();
4445
+ start$w();
4368
4446
  start$h();
4369
4447
  start$i();
4370
4448
  start$j();
@@ -4446,6 +4524,10 @@ function compute(entry) {
4446
4524
  var observer;
4447
4525
  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
4526
  function start$2() {
4527
+ // Capture connection properties, if available
4528
+ if (navigator && "connection" in navigator) {
4529
+ log(27 /* Dimension.ConnectionType */, navigator["connection"]["effectiveType"]);
4530
+ }
4449
4531
  // Check the browser support performance observer as a pre-requisite for any performance measurement
4450
4532
  if (window["PerformanceObserver"] && PerformanceObserver.supportedEntryTypes) {
4451
4533
  // Start monitoring performance data after page has finished loading.
@@ -4569,7 +4651,7 @@ function start(config$1) {
4569
4651
  if (check()) {
4570
4652
  config(config$1);
4571
4653
  start$6();
4572
- start$y();
4654
+ start$z();
4573
4655
  modules.forEach(function (x) { return measure(x.start)(); });
4574
4656
  }
4575
4657
  }
@@ -4595,7 +4677,7 @@ function stop() {
4595
4677
  if (active()) {
4596
4678
  // Stop modules in the reverse order of their initialization
4597
4679
  modules.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
4598
- stop$u();
4680
+ stop$v();
4599
4681
  stop$5();
4600
4682
  }
4601
4683
  }