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.
package/build/clarity.js CHANGED
@@ -84,12 +84,14 @@ var config$1 = {
84
84
  lean: false,
85
85
  track: true,
86
86
  content: true,
87
+ drop: [],
87
88
  mask: [],
88
89
  unmask: [],
89
90
  regions: [],
90
91
  extract: [],
91
92
  cookies: [],
92
- fraud: [],
93
+ fraud: true,
94
+ checksum: [],
93
95
  report: null,
94
96
  upload: null,
95
97
  fallback: null,
@@ -105,22 +107,23 @@ function api(method) {
105
107
  }
106
108
 
107
109
  var startTime = 0;
108
- function start$F() {
110
+ function start$G() {
109
111
  startTime = performance.now();
110
112
  }
111
- function time(ts) {
112
- if (ts === void 0) { ts = null; }
113
- ts = ts ? ts : performance.now();
113
+ function time(event) {
114
+ if (event === void 0) { event = null; }
115
+ var ts = event && event.timeStamp > 0 ? event.timeStamp : performance.now();
114
116
  return Math.max(Math.round(ts - startTime), 0);
115
117
  }
116
- function stop$B() {
118
+ function stop$C() {
117
119
  startTime = 0;
118
120
  }
119
121
 
120
- var version$1 = "0.6.43";
122
+ var version$1 = "0.7.1";
121
123
 
122
124
  // tslint:disable: no-bitwise
123
- function hash (input) {
125
+ function hash (input, precision) {
126
+ if (precision === void 0) { precision = null; }
124
127
  // Code inspired from C# GetHashCode: https://github.com/Microsoft/referencesource/blob/master/mscorlib/system/string.cs
125
128
  var hash = 0;
126
129
  var hashOne = 5381;
@@ -136,21 +139,166 @@ function hash (input) {
136
139
  // Replace the magic number from C# implementation (1566083941) with a smaller prime number (11579)
137
140
  // This ensures we don't hit integer overflow and prevent collisions
138
141
  hash = Math.abs(hashOne + (hashTwo * 11579));
139
- return hash.toString(36);
142
+ return (precision ? hash % Math.pow(2, precision) : hash).toString(36);
140
143
  }
141
144
 
142
- var state$9 = null;
145
+ var catchallRegex = /\S/gi;
146
+ var unicodeRegex = true;
147
+ var digitRegex = null;
148
+ var letterRegex = null;
149
+ var currencyRegex = null;
150
+ function text$1(value, hint, privacy, mangle) {
151
+ if (mangle === void 0) { mangle = false; }
152
+ if (value) {
153
+ switch (privacy) {
154
+ case 0 /* Privacy.None */:
155
+ return value;
156
+ case 1 /* Privacy.Sensitive */:
157
+ switch (hint) {
158
+ case "*T" /* Layout.Constant.TextTag */:
159
+ case "value":
160
+ case "placeholder":
161
+ case "click":
162
+ return redact(value);
163
+ case "input":
164
+ case "change":
165
+ return mangleToken(value);
166
+ }
167
+ return value;
168
+ case 2 /* Privacy.Text */:
169
+ case 3 /* Privacy.TextImage */:
170
+ switch (hint) {
171
+ case "*T" /* Layout.Constant.TextTag */:
172
+ return mangle ? mangleText(value) : mask(value);
173
+ case "src":
174
+ case "srcset":
175
+ case "title":
176
+ case "alt":
177
+ return privacy === 3 /* Privacy.TextImage */ ? "" /* Data.Constant.Empty */ : value;
178
+ case "value":
179
+ case "click":
180
+ case "input":
181
+ case "change":
182
+ return mangleToken(value);
183
+ case "placeholder":
184
+ return mask(value);
185
+ }
186
+ break;
187
+ case 4 /* Privacy.Exclude */:
188
+ switch (hint) {
189
+ case "*T" /* Layout.Constant.TextTag */:
190
+ return mangle ? mangleText(value) : mask(value);
191
+ case "value":
192
+ case "input":
193
+ case "click":
194
+ case "change":
195
+ return Array(5 /* Data.Setting.WordLength */).join("\u2022" /* Data.Constant.Mask */);
196
+ case "checksum":
197
+ return "" /* Data.Constant.Empty */;
198
+ }
199
+ }
200
+ }
201
+ return value;
202
+ }
203
+ function url$1(input) {
204
+ var drop = config$1.drop;
205
+ if (drop && drop.length > 0 && input && input.indexOf("?") > 0) {
206
+ var _a = input.split("?"), path = _a[0], query = _a[1];
207
+ var swap_1 = "*na*" /* Data.Constant.Dropped */;
208
+ 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("&");
209
+ }
210
+ return input;
211
+ }
212
+ function mangleText(value) {
213
+ var trimmed = value.trim();
214
+ if (trimmed.length > 0) {
215
+ var first = trimmed[0];
216
+ var index = value.indexOf(first);
217
+ var prefix = value.substr(0, index);
218
+ var suffix = value.substr(index + trimmed.length);
219
+ return "".concat(prefix).concat(trimmed.length.toString(36)).concat(suffix);
220
+ }
221
+ return value;
222
+ }
223
+ function mask(value) {
224
+ return value.replace(catchallRegex, "\u2022" /* Data.Constant.Mask */);
225
+ }
226
+ function mangleToken(value) {
227
+ var length = ((Math.floor(value.length / 5 /* Data.Setting.WordLength */) + 1) * 5 /* Data.Setting.WordLength */);
228
+ var output = "" /* Layout.Constant.Empty */;
229
+ for (var i = 0; i < length; i++) {
230
+ output += i > 0 && i % 5 /* Data.Setting.WordLength */ === 0 ? " " /* Data.Constant.Space */ : "\u2022" /* Data.Constant.Mask */;
231
+ }
232
+ return output;
233
+ }
234
+ function redact(value) {
235
+ var spaceIndex = -1;
236
+ var gap = 0;
237
+ var hasDigit = false;
238
+ var hasEmail = false;
239
+ var hasWhitespace = false;
240
+ var array = null;
241
+ // Initialize unicode regex, if supported by the browser
242
+ // Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes
243
+ if (unicodeRegex && digitRegex === null) {
244
+ try {
245
+ digitRegex = new RegExp("\\p{N}", "gu");
246
+ letterRegex = new RegExp("\\p{L}", "gu");
247
+ currencyRegex = new RegExp("\\p{Sc}", "gu");
248
+ }
249
+ catch (_a) {
250
+ unicodeRegex = false;
251
+ }
252
+ }
253
+ for (var i = 0; i < value.length; i++) {
254
+ var c = value.charCodeAt(i);
255
+ hasDigit = hasDigit || (c >= 48 /* Data.Character.Zero */ && c <= 57 /* Data.Character.Nine */); // Check for digits in the current word
256
+ hasEmail = hasEmail || c === 64 /* Data.Character.At */; // Check for @ sign anywhere within the current word
257
+ hasWhitespace = c === 9 /* Data.Character.Tab */ || c === 10 /* Data.Character.NewLine */ || c === 13 /* Data.Character.Return */ || c === 32 /* Data.Character.Blank */;
258
+ // Process each word as an individual token to redact any sensitive information
259
+ if (i === 0 || i === value.length - 1 || hasWhitespace) {
260
+ // Performance optimization: Lazy load string -> array conversion only when required
261
+ if (hasDigit || hasEmail) {
262
+ if (array === null) {
263
+ array = value.split("" /* Data.Constant.Empty */);
264
+ }
265
+ // Work on a token at a time so we don't have to apply regex to a larger string
266
+ var token = value.substring(spaceIndex + 1, hasWhitespace ? i : i + 1);
267
+ // Check if unicode regex is supported, otherwise fallback to calling mask function on this token
268
+ if (unicodeRegex && currencyRegex !== null) {
269
+ // Do not redact information if the token contains a currency symbol
270
+ token = token.match(currencyRegex) ? token : token.replace(letterRegex, "\u25AA" /* Data.Constant.Letter */).replace(digitRegex, "\u25AB" /* Data.Constant.Digit */);
271
+ }
272
+ else {
273
+ token = mask(token);
274
+ }
275
+ // Merge token back into array at the right place
276
+ array.splice(spaceIndex + 1 - gap, token.length, token);
277
+ gap += token.length - 1;
278
+ }
279
+ // Reset digit and email flags after every word boundary, except the beginning of string
280
+ if (hasWhitespace) {
281
+ hasDigit = false;
282
+ hasEmail = false;
283
+ spaceIndex = i;
284
+ }
285
+ }
286
+ }
287
+ return array ? array.join("" /* Data.Constant.Empty */) : value;
288
+ }
289
+
290
+ var state$a = null;
143
291
  var buffer = null;
144
292
  var update$2 = false;
145
- function start$E() {
293
+ function start$F() {
146
294
  update$2 = false;
147
- reset$p();
295
+ reset$q();
148
296
  }
149
- function reset$p() {
297
+ function reset$q() {
150
298
  // Baseline state holds the previous values - if it is updated in the current payload,
151
299
  // reset the state to current value after sending the previous state
152
300
  if (update$2) {
153
- state$9 = { time: time(), event: 4 /* Event.Baseline */, data: {
301
+ state$a = { time: time(), event: 4 /* Event.Baseline */, data: {
154
302
  visible: buffer.visible,
155
303
  docWidth: buffer.docWidth,
156
304
  docHeight: buffer.docHeight,
@@ -213,20 +361,20 @@ function compute$c() {
213
361
  encode$1(4 /* Event.Baseline */);
214
362
  }
215
363
  }
216
- function stop$A() {
217
- reset$p();
364
+ function stop$B() {
365
+ reset$q();
218
366
  }
219
367
 
220
368
  var baseline = /*#__PURE__*/Object.freeze({
221
369
  __proto__: null,
222
- get state () { return state$9; },
223
- start: start$E,
224
- reset: reset$p,
370
+ get state () { return state$a; },
371
+ start: start$F,
372
+ reset: reset$q,
225
373
  track: track$7,
226
374
  activity: activity,
227
375
  visibility: visibility,
228
376
  compute: compute$c,
229
- stop: stop$A
377
+ stop: stop$B
230
378
  });
231
379
 
232
380
  var data$j = null;
@@ -245,12 +393,12 @@ function event(key, value) {
245
393
 
246
394
  var data$i = null;
247
395
  var updates$3 = null;
248
- function start$D() {
396
+ function start$E() {
249
397
  data$i = {};
250
398
  updates$3 = {};
251
399
  count$1(5 /* Metric.InvokeCount */);
252
400
  }
253
- function stop$z() {
401
+ function stop$A() {
254
402
  data$i = {};
255
403
  updates$3 = {};
256
404
  }
@@ -291,7 +439,7 @@ function max(metric, value) {
291
439
  function compute$b() {
292
440
  encode$1(0 /* Event.Metric */);
293
441
  }
294
- function reset$o() {
442
+ function reset$p() {
295
443
  updates$3 = {};
296
444
  }
297
445
 
@@ -306,11 +454,11 @@ var data$h;
306
454
  var last = 0;
307
455
  var interval = 0;
308
456
  var timeout$6 = null;
309
- function start$C() {
457
+ function start$D() {
310
458
  interval = 60000 /* Setting.PingInterval */;
311
459
  last = 0;
312
460
  }
313
- function reset$n() {
461
+ function reset$o() {
314
462
  if (timeout$6) {
315
463
  clearTimeout(timeout$6);
316
464
  }
@@ -328,7 +476,7 @@ function ping() {
328
476
  suspend();
329
477
  }
330
478
  }
331
- function stop$y() {
479
+ function stop$z() {
332
480
  clearTimeout(timeout$6);
333
481
  last = 0;
334
482
  interval = 0;
@@ -337,16 +485,16 @@ function stop$y() {
337
485
  var ping$1 = /*#__PURE__*/Object.freeze({
338
486
  __proto__: null,
339
487
  get data () { return data$h; },
340
- start: start$C,
341
- reset: reset$n,
342
- stop: stop$y
488
+ start: start$D,
489
+ reset: reset$o,
490
+ stop: stop$z
343
491
  });
344
492
 
345
493
  var data$g = null;
346
- function start$B() {
494
+ function start$C() {
347
495
  data$g = {};
348
496
  }
349
- function stop$x() {
497
+ function stop$y() {
350
498
  data$g = {};
351
499
  }
352
500
  function track$6(event, time) {
@@ -369,22 +517,22 @@ function track$6(event, time) {
369
517
  function compute$a() {
370
518
  encode$1(36 /* Event.Summary */);
371
519
  }
372
- function reset$m() {
520
+ function reset$n() {
373
521
  data$g = {};
374
522
  }
375
523
 
376
524
  var summary = /*#__PURE__*/Object.freeze({
377
525
  __proto__: null,
378
526
  get data () { return data$g; },
379
- start: start$B,
380
- stop: stop$x,
527
+ start: start$C,
528
+ stop: stop$y,
381
529
  track: track$6,
382
530
  compute: compute$a,
383
- reset: reset$m
531
+ reset: reset$n
384
532
  });
385
533
 
386
534
  var data$f = null;
387
- function start$A() {
535
+ function start$B() {
388
536
  if (!config$1.lean && config$1.upgrade) {
389
537
  config$1.upgrade("Config" /* Constant.Config */);
390
538
  }
@@ -408,21 +556,21 @@ function upgrade(key) {
408
556
  encode$1(3 /* Event.Upgrade */);
409
557
  }
410
558
  }
411
- function stop$w() {
559
+ function stop$x() {
412
560
  data$f = null;
413
561
  }
414
562
 
415
563
  var upgrade$1 = /*#__PURE__*/Object.freeze({
416
564
  __proto__: null,
417
565
  get data () { return data$f; },
418
- start: start$A,
566
+ start: start$B,
419
567
  upgrade: upgrade,
420
- stop: stop$w
568
+ stop: stop$x
421
569
  });
422
570
 
423
571
  var data$e = null;
424
- function start$z() {
425
- reset$l();
572
+ function start$A() {
573
+ reset$m();
426
574
  }
427
575
  function set(variable, value) {
428
576
  var values = typeof value === "string" /* Constant.String */ ? [value] : value;
@@ -453,22 +601,22 @@ function log$2(variable, value) {
453
601
  function compute$9() {
454
602
  encode$1(34 /* Event.Variable */);
455
603
  }
456
- function reset$l() {
604
+ function reset$m() {
457
605
  data$e = {};
458
606
  }
459
- function stop$v() {
460
- reset$l();
607
+ function stop$w() {
608
+ reset$m();
461
609
  }
462
610
 
463
611
  var variable = /*#__PURE__*/Object.freeze({
464
612
  __proto__: null,
465
613
  get data () { return data$e; },
466
- start: start$z,
614
+ start: start$A,
467
615
  set: set,
468
616
  identify: identify,
469
617
  compute: compute$9,
470
- reset: reset$l,
471
- stop: stop$v
618
+ reset: reset$m,
619
+ stop: stop$w
472
620
  });
473
621
 
474
622
  /******************************************************************************
@@ -583,18 +731,18 @@ function read(stream) {
583
731
  }
584
732
 
585
733
  var modules$1 = [baseline, dimension, variable, limit, summary, metadata$1, envelope$1, upload$1, ping$1, upgrade$1, extract];
586
- function start$y() {
734
+ function start$z() {
587
735
  // Metric needs to be initialized before we can start measuring. so metric is not wrapped in measure
588
- start$D();
736
+ start$E();
589
737
  modules$1.forEach(function (x) { return measure(x.start)(); });
590
738
  }
591
- function stop$u() {
739
+ function stop$v() {
592
740
  // Stop modules in the reverse order of their initialization
593
741
  // The ordering below should respect inter-module dependency.
594
742
  // E.g. if upgrade depends on upload, then upgrade needs to end before upload.
595
743
  // Similarly, if upload depends on metadata, upload needs to end before metadata.
596
744
  modules$1.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
597
- stop$z();
745
+ stop$A();
598
746
  }
599
747
  function compute$8() {
600
748
  compute$9();
@@ -606,130 +754,9 @@ function compute$8() {
606
754
  compute$4();
607
755
  }
608
756
 
609
- var catchallRegex = /\S/gi;
610
- var unicodeRegex = true;
611
- var digitRegex = null;
612
- var letterRegex = null;
613
- var currencyRegex = null;
614
- function scrub (value, hint, privacy, mangle) {
615
- if (mangle === void 0) { mangle = false; }
616
- if (value) {
617
- switch (privacy) {
618
- case 0 /* Privacy.None */:
619
- return value;
620
- case 1 /* Privacy.Sensitive */:
621
- switch (hint) {
622
- case "*T" /* Layout.Constant.TextTag */:
623
- case "value":
624
- case "placeholder":
625
- case "click":
626
- case "input":
627
- return redact(value);
628
- }
629
- return value;
630
- case 2 /* Privacy.Text */:
631
- case 3 /* Privacy.TextImage */:
632
- switch (hint) {
633
- case "*T" /* Layout.Constant.TextTag */:
634
- return mangle ? mangleText(value) : mask(value);
635
- case "src":
636
- case "srcset":
637
- case "title":
638
- case "alt":
639
- return privacy === 3 /* Privacy.TextImage */ ? "" /* Data.Constant.Empty */ : value;
640
- case "value":
641
- case "click":
642
- case "input":
643
- return mangleToken(value);
644
- case "placeholder":
645
- return mask(value);
646
- }
647
- break;
648
- }
649
- }
650
- return value;
651
- }
652
- function mangleText(value) {
653
- var trimmed = value.trim();
654
- if (trimmed.length > 0) {
655
- var first = trimmed[0];
656
- var index = value.indexOf(first);
657
- var prefix = value.substr(0, index);
658
- var suffix = value.substr(index + trimmed.length);
659
- return "".concat(prefix).concat(trimmed.length.toString(36)).concat(suffix);
660
- }
661
- return value;
662
- }
663
- function mask(value) {
664
- return value.replace(catchallRegex, "\u2022" /* Data.Constant.Mask */);
665
- }
666
- function mangleToken(value) {
667
- var length = ((Math.floor(value.length / 5 /* Data.Setting.WordLength */) + 1) * 5 /* Data.Setting.WordLength */);
668
- var output = "" /* Layout.Constant.Empty */;
669
- for (var i = 0; i < length; i++) {
670
- output += i > 0 && i % 5 /* Data.Setting.WordLength */ === 0 ? " " /* Data.Constant.Space */ : "\u2022" /* Data.Constant.Mask */;
671
- }
672
- return output;
673
- }
674
- function redact(value) {
675
- var spaceIndex = -1;
676
- var gap = 0;
677
- var hasDigit = false;
678
- var hasEmail = false;
679
- var hasWhitespace = false;
680
- var array = null;
681
- // Initialize unicode regex, if supported by the browser
682
- // Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes
683
- if (unicodeRegex && digitRegex === null) {
684
- try {
685
- digitRegex = new RegExp("\\p{N}", "gu");
686
- letterRegex = new RegExp("\\p{L}", "gu");
687
- currencyRegex = new RegExp("\\p{Sc}", "gu");
688
- }
689
- catch (_a) {
690
- unicodeRegex = false;
691
- }
692
- }
693
- for (var i = 0; i < value.length; i++) {
694
- var c = value.charCodeAt(i);
695
- hasDigit = hasDigit || (c >= 48 /* Data.Character.Zero */ && c <= 57 /* Data.Character.Nine */); // Check for digits in the current word
696
- hasEmail = hasEmail || c === 64 /* Data.Character.At */; // Check for @ sign anywhere within the current word
697
- hasWhitespace = c === 9 /* Data.Character.Tab */ || c === 10 /* Data.Character.NewLine */ || c === 13 /* Data.Character.Return */ || c === 32 /* Data.Character.Blank */;
698
- // Process each word as an individual token to redact any sensitive information
699
- if (i === 0 || i === value.length - 1 || hasWhitespace) {
700
- // Performance optimization: Lazy load string -> array conversion only when required
701
- if (hasDigit || hasEmail) {
702
- if (array === null) {
703
- array = value.split("" /* Data.Constant.Empty */);
704
- }
705
- // Work on a token at a time so we don't have to apply regex to a larger string
706
- var token = value.substring(spaceIndex + 1, hasWhitespace ? i : i + 1);
707
- // Check if unicode regex is supported, otherwise fallback to calling mask function on this token
708
- if (unicodeRegex && currencyRegex !== null) {
709
- // Do not redact information if the token contains a currency symbol
710
- token = token.match(currencyRegex) ? token : token.replace(letterRegex, "\u25AA" /* Data.Constant.Letter */).replace(digitRegex, "\u25AB" /* Data.Constant.Digit */);
711
- }
712
- else {
713
- token = mask(token);
714
- }
715
- // Merge token back into array at the right place
716
- array.splice(spaceIndex + 1 - gap, token.length, token);
717
- gap += token.length - 1;
718
- }
719
- // Reset digit and email flags after every word boundary, except the beginning of string
720
- if (hasWhitespace) {
721
- hasDigit = false;
722
- hasEmail = false;
723
- spaceIndex = i;
724
- }
725
- }
726
- }
727
- return array ? array.join("" /* Data.Constant.Empty */) : value;
728
- }
729
-
730
757
  var history$5 = [];
731
758
  var data$d;
732
- function start$x() {
759
+ function start$y() {
733
760
  history$5 = [];
734
761
  max(26 /* Metric.Automation */, navigator.webdriver ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */);
735
762
  try {
@@ -740,12 +767,12 @@ function start$x() {
740
767
  }
741
768
  }
742
769
  function check$4(id, target, input) {
743
- // Compute hash for fraud detection. Hash is computed only if input meets the minimum length criteria
744
- if (id !== null && input && input.length >= 5 /* Setting.WordLength */) {
745
- data$d = { id: id, target: target, hash: hash(input) };
770
+ // Compute hash for fraud detection, if enabled. Hash is computed only if input meets the minimum length criteria
771
+ if (config$1.fraud && id !== null && input && input.length >= 5 /* Setting.WordLength */) {
772
+ data$d = { id: id, target: target, checksum: hash(input, 24 /* Setting.ChecksumPrecision */) };
746
773
  // Only encode this event if we haven't already reported this hash
747
- if (history$5.indexOf(data$d.hash) < 0) {
748
- history$5.push(data$d.hash);
774
+ if (history$5.indexOf(data$d.checksum) < 0) {
775
+ history$5.push(data$d.checksum);
749
776
  encode$2(41 /* Event.Fraud */);
750
777
  }
751
778
  }
@@ -753,7 +780,7 @@ function check$4(id, target, input) {
753
780
 
754
781
  var excludeClassNames = "load,active,fixed,visible,focus,show,collaps,animat" /* Constant.ExcludeClassNames */.split("," /* Constant.Comma */);
755
782
  var selectorMap = {};
756
- function reset$k() {
783
+ function reset$l() {
757
784
  selectorMap = {};
758
785
  }
759
786
  function get$1(input, type) {
@@ -841,7 +868,7 @@ function filter(value) {
841
868
 
842
869
  var selector = /*#__PURE__*/Object.freeze({
843
870
  __proto__: null,
844
- reset: reset$k,
871
+ reset: reset$l,
845
872
  get: get$1
846
873
  });
847
874
 
@@ -868,7 +895,7 @@ function resume$1() {
868
895
  }
869
896
  }
870
897
  }
871
- function reset$j() {
898
+ function reset$k() {
872
899
  tracker = {};
873
900
  queuedTasks = [];
874
901
  activeTask = null;
@@ -929,7 +956,7 @@ function run() {
929
956
  });
930
957
  }
931
958
  }
932
- function state$8(timer) {
959
+ function state$9(timer) {
933
960
  var id = key(timer);
934
961
  if (id in tracker) {
935
962
  var elapsed = performance.now() - tracker[id].start;
@@ -938,7 +965,7 @@ function state$8(timer) {
938
965
  // If this task is no longer being tracked, send stop message to the caller
939
966
  return 2 /* Task.Stop */;
940
967
  }
941
- function start$w(timer) {
968
+ function start$x(timer) {
942
969
  tracker[key(timer)] = { start: performance.now(), calls: 0, yield: 30 /* Setting.LongTask */ };
943
970
  }
944
971
  function restart$2(timer) {
@@ -946,12 +973,12 @@ function restart$2(timer) {
946
973
  if (tracker && tracker[id]) {
947
974
  var c = tracker[id].calls;
948
975
  var y = tracker[id].yield;
949
- start$w(timer);
976
+ start$x(timer);
950
977
  tracker[id].calls = c + 1;
951
978
  tracker[id].yield = y;
952
979
  }
953
980
  }
954
- function stop$t(timer) {
981
+ function stop$u(timer) {
955
982
  var end = performance.now();
956
983
  var id = key(timer);
957
984
  var duration = end - tracker[id].start;
@@ -971,7 +998,7 @@ function suspend$1(timer) {
971
998
  case 0:
972
999
  id = key(timer);
973
1000
  if (!(id in tracker)) return [3 /*break*/, 2];
974
- stop$t(timer);
1001
+ stop$u(timer);
975
1002
  _a = tracker[id];
976
1003
  return [4 /*yield*/, wait()];
977
1004
  case 1:
@@ -1122,7 +1149,7 @@ function encode$4 (type, timer, ts) {
1122
1149
  return [3 /*break*/, 10];
1123
1150
  case 3:
1124
1151
  // Check if we are operating within the context of the current page
1125
- if (state$8(timer) === 2 /* Task.Stop */) {
1152
+ if (state$9(timer) === 2 /* Task.Stop */) {
1126
1153
  return [3 /*break*/, 10];
1127
1154
  }
1128
1155
  values = updates$2();
@@ -1132,7 +1159,7 @@ function encode$4 (type, timer, ts) {
1132
1159
  case 4:
1133
1160
  if (!(_c < values_1.length)) return [3 /*break*/, 8];
1134
1161
  value = values_1[_c];
1135
- state = state$8(timer);
1162
+ state = state$9(timer);
1136
1163
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 6];
1137
1164
  return [4 /*yield*/, suspend$1(timer)];
1138
1165
  case 5:
@@ -1176,7 +1203,7 @@ function encode$4 (type, timer, ts) {
1176
1203
  break;
1177
1204
  case "value":
1178
1205
  check$4(value.metadata.fraud, value.id, data[key]);
1179
- tokens.push(scrub(data[key], data.tag, privacy, mangle));
1206
+ tokens.push(text$1(data[key], data.tag, privacy, mangle));
1180
1207
  break;
1181
1208
  }
1182
1209
  }
@@ -1214,15 +1241,15 @@ function str$1(input) {
1214
1241
  return input.toString(36);
1215
1242
  }
1216
1243
  function attribute(key, value, privacy) {
1217
- return "".concat(key, "=").concat(scrub(value, key, privacy));
1244
+ return "".concat(key, "=").concat(text$1(value, key, privacy));
1218
1245
  }
1219
1246
 
1220
1247
  var data$c;
1221
- function reset$i() {
1248
+ function reset$j() {
1222
1249
  data$c = null;
1223
1250
  }
1224
- function start$v() {
1225
- reset$i();
1251
+ function start$w() {
1252
+ reset$j();
1226
1253
  compute$7();
1227
1254
  }
1228
1255
  function compute$7() {
@@ -1249,6 +1276,29 @@ function compute$7() {
1249
1276
  }
1250
1277
  }
1251
1278
  function end() {
1279
+ reset$j();
1280
+ }
1281
+
1282
+ var state$8 = [];
1283
+ function start$v() {
1284
+ reset$i();
1285
+ }
1286
+ function observe$c(root) {
1287
+ bind(root, "change", recompute$8, true);
1288
+ }
1289
+ function recompute$8(evt) {
1290
+ var element = target(evt);
1291
+ if (element) {
1292
+ var value = element.value;
1293
+ var checksum = value && value.length >= 5 /* Setting.WordLength */ && config$1.fraud ? hash(value, 24 /* Setting.ChecksumPrecision */) : "" /* Constant.Empty */;
1294
+ state$8.push({ time: time(evt), event: 42 /* Event.Change */, data: { target: target(evt), type: element.type, value: value, checksum: checksum } });
1295
+ schedule$1(encode$3.bind(this, 42 /* Event.Change */));
1296
+ }
1297
+ }
1298
+ function reset$i() {
1299
+ state$8 = [];
1300
+ }
1301
+ function stop$t() {
1252
1302
  reset$i();
1253
1303
  }
1254
1304
 
@@ -1305,7 +1355,7 @@ function handler$3(event, root, evt) {
1305
1355
  // Check for null values before processing this event
1306
1356
  if (x !== null && y !== null) {
1307
1357
  state$7.push({
1308
- time: time(),
1358
+ time: time(evt),
1309
1359
  event: event,
1310
1360
  data: {
1311
1361
  target: t,
@@ -1396,7 +1446,7 @@ function observe$a(root) {
1396
1446
  bind(root, "paste", recompute$7.bind(this, 2 /* Clipboard.Paste */), true);
1397
1447
  }
1398
1448
  function recompute$7(action, evt) {
1399
- state$6.push({ time: time(), event: 38 /* Event.Clipboard */, data: { target: target(evt), action: action } });
1449
+ state$6.push({ time: time(evt), event: 38 /* Event.Clipboard */, data: { target: target(evt), action: action } });
1400
1450
  schedule$1(encode$3.bind(this, 38 /* Event.Clipboard */));
1401
1451
  }
1402
1452
  function reset$g() {
@@ -1430,9 +1480,9 @@ function recompute$6(evt) {
1430
1480
  if (state$5.length > 0 && (state$5[state$5.length - 1].data.target === data.target)) {
1431
1481
  state$5.pop();
1432
1482
  }
1433
- state$5.push({ time: time(), event: 27 /* Event.Input */, data: data });
1483
+ state$5.push({ time: time(evt), event: 27 /* Event.Input */, data: data });
1434
1484
  clearTimeout(timeout$5);
1435
- timeout$5 = setTimeout(process$6, 500 /* Setting.LookAhead */, 27 /* Event.Input */);
1485
+ timeout$5 = setTimeout(process$6, 1000 /* Setting.InputLookAhead */, 27 /* Event.Input */);
1436
1486
  }
1437
1487
  }
1438
1488
  function process$6(event) {
@@ -1475,14 +1525,14 @@ function mouse(event, root, evt) {
1475
1525
  }
1476
1526
  // Check for null values before processing this event
1477
1527
  if (x !== null && y !== null) {
1478
- handler$2({ time: time(), event: event, data: { target: target(evt), x: x, y: y } });
1528
+ handler$2({ time: time(evt), event: event, data: { target: target(evt), x: x, y: y } });
1479
1529
  }
1480
1530
  }
1481
1531
  function touch(event, root, evt) {
1482
1532
  var frame = iframe(root);
1483
1533
  var d = frame ? frame.contentDocument.documentElement : document.documentElement;
1484
1534
  var touches = evt.changedTouches;
1485
- var t = time();
1535
+ var t = time(evt);
1486
1536
  if (touches) {
1487
1537
  for (var i = 0; i < touches.length; i++) {
1488
1538
  var entry = touches[i];
@@ -1588,7 +1638,7 @@ function recompute$4(event) {
1588
1638
  // And, if for some reason that is not available, fall back to looking up scrollTop on document.documentElement.
1589
1639
  var x = element === de && "pageXOffset" in w ? Math.round(w.pageXOffset) : Math.round(element.scrollLeft);
1590
1640
  var y = element === de && "pageYOffset" in w ? Math.round(w.pageYOffset) : Math.round(element.scrollTop);
1591
- var current = { time: time(), event: 10 /* Event.Scroll */, data: { target: element, x: x, y: y } };
1641
+ var current = { time: time(event), event: 10 /* Event.Scroll */, data: { target: element, x: x, y: y } };
1592
1642
  // We don't send any scroll events if this is the first event and the current position is top (0,0)
1593
1643
  if ((event === null && x === 0 && y === 0) || (x === null || y === null)) {
1594
1644
  return;
@@ -1678,7 +1728,7 @@ function observe$5(root) {
1678
1728
  bind(root, "submit", recompute$2, true);
1679
1729
  }
1680
1730
  function recompute$2(evt) {
1681
- state$2.push({ time: time(), event: 39 /* Event.Submit */, data: { target: target(evt) } });
1731
+ state$2.push({ time: time(evt), event: 39 /* Event.Submit */, data: { target: target(evt) } });
1682
1732
  schedule$1(encode$3.bind(this, 39 /* Event.Submit */));
1683
1733
  }
1684
1734
  function reset$a() {
@@ -1694,7 +1744,7 @@ function start$m() {
1694
1744
  }
1695
1745
  function recompute$1(evt) {
1696
1746
  data$9 = { name: evt.type };
1697
- encode$3(26 /* Event.Unload */);
1747
+ encode$3(26 /* Event.Unload */, time(evt));
1698
1748
  stop();
1699
1749
  }
1700
1750
  function reset$9() {
@@ -1709,9 +1759,10 @@ function start$l() {
1709
1759
  bind(document, "visibilitychange", recompute);
1710
1760
  recompute();
1711
1761
  }
1712
- function recompute() {
1762
+ function recompute(evt) {
1763
+ if (evt === void 0) { evt = null; }
1713
1764
  data$8 = { visible: "visibilityState" in document ? document.visibilityState : "default" };
1714
- encode$3(28 /* Event.Visibility */);
1765
+ encode$3(28 /* Event.Visibility */, time(evt));
1715
1766
  }
1716
1767
  function reset$8() {
1717
1768
  data$8 = null;
@@ -1730,6 +1781,7 @@ function start$k() {
1730
1781
  start$l();
1731
1782
  start$p();
1732
1783
  start$o();
1784
+ start$v();
1733
1785
  start$n();
1734
1786
  start$m();
1735
1787
  }
@@ -1743,6 +1795,7 @@ function stop$i() {
1743
1795
  stop$j();
1744
1796
  stop$n();
1745
1797
  stop$m();
1798
+ stop$t();
1746
1799
  stop$l();
1747
1800
  stop$k();
1748
1801
  }
@@ -1756,6 +1809,7 @@ function observe$4(root) {
1756
1809
  observe$8(root);
1757
1810
  observe$9(root);
1758
1811
  observe$6(root);
1812
+ observe$c(root);
1759
1813
  observe$5(root);
1760
1814
  }
1761
1815
  }
@@ -1836,6 +1890,7 @@ function num$1(input, scale) {
1836
1890
  var IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last"];
1837
1891
  var newlineRegex = /[\r\n]+/g;
1838
1892
  function processNode (node, source) {
1893
+ var _a;
1839
1894
  var child = null;
1840
1895
  // Do not track this change if we are attempting to remove a node before discovering it
1841
1896
  if (source === 2 /* Source.ChildListRemove */ && has(node) === false) {
@@ -1932,7 +1987,7 @@ function processNode (node, source) {
1932
1987
  try {
1933
1988
  ld(JSON.parse(element.text.replace(newlineRegex, "" /* Constant.Empty */)));
1934
1989
  }
1935
- catch ( /* do nothing */_a) { /* do nothing */ }
1990
+ catch ( /* do nothing */_b) { /* do nothing */ }
1936
1991
  }
1937
1992
  break;
1938
1993
  case "NOSCRIPT":
@@ -1958,11 +2013,20 @@ function processNode (node, source) {
1958
2013
  break;
1959
2014
  case "HEAD":
1960
2015
  var head = { tag: tag, attributes: attributes };
1961
- if (location) {
1962
- head.attributes["*B" /* Constant.Base */] = location.protocol + "//" + location.hostname;
1963
- }
2016
+ var l = insideFrame && ((_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.location) ? node.ownerDocument.location : location;
2017
+ head.attributes["*B" /* Constant.Base */] = l.protocol + "//" + l.hostname + l.pathname;
1964
2018
  dom[call](node, parent, head, source);
1965
2019
  break;
2020
+ case "BASE":
2021
+ // Override the auto detected base path to explicit value specified in this tag
2022
+ var baseHead = get(node.parentElement);
2023
+ if (baseHead) {
2024
+ // We create "a" element so we can generate protocol and hostname for relative paths like "/path/"
2025
+ var a = document.createElement("a");
2026
+ a.href = attributes["href"];
2027
+ baseHead.data.attributes["*B" /* Constant.Base */] = a.protocol + "//" + a.hostname + a.pathname;
2028
+ }
2029
+ break;
1966
2030
  case "STYLE":
1967
2031
  var styleData = { tag: tag, attributes: attributes, value: getStyleValue(element) };
1968
2032
  dom[call](node, parent, styleData, source);
@@ -2062,7 +2126,7 @@ function traverse (root, timer, source) {
2062
2126
  queue.push(next);
2063
2127
  next = next.nextSibling;
2064
2128
  }
2065
- state = state$8(timer);
2129
+ state = state$9(timer);
2066
2130
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 3];
2067
2131
  return [4 /*yield*/, suspend$1(timer)];
2068
2132
  case 2:
@@ -2199,7 +2263,7 @@ function process$2() {
2199
2263
  switch (_b.label) {
2200
2264
  case 0:
2201
2265
  timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
2202
- start$w(timer);
2266
+ start$x(timer);
2203
2267
  _b.label = 1;
2204
2268
  case 1:
2205
2269
  if (!(mutations.length > 0)) return [3 /*break*/, 8];
@@ -2209,7 +2273,7 @@ function process$2() {
2209
2273
  case 2:
2210
2274
  if (!(_i < _a.length)) return [3 /*break*/, 6];
2211
2275
  mutation = _a[_i];
2212
- state = state$8(timer);
2276
+ state = state$9(timer);
2213
2277
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 4];
2214
2278
  return [4 /*yield*/, suspend$1(timer)];
2215
2279
  case 3:
@@ -2254,7 +2318,7 @@ function process$2() {
2254
2318
  _b.sent();
2255
2319
  return [3 /*break*/, 1];
2256
2320
  case 8:
2257
- stop$t(timer);
2321
+ stop$u(timer);
2258
2322
  return [2 /*return*/];
2259
2323
  }
2260
2324
  });
@@ -2316,7 +2380,7 @@ function processNodeList(list, source, timer) {
2316
2380
  traverse(list[i], timer, source);
2317
2381
  return [3 /*break*/, 5];
2318
2382
  case 2:
2319
- state = state$8(timer);
2383
+ state = state$9(timer);
2320
2384
  if (!(state === 0 /* Task.Wait */)) return [3 /*break*/, 4];
2321
2385
  return [4 /*yield*/, suspend$1(timer)];
2322
2386
  case 3:
@@ -2389,8 +2453,9 @@ var override = [];
2389
2453
  var unmask = [];
2390
2454
  var updatedFragments = {};
2391
2455
  var maskText = [];
2392
- var maskInput = [];
2456
+ var maskExclude = [];
2393
2457
  var maskDisable = [];
2458
+ var maskTags = [];
2394
2459
  // The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced
2395
2460
  var idMap = null; // Maps node => id.
2396
2461
  var iframeMap = null; // Maps iframe's contentDocument => parent iframe element
@@ -2412,13 +2477,14 @@ function reset$7() {
2412
2477
  override = [];
2413
2478
  unmask = [];
2414
2479
  maskText = "address,password,contact" /* Mask.Text */.split("," /* Constant.Comma */);
2415
- 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 */);
2480
+ maskExclude = "password,secret,pass,social,ssn,code,hidden" /* Mask.Exclude */.split("," /* Constant.Comma */);
2416
2481
  maskDisable = "radio,checkbox,range,button,reset,submit" /* Mask.Disable */.split("," /* Constant.Comma */);
2482
+ maskTags = "INPUT,SELECT,TEXTAREA" /* Mask.Tags */.split("," /* Constant.Comma */);
2417
2483
  idMap = new WeakMap();
2418
2484
  iframeMap = new WeakMap();
2419
2485
  privacyMap = new WeakMap();
2420
2486
  fraudMap = new WeakMap();
2421
- reset$k();
2487
+ reset$l();
2422
2488
  }
2423
2489
  // We parse new root nodes for any regions or masked nodes in the beginning (document) and
2424
2490
  // later whenever there are new additions or modifications to DOM (mutations)
@@ -2436,7 +2502,7 @@ function parse$1(root, init) {
2436
2502
  if ("querySelectorAll" in root) {
2437
2503
  config$1.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "".concat(x[0])); }); }); // Regions
2438
2504
  config$1.mask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 3 /* Privacy.TextImage */); }); }); // Masked Elements
2439
- config$1.fraud.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Check
2505
+ config$1.checksum.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Checksum Check
2440
2506
  unmask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 0 /* Privacy.None */); }); }); // Unmasked Elements
2441
2507
  }
2442
2508
  }
@@ -2580,6 +2646,16 @@ function privacy(node, value, parent) {
2580
2646
  var attributes = data.attributes || {};
2581
2647
  var tag = data.tag.toUpperCase();
2582
2648
  switch (true) {
2649
+ case maskTags.indexOf(tag) >= 0:
2650
+ var type = attributes["type" /* Constant.Type */];
2651
+ var meta_1 = "" /* Constant.Empty */;
2652
+ Object.keys(attributes).forEach(function (x) { return meta_1 += attributes[x].toLowerCase(); });
2653
+ var exclude = maskExclude.some(function (x) { return meta_1.indexOf(x) >= 0; });
2654
+ // Regardless of privacy mode, always mask off user input from input boxes or drop downs with two exceptions:
2655
+ // (1) The node is detected to be one of the excluded fields, in which case we drop everything
2656
+ // (2) The node's type is one of the allowed types (like checkboxes)
2657
+ metadata.privacy = tag === "INPUT" /* Constant.InputTag */ && maskDisable.indexOf(type) >= 0 ? current : (exclude ? 4 /* Privacy.Exclude */ : 2 /* Privacy.Text */);
2658
+ break;
2583
2659
  case "data-clarity-mask" /* Constant.MaskData */ in attributes:
2584
2660
  metadata.privacy = 3 /* Privacy.TextImage */;
2585
2661
  break;
@@ -2601,20 +2677,6 @@ function privacy(node, value, parent) {
2601
2677
  var tags = ["STYLE" /* Constant.StyleTag */, "TITLE" /* Constant.TitleTag */, "svg:style" /* Constant.SvgStyle */];
2602
2678
  metadata.privacy = tags.includes(pTag) || override.some(function (x) { return pSelector_1.indexOf(x) >= 0; }) ? 0 /* Privacy.None */ : current;
2603
2679
  break;
2604
- case tag === "INPUT" /* Constant.InputTag */ && current === 0 /* Privacy.None */:
2605
- // If even default privacy setting is to not mask, we still scan through input fields for any sensitive information
2606
- var field_1 = "" /* Constant.Empty */;
2607
- Object.keys(attributes).forEach(function (x) { return field_1 += attributes[x].toLowerCase(); });
2608
- metadata.privacy = inspect(field_1, maskInput, metadata);
2609
- break;
2610
- case tag === "INPUT" /* Constant.InputTag */ && current === 1 /* Privacy.Sensitive */:
2611
- // Look through class names to aggressively mask content
2612
- metadata.privacy = inspect(attributes["class" /* Constant.Class */], maskText, metadata);
2613
- // If this node has an explicit type assigned to it, go through masking rules to determine right privacy setting
2614
- metadata.privacy = inspect(attributes["type" /* Constant.Type */], maskInput, metadata);
2615
- // If it's a button or an input option, make an exception to disable masking in sensitive mode
2616
- metadata.privacy = maskDisable.indexOf(attributes["type" /* Constant.Type */]) >= 0 ? 0 /* Privacy.None */ : metadata.privacy;
2617
- break;
2618
2680
  case current === 1 /* Privacy.Sensitive */:
2619
2681
  // In a mode where we mask sensitive information by default, look through class names to aggressively mask content
2620
2682
  metadata.privacy = inspect(attributes["class" /* Constant.Class */], maskText, metadata);
@@ -2952,11 +3014,12 @@ function metadata$2(node, event, text) {
2952
3014
  return output;
2953
3015
  }
2954
3016
 
2955
- function encode$3 (type) {
3017
+ function encode$3 (type, ts) {
3018
+ if (ts === void 0) { ts = null; }
2956
3019
  return __awaiter(this, void 0, void 0, function () {
2957
- 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;
2958
- return __generator(this, function (_p) {
2959
- t = time();
3020
+ 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;
3021
+ return __generator(this, function (_r) {
3022
+ t = ts || time();
2960
3023
  tokens = [t, type];
2961
3024
  switch (type) {
2962
3025
  case 13 /* Event.MouseDown */:
@@ -2996,8 +3059,8 @@ function encode$3 (type) {
2996
3059
  tokens.push(entry.data.button);
2997
3060
  tokens.push(entry.data.reaction);
2998
3061
  tokens.push(entry.data.context);
2999
- tokens.push(scrub(entry.data.text, "click", cTarget.privacy));
3000
- tokens.push(entry.data.link);
3062
+ tokens.push(text$1(entry.data.text, "click", cTarget.privacy));
3063
+ tokens.push(url$1(entry.data.link));
3001
3064
  tokens.push(cHash);
3002
3065
  tokens.push(entry.data.trust);
3003
3066
  queue(tokens);
@@ -3038,7 +3101,7 @@ function encode$3 (type) {
3038
3101
  iTarget = metadata$2(entry.data.target, entry.event, entry.data.value);
3039
3102
  tokens = [entry.time, entry.event];
3040
3103
  tokens.push(iTarget.id);
3041
- tokens.push(scrub(entry.data.value, "input", iTarget.privacy));
3104
+ tokens.push(text$1(entry.data.value, "input", iTarget.privacy));
3042
3105
  queue(tokens);
3043
3106
  }
3044
3107
  reset$f();
@@ -3071,11 +3134,27 @@ function encode$3 (type) {
3071
3134
  }
3072
3135
  reset$c();
3073
3136
  break;
3074
- case 39 /* Event.Submit */:
3075
- for (_k = 0, _l = state$2; _k < _l.length; _k++) {
3137
+ case 42 /* Event.Change */:
3138
+ for (_k = 0, _l = state$8; _k < _l.length; _k++) {
3076
3139
  entry = _l[_k];
3077
3140
  tokens = [entry.time, entry.event];
3078
3141
  target = metadata$2(entry.data.target, entry.event);
3142
+ if (target.id > 0) {
3143
+ tokens = [entry.time, entry.event];
3144
+ tokens.push(target.id);
3145
+ tokens.push(entry.data.type);
3146
+ tokens.push(text$1(entry.data.value, "change", target.privacy));
3147
+ tokens.push(text$1(entry.data.checksum, "checksum", target.privacy));
3148
+ queue(tokens);
3149
+ }
3150
+ }
3151
+ reset$i();
3152
+ break;
3153
+ case 39 /* Event.Submit */:
3154
+ for (_m = 0, _o = state$2; _m < _o.length; _m++) {
3155
+ entry = _o[_m];
3156
+ tokens = [entry.time, entry.event];
3157
+ target = metadata$2(entry.data.target, entry.event);
3079
3158
  if (target.id > 0) {
3080
3159
  tokens.push(target.id);
3081
3160
  queue(tokens);
@@ -3084,8 +3163,8 @@ function encode$3 (type) {
3084
3163
  reset$a();
3085
3164
  break;
3086
3165
  case 22 /* Event.Timeline */:
3087
- for (_m = 0, _o = updates$1; _m < _o.length; _m++) {
3088
- entry = _o[_m];
3166
+ for (_p = 0, _q = updates$1; _p < _q.length; _p++) {
3167
+ entry = _q[_p];
3089
3168
  tokens = [entry.time, entry.event];
3090
3169
  tokens.push(entry.data.type);
3091
3170
  tokens.push(entry.data.hash);
@@ -3213,7 +3292,7 @@ function queue(tokens, transmit) {
3213
3292
  // We enrich the data going out with the existing upload. In these cases, call to upload comes with 'transmit' set to false.
3214
3293
  if (transmit && timeout === null) {
3215
3294
  if (type !== 25 /* Event.Ping */) {
3216
- reset$n();
3295
+ reset$o();
3217
3296
  }
3218
3297
  timeout = setTimeout(upload, gap);
3219
3298
  queuedTime = now;
@@ -3463,7 +3542,7 @@ function encode$2 (type) {
3463
3542
  tokens.push(data$7.line);
3464
3543
  tokens.push(data$7.column);
3465
3544
  tokens.push(data$7.stack);
3466
- tokens.push(data$7.source);
3545
+ tokens.push(url$1(data$7.source));
3467
3546
  queue(tokens);
3468
3547
  break;
3469
3548
  case 33 /* Event.Log */:
@@ -3480,7 +3559,7 @@ function encode$2 (type) {
3480
3559
  if (data$d) {
3481
3560
  tokens.push(data$d.id);
3482
3561
  tokens.push(data$d.target);
3483
- tokens.push(data$d.hash);
3562
+ tokens.push(data$d.checksum);
3484
3563
  queue(tokens, false);
3485
3564
  }
3486
3565
  break;
@@ -3659,7 +3738,7 @@ function encode$1 (event) {
3659
3738
  var tokens = [t, event];
3660
3739
  switch (event) {
3661
3740
  case 4 /* Event.Baseline */:
3662
- var b = state$9;
3741
+ var b = state$a;
3663
3742
  if (b) {
3664
3743
  tokens = [b.time, b.event];
3665
3744
  tokens.push(b.data.visible);
@@ -3674,7 +3753,7 @@ function encode$1 (event) {
3674
3753
  tokens.push(b.data.activityTime);
3675
3754
  queue(tokens, false);
3676
3755
  }
3677
- reset$p();
3756
+ reset$q();
3678
3757
  break;
3679
3758
  case 25 /* Event.Ping */:
3680
3759
  tokens.push(data$h.gap);
@@ -3707,7 +3786,7 @@ function encode$1 (event) {
3707
3786
  tokens.push(v);
3708
3787
  tokens.push(data$e[v]);
3709
3788
  }
3710
- reset$l();
3789
+ reset$m();
3711
3790
  queue(tokens, false);
3712
3791
  }
3713
3792
  break;
@@ -3722,7 +3801,7 @@ function encode$1 (event) {
3722
3801
  // However, for data over the wire, we round it off to milliseconds precision.
3723
3802
  tokens.push(Math.round(updates$3[m]));
3724
3803
  }
3725
- reset$o();
3804
+ reset$p();
3726
3805
  queue(tokens, false);
3727
3806
  }
3728
3807
  break;
@@ -3748,7 +3827,7 @@ function encode$1 (event) {
3748
3827
  tokens.push(key);
3749
3828
  tokens.push([].concat.apply([], data$g[e]));
3750
3829
  }
3751
- reset$m();
3830
+ reset$n();
3752
3831
  queue(tokens, false);
3753
3832
  }
3754
3833
  break;
@@ -3843,30 +3922,31 @@ function start$9() {
3843
3922
  // Populate ids for this page
3844
3923
  var s = session();
3845
3924
  var u = user();
3846
- data$2 = {
3847
- projectId: config$1.projectId || hash(location.host),
3848
- userId: u.id,
3849
- sessionId: s.session,
3850
- pageNum: s.count
3851
- };
3925
+ var projectId = config$1.projectId || hash(location.host);
3926
+ data$2 = { projectId: projectId, userId: u.id, sessionId: s.session, pageNum: s.count };
3852
3927
  // Override configuration based on what's in the session storage, unless it is blank (e.g. using upload callback, like in devtools)
3853
3928
  config$1.lean = config$1.track && s.upgrade !== null ? s.upgrade === 0 /* BooleanFlag.False */ : config$1.lean;
3854
3929
  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;
3855
- // Log dimensions
3930
+ // Log page metadata as dimensions
3856
3931
  log(0 /* Dimension.UserAgent */, ua);
3857
3932
  log(3 /* Dimension.PageTitle */, title);
3858
- log(1 /* Dimension.Url */, location.href);
3933
+ log(1 /* Dimension.Url */, url$1(location.href));
3859
3934
  log(2 /* Dimension.Referrer */, document.referrer);
3860
3935
  log(15 /* Dimension.TabId */, tab());
3861
3936
  log(16 /* Dimension.PageLanguage */, document.documentElement.lang);
3862
3937
  log(17 /* Dimension.DocumentDirection */, document.dir);
3938
+ log(26 /* Dimension.DevicePixelRatio */, "".concat(window.devicePixelRatio));
3939
+ // Capture additional metadata as metrics
3940
+ max(0 /* Metric.ClientTimestamp */, s.ts);
3941
+ max(1 /* Metric.Playback */, 0 /* BooleanFlag.False */);
3942
+ // Capture navigator specific dimensions
3863
3943
  if (navigator) {
3864
- log(9 /* Dimension.Language */, navigator.userLanguage || navigator.language);
3944
+ log(9 /* Dimension.Language */, navigator.language);
3945
+ max(33 /* Metric.HardwareConcurrency */, navigator.hardwareConcurrency);
3946
+ max(32 /* Metric.MaxTouchPoints */, navigator.maxTouchPoints);
3947
+ max(34 /* Metric.DeviceMemory */, Math.round(navigator.deviceMemory));
3865
3948
  userAgentData();
3866
3949
  }
3867
- // Metrics
3868
- max(0 /* Metric.ClientTimestamp */, s.ts);
3869
- max(1 /* Metric.Playback */, 0 /* BooleanFlag.False */);
3870
3950
  if (screen) {
3871
3951
  max(14 /* Metric.ScreenWidth */, Math.round(screen.width));
3872
3952
  max(15 /* Metric.ScreenHeight */, Math.round(screen.height));
@@ -3884,22 +3964,20 @@ function start$9() {
3884
3964
  track(u);
3885
3965
  }
3886
3966
  function userAgentData() {
3887
- if (navigator["userAgentData"] && navigator["userAgentData"].getHighEntropyValues) {
3888
- navigator["userAgentData"].getHighEntropyValues(["model",
3889
- "platform",
3890
- "platformVersion",
3891
- "uaFullVersion"])
3892
- .then(function (ua) {
3967
+ var uaData = navigator["userAgentData"];
3968
+ if (uaData && uaData.getHighEntropyValues) {
3969
+ uaData.getHighEntropyValues(["model", "platform", "platformVersion", "uaFullVersion"]).then(function (ua) {
3893
3970
  var _a;
3894
3971
  log(22 /* Dimension.Platform */, ua.platform);
3895
3972
  log(23 /* Dimension.PlatformVersion */, ua.platformVersion);
3896
- (_a = ua.brands) === null || _a === void 0 ? void 0 : _a.forEach(function (brand) {
3897
- log(24 /* Dimension.Brand */, brand.name + "~" /* Constant.Tilde */ + brand.version);
3898
- });
3973
+ (_a = ua.brands) === null || _a === void 0 ? void 0 : _a.forEach(function (brand) { log(24 /* Dimension.Brand */, brand.name + "~" /* Constant.Tilde */ + brand.version); });
3899
3974
  log(25 /* Dimension.Model */, ua.model);
3900
3975
  max(27 /* Metric.Mobile */, ua.mobile ? 1 /* BooleanFlag.True */ : 0 /* BooleanFlag.False */);
3901
3976
  });
3902
3977
  }
3978
+ else {
3979
+ log(22 /* Dimension.Platform */, navigator.platform);
3980
+ }
3903
3981
  }
3904
3982
  function stop$8() {
3905
3983
  rootDomain = null;
@@ -4258,8 +4336,8 @@ function stop$6() {
4258
4336
  var status = false;
4259
4337
  function start$6() {
4260
4338
  status = true;
4261
- start$F();
4262
- reset$j();
4339
+ start$G();
4340
+ reset$k();
4263
4341
  reset$1();
4264
4342
  reset$2();
4265
4343
  start$7();
@@ -4268,8 +4346,8 @@ function stop$5() {
4268
4346
  stop$6();
4269
4347
  reset$2();
4270
4348
  reset$1();
4271
- reset$j();
4272
- stop$B();
4349
+ reset$k();
4350
+ stop$C();
4273
4351
  status = false;
4274
4352
  }
4275
4353
  function active() {
@@ -4323,7 +4401,7 @@ function restart() {
4323
4401
  }
4324
4402
 
4325
4403
  function start$5() {
4326
- start$x();
4404
+ start$y();
4327
4405
  start$e();
4328
4406
  start$d();
4329
4407
  }
@@ -4351,14 +4429,14 @@ function discover() {
4351
4429
  case 0:
4352
4430
  ts = time();
4353
4431
  timer = { id: id(), cost: 3 /* Metric.LayoutCost */ };
4354
- start$w(timer);
4432
+ start$x(timer);
4355
4433
  return [4 /*yield*/, traverse(document, timer, 0 /* Source.Discover */)];
4356
4434
  case 1:
4357
4435
  _a.sent();
4358
4436
  return [4 /*yield*/, encode$4(5 /* Event.Discover */, timer, ts)];
4359
4437
  case 2:
4360
4438
  _a.sent();
4361
- stop$t(timer);
4439
+ stop$u(timer);
4362
4440
  return [2 /*return*/];
4363
4441
  }
4364
4442
  });
@@ -4368,7 +4446,7 @@ function discover() {
4368
4446
  function start$3() {
4369
4447
  // The order below is important
4370
4448
  // and is determined by interdependencies of modules
4371
- start$v();
4449
+ start$w();
4372
4450
  start$h();
4373
4451
  start$i();
4374
4452
  start$j();
@@ -4450,6 +4528,10 @@ function compute(entry) {
4450
4528
  var observer;
4451
4529
  var types = ["navigation" /* Constant.Navigation */, "resource" /* Constant.Resource */, "longtask" /* Constant.LongTask */, "first-input" /* Constant.FID */, "layout-shift" /* Constant.CLS */, "largest-contentful-paint" /* Constant.LCP */];
4452
4530
  function start$2() {
4531
+ // Capture connection properties, if available
4532
+ if (navigator && "connection" in navigator) {
4533
+ log(27 /* Dimension.ConnectionType */, navigator["connection"]["effectiveType"]);
4534
+ }
4453
4535
  // Check the browser support performance observer as a pre-requisite for any performance measurement
4454
4536
  if (window["PerformanceObserver"] && PerformanceObserver.supportedEntryTypes) {
4455
4537
  // Start monitoring performance data after page has finished loading.
@@ -4573,7 +4655,7 @@ function start(config$1) {
4573
4655
  if (check()) {
4574
4656
  config(config$1);
4575
4657
  start$6();
4576
- start$y();
4658
+ start$z();
4577
4659
  modules.forEach(function (x) { return measure(x.start)(); });
4578
4660
  }
4579
4661
  }
@@ -4599,7 +4681,7 @@ function stop() {
4599
4681
  if (active()) {
4600
4682
  // Stop modules in the reverse order of their initialization
4601
4683
  modules.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
4602
- stop$u();
4684
+ stop$v();
4603
4685
  stop$5();
4604
4686
  }
4605
4687
  }