clarity-js 0.6.26 → 0.6.30

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.
@@ -1,9 +1,48 @@
1
1
  var upload$1 = /*#__PURE__*/Object.freeze({
2
2
  __proto__: null,
3
- get track () { return track; },
4
- get start () { return start$a; },
3
+ get track () { return track$1; },
4
+ get start () { return start$c; },
5
5
  get queue () { return queue; },
6
- get stop () { return stop$9; }
6
+ get stop () { return stop$b; }
7
+ });
8
+ var limit = /*#__PURE__*/Object.freeze({
9
+ __proto__: null,
10
+ get data () { return data$4; },
11
+ get start () { return start$b; },
12
+ get check () { return check$2; },
13
+ get trigger () { return trigger; },
14
+ get compute () { return compute$3; },
15
+ get stop () { return stop$a; }
16
+ });
17
+ var dimension = /*#__PURE__*/Object.freeze({
18
+ __proto__: null,
19
+ get data () { return data$3; },
20
+ get updates () { return updates; },
21
+ get start () { return start$a; },
22
+ get stop () { return stop$9; },
23
+ get log () { return log; },
24
+ get compute () { return compute$2; },
25
+ get reset () { return reset$3; }
26
+ });
27
+ var metadata$1 = /*#__PURE__*/Object.freeze({
28
+ __proto__: null,
29
+ get data () { return data$2; },
30
+ get callback () { return callback; },
31
+ get start () { return start$9; },
32
+ get userAgentData () { return userAgentData; },
33
+ get stop () { return stop$8; },
34
+ get metadata () { return metadata; },
35
+ get id () { return id; },
36
+ get consent () { return consent; },
37
+ get clear () { return clear; },
38
+ get save () { return save; }
39
+ });
40
+ var envelope$1 = /*#__PURE__*/Object.freeze({
41
+ __proto__: null,
42
+ get data () { return data$1; },
43
+ get start () { return start$8; },
44
+ get stop () { return stop$7; },
45
+ get envelope () { return envelope; }
7
46
  });
8
47
 
9
48
  var config$1 = {
@@ -16,6 +55,7 @@ var config$1 = {
16
55
  unmask: [],
17
56
  regions: [],
18
57
  metrics: [],
58
+ dimensions: [],
19
59
  cookies: [],
20
60
  report: null,
21
61
  upload: null,
@@ -36,18 +76,40 @@ function stop$B() {
36
76
  startTime = 0;
37
77
  }
38
78
 
39
- var state$7 = null;
79
+ var version$1 = "0.6.30";
80
+
81
+ // tslint:disable: no-bitwise
82
+ function hash (input) {
83
+ // Code inspired from C# GetHashCode: https://github.com/Microsoft/referencesource/blob/master/mscorlib/system/string.cs
84
+ var hash = 0;
85
+ var hashOne = 5381;
86
+ var hashTwo = hashOne;
87
+ for (var i = 0; i < input.length; i += 2) {
88
+ var charOne = input.charCodeAt(i);
89
+ hashOne = ((hashOne << 5) + hashOne) ^ charOne;
90
+ if (i + 1 < input.length) {
91
+ var charTwo = input.charCodeAt(i + 1);
92
+ hashTwo = ((hashTwo << 5) + hashTwo) ^ charTwo;
93
+ }
94
+ }
95
+ // Replace the magic number from C# implementation (1566083941) with a smaller prime number (11579)
96
+ // This ensures we don't hit integer overflow and prevent collisions
97
+ hash = Math.abs(hashOne + (hashTwo * 11579));
98
+ return hash.toString(36);
99
+ }
100
+
101
+ var state$9 = null;
40
102
  var buffer = null;
41
103
  var update$1 = false;
42
104
  function start$D() {
43
105
  update$1 = false;
44
- reset$n();
106
+ reset$o();
45
107
  }
46
- function reset$n() {
108
+ function reset$o() {
47
109
  // Baseline state holds the previous values - if it is updated in the current payload,
48
110
  // reset the state to current value after sending the previous state
49
111
  if (update$1) {
50
- state$7 = { time: time(), event: 4 /* Baseline */, data: {
112
+ state$9 = { time: time(), event: 4 /* Baseline */, data: {
51
113
  visible: buffer.visible,
52
114
  docWidth: buffer.docWidth,
53
115
  docHeight: buffer.docHeight,
@@ -111,14 +173,14 @@ function compute$c() {
111
173
  }
112
174
  }
113
175
  function stop$A() {
114
- reset$n();
176
+ reset$o();
115
177
  }
116
178
 
117
179
  var baseline = /*#__PURE__*/Object.freeze({
118
180
  __proto__: null,
119
- get state () { return state$7; },
181
+ get state () { return state$9; },
120
182
  start: start$D,
121
- reset: reset$n,
183
+ reset: reset$o,
122
184
  track: track$7,
123
185
  activity: activity,
124
186
  visibility: visibility,
@@ -126,7 +188,7 @@ var baseline = /*#__PURE__*/Object.freeze({
126
188
  stop: stop$A
127
189
  });
128
190
 
129
- var data$k = null;
191
+ var data$i = null;
130
192
  function event(key, value) {
131
193
  if (active() &&
132
194
  key &&
@@ -135,484 +197,64 @@ function event(key, value) {
135
197
  typeof value === "string" /* String */ &&
136
198
  key.length < 255 &&
137
199
  value.length < 255) {
138
- data$k = { key: key, value: value };
200
+ data$i = { key: key, value: value };
139
201
  encode$1(24 /* Custom */);
140
202
  }
141
203
  }
142
204
 
143
- // tslint:disable: no-bitwise
144
- function hash (input) {
145
- // Code inspired from C# GetHashCode: https://github.com/Microsoft/referencesource/blob/master/mscorlib/system/string.cs
146
- var hash = 0;
147
- var hashOne = 5381;
148
- var hashTwo = hashOne;
149
- for (var i = 0; i < input.length; i += 2) {
150
- var charOne = input.charCodeAt(i);
151
- hashOne = ((hashOne << 5) + hashOne) ^ charOne;
152
- if (i + 1 < input.length) {
153
- var charTwo = input.charCodeAt(i + 1);
154
- hashTwo = ((hashTwo << 5) + hashTwo) ^ charTwo;
155
- }
156
- }
157
- // Replace the magic number from C# implementation (1566083941) with a smaller prime number (11579)
158
- // This ensures we don't hit integer overflow and prevent collisions
159
- hash = Math.abs(hashOne + (hashTwo * 11579));
160
- return hash.toString(36);
161
- }
162
-
163
- var data$j = null;
205
+ var data$h = null;
206
+ var updates$3 = null;
164
207
  function start$C() {
165
- reset$m();
166
- }
167
- function set(variable, value) {
168
- var values = typeof value === "string" /* String */ ? [value] : value;
169
- log$2(variable, values);
170
- }
171
- function identify(userId, sessionId, pageId) {
172
- if (sessionId === void 0) { sessionId = null; }
173
- if (pageId === void 0) { pageId = null; }
174
- log$2("userId" /* UserId */, [userId]);
175
- log$2("sessionId" /* SessionId */, [sessionId]);
176
- log$2("pageId" /* PageId */, [pageId]);
177
- }
178
- function log$2(variable, value) {
179
- if (active() &&
180
- variable &&
181
- value &&
182
- typeof variable === "string" /* String */ &&
183
- variable.length < 255) {
184
- var validValues = variable in data$j ? data$j[variable] : [];
185
- for (var i = 0; i < value.length; i++) {
186
- if (typeof value[i] === "string" /* String */ && value[i].length < 255) {
187
- validValues.push(value[i]);
188
- }
189
- }
190
- data$j[variable] = validValues;
191
- }
192
- }
193
- function compute$b() {
194
- encode$1(34 /* Variable */);
195
- }
196
- function reset$m() {
197
- data$j = {};
208
+ data$h = {};
209
+ updates$3 = {};
210
+ count$1(5 /* InvokeCount */);
198
211
  }
199
212
  function stop$z() {
200
- reset$m();
201
- }
202
-
203
- var variable = /*#__PURE__*/Object.freeze({
204
- __proto__: null,
205
- get data () { return data$j; },
206
- start: start$C,
207
- set: set,
208
- identify: identify,
209
- compute: compute$b,
210
- reset: reset$m,
211
- stop: stop$z
212
- });
213
-
214
- var data$i = null;
215
- var callback = null;
216
- var rootDomain = null;
217
- function start$B() {
218
- callback = null;
219
- rootDomain = null;
220
- var ua = navigator && "userAgent" in navigator ? navigator.userAgent : "" /* Empty */;
221
- var title = document && document.title ? document.title : "" /* Empty */;
222
- // Populate ids for this page
223
- var s = session();
224
- var u = user();
225
- data$i = {
226
- projectId: config$1.projectId || hash(location.host),
227
- userId: u.id,
228
- sessionId: s.session,
229
- pageNum: s.count
230
- };
231
- // Override configuration based on what's in the session storage, unless it is blank (e.g. using upload callback, like in devtools)
232
- config$1.lean = config$1.track && s.upgrade !== null ? s.upgrade === 0 /* False */ : config$1.lean;
233
- config$1.upload = config$1.track && typeof config$1.upload === "string" /* String */ && s.upload && s.upload.length > "https://" /* HTTPS */.length ? s.upload : config$1.upload;
234
- // Log dimensions
235
- log$1(0 /* UserAgent */, ua);
236
- log$1(3 /* PageTitle */, title);
237
- log$1(1 /* Url */, location.href);
238
- log$1(2 /* Referrer */, document.referrer);
239
- log$1(15 /* TabId */, tab());
240
- log$1(16 /* PageLanguage */, document.documentElement.lang);
241
- log$1(17 /* DocumentDirection */, document.dir);
242
- if (navigator) {
243
- log$1(9 /* Language */, navigator.userLanguage || navigator.language);
244
- }
245
- // Metrics
246
- max(0 /* ClientTimestamp */, s.ts);
247
- max(1 /* Playback */, 0 /* False */);
248
- if (screen) {
249
- max(14 /* ScreenWidth */, Math.round(screen.width));
250
- max(15 /* ScreenHeight */, Math.round(screen.height));
251
- max(16 /* ColorDepth */, Math.round(screen.colorDepth));
252
- }
253
- // Read cookies specified in configuration
254
- for (var _i = 0, _a = config$1.cookies; _i < _a.length; _i++) {
255
- var key = _a[_i];
256
- var value = getCookie(key);
257
- if (value) {
258
- set(key, value);
259
- }
260
- }
261
- // Track ids using a cookie if configuration allows it
262
- track$6(u);
263
- }
264
- function stop$y() {
265
- callback = null;
266
- rootDomain = null;
267
- }
268
- function metadata$1(cb) {
269
- callback = cb;
270
- }
271
- function id() {
272
- return data$i ? [data$i.userId, data$i.sessionId, data$i.pageNum].join("." /* Dot */) : "" /* Empty */;
273
- }
274
- function consent() {
275
- if (active()) {
276
- config$1.track = true;
277
- track$6(user(), 1 /* True */);
278
- }
279
- }
280
- function clear() {
281
- // Clear any stored information in the cookie that tracks session information so we can restart fresh the next time
282
- setCookie("_clsk" /* SessionKey */, "" /* Empty */, 0);
283
- }
284
- function tab() {
285
- var id = shortid();
286
- if (config$1.track && supported$1(window, "sessionStorage" /* SessionStorage */)) {
287
- var value = sessionStorage.getItem("_cltk" /* TabKey */);
288
- id = value ? value : id;
289
- sessionStorage.setItem("_cltk" /* TabKey */, id);
290
- }
291
- return id;
292
- }
293
- function save() {
294
- var ts = Math.round(Date.now());
295
- var upgrade = config$1.lean ? 0 /* False */ : 1 /* True */;
296
- var upload = config$1.upload && typeof config$1.upload === "string" /* String */ ? config$1.upload.replace("https://" /* HTTPS */, "" /* Empty */) : "" /* Empty */;
297
- if (upgrade && callback) {
298
- callback(data$i, !config$1.lean);
299
- }
300
- setCookie("_clsk" /* SessionKey */, [data$i.sessionId, ts, data$i.pageNum, upgrade, upload].join("|" /* Pipe */), 1 /* SessionExpire */);
301
- }
302
- function supported$1(target, api) {
303
- try {
304
- return !!target[api];
305
- }
306
- catch (_a) {
307
- return false;
308
- }
309
- }
310
- function track$6(u, consent) {
311
- if (consent === void 0) { consent = null; }
312
- // If consent is not explicitly specified, infer it from the user object
313
- consent = consent === null ? u.consent : consent;
314
- // Convert time precision into days to reduce number of bytes we have to write in a cookie
315
- // E.g. Math.ceil(1628735962643 / (24*60*60*1000)) => 18852 (days) => ejo in base36 (13 bytes => 3 bytes)
316
- var end = Math.ceil((Date.now() + (365 /* Expire */ * 86400000 /* Day */)) / 86400000 /* Day */);
317
- // To avoid cookie churn, write user id cookie only once every day
318
- if (u.expiry === null || Math.abs(end - u.expiry) >= 1 /* CookieInterval */ || u.consent !== consent) {
319
- setCookie("_clck" /* CookieKey */, [data$i.userId, 1 /* CookieVersion */, end.toString(36), consent].join("|" /* Pipe */), 365 /* Expire */);
320
- }
321
- }
322
- function shortid() {
323
- var id = Math.floor(Math.random() * Math.pow(2, 32));
324
- if (window && window.crypto && window.crypto.getRandomValues && Uint32Array) {
325
- id = window.crypto.getRandomValues(new Uint32Array(1))[0];
326
- }
327
- return id.toString(36);
328
- }
329
- function session() {
330
- var output = { session: shortid(), ts: Math.round(Date.now()), count: 1, upgrade: null, upload: "" /* Empty */ };
331
- var value = getCookie("_clsk" /* SessionKey */);
332
- if (value) {
333
- var parts = value.split("|" /* Pipe */);
334
- // Making it backward & forward compatible by using greater than comparison (v0.6.21)
335
- // In future version, we can reduce the parts length to be 5 where the last part contains the full upload URL
336
- if (parts.length >= 5 && output.ts - num$2(parts[1]) < 1800000 /* SessionTimeout */) {
337
- output.session = parts[0];
338
- output.count = num$2(parts[2]) + 1;
339
- output.upgrade = num$2(parts[3]);
340
- output.upload = parts.length >= 6 ? "" + "https://" /* HTTPS */ + parts[5] + "/" + parts[4] : "" + "https://" /* HTTPS */ + parts[4];
341
- }
342
- }
343
- return output;
344
- }
345
- function num$2(string, base) {
346
- if (base === void 0) { base = 10; }
347
- return parseInt(string, base);
348
- }
349
- function user() {
350
- var output = { id: shortid(), expiry: null, consent: 0 /* False */ };
351
- var cookie = getCookie("_clck" /* CookieKey */);
352
- if (cookie && cookie.length > 0) {
353
- // Splitting and looking up first part for forward compatibility, in case we wish to store additional information in a cookie
354
- var parts = cookie.split("|" /* Pipe */);
355
- // For backward compatibility introduced in v0.6.18; following code can be removed with future iterations
356
- // Count number of times Clarity's user cookie crumb appears in document.cookie (could be on different sub-domains e.g. www.domain.com and .domain.com)
357
- var count = 0;
358
- for (var _i = 0, _a = document.cookie.split(";" /* Semicolon */); _i < _a.length; _i++) {
359
- var c = _a[_i];
360
- count += c.split("=" /* Equals */)[0].trim() === "_clck" /* CookieKey */ ? 1 : 0;
361
- }
362
- // Check if we either got version-less cookie value or saw multiple copies of the user cookie crumbs
363
- // In both these cases, we go ahead and delete the existing cookie set on current domain
364
- if (parts.length === 1 || count > 1) {
365
- var deleted = "" + ";" /* Semicolon */ + "expires=" /* Expires */ + (new Date(0)).toUTCString() + ";path=/" /* Path */;
366
- // First, delete current user cookie which might be set on current sub-domain vs. root domain
367
- document.cookie = "_clck" /* CookieKey */ + "=" + deleted;
368
- // Second, same thing for current session cookie so it can be re-written later with the root domain
369
- document.cookie = "_clsk" /* SessionKey */ + "=" + deleted;
370
- }
371
- // End code for backward compatibility
372
- // Read version information and timestamp from cookie, if available
373
- if (parts.length > 2) {
374
- output.expiry = num$2(parts[2], 36);
375
- }
376
- // Check if we have explicit consent to track this user
377
- if (parts.length > 3 && num$2(parts[3]) === 1) {
378
- output.consent = 1 /* True */;
379
- }
380
- // Set track configuration to true for this user if we have explicit consent, regardless of project setting
381
- config$1.track = config$1.track || output.consent === 1 /* True */;
382
- // Get user id from cookie only if we tracking is enabled, otherwise fallback to a random id
383
- output.id = config$1.track ? parts[0] : output.id;
384
- }
385
- return output;
213
+ data$h = {};
214
+ updates$3 = {};
386
215
  }
387
- function getCookie(key) {
388
- if (supported$1(document, "cookie" /* Cookie */)) {
389
- var cookies = document.cookie.split(";" /* Semicolon */);
390
- if (cookies) {
391
- for (var i = 0; i < cookies.length; i++) {
392
- var pair = cookies[i].split("=" /* Equals */);
393
- if (pair.length > 1 && pair[0] && pair[0].trim() === key) {
394
- return pair[1];
395
- }
396
- }
397
- }
216
+ function count$1(metric, increment) {
217
+ if (increment === void 0) { increment = 1; }
218
+ if (!(metric in data$h)) {
219
+ data$h[metric] = 0;
398
220
  }
399
- return null;
400
- }
401
- function setCookie(key, value, time) {
402
- if (config$1.track && ((navigator && navigator.cookieEnabled) || supported$1(document, "cookie" /* Cookie */))) {
403
- var expiry = new Date();
404
- expiry.setDate(expiry.getDate() + time);
405
- var expires = expiry ? "expires=" /* Expires */ + expiry.toUTCString() : "" /* Empty */;
406
- var cookie = key + "=" + value + ";" /* Semicolon */ + expires + ";path=/" /* Path */;
407
- try {
408
- // Attempt to get the root domain only once and fall back to writing cookie on the current domain.
409
- if (rootDomain === null) {
410
- var hostname = location.hostname ? location.hostname.split("." /* Dot */) : [];
411
- // Walk backwards on a domain and attempt to set a cookie, until successful
412
- for (var i = hostname.length - 1; i >= 0; i--) {
413
- rootDomain = "." + hostname[i] + (rootDomain ? rootDomain : "" /* Empty */);
414
- // We do not wish to attempt writing a cookie on the absolute last part of the domain, e.g. .com or .net.
415
- // So we start attempting after second-last part, e.g. .domain.com (PASS) or .co.uk (FAIL)
416
- if (i < hostname.length - 1) {
417
- // Write the cookie on the current computed top level domain
418
- document.cookie = "" + cookie + ";" /* Semicolon */ + "domain=" /* Domain */ + rootDomain;
419
- // Once written, check if the cookie exists and its value matches exactly with what we intended to set
420
- // Checking for exact value match helps us eliminate a corner case where the cookie may already be present with a different value
421
- // If the check is successful, no more action is required and we can return from the function since rootDomain cookie is already set
422
- // If the check fails, continue with the for loop until we can successfully set and verify the cookie
423
- if (getCookie(key) === value) {
424
- return;
425
- }
426
- }
427
- }
428
- // Finally, if we were not successful and gone through all the options, play it safe and reset rootDomain to be empty
429
- // This forces our code to fall back to always writing cookie to the current domain
430
- rootDomain = "" /* Empty */;
431
- }
432
- }
433
- catch (_a) {
434
- rootDomain = "" /* Empty */;
435
- }
436
- document.cookie = rootDomain ? "" + cookie + ";" /* Semicolon */ + "domain=" /* Domain */ + rootDomain : cookie;
221
+ if (!(metric in updates$3)) {
222
+ updates$3[metric] = 0;
437
223
  }
438
- }
439
-
440
- var metadata$2 = /*#__PURE__*/Object.freeze({
441
- __proto__: null,
442
- get data () { return data$i; },
443
- get callback () { return callback; },
444
- start: start$B,
445
- stop: stop$y,
446
- metadata: metadata$1,
447
- id: id,
448
- consent: consent,
449
- clear: clear,
450
- save: save
451
- });
452
-
453
- var history$4;
454
- function reset$l() {
455
- history$4 = [];
224
+ data$h[metric] += increment;
225
+ updates$3[metric] += increment;
456
226
  }
457
- function report(check, message) {
458
- if (message === void 0) { message = null; }
459
- // Do not report the same message twice for the same page
460
- if (history$4 && history$4.indexOf(message) === -1) {
461
- var url = config$1.report;
462
- if (url && url.length > 0) {
463
- var payload = { c: check, p: data$i.projectId, u: data$i.userId, s: data$i.sessionId, n: data$i.pageNum };
464
- if (message)
465
- payload.m = message;
466
- // Using POST request instead of a GET request (img-src) to not violate existing CSP rules
467
- // Since, Clarity already uses XHR to upload data, we stick with similar POST mechanism for reporting too
468
- var xhr = new XMLHttpRequest();
469
- xhr.open("POST", url);
470
- xhr.send(JSON.stringify(payload));
471
- history$4.push(message);
227
+ function sum(metric, value) {
228
+ if (value !== null) {
229
+ if (!(metric in data$h)) {
230
+ data$h[metric] = 0;
472
231
  }
473
- }
474
- }
475
-
476
- var version$1 = "0.6.26";
477
-
478
- var data$h = null;
479
- function start$A() {
480
- var m = data$i;
481
- data$h = {
482
- version: version$1,
483
- sequence: 0,
484
- start: 0,
485
- duration: 0,
486
- projectId: m.projectId,
487
- userId: m.userId,
488
- sessionId: m.sessionId,
489
- pageNum: m.pageNum,
490
- upload: 0 /* Async */,
491
- end: 0 /* False */
492
- };
493
- }
494
- function stop$x() {
495
- data$h = null;
496
- }
497
- function envelope(last) {
498
- data$h.start = data$h.start + data$h.duration;
499
- data$h.duration = time() - data$h.start;
500
- data$h.sequence++;
501
- data$h.upload = last && "sendBeacon" in navigator ? 1 /* Beacon */ : 0 /* Async */;
502
- data$h.end = last ? 1 /* True */ : 0 /* False */;
503
- return [
504
- data$h.version,
505
- data$h.sequence,
506
- data$h.start,
507
- data$h.duration,
508
- data$h.projectId,
509
- data$h.userId,
510
- data$h.sessionId,
511
- data$h.pageNum,
512
- data$h.upload,
513
- data$h.end
514
- ];
515
- }
516
-
517
- var envelope$1 = /*#__PURE__*/Object.freeze({
518
- __proto__: null,
519
- get data () { return data$h; },
520
- start: start$A,
521
- stop: stop$x,
522
- envelope: envelope
523
- });
524
-
525
- var data$g;
526
- function start$z() {
527
- data$g = { check: 0 /* None */ };
528
- }
529
- function check$3(bytes) {
530
- if (data$g.check === 0 /* None */) {
531
- var reason = data$g.check;
532
- reason = data$h.sequence >= 128 /* PayloadLimit */ ? 1 /* Payload */ : reason;
533
- reason = time() > 7200000 /* ShutdownLimit */ ? 2 /* Shutdown */ : reason;
534
- reason = bytes > 10485760 /* PlaybackBytesLimit */ ? 2 /* Shutdown */ : reason;
535
- if (reason !== data$g.check) {
536
- trigger$1(reason);
232
+ if (!(metric in updates$3)) {
233
+ updates$3[metric] = 0;
537
234
  }
235
+ data$h[metric] += value;
236
+ updates$3[metric] += value;
538
237
  }
539
238
  }
540
- function trigger$1(reason) {
541
- report(reason);
542
- data$g.check = reason;
543
- clear();
544
- stop();
545
- }
546
- function compute$a() {
547
- if (data$g.check !== 0 /* None */) {
548
- encode$1(35 /* Limit */);
549
- }
550
- }
551
- function stop$w() {
552
- data$g = null;
553
- }
554
-
555
- var limit = /*#__PURE__*/Object.freeze({
556
- __proto__: null,
557
- get data () { return data$g; },
558
- start: start$z,
559
- check: check$3,
560
- trigger: trigger$1,
561
- compute: compute$a,
562
- stop: stop$w
563
- });
564
-
565
- var data$f = null;
566
- var updates$3 = null;
567
- function start$y() {
568
- data$f = {};
569
- updates$3 = {};
570
- }
571
- function stop$v() {
572
- data$f = {};
573
- updates$3 = {};
574
- }
575
- function log$1(dimension, value) {
576
- // Check valid value before moving ahead
577
- if (value) {
578
- // Ensure received value is casted into a string if it wasn't a string to begin with
579
- value = "" + value;
580
- if (!(dimension in data$f)) {
581
- data$f[dimension] = [];
239
+ function max(metric, value) {
240
+ // Ensure that we do not process null or NaN values
241
+ if (value !== null && isNaN(value) === false) {
242
+ if (!(metric in data$h)) {
243
+ data$h[metric] = 0;
582
244
  }
583
- if (data$f[dimension].indexOf(value) < 0) {
584
- data$f[dimension].push(value);
585
- // If this is a new value, track it as part of updates object
586
- // This allows us to only send back new values in subsequent payloads
587
- if (!(dimension in updates$3)) {
588
- updates$3[dimension] = [];
589
- }
590
- updates$3[dimension].push(value);
591
- // Limit check to ensure we have a cap on number of dimensions we can collect
592
- if (data$f[dimension].length > 128 /* CollectionLimit */) {
593
- trigger$1(5 /* Collection */);
594
- }
245
+ if (value > data$h[metric] || data$h[metric] === 0) {
246
+ updates$3[metric] = value;
247
+ data$h[metric] = value;
595
248
  }
596
249
  }
597
250
  }
598
- function compute$9() {
599
- encode$1(1 /* Dimension */);
251
+ function compute$b() {
252
+ encode$1(0 /* Metric */);
600
253
  }
601
- function reset$k() {
254
+ function reset$n() {
602
255
  updates$3 = {};
603
256
  }
604
257
 
605
- var dimension = /*#__PURE__*/Object.freeze({
606
- __proto__: null,
607
- get data () { return data$f; },
608
- get updates () { return updates$3; },
609
- start: start$y,
610
- stop: stop$v,
611
- log: log$1,
612
- compute: compute$9,
613
- reset: reset$k
614
- });
615
-
616
258
  function setTimeout(handler, timeout, event) {
617
259
  return window.setTimeout(measure(handler), timeout, event);
618
260
  }
@@ -620,15 +262,15 @@ function clearTimeout(handle) {
620
262
  return window.clearTimeout(handle);
621
263
  }
622
264
 
623
- var data$e;
265
+ var data$g;
624
266
  var last = 0;
625
267
  var interval = 0;
626
268
  var timeout$6 = null;
627
- function start$x() {
269
+ function start$B() {
628
270
  interval = 60000 /* PingInterval */;
629
271
  last = 0;
630
272
  }
631
- function reset$j() {
273
+ function reset$m() {
632
274
  if (timeout$6) {
633
275
  clearTimeout(timeout$6);
634
276
  }
@@ -637,16 +279,16 @@ function reset$j() {
637
279
  }
638
280
  function ping() {
639
281
  var now = time();
640
- data$e = { gap: now - last };
282
+ data$g = { gap: now - last };
641
283
  encode$1(25 /* Ping */);
642
- if (data$e.gap < 300000 /* PingTimeout */) {
284
+ if (data$g.gap < 300000 /* PingTimeout */) {
643
285
  timeout$6 = setTimeout(ping, interval);
644
286
  }
645
287
  else {
646
288
  suspend();
647
289
  }
648
290
  }
649
- function stop$u() {
291
+ function stop$y() {
650
292
  clearTimeout(timeout$6);
651
293
  last = 0;
652
294
  interval = 0;
@@ -654,59 +296,59 @@ function stop$u() {
654
296
 
655
297
  var ping$1 = /*#__PURE__*/Object.freeze({
656
298
  __proto__: null,
657
- get data () { return data$e; },
658
- start: start$x,
659
- reset: reset$j,
660
- stop: stop$u
299
+ get data () { return data$g; },
300
+ start: start$B,
301
+ reset: reset$m,
302
+ stop: stop$y
661
303
  });
662
304
 
663
- var data$d = null;
664
- function start$w() {
665
- data$d = {};
305
+ var data$f = null;
306
+ function start$A() {
307
+ data$f = {};
666
308
  }
667
- function stop$t() {
668
- data$d = {};
309
+ function stop$x() {
310
+ data$f = {};
669
311
  }
670
- function track$5(event, time) {
671
- if (!(event in data$d)) {
672
- data$d[event] = [[time, 0]];
312
+ function track$6(event, time) {
313
+ if (!(event in data$f)) {
314
+ data$f[event] = [[time, 0]];
673
315
  }
674
316
  else {
675
- var e = data$d[event];
317
+ var e = data$f[event];
676
318
  var last = e[e.length - 1];
677
319
  // Add a new entry only if the new event occurs after configured interval
678
320
  // Otherwise, extend the duration of the previous entry
679
321
  if (time - last[0] > 100 /* SummaryInterval */) {
680
- data$d[event].push([time, 0]);
322
+ data$f[event].push([time, 0]);
681
323
  }
682
324
  else {
683
325
  last[1] = time - last[0];
684
326
  }
685
327
  }
686
328
  }
687
- function compute$8() {
329
+ function compute$a() {
688
330
  encode$1(36 /* Summary */);
689
331
  }
690
- function reset$i() {
691
- data$d = {};
332
+ function reset$l() {
333
+ data$f = {};
692
334
  }
693
335
 
694
336
  var summary = /*#__PURE__*/Object.freeze({
695
337
  __proto__: null,
696
- get data () { return data$d; },
697
- start: start$w,
698
- stop: stop$t,
699
- track: track$5,
700
- compute: compute$8,
701
- reset: reset$i
338
+ get data () { return data$f; },
339
+ start: start$A,
340
+ stop: stop$x,
341
+ track: track$6,
342
+ compute: compute$a,
343
+ reset: reset$l
702
344
  });
703
345
 
704
- var data$c = null;
705
- function start$v() {
346
+ var data$e = null;
347
+ function start$z() {
706
348
  if (!config$1.lean && config$1.upgrade) {
707
349
  config$1.upgrade("Config" /* Config */);
708
350
  }
709
- data$c = null;
351
+ data$e = null;
710
352
  }
711
353
  // Following call will upgrade the session from lean mode into the full mode retroactively from the start of the page.
712
354
  // As part of the lean mode, we do not send back any layout information - including discovery of DOM and mutations.
@@ -716,7 +358,7 @@ function upgrade(key) {
716
358
  // Upgrade only if Clarity was successfully activated on the page
717
359
  if (active() && config$1.lean) {
718
360
  config$1.lean = false;
719
- data$c = { key: key };
361
+ data$e = { key: key };
720
362
  // Update metadata to track we have upgraded this session
721
363
  save();
722
364
  // Callback upgrade handler, if configured
@@ -726,16 +368,67 @@ function upgrade(key) {
726
368
  encode$1(3 /* Upgrade */);
727
369
  }
728
370
  }
729
- function stop$s() {
730
- data$c = null;
371
+ function stop$w() {
372
+ data$e = null;
731
373
  }
732
374
 
733
375
  var upgrade$1 = /*#__PURE__*/Object.freeze({
734
376
  __proto__: null,
735
- get data () { return data$c; },
736
- start: start$v,
377
+ get data () { return data$e; },
378
+ start: start$z,
737
379
  upgrade: upgrade,
738
- stop: stop$s
380
+ stop: stop$w
381
+ });
382
+
383
+ var data$d = null;
384
+ function start$y() {
385
+ reset$k();
386
+ }
387
+ function set(variable, value) {
388
+ var values = typeof value === "string" /* String */ ? [value] : value;
389
+ log$2(variable, values);
390
+ }
391
+ function identify(userId, sessionId, pageId) {
392
+ if (sessionId === void 0) { sessionId = null; }
393
+ if (pageId === void 0) { pageId = null; }
394
+ log$2("userId" /* UserId */, [userId]);
395
+ log$2("sessionId" /* SessionId */, [sessionId]);
396
+ log$2("pageId" /* PageId */, [pageId]);
397
+ }
398
+ function log$2(variable, value) {
399
+ if (active() &&
400
+ variable &&
401
+ value &&
402
+ typeof variable === "string" /* String */ &&
403
+ variable.length < 255) {
404
+ var validValues = variable in data$d ? data$d[variable] : [];
405
+ for (var i = 0; i < value.length; i++) {
406
+ if (typeof value[i] === "string" /* String */ && value[i].length < 255) {
407
+ validValues.push(value[i]);
408
+ }
409
+ }
410
+ data$d[variable] = validValues;
411
+ }
412
+ }
413
+ function compute$9() {
414
+ encode$1(34 /* Variable */);
415
+ }
416
+ function reset$k() {
417
+ data$d = {};
418
+ }
419
+ function stop$v() {
420
+ reset$k();
421
+ }
422
+
423
+ var variable = /*#__PURE__*/Object.freeze({
424
+ __proto__: null,
425
+ get data () { return data$d; },
426
+ start: start$y,
427
+ set: set,
428
+ identify: identify,
429
+ compute: compute$9,
430
+ reset: reset$k,
431
+ stop: stop$v
739
432
  });
740
433
 
741
434
  /*! *****************************************************************************
@@ -791,7 +484,7 @@ function __generator(thisArg, body) {
791
484
  }
792
485
  }
793
486
 
794
- var supported = "CompressionStream" /* CompressionStream */ in window;
487
+ var supported$1 = "CompressionStream" /* CompressionStream */ in window;
795
488
  function compress (input) {
796
489
  return __awaiter(this, void 0, void 0, function () {
797
490
  var stream, _a;
@@ -799,7 +492,7 @@ function compress (input) {
799
492
  switch (_c.label) {
800
493
  case 0:
801
494
  _c.trys.push([0, 3, , 4]);
802
- if (!supported) return [3 /*break*/, 2];
495
+ if (!supported$1) return [3 /*break*/, 2];
803
496
  stream = new ReadableStream({ start: function (controller) {
804
497
  return __awaiter(this, void 0, void 0, function () {
805
498
  return __generator(this, function (_a) {
@@ -849,27 +542,27 @@ function read(stream) {
849
542
  });
850
543
  }
851
544
 
852
- var modules$1 = [baseline, dimension, variable, limit, summary, metadata$2, envelope$1, upload$1, ping$1, upgrade$1];
853
- function start$u() {
545
+ var modules$1 = [baseline, dimension, variable, limit, summary, metadata$1, envelope$1, upload$1, ping$1, upgrade$1];
546
+ function start$x() {
854
547
  // Metric needs to be initialized before we can start measuring. so metric is not wrapped in measure
855
- start$9();
548
+ start$C();
856
549
  modules$1.forEach(function (x) { return measure(x.start)(); });
857
550
  }
858
- function stop$r() {
551
+ function stop$u() {
859
552
  // Stop modules in the reverse order of their initialization
860
553
  // The ordering below should respect inter-module dependency.
861
554
  // E.g. if upgrade depends on upload, then upgrade needs to end before upload.
862
555
  // Similarly, if upload depends on metadata, upload needs to end before metadata.
863
556
  modules$1.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
864
- stop$8();
557
+ stop$z();
865
558
  }
866
- function compute$7() {
867
- compute$b();
868
- compute$c();
559
+ function compute$8() {
869
560
  compute$9();
561
+ compute$c();
870
562
  compute$2();
871
- compute$8();
563
+ compute$b();
872
564
  compute$a();
565
+ compute$3();
873
566
  }
874
567
 
875
568
  function scrub (value, hint, privacy, mangle) {
@@ -991,7 +684,7 @@ function resume$1() {
991
684
  }
992
685
  }
993
686
  }
994
- function reset$h() {
687
+ function reset$j() {
995
688
  tracker = {};
996
689
  queuedTasks = [];
997
690
  activeTask = null;
@@ -1045,14 +738,14 @@ function run() {
1045
738
  return;
1046
739
  }
1047
740
  if (error) {
1048
- log(0 /* RunTask */, 1 /* Warning */, error.name, error.message, error.stack);
741
+ log$1(0 /* RunTask */, 1 /* Warning */, error.name, error.message, error.stack);
1049
742
  }
1050
743
  activeTask = null;
1051
744
  run();
1052
745
  });
1053
746
  }
1054
747
  }
1055
- function state$6(timer) {
748
+ function state$8(timer) {
1056
749
  var id = key(timer);
1057
750
  if (id in tracker) {
1058
751
  var elapsed = performance.now() - tracker[id].start;
@@ -1061,7 +754,7 @@ function state$6(timer) {
1061
754
  // If this task is no longer being tracked, send stop message to the caller
1062
755
  return 2 /* Stop */;
1063
756
  }
1064
- function start$t(timer) {
757
+ function start$w(timer) {
1065
758
  tracker[key(timer)] = { start: performance.now(), calls: 0, yield: 30 /* LongTask */ };
1066
759
  }
1067
760
  function restart$1(timer) {
@@ -1069,12 +762,12 @@ function restart$1(timer) {
1069
762
  if (tracker && tracker[id]) {
1070
763
  var c = tracker[id].calls;
1071
764
  var y = tracker[id].yield;
1072
- start$t(timer);
765
+ start$w(timer);
1073
766
  tracker[id].calls = c + 1;
1074
767
  tracker[id].yield = y;
1075
768
  }
1076
769
  }
1077
- function stop$q(timer) {
770
+ function stop$t(timer) {
1078
771
  var end = performance.now();
1079
772
  var id = key(timer);
1080
773
  var duration = end - tracker[id].start;
@@ -1094,7 +787,7 @@ function suspend$1(timer) {
1094
787
  case 0:
1095
788
  id = key(timer);
1096
789
  if (!(id in tracker)) return [3 /*break*/, 2];
1097
- stop$q(timer);
790
+ stop$t(timer);
1098
791
  _a = tracker[id];
1099
792
  return [4 /*yield*/, wait()];
1100
793
  case 1:
@@ -1163,21 +856,6 @@ function requestIdleCallbackPolyfill(callback, options) {
1163
856
  }
1164
857
  var requestIdleCallback = window["requestIdleCallback"] || requestIdleCallbackPolyfill;
1165
858
 
1166
- var data$b;
1167
- function start$s() {
1168
- bind(document, "error", handler$5, true);
1169
- }
1170
- function handler$5(error) {
1171
- var element = error.target;
1172
- if (element && element.tagName === "IMG") {
1173
- data$b = { source: element.src, target: element };
1174
- schedule$1(encode$3.bind(this, 32 /* ImageError */));
1175
- }
1176
- }
1177
- function stop$p() {
1178
- data$b = null;
1179
- }
1180
-
1181
859
  // Following code takes an array of tokens and transforms it to optimize for repeating tokens and make it efficient to send over the wire
1182
860
  // The way it works is that it iterate over all tokens and checks if the current token was already seen in the tokens array so far
1183
861
  // If so, it replaces the token with its reference (index). This helps us save bytes by not repeating the same value twice.
@@ -1221,15 +899,15 @@ function tokenize (tokens) {
1221
899
  return output;
1222
900
  }
1223
901
 
1224
- var data$a;
1225
- function reset$g() {
1226
- data$a = null;
902
+ var data$c;
903
+ function reset$i() {
904
+ data$c = null;
1227
905
  }
1228
- function start$r() {
1229
- reset$g();
1230
- compute$6();
906
+ function start$v() {
907
+ reset$i();
908
+ compute$7();
1231
909
  }
1232
- function compute$6() {
910
+ function compute$7() {
1233
911
  var body = document.body;
1234
912
  var d = document.documentElement;
1235
913
  var bodyClientWidth = body ? body.clientWidth : null;
@@ -1247,13 +925,13 @@ function compute$6() {
1247
925
  var documentOffsetHeight = d ? d.offsetHeight : null;
1248
926
  var height = Math.max(bodyClientHeight, bodyScrollHeight, bodyOffsetHeight, documentClientHeight, documentScrollHeight, documentOffsetHeight);
1249
927
  // Check that width or height has changed from before, and also that width & height are not null values
1250
- if ((data$a === null || width !== data$a.width || height !== data$a.height) && width !== null && height !== null) {
1251
- data$a = { width: width, height: height };
928
+ if ((data$c === null || width !== data$c.width || height !== data$c.height) && width !== null && height !== null) {
929
+ data$c = { width: width, height: height };
1252
930
  encode$4(8 /* Document */);
1253
931
  }
1254
932
  }
1255
933
  function end() {
1256
- reset$g();
934
+ reset$i();
1257
935
  }
1258
936
 
1259
937
  function encode$4 (type, timer, ts) {
@@ -1276,14 +954,14 @@ function encode$4 (type, timer, ts) {
1276
954
  }
1277
955
  return [3 /*break*/, 11];
1278
956
  case 1:
1279
- d = data$a;
957
+ d = data$c;
1280
958
  tokens.push(d.width);
1281
959
  tokens.push(d.height);
1282
960
  track$7(type, d.width, d.height);
1283
961
  queue(tokens);
1284
962
  return [3 /*break*/, 11];
1285
963
  case 2:
1286
- for (_i = 0, _b = state$5; _i < _b.length; _i++) {
964
+ for (_i = 0, _b = state$7; _i < _b.length; _i++) {
1287
965
  r = _b[_i];
1288
966
  tokens = [r.time, 7 /* Region */];
1289
967
  tokens.push(r.data.id);
@@ -1292,22 +970,22 @@ function encode$4 (type, timer, ts) {
1292
970
  tokens.push(r.data.name);
1293
971
  queue(tokens);
1294
972
  }
1295
- reset$d();
973
+ reset$f();
1296
974
  return [3 /*break*/, 11];
1297
975
  case 3:
1298
- b = data$9;
976
+ b = data$b;
1299
977
  for (_c = 0, b_1 = b; _c < b_1.length; _c++) {
1300
978
  entry = b_1[_c];
1301
979
  tokens.push(entry.id);
1302
980
  tokens.push(entry.width);
1303
981
  tokens.push(entry.height);
1304
982
  }
1305
- reset$f();
983
+ reset$h();
1306
984
  queue(tokens);
1307
985
  return [3 /*break*/, 11];
1308
986
  case 4:
1309
987
  // Check if we are operating within the context of the current page
1310
- if (state$6(timer) === 2 /* Stop */) {
988
+ if (state$8(timer) === 2 /* Stop */) {
1311
989
  return [3 /*break*/, 11];
1312
990
  }
1313
991
  values = updates$2();
@@ -1317,7 +995,7 @@ function encode$4 (type, timer, ts) {
1317
995
  case 5:
1318
996
  if (!(_d < values_1.length)) return [3 /*break*/, 9];
1319
997
  value = values_1[_d];
1320
- state = state$6(timer);
998
+ state = state$8(timer);
1321
999
  if (!(state === 0 /* Wait */)) return [3 /*break*/, 7];
1322
1000
  return [4 /*yield*/, suspend$1(timer)];
1323
1001
  case 6:
@@ -1333,7 +1011,7 @@ function encode$4 (type, timer, ts) {
1333
1011
  privacy = value.metadata.privacy;
1334
1012
  mangle = shouldMangle(value);
1335
1013
  keys = active ? ["tag", "attributes", "value"] : ["tag"];
1336
- compute$5(value.id);
1014
+ compute$6(value.id);
1337
1015
  for (_e = 0, keys_1 = keys; _e < keys_1.length; _e++) {
1338
1016
  key = keys_1[_e];
1339
1017
  if (data[key]) {
@@ -1350,7 +1028,7 @@ function encode$4 (type, timer, ts) {
1350
1028
  }
1351
1029
  tokens.push(suspend ? "*M" /* SuspendMutationTag */ : data[key]);
1352
1030
  if (size && size.length === 2) {
1353
- tokens.push("" + "#" /* Box */ + str(size[0]) + "." + str(size[1]));
1031
+ tokens.push("" + "#" /* Box */ + str$1(size[0]) + "." + str$1(size[1]));
1354
1032
  }
1355
1033
  break;
1356
1034
  case "attributes":
@@ -1386,22 +1064,22 @@ function shouldMangle(value) {
1386
1064
  var privacy = value.metadata.privacy;
1387
1065
  return value.data.tag === "*T" /* TextTag */ && !(privacy === 0 /* None */ || privacy === 1 /* Sensitive */);
1388
1066
  }
1389
- function str(input) {
1067
+ function str$1(input) {
1390
1068
  return input.toString(36);
1391
1069
  }
1392
1070
  function attribute(key, value, privacy) {
1393
1071
  return key + "=" + scrub(value, key, privacy);
1394
1072
  }
1395
1073
 
1396
- var data$9 = [];
1074
+ var data$b = [];
1397
1075
  var enabled = false;
1398
1076
  var observer$2 = null;
1399
- function start$q() {
1400
- reset$f();
1077
+ function start$u() {
1078
+ reset$h();
1401
1079
  observer$2 = null;
1402
1080
  enabled = window["ResizeObserver"] ? true : false;
1403
1081
  }
1404
- function compute$5(id) {
1082
+ function compute$6(id) {
1405
1083
  if (enabled === false) {
1406
1084
  return;
1407
1085
  }
@@ -1449,21 +1127,21 @@ function handler$4(entries) {
1449
1127
  // Capture new width & height only if they are different from what we have in in-memory cache
1450
1128
  if (w !== s[0] && h !== s[1]) {
1451
1129
  s = [w, h];
1452
- data$9.push({ id: id, width: w, height: h });
1130
+ data$b.push({ id: id, width: w, height: h });
1453
1131
  }
1454
1132
  }
1455
1133
  }
1456
1134
  // Schedule encode only when we have at least one valid data entry
1457
- if (data$9.length > 0) {
1135
+ if (data$b.length > 0) {
1458
1136
  encode$4(37 /* Box */);
1459
1137
  }
1460
1138
  });
1461
1139
  }
1462
- function reset$f() {
1463
- data$9 = [];
1140
+ function reset$h() {
1141
+ data$b = [];
1464
1142
  }
1465
- function stop$o() {
1466
- reset$f();
1143
+ function stop$s() {
1144
+ reset$h();
1467
1145
  if (observer$2) {
1468
1146
  observer$2.disconnect();
1469
1147
  observer$2 = null;
@@ -1471,25 +1149,25 @@ function stop$o() {
1471
1149
  enabled = false;
1472
1150
  }
1473
1151
 
1474
- var history$3 = {};
1475
- var data$8;
1476
- function start$p() {
1152
+ var history$4 = {};
1153
+ var data$a;
1154
+ function start$t() {
1477
1155
  bind(window, "error", handler$3);
1478
- history$3 = {};
1156
+ history$4 = {};
1479
1157
  }
1480
1158
  function handler$3(error) {
1481
1159
  var e = error["error"] || error;
1482
1160
  // While rare, it's possible for code to fail repeatedly during the lifetime of the same page
1483
1161
  // In those cases, we only want to log the failure first few times and not spam logs with redundant information.
1484
- if (!(e.message in history$3)) {
1485
- history$3[e.message] = 0;
1162
+ if (!(e.message in history$4)) {
1163
+ history$4[e.message] = 0;
1486
1164
  }
1487
- if (history$3[e.message]++ >= 5 /* ScriptErrorLimit */) {
1165
+ if (history$4[e.message]++ >= 5 /* ScriptErrorLimit */) {
1488
1166
  return true;
1489
1167
  }
1490
1168
  // Send back information only if the handled error has valid information
1491
1169
  if (e && e.message) {
1492
- data$8 = {
1170
+ data$a = {
1493
1171
  message: e.message,
1494
1172
  line: error["lineno"],
1495
1173
  column: error["colno"],
@@ -1501,7 +1179,7 @@ function handler$3(error) {
1501
1179
  // Even though it doesn't impact user experience, or show up in console, it can still flood error reporting through on error
1502
1180
  // To mitigate that, we turn off Clarity's ResizeObserver on getting the first instance of this error
1503
1181
  if (e.message.indexOf("ResizeObserver" /* ResizeObserver */) >= 0) {
1504
- stop$o();
1182
+ stop$s();
1505
1183
  return false;
1506
1184
  }
1507
1185
  encode$3(31 /* ScriptError */);
@@ -1511,33 +1189,25 @@ function handler$3(error) {
1511
1189
 
1512
1190
  function encode$3 (type) {
1513
1191
  return __awaiter(this, void 0, void 0, function () {
1514
- var tokens, imageTarget;
1192
+ var tokens;
1515
1193
  return __generator(this, function (_a) {
1516
1194
  tokens = [time(), type];
1517
1195
  switch (type) {
1518
1196
  case 31 /* ScriptError */:
1519
- tokens.push(data$8.message);
1520
- tokens.push(data$8.line);
1521
- tokens.push(data$8.column);
1522
- tokens.push(data$8.stack);
1523
- tokens.push(data$8.source);
1197
+ tokens.push(data$a.message);
1198
+ tokens.push(data$a.line);
1199
+ tokens.push(data$a.column);
1200
+ tokens.push(data$a.stack);
1201
+ tokens.push(data$a.source);
1524
1202
  queue(tokens);
1525
1203
  break;
1526
- case 32 /* ImageError */:
1527
- if (data$b) {
1528
- imageTarget = metadata(data$b.target, type);
1529
- tokens.push(data$b.source);
1530
- tokens.push(imageTarget.id);
1531
- queue(tokens);
1532
- }
1533
- break;
1534
1204
  case 33 /* Log */:
1535
- if (data$7) {
1536
- tokens.push(data$7.code);
1537
- tokens.push(data$7.name);
1538
- tokens.push(data$7.message);
1539
- tokens.push(data$7.stack);
1540
- tokens.push(data$7.severity);
1205
+ if (data$9) {
1206
+ tokens.push(data$9.code);
1207
+ tokens.push(data$9.name);
1208
+ tokens.push(data$9.message);
1209
+ tokens.push(data$9.stack);
1210
+ tokens.push(data$9.severity);
1541
1211
  queue(tokens, false);
1542
1212
  }
1543
1213
  break;
@@ -1547,29 +1217,29 @@ function encode$3 (type) {
1547
1217
  });
1548
1218
  }
1549
1219
 
1550
- var history$2 = {};
1551
- var data$7;
1552
- function start$o() {
1553
- history$2 = {};
1220
+ var history$3 = {};
1221
+ var data$9;
1222
+ function start$s() {
1223
+ history$3 = {};
1554
1224
  bind(document, "securitypolicyviolation", csp);
1555
1225
  }
1556
- function log(code, severity, name, message, stack) {
1226
+ function log$1(code, severity, name, message, stack) {
1557
1227
  if (name === void 0) { name = null; }
1558
1228
  if (message === void 0) { message = null; }
1559
1229
  if (stack === void 0) { stack = null; }
1560
1230
  var key = name ? name + "|" + message : "";
1561
1231
  // While rare, it's possible for code to fail repeatedly during the lifetime of the same page
1562
1232
  // In those cases, we only want to log the failure once and not spam logs with redundant information.
1563
- if (code in history$2 && history$2[code].indexOf(key) >= 0) {
1233
+ if (code in history$3 && history$3[code].indexOf(key) >= 0) {
1564
1234
  return;
1565
1235
  }
1566
- data$7 = { code: code, name: name, message: message, stack: stack, severity: severity };
1236
+ data$9 = { code: code, name: name, message: message, stack: stack, severity: severity };
1567
1237
  // Maintain history of errors in memory to avoid sending redundant information
1568
- if (code in history$2) {
1569
- history$2[code].push(key);
1238
+ if (code in history$3) {
1239
+ history$3[code].push(key);
1570
1240
  }
1571
1241
  else {
1572
- history$2[code] = [key];
1242
+ history$3[code] = [key];
1573
1243
  }
1574
1244
  encode$3(33 /* Log */);
1575
1245
  }
@@ -1579,11 +1249,11 @@ function csp(e) {
1579
1249
  var domain = parts.length >= 2 ? parts.splice(-2).join("." /* Dot */) : null;
1580
1250
  // Capture content security policy violation only if disposition value is not explicitly set to "report"
1581
1251
  if (domain && e.blockedURI && e.blockedURI.indexOf(domain) >= 0 && e["disposition"] !== "report" /* Report */) {
1582
- log(7 /* ContentSecurityPolicy */, 1 /* Warning */, e.blockedURI);
1252
+ log$1(7 /* ContentSecurityPolicy */, 1 /* Warning */, e.blockedURI);
1583
1253
  }
1584
1254
  }
1585
- function stop$n() {
1586
- history$2 = {};
1255
+ function stop$r() {
1256
+ history$3 = {};
1587
1257
  }
1588
1258
 
1589
1259
  var formatRegex = /1/g;
@@ -1603,7 +1273,7 @@ function regions$1(root, value) {
1603
1273
  break;
1604
1274
  }
1605
1275
  if (valid) {
1606
- root.querySelectorAll(selector).forEach(function (e) { return observe$9(e, regionId.toString()); });
1276
+ root.querySelectorAll(selector).forEach(function (e) { return observe$b(e, regionId.toString()); });
1607
1277
  }
1608
1278
  };
1609
1279
  for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
@@ -1617,10 +1287,10 @@ function metrics(root, value) {
1617
1287
  if (match) {
1618
1288
  switch (source) {
1619
1289
  case 0 /* Text */:
1620
- root.querySelectorAll(match).forEach(function (e) { max(metricId, num$1(e.innerText, scale)); });
1290
+ root.querySelectorAll(match).forEach(function (e) { max(metricId, num$2(e.innerText, scale)); });
1621
1291
  break;
1622
1292
  case 2 /* Attribute */:
1623
- root.querySelectorAll("[" + match + "]").forEach(function (e) { max(metricId, num$1(e.getAttribute(match), scale, false)); });
1293
+ root.querySelectorAll("[" + match + "]").forEach(function (e) { max(metricId, num$2(e.getAttribute(match), scale, false)); });
1624
1294
  break;
1625
1295
  case 1 /* Javascript */:
1626
1296
  max(metricId, evaluate(match, "number" /* Number */));
@@ -1633,6 +1303,28 @@ function metrics(root, value) {
1633
1303
  _loop_2(v);
1634
1304
  }
1635
1305
  }
1306
+ function dimensions(root, value) {
1307
+ var _loop_3 = function (v) {
1308
+ var dimensionId = v[0], source = v[1], match = v[2];
1309
+ if (match) {
1310
+ switch (source) {
1311
+ case 0 /* Text */:
1312
+ root.querySelectorAll(match).forEach(function (e) { log(dimensionId, str(e.innerText)); });
1313
+ break;
1314
+ case 2 /* Attribute */:
1315
+ root.querySelectorAll("[" + match + "]").forEach(function (e) { log(dimensionId, str(e.getAttribute(match))); });
1316
+ break;
1317
+ case 1 /* Javascript */:
1318
+ log(dimensionId, str(evaluate(match, "string" /* String */)));
1319
+ break;
1320
+ }
1321
+ }
1322
+ };
1323
+ for (var _i = 0, value_3 = value; _i < value_3.length; _i++) {
1324
+ var v = value_3[_i];
1325
+ _loop_3(v);
1326
+ }
1327
+ }
1636
1328
  function regex(match) {
1637
1329
  regexCache[match] = match in regexCache ? regexCache[match] : new RegExp(match);
1638
1330
  return regexCache[match];
@@ -1654,7 +1346,11 @@ function evaluate(variable, type, base) {
1654
1346
  }
1655
1347
  return null;
1656
1348
  }
1657
- function num$1(text, scale, localize) {
1349
+ function str(input) {
1350
+ // Automatically trim string to max of Setting.DimensionLimit to avoid fetching long strings
1351
+ return input ? input.substr(0, 256 /* DimensionLimit */) : input;
1352
+ }
1353
+ function num$2(text, scale, localize) {
1658
1354
  if (localize === void 0) { localize = true; }
1659
1355
  try {
1660
1356
  scale = scale || 1;
@@ -1703,12 +1399,13 @@ function selector (input, beta) {
1703
1399
  var selector = "" + prefix + input.tag + suffix;
1704
1400
  var classes = "class" /* Class */ in a && a["class" /* Class */].length > 0 ? a["class" /* Class */].trim().split(/\s+/) : null;
1705
1401
  if (beta) {
1706
- // In beta mode, update selector to use "id" field when available
1707
- // The only exception is if "id" appears to be an auto generated string token, e.g. guid or a random id
1402
+ // In beta mode, update selector to use "id" field when available. There are two exceptions:
1403
+ // (1) if "id" appears to be an auto generated string token, e.g. guid or a random id containing digits
1404
+ // (2) if "id" appears inside a shadow DOM, in which case we continue to prefix up to shadow DOM to prevent conflicts
1708
1405
  var id = "id" /* Id */ in a && a["id" /* Id */].length > 0 ? a["id" /* Id */] : null;
1709
1406
  classes = input.tag !== "BODY" /* BodyTag */ && classes ? classes.filter(function (c) { return !hasDigits(c); }) : [];
1710
1407
  selector = classes.length > 0 ? "" + prefix + input.tag + "." + classes.join(".") + suffix : selector;
1711
- selector = id && hasDigits(id) === false ? "#" + id : selector;
1408
+ selector = id && hasDigits(id) === false ? getDomPrefix(prefix) + "#" + id : selector;
1712
1409
  }
1713
1410
  else {
1714
1411
  // Otherwise, fallback to stable mode, where we include class names as part of the selector
@@ -1717,11 +1414,23 @@ function selector (input, beta) {
1717
1414
  return selector;
1718
1415
  }
1719
1416
  }
1417
+ function getDomPrefix(prefix) {
1418
+ var shadowDomStart = prefix.lastIndexOf("*S" /* ShadowDomTag */);
1419
+ var iframeDomStart = prefix.lastIndexOf("" + "iframe:" /* IFramePrefix */ + "HTML" /* HTML */);
1420
+ var domStart = Math.max(shadowDomStart, iframeDomStart);
1421
+ if (domStart < 0) {
1422
+ return "";
1423
+ }
1424
+ var domEnd = prefix.indexOf(">", domStart) + 1;
1425
+ return prefix.substr(0, domEnd);
1426
+ }
1720
1427
  // Check if the given input string has digits or not
1721
1428
  function hasDigits(value) {
1722
1429
  for (var i = 0; i < value.length; i++) {
1723
1430
  var c = value.charCodeAt(i);
1724
- return c >= 48 /* Zero */ && c <= 57 /* Nine */;
1431
+ if (c >= 48 /* Zero */ && c <= 57 /* Nine */) {
1432
+ return true;
1433
+ }
1725
1434
  }
1726
1435
  return false;
1727
1436
  }
@@ -1729,7 +1438,7 @@ function hasDigits(value) {
1729
1438
  var index = 1;
1730
1439
  // Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#%3Cinput%3E_types
1731
1440
  var DISALLOWED_TYPES = ["password", "hidden", "email", "tel"];
1732
- var DISALLOWED_NAMES = ["addr", "cell", "code", "dob", "email", "mob", "name", "phone", "secret", "social", "ssn", "tel", "zip", "pass"];
1441
+ var DISALLOWED_NAMES = ["addr", "cell", "code", "dob", "email", "mob", "name", "phone", "secret", "social", "ssn", "tel", "zip", "pass", "card", "account", "cvv", "ccv"];
1733
1442
  var DISALLOWED_MATCH = ["address", "password", "contact"];
1734
1443
  var nodes = [];
1735
1444
  var values = [];
@@ -1739,14 +1448,14 @@ var hashMap = {};
1739
1448
  var idMap = null; // Maps node => id.
1740
1449
  var iframeMap = null; // Maps iframe's contentDocument => parent iframe element
1741
1450
  var privacyMap = null; // Maps node => Privacy (enum)
1742
- function start$n() {
1743
- reset$e();
1451
+ function start$r() {
1452
+ reset$g();
1744
1453
  parse(document);
1745
1454
  }
1746
- function stop$m() {
1747
- reset$e();
1455
+ function stop$q() {
1456
+ reset$g();
1748
1457
  }
1749
- function reset$e() {
1458
+ function reset$g() {
1750
1459
  index = 1;
1751
1460
  nodes = [];
1752
1461
  values = [];
@@ -1767,12 +1476,13 @@ function parse(root) {
1767
1476
  if ("querySelectorAll" in root) {
1768
1477
  regions$1(root, config$1.regions);
1769
1478
  metrics(root, config$1.metrics);
1479
+ dimensions(root, config$1.dimensions);
1770
1480
  config$1.mask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 3 /* TextImage */); }); }); // Masked Elements
1771
1481
  config$1.unmask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 0 /* None */); }); }); // Unmasked Elements
1772
1482
  }
1773
1483
  }
1774
1484
  catch (e) {
1775
- log(5 /* Selector */, 1 /* Warning */, e ? e.name : null);
1485
+ log$1(5 /* Selector */, 1 /* Warning */, e ? e.name : null);
1776
1486
  }
1777
1487
  }
1778
1488
  function getId(node, autogen) {
@@ -1806,7 +1516,7 @@ function add(node, parent, data, source) {
1806
1516
  privacy = getPrivacy(node, data, parentTag, privacy);
1807
1517
  // If there's an explicit region attribute set on the element, use it to mark a region on the page
1808
1518
  if (data.attributes && "data-clarity-region" /* RegionData */ in data.attributes) {
1809
- observe$9(node, data.attributes["data-clarity-region" /* RegionData */]);
1519
+ observe$b(node, data.attributes["data-clarity-region" /* RegionData */]);
1810
1520
  regionId = id;
1811
1521
  }
1812
1522
  nodes[id] = node;
@@ -1823,7 +1533,7 @@ function add(node, parent, data, source) {
1823
1533
  };
1824
1534
  updateSelector(values[id]);
1825
1535
  size(values[id], parentValue);
1826
- track$4(id, source);
1536
+ track$5(id, source);
1827
1537
  }
1828
1538
  function update(node, parent, data, source) {
1829
1539
  var id = getId(node);
@@ -1873,7 +1583,7 @@ function update(node, parent, data, source) {
1873
1583
  }
1874
1584
  // Update selector
1875
1585
  updateSelector(value);
1876
- track$4(id, source, changed, parentChanged);
1586
+ track$5(id, source, changed, parentChanged);
1877
1587
  }
1878
1588
  }
1879
1589
  function sameorigin(node) {
@@ -2035,7 +1745,7 @@ function remove(id, source) {
2035
1745
  var value = values[id];
2036
1746
  value.metadata.active = false;
2037
1747
  value.parent = null;
2038
- track$4(id, source);
1748
+ track$5(id, source);
2039
1749
  }
2040
1750
  }
2041
1751
  function size(value, parent) {
@@ -2062,7 +1772,7 @@ function getPreviousId(node) {
2062
1772
  }
2063
1773
  return id;
2064
1774
  }
2065
- function track$4(id, source, changed, parentChanged) {
1775
+ function track$5(id, source, changed, parentChanged) {
2066
1776
  if (changed === void 0) { changed = true; }
2067
1777
  if (parentChanged === void 0) { parentChanged = false; }
2068
1778
  // Keep track of the order in which mutations happened, they may not be sequential
@@ -2080,8 +1790,8 @@ function track$4(id, source, changed, parentChanged) {
2080
1790
 
2081
1791
  var dom = /*#__PURE__*/Object.freeze({
2082
1792
  __proto__: null,
2083
- start: start$n,
2084
- stop: stop$m,
1793
+ start: start$r,
1794
+ stop: stop$q,
2085
1795
  parse: parse,
2086
1796
  getId: getId,
2087
1797
  add: add,
@@ -2096,21 +1806,21 @@ var dom = /*#__PURE__*/Object.freeze({
2096
1806
  updates: updates$2
2097
1807
  });
2098
1808
 
2099
- var state$5 = [];
1809
+ var state$7 = [];
2100
1810
  var regionMap = null; // Maps region nodes => region name
2101
1811
  var regions = {};
2102
1812
  var queue$2 = [];
2103
1813
  var watch = false;
2104
1814
  var observer$1 = null;
2105
- function start$m() {
2106
- reset$d();
1815
+ function start$q() {
1816
+ reset$f();
2107
1817
  observer$1 = null;
2108
1818
  regionMap = new WeakMap();
2109
1819
  regions = {};
2110
1820
  queue$2 = [];
2111
1821
  watch = window["IntersectionObserver"] ? true : false;
2112
1822
  }
2113
- function observe$9(node, name) {
1823
+ function observe$b(node, name) {
2114
1824
  if (regionMap.has(node) === false) {
2115
1825
  regionMap.set(node, name);
2116
1826
  observer$1 = observer$1 === null && watch ? new IntersectionObserver(handler$2, {
@@ -2131,7 +1841,7 @@ function exists(node) {
2131
1841
  // and still attempt to call exists on a late coming DOM mutation (or addition), effectively causing a script error
2132
1842
  return regionMap && regionMap.has(node);
2133
1843
  }
2134
- function track$3(id, event) {
1844
+ function track$4(id, event) {
2135
1845
  var node = getNode(id);
2136
1846
  var data = id in regions ? regions[id] : { id: id, visibility: 0 /* Rendered */, interaction: 16 /* None */, name: regionMap.get(node) };
2137
1847
  // Determine the interaction state based on incoming event
@@ -2147,7 +1857,7 @@ function track$3(id, event) {
2147
1857
  // Process updates to this region, if applicable
2148
1858
  process$6(node, data, interaction, data.visibility);
2149
1859
  }
2150
- function compute$4() {
1860
+ function compute$5() {
2151
1861
  // Process any regions where we couldn't resolve an "id" for at the time of last intersection observer event
2152
1862
  // This could happen in cases where elements are not yet processed by Clarity's virtual DOM but browser reports a change, regardless.
2153
1863
  // For those cases we add them to the queue and re-process them below
@@ -2159,7 +1869,7 @@ function compute$4() {
2159
1869
  if (id) {
2160
1870
  r.data.id = id;
2161
1871
  regions[id] = r.data;
2162
- state$5.push(clone(r.data));
1872
+ state$7.push(clone(r.data));
2163
1873
  }
2164
1874
  else {
2165
1875
  q.push(r);
@@ -2168,7 +1878,7 @@ function compute$4() {
2168
1878
  }
2169
1879
  queue$2 = q;
2170
1880
  // Schedule encode only when we have at least one valid data entry
2171
- if (state$5.length > 0) {
1881
+ if (state$7.length > 0) {
2172
1882
  encode$4(7 /* Region */);
2173
1883
  }
2174
1884
  }
@@ -2204,7 +1914,7 @@ function handler$2(entries) {
2204
1914
  }
2205
1915
  }
2206
1916
  }
2207
- if (state$5.length > 0) {
1917
+ if (state$7.length > 0) {
2208
1918
  encode$4(7 /* Region */);
2209
1919
  }
2210
1920
  }
@@ -2218,7 +1928,7 @@ function process$6(n, d, s, v) {
2218
1928
  if (d.id) {
2219
1929
  if ((d.id in regions && updated) || !(d.id in regions)) {
2220
1930
  regions[d.id] = d;
2221
- state$5.push(clone(d));
1931
+ state$7.push(clone(d));
2222
1932
  }
2223
1933
  }
2224
1934
  else {
@@ -2228,11 +1938,11 @@ function process$6(n, d, s, v) {
2228
1938
  function clone(r) {
2229
1939
  return { time: time(), data: { id: r.id, interaction: r.interaction, visibility: r.visibility, name: r.name } };
2230
1940
  }
2231
- function reset$d() {
2232
- state$5 = [];
1941
+ function reset$f() {
1942
+ state$7 = [];
2233
1943
  }
2234
- function stop$l() {
2235
- reset$d();
1944
+ function stop$p() {
1945
+ reset$f();
2236
1946
  regionMap = null;
2237
1947
  regions = {};
2238
1948
  queue$2 = [];
@@ -2260,11 +1970,11 @@ function offset (element) {
2260
1970
  }
2261
1971
 
2262
1972
  var UserInputTags = ["input", "textarea", "radio", "button", "canvas"];
2263
- var state$4 = [];
2264
- function start$l() {
2265
- reset$c();
1973
+ var state$6 = [];
1974
+ function start$p() {
1975
+ reset$e();
2266
1976
  }
2267
- function observe$8(root) {
1977
+ function observe$a(root) {
2268
1978
  bind(root, "click", handler$1.bind(this, 9 /* Click */, root), true);
2269
1979
  }
2270
1980
  function handler$1(event, root, evt) {
@@ -2295,7 +2005,7 @@ function handler$1(event, root, evt) {
2295
2005
  var eY = l ? Math.max(Math.floor(((y - l.y) / l.h) * 32767 /* ClickPrecision */), 0) : 0;
2296
2006
  // Check for null values before processing this event
2297
2007
  if (x !== null && y !== null) {
2298
- state$4.push({
2008
+ state$6.push({
2299
2009
  time: time(),
2300
2010
  event: event,
2301
2011
  data: {
@@ -2369,19 +2079,39 @@ function context(a) {
2369
2079
  }
2370
2080
  return 0 /* Self */;
2371
2081
  }
2372
- function reset$c() {
2373
- state$4 = [];
2082
+ function reset$e() {
2083
+ state$6 = [];
2374
2084
  }
2375
- function stop$k() {
2376
- reset$c();
2085
+ function stop$o() {
2086
+ reset$e();
2087
+ }
2088
+
2089
+ var state$5 = [];
2090
+ function start$o() {
2091
+ reset$d();
2092
+ }
2093
+ function observe$9(root) {
2094
+ bind(root, "cut", recompute$7.bind(this, 0 /* Cut */), true);
2095
+ bind(root, "copy", recompute$7.bind(this, 1 /* Copy */), true);
2096
+ bind(root, "paste", recompute$7.bind(this, 2 /* Paste */), true);
2097
+ }
2098
+ function recompute$7(action, evt) {
2099
+ state$5.push({ time: time(), event: 38 /* Clipboard */, data: { target: target(evt), action: action } });
2100
+ schedule$1(encode$2.bind(this, 38 /* Clipboard */));
2101
+ }
2102
+ function reset$d() {
2103
+ state$5 = [];
2104
+ }
2105
+ function stop$n() {
2106
+ reset$d();
2377
2107
  }
2378
2108
 
2379
2109
  var timeout$5 = null;
2380
- var state$3 = [];
2381
- function start$k() {
2382
- reset$b();
2110
+ var state$4 = [];
2111
+ function start$n() {
2112
+ reset$c();
2383
2113
  }
2384
- function observe$7(root) {
2114
+ function observe$8(root) {
2385
2115
  bind(root, "input", recompute$6, true);
2386
2116
  }
2387
2117
  function recompute$6(evt) {
@@ -2403,10 +2133,10 @@ function recompute$6(evt) {
2403
2133
  }
2404
2134
  var data = { target: input, value: v };
2405
2135
  // If last entry in the queue is for the same target node as the current one, remove it so we can later swap it with current data.
2406
- if (state$3.length > 0 && (state$3[state$3.length - 1].data.target === data.target)) {
2407
- state$3.pop();
2136
+ if (state$4.length > 0 && (state$4[state$4.length - 1].data.target === data.target)) {
2137
+ state$4.pop();
2408
2138
  }
2409
- state$3.push({ time: time(), event: 27 /* Input */, data: data });
2139
+ state$4.push({ time: time(), event: 27 /* Input */, data: data });
2410
2140
  clearTimeout(timeout$5);
2411
2141
  timeout$5 = setTimeout(process$5, 500 /* LookAhead */, 27 /* Input */);
2412
2142
  }
@@ -2414,20 +2144,20 @@ function recompute$6(evt) {
2414
2144
  function process$5(event) {
2415
2145
  schedule$1(encode$2.bind(this, event));
2416
2146
  }
2417
- function reset$b() {
2418
- state$3 = [];
2147
+ function reset$c() {
2148
+ state$4 = [];
2419
2149
  }
2420
- function stop$j() {
2150
+ function stop$m() {
2421
2151
  clearTimeout(timeout$5);
2422
- reset$b();
2152
+ reset$c();
2423
2153
  }
2424
2154
 
2425
- var state$2 = [];
2155
+ var state$3 = [];
2426
2156
  var timeout$4 = null;
2427
- function start$j() {
2428
- reset$a();
2157
+ function start$m() {
2158
+ reset$b();
2429
2159
  }
2430
- function observe$6(root) {
2160
+ function observe$7(root) {
2431
2161
  bind(root, "mousedown", mouse.bind(this, 13 /* MouseDown */, root), true);
2432
2162
  bind(root, "mouseup", mouse.bind(this, 14 /* MouseUp */, root), true);
2433
2163
  bind(root, "mousemove", mouse.bind(this, 12 /* MouseMove */, root), true);
@@ -2478,17 +2208,17 @@ function handler(current) {
2478
2208
  case 12 /* MouseMove */:
2479
2209
  case 15 /* MouseWheel */:
2480
2210
  case 19 /* TouchMove */:
2481
- var length_1 = state$2.length;
2482
- var last = length_1 > 1 ? state$2[length_1 - 2] : null;
2211
+ var length_1 = state$3.length;
2212
+ var last = length_1 > 1 ? state$3[length_1 - 2] : null;
2483
2213
  if (last && similar$1(last, current)) {
2484
- state$2.pop();
2214
+ state$3.pop();
2485
2215
  }
2486
- state$2.push(current);
2216
+ state$3.push(current);
2487
2217
  clearTimeout(timeout$4);
2488
2218
  timeout$4 = setTimeout(process$4, 500 /* LookAhead */, current.event);
2489
2219
  break;
2490
2220
  default:
2491
- state$2.push(current);
2221
+ state$3.push(current);
2492
2222
  process$4(current.event);
2493
2223
  break;
2494
2224
  }
@@ -2496,8 +2226,8 @@ function handler(current) {
2496
2226
  function process$4(event) {
2497
2227
  schedule$1(encode$2.bind(this, event));
2498
2228
  }
2499
- function reset$a() {
2500
- state$2 = [];
2229
+ function reset$b() {
2230
+ state$3 = [];
2501
2231
  }
2502
2232
  function similar$1(last, current) {
2503
2233
  var dx = last.data.x - current.data.x;
@@ -2507,16 +2237,16 @@ function similar$1(last, current) {
2507
2237
  var match = current.data.target === last.data.target;
2508
2238
  return current.event === last.event && match && distance < 20 /* Distance */ && gap < 25 /* Interval */;
2509
2239
  }
2510
- function stop$i() {
2240
+ function stop$l() {
2511
2241
  clearTimeout(timeout$4);
2512
2242
  // Send out any pending pointer events in the pipeline
2513
- if (state$2.length > 0) {
2514
- process$4(state$2[state$2.length - 1].event);
2243
+ if (state$3.length > 0) {
2244
+ process$4(state$3[state$3.length - 1].event);
2515
2245
  }
2516
2246
  }
2517
2247
 
2518
- var data$6;
2519
- function start$i() {
2248
+ var data$8;
2249
+ function start$l() {
2520
2250
  bind(window, "resize", recompute$5);
2521
2251
  recompute$5();
2522
2252
  }
@@ -2524,26 +2254,26 @@ function recompute$5() {
2524
2254
  var de = document.documentElement;
2525
2255
  // window.innerWidth includes width of the scrollbar and is not a true representation of the viewport width.
2526
2256
  // Therefore, when possible, use documentElement's clientWidth property.
2527
- data$6 = {
2257
+ data$8 = {
2528
2258
  width: de && "clientWidth" in de ? Math.min(de.clientWidth, window.innerWidth) : window.innerWidth,
2529
2259
  height: de && "clientHeight" in de ? Math.min(de.clientHeight, window.innerHeight) : window.innerHeight,
2530
2260
  };
2531
2261
  encode$2(11 /* Resize */);
2532
2262
  }
2533
- function reset$9() {
2534
- data$6 = null;
2263
+ function reset$a() {
2264
+ data$8 = null;
2535
2265
  }
2536
- function stop$h() {
2537
- reset$9();
2266
+ function stop$k() {
2267
+ reset$a();
2538
2268
  }
2539
2269
 
2540
- var state$1 = [];
2270
+ var state$2 = [];
2541
2271
  var timeout$3 = null;
2542
- function start$h() {
2543
- state$1 = [];
2272
+ function start$k() {
2273
+ state$2 = [];
2544
2274
  recompute$4();
2545
2275
  }
2546
- function observe$5(root) {
2276
+ function observe$6(root) {
2547
2277
  var frame = iframe(root);
2548
2278
  var node = frame ? frame.contentWindow : (root === document ? window : root);
2549
2279
  bind(node, "scroll", recompute$4, true);
@@ -2569,17 +2299,17 @@ function recompute$4(event) {
2569
2299
  if ((event === null && x === 0 && y === 0) || (x === null || y === null)) {
2570
2300
  return;
2571
2301
  }
2572
- var length = state$1.length;
2573
- var last = length > 1 ? state$1[length - 2] : null;
2302
+ var length = state$2.length;
2303
+ var last = length > 1 ? state$2[length - 2] : null;
2574
2304
  if (last && similar(last, current)) {
2575
- state$1.pop();
2305
+ state$2.pop();
2576
2306
  }
2577
- state$1.push(current);
2307
+ state$2.push(current);
2578
2308
  clearTimeout(timeout$3);
2579
2309
  timeout$3 = setTimeout(process$3, 500 /* LookAhead */, 10 /* Scroll */);
2580
2310
  }
2581
- function reset$8() {
2582
- state$1 = [];
2311
+ function reset$9() {
2312
+ state$2 = [];
2583
2313
  }
2584
2314
  function process$3(event) {
2585
2315
  schedule$1(encode$2.bind(this, event));
@@ -2589,18 +2319,18 @@ function similar(last, current) {
2589
2319
  var dy = last.data.y - current.data.y;
2590
2320
  return (dx * dx + dy * dy < 20 /* Distance */ * 20 /* Distance */) && (current.time - last.time < 25 /* Interval */);
2591
2321
  }
2592
- function stop$g() {
2322
+ function stop$j() {
2593
2323
  clearTimeout(timeout$3);
2594
- state$1 = [];
2324
+ state$2 = [];
2595
2325
  }
2596
2326
 
2597
- var data$5 = null;
2327
+ var data$7 = null;
2598
2328
  var previous = null;
2599
2329
  var timeout$2 = null;
2600
- function start$g() {
2601
- reset$7();
2330
+ function start$j() {
2331
+ reset$8();
2602
2332
  }
2603
- function observe$4(root) {
2333
+ function observe$5(root) {
2604
2334
  bind(root, "selectstart", recompute$3.bind(this, root), true);
2605
2335
  bind(root, "selectionchange", recompute$3.bind(this, root), true);
2606
2336
  }
@@ -2619,12 +2349,12 @@ function recompute$3(root) {
2619
2349
  (current.anchorNode === current.focusNode && current.anchorOffset === current.focusOffset)) {
2620
2350
  return;
2621
2351
  }
2622
- var startNode = data$5.start ? data$5.start : null;
2623
- if (previous !== null && data$5.start !== null && startNode !== current.anchorNode) {
2352
+ var startNode = data$7.start ? data$7.start : null;
2353
+ if (previous !== null && data$7.start !== null && startNode !== current.anchorNode) {
2624
2354
  clearTimeout(timeout$2);
2625
2355
  process$2(21 /* Selection */);
2626
2356
  }
2627
- data$5 = {
2357
+ data$7 = {
2628
2358
  start: current.anchorNode,
2629
2359
  startOffset: current.anchorOffset,
2630
2360
  end: current.focusNode,
@@ -2637,85 +2367,109 @@ function recompute$3(root) {
2637
2367
  function process$2(event) {
2638
2368
  schedule$1(encode$2.bind(this, event));
2639
2369
  }
2640
- function reset$7() {
2370
+ function reset$8() {
2641
2371
  previous = null;
2642
- data$5 = { start: 0, startOffset: 0, end: 0, endOffset: 0 };
2372
+ data$7 = { start: 0, startOffset: 0, end: 0, endOffset: 0 };
2643
2373
  }
2644
- function stop$f() {
2645
- reset$7();
2374
+ function stop$i() {
2375
+ reset$8();
2646
2376
  clearTimeout(timeout$2);
2647
2377
  }
2648
2378
 
2649
- var data$4;
2650
- function start$f() {
2651
- bind(window, "pagehide", recompute$2);
2379
+ var state$1 = [];
2380
+ function start$i() {
2381
+ reset$7();
2382
+ }
2383
+ function observe$4(root) {
2384
+ bind(root, "submit", recompute$2, true);
2652
2385
  }
2653
2386
  function recompute$2(evt) {
2654
- data$4 = { name: evt.type };
2387
+ state$1.push({ time: time(), event: 39 /* Submit */, data: { target: target(evt) } });
2388
+ schedule$1(encode$2.bind(this, 39 /* Submit */));
2389
+ }
2390
+ function reset$7() {
2391
+ state$1 = [];
2392
+ }
2393
+ function stop$h() {
2394
+ reset$7();
2395
+ }
2396
+
2397
+ var data$6;
2398
+ function start$h() {
2399
+ bind(window, "pagehide", recompute$1);
2400
+ }
2401
+ function recompute$1(evt) {
2402
+ data$6 = { name: evt.type };
2655
2403
  encode$2(26 /* Unload */);
2656
2404
  stop();
2657
2405
  }
2658
2406
  function reset$6() {
2659
- data$4 = null;
2407
+ data$6 = null;
2660
2408
  }
2661
- function stop$e() {
2409
+ function stop$g() {
2662
2410
  reset$6();
2663
2411
  }
2664
2412
 
2665
- var data$3;
2666
- function start$e() {
2667
- bind(document, "visibilitychange", recompute$1);
2668
- recompute$1();
2413
+ var data$5;
2414
+ function start$g() {
2415
+ bind(document, "visibilitychange", recompute);
2416
+ recompute();
2669
2417
  }
2670
- function recompute$1() {
2671
- data$3 = { visible: "visibilityState" in document ? document.visibilityState : "default" };
2418
+ function recompute() {
2419
+ data$5 = { visible: "visibilityState" in document ? document.visibilityState : "default" };
2672
2420
  encode$2(28 /* Visibility */);
2673
2421
  }
2674
2422
  function reset$5() {
2675
- data$3 = null;
2423
+ data$5 = null;
2676
2424
  }
2677
- function stop$d() {
2425
+ function stop$f() {
2678
2426
  reset$5();
2679
2427
  }
2680
2428
 
2681
- function start$d() {
2682
- start$b();
2429
+ function start$f() {
2430
+ start$d();
2431
+ start$p();
2432
+ start$o();
2433
+ start$m();
2434
+ start$n();
2683
2435
  start$l();
2684
- start$j();
2436
+ start$g();
2685
2437
  start$k();
2438
+ start$j();
2686
2439
  start$i();
2687
- start$e();
2688
2440
  start$h();
2689
- start$g();
2690
- start$f();
2691
2441
  }
2692
- function stop$c() {
2693
- stop$a();
2442
+ function stop$e() {
2443
+ stop$c();
2444
+ stop$o();
2445
+ stop$n();
2446
+ stop$l();
2447
+ stop$m();
2694
2448
  stop$k();
2695
- stop$i();
2449
+ stop$f();
2696
2450
  stop$j();
2451
+ stop$i();
2697
2452
  stop$h();
2698
- stop$d();
2699
2453
  stop$g();
2700
- stop$f();
2701
- stop$e();
2702
2454
  }
2703
2455
  function observe$3(root) {
2704
- observe$5(root);
2456
+ observe$6(root);
2705
2457
  // Only monitor following interactions if the root node is a document
2706
2458
  // In case of shadow DOM, following events automatically bubble up to the parent document.
2707
2459
  if (root.nodeType === Node.DOCUMENT_NODE) {
2708
- observe$8(root);
2709
- observe$6(root);
2460
+ observe$a(root);
2461
+ observe$9(root);
2710
2462
  observe$7(root);
2463
+ observe$8(root);
2464
+ observe$5(root);
2711
2465
  observe$4(root);
2712
2466
  }
2713
2467
  }
2714
2468
 
2715
2469
  var interaction = /*#__PURE__*/Object.freeze({
2716
2470
  __proto__: null,
2717
- start: start$d,
2718
- stop: stop$c,
2471
+ start: start$f,
2472
+ stop: stop$e,
2719
2473
  observe: observe$3
2720
2474
  });
2721
2475
 
@@ -2732,39 +2486,39 @@ function ld(json) {
2732
2486
  switch (value) {
2733
2487
  case "article" /* Article */:
2734
2488
  case "recipe" /* Recipe */:
2735
- log$1(5 /* SchemaType */, json[key]);
2736
- log$1(8 /* AuthorName */, json["creator" /* Creator */]);
2737
- log$1(18 /* Headline */, json["headline" /* Headline */]);
2489
+ log(5 /* SchemaType */, json[key]);
2490
+ log(8 /* AuthorName */, json["creator" /* Creator */]);
2491
+ log(18 /* Headline */, json["headline" /* Headline */]);
2738
2492
  break;
2739
2493
  case "product" /* Product */:
2740
- log$1(5 /* SchemaType */, json[key]);
2741
- log$1(10 /* ProductName */, json["name" /* Name */]);
2742
- log$1(12 /* ProductSku */, json["sku" /* Sku */]);
2494
+ log(5 /* SchemaType */, json[key]);
2495
+ log(10 /* ProductName */, json["name" /* Name */]);
2496
+ log(12 /* ProductSku */, json["sku" /* Sku */]);
2743
2497
  if (json["brand" /* Brand */]) {
2744
- log$1(6 /* ProductBrand */, json["brand" /* Brand */]["name" /* Name */]);
2498
+ log(6 /* ProductBrand */, json["brand" /* Brand */]["name" /* Name */]);
2745
2499
  }
2746
2500
  break;
2747
2501
  case "aggregaterating" /* AggregateRating */:
2748
2502
  if (json["ratingValue" /* RatingValue */]) {
2749
- max(11 /* RatingValue */, num(json["ratingValue" /* RatingValue */], 100 /* RatingScale */));
2750
- max(18 /* BestRating */, num(json["bestRating" /* BestRating */]));
2751
- max(19 /* WorstRating */, num(json["worstRating" /* WorstRating */]));
2503
+ max(11 /* RatingValue */, num$1(json["ratingValue" /* RatingValue */], 100 /* RatingScale */));
2504
+ max(18 /* BestRating */, num$1(json["bestRating" /* BestRating */]));
2505
+ max(19 /* WorstRating */, num$1(json["worstRating" /* WorstRating */]));
2752
2506
  }
2753
- max(12 /* RatingCount */, num(json["ratingCount" /* RatingCount */]));
2754
- max(17 /* ReviewCount */, num(json["reviewCount" /* ReviewCount */]));
2507
+ max(12 /* RatingCount */, num$1(json["ratingCount" /* RatingCount */]));
2508
+ max(17 /* ReviewCount */, num$1(json["reviewCount" /* ReviewCount */]));
2755
2509
  break;
2756
2510
  case "person" /* Author */:
2757
- log$1(8 /* AuthorName */, json["name" /* Name */]);
2511
+ log(8 /* AuthorName */, json["name" /* Name */]);
2758
2512
  break;
2759
2513
  case "offer" /* Offer */:
2760
- log$1(7 /* ProductAvailability */, json["availability" /* Availability */]);
2761
- log$1(14 /* ProductCondition */, json["itemCondition" /* ItemCondition */]);
2762
- log$1(13 /* ProductCurrency */, json["priceCurrency" /* PriceCurrency */]);
2763
- log$1(12 /* ProductSku */, json["sku" /* Sku */]);
2764
- max(13 /* ProductPrice */, num(json["price" /* Price */]));
2514
+ log(7 /* ProductAvailability */, json["availability" /* Availability */]);
2515
+ log(14 /* ProductCondition */, json["itemCondition" /* ItemCondition */]);
2516
+ log(13 /* ProductCurrency */, json["priceCurrency" /* PriceCurrency */]);
2517
+ log(12 /* ProductSku */, json["sku" /* Sku */]);
2518
+ max(13 /* ProductPrice */, num$1(json["price" /* Price */]));
2765
2519
  break;
2766
2520
  case "brand" /* Brand */:
2767
- log$1(6 /* ProductBrand */, json["name" /* Name */]);
2521
+ log(6 /* ProductBrand */, json["name" /* Name */]);
2768
2522
  break;
2769
2523
  }
2770
2524
  }
@@ -2774,7 +2528,7 @@ function ld(json) {
2774
2528
  }
2775
2529
  }
2776
2530
  }
2777
- function num(input, scale) {
2531
+ function num$1(input, scale) {
2778
2532
  if (scale === void 0) { scale = 1; }
2779
2533
  if (input !== null) {
2780
2534
  switch (typeof input) {
@@ -2896,13 +2650,13 @@ function processNode (node, source) {
2896
2650
  var content = attributes["content" /* Content */];
2897
2651
  switch (attributes[key]) {
2898
2652
  case "og:title" /* ogTitle */:
2899
- log$1(20 /* MetaTitle */, content);
2653
+ log(20 /* MetaTitle */, content);
2900
2654
  break;
2901
2655
  case "og:type" /* ogType */:
2902
- log$1(19 /* MetaType */, content);
2656
+ log(19 /* MetaType */, content);
2903
2657
  break;
2904
2658
  case "generator" /* Generator */:
2905
- log$1(21 /* Generator */, content);
2659
+ log(21 /* Generator */, content);
2906
2660
  break;
2907
2661
  }
2908
2662
  }
@@ -2967,7 +2721,7 @@ function getCssRules(sheet) {
2967
2721
  cssRules = sheet ? sheet.cssRules : [];
2968
2722
  }
2969
2723
  catch (e) {
2970
- log(1 /* CssRules */, 1 /* Warning */, e ? e.name : null);
2724
+ log$1(1 /* CssRules */, 1 /* Warning */, e ? e.name : null);
2971
2725
  if (e && e.name !== "SecurityError") {
2972
2726
  throw e;
2973
2727
  }
@@ -3013,7 +2767,7 @@ function traverse (root, timer, source) {
3013
2767
  queue.push(next);
3014
2768
  next = next.nextSibling;
3015
2769
  }
3016
- state = state$6(timer);
2770
+ state = state$8(timer);
3017
2771
  if (!(state === 0 /* Wait */)) return [3 /*break*/, 3];
3018
2772
  return [4 /*yield*/, suspend$1(timer)];
3019
2773
  case 2:
@@ -3042,13 +2796,13 @@ var attachShadow = null;
3042
2796
  var queue$1 = [];
3043
2797
  var timeout$1 = null;
3044
2798
  var activePeriod = null;
3045
- var history$1 = {};
3046
- function start$c() {
2799
+ var history$2 = {};
2800
+ function start$e() {
3047
2801
  observers = [];
3048
2802
  queue$1 = [];
3049
2803
  timeout$1 = null;
3050
2804
  activePeriod = 0;
3051
- history$1 = {};
2805
+ history$2 = {};
3052
2806
  if (insertRule === null) {
3053
2807
  insertRule = CSSStyleSheet.prototype.insertRule;
3054
2808
  }
@@ -3056,7 +2810,7 @@ function start$c() {
3056
2810
  deleteRule = CSSStyleSheet.prototype.deleteRule;
3057
2811
  }
3058
2812
  if (attachShadow === null) {
3059
- attachShadow = HTMLElement.prototype.attachShadow;
2813
+ attachShadow = Element.prototype.attachShadow;
3060
2814
  }
3061
2815
  // Some popular open source libraries, like styled-components, optimize performance
3062
2816
  // by injecting CSS using insertRule API vs. appending text node. A side effect of
@@ -3070,10 +2824,17 @@ function start$c() {
3070
2824
  schedule(this.ownerNode);
3071
2825
  return deleteRule.apply(this, arguments);
3072
2826
  };
3073
- // Listening to attachShadow API
3074
- HTMLElement.prototype.attachShadow = function () {
3075
- return schedule(attachShadow.apply(this, arguments));
3076
- };
2827
+ // Add a hook to attachShadow API calls
2828
+ // In case we are unable to add a hook and browser throws an exception,
2829
+ // reset attachShadow variable and resume processing like before
2830
+ try {
2831
+ Element.prototype.attachShadow = function () {
2832
+ return schedule(attachShadow.apply(this, arguments));
2833
+ };
2834
+ }
2835
+ catch (_a) {
2836
+ attachShadow = null;
2837
+ }
3077
2838
  }
3078
2839
  function observe$1(node) {
3079
2840
  // Create a new observer for every time a new DOM tree (e.g. root document or shadowdom root) is discovered on the page
@@ -3092,7 +2853,7 @@ function observe$1(node) {
3092
2853
  }
3093
2854
  }
3094
2855
  catch (e) {
3095
- log(2 /* MutationObserver */, 0 /* Info */, e ? e.name : null);
2856
+ log$1(2 /* MutationObserver */, 0 /* Info */, e ? e.name : null);
3096
2857
  }
3097
2858
  }
3098
2859
  function monitor(frame) {
@@ -3103,7 +2864,7 @@ function monitor(frame) {
3103
2864
  bind(frame, "load" /* LoadEvent */, generate.bind(this, frame, "childList" /* ChildList */), true);
3104
2865
  }
3105
2866
  }
3106
- function stop$b() {
2867
+ function stop$d() {
3107
2868
  for (var _i = 0, observers_1 = observers; _i < observers_1.length; _i++) {
3108
2869
  var observer = observers_1[_i];
3109
2870
  if (observer) {
@@ -3123,10 +2884,10 @@ function stop$b() {
3123
2884
  }
3124
2885
  // Restoring original attachShadow
3125
2886
  if (attachShadow != null) {
3126
- HTMLElement.prototype.attachShadow = attachShadow;
2887
+ Element.prototype.attachShadow = attachShadow;
3127
2888
  attachShadow = null;
3128
2889
  }
3129
- history$1 = {};
2890
+ history$2 = {};
3130
2891
  mutations = [];
3131
2892
  queue$1 = [];
3132
2893
  activePeriod = 0;
@@ -3138,11 +2899,11 @@ function active$2() {
3138
2899
  function handle$1(m) {
3139
2900
  // Queue up mutation records for asynchronous processing
3140
2901
  var now = time();
3141
- track$5(6 /* Mutation */, now);
2902
+ track$6(6 /* Mutation */, now);
3142
2903
  mutations.push({ time: now, mutations: m });
3143
2904
  schedule$1(process$1, 1 /* High */).then(function () {
3144
- measure(compute$6)();
3145
- measure(compute$4)();
2905
+ measure(compute$7)();
2906
+ measure(compute$5)();
3146
2907
  });
3147
2908
  }
3148
2909
  function process$1() {
@@ -3152,7 +2913,7 @@ function process$1() {
3152
2913
  switch (_b.label) {
3153
2914
  case 0:
3154
2915
  timer = { id: id(), cost: 3 /* LayoutCost */ };
3155
- start$t(timer);
2916
+ start$w(timer);
3156
2917
  _b.label = 1;
3157
2918
  case 1:
3158
2919
  if (!(mutations.length > 0)) return [3 /*break*/, 8];
@@ -3162,7 +2923,7 @@ function process$1() {
3162
2923
  case 2:
3163
2924
  if (!(_i < _a.length)) return [3 /*break*/, 6];
3164
2925
  mutation = _a[_i];
3165
- state = state$6(timer);
2926
+ state = state$8(timer);
3166
2927
  if (!(state === 0 /* Wait */)) return [3 /*break*/, 4];
3167
2928
  return [4 /*yield*/, suspend$1(timer)];
3168
2929
  case 3:
@@ -3173,7 +2934,7 @@ function process$1() {
3173
2934
  return [3 /*break*/, 6];
3174
2935
  }
3175
2936
  target = mutation.target;
3176
- type = track$2(mutation, timer);
2937
+ type = track$3(mutation, timer);
3177
2938
  if (type && target && target.ownerDocument) {
3178
2939
  parse(target.ownerDocument);
3179
2940
  }
@@ -3204,13 +2965,13 @@ function process$1() {
3204
2965
  _b.sent();
3205
2966
  return [3 /*break*/, 1];
3206
2967
  case 8:
3207
- stop$q(timer);
2968
+ stop$t(timer);
3208
2969
  return [2 /*return*/];
3209
2970
  }
3210
2971
  });
3211
2972
  });
3212
2973
  }
3213
- function track$2(m, timer) {
2974
+ function track$3(m, timer) {
3214
2975
  var value = m.target ? get(m.target.parentNode) : null;
3215
2976
  // Check if the parent is already discovered and that the parent is not the document root
3216
2977
  if (value && value.data.tag !== "HTML" /* HTML */) {
@@ -3223,8 +2984,8 @@ function track$2(m, timer) {
3223
2984
  // In those cases, IDs will change however the selector (which is relative to DOM xPath) remains the same
3224
2985
  var key = [parent_1, element, m.attributeName, names(m.addedNodes), names(m.removedNodes)].join();
3225
2986
  // Initialize an entry if it doesn't already exist
3226
- history$1[key] = key in history$1 ? history$1[key] : [0];
3227
- var h = history$1[key];
2987
+ history$2[key] = key in history$2 ? history$2[key] : [0];
2988
+ var h = history$2[key];
3228
2989
  // Lookup any pending nodes queued up for removal, and process them now if we suspended a mutation before
3229
2990
  if (inactive === false && h[0] >= 10 /* MutationSuspendThreshold */) {
3230
2991
  processNodeList(h[1], 2 /* ChildListRemove */, timer);
@@ -3266,7 +3027,7 @@ function processNodeList(list, source, timer) {
3266
3027
  traverse(list[i], timer, source);
3267
3028
  return [3 /*break*/, 5];
3268
3029
  case 2:
3269
- state = state$6(timer);
3030
+ state = state$8(timer);
3270
3031
  if (!(state === 0 /* Wait */)) return [3 /*break*/, 4];
3271
3032
  return [4 /*yield*/, suspend$1(timer)];
3272
3033
  case 3:
@@ -3297,10 +3058,10 @@ function schedule(node) {
3297
3058
  if (timeout$1) {
3298
3059
  clearTimeout(timeout$1);
3299
3060
  }
3300
- timeout$1 = setTimeout(trigger, 33 /* LookAhead */);
3061
+ timeout$1 = setTimeout(trigger$1, 33 /* LookAhead */);
3301
3062
  return node;
3302
3063
  }
3303
- function trigger() {
3064
+ function trigger$1() {
3304
3065
  for (var _i = 0, queue_1 = queue$1; _i < queue_1.length; _i++) {
3305
3066
  var node = queue_1[_i];
3306
3067
  var shadowRoot = node && node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
@@ -3344,7 +3105,7 @@ function link(node) {
3344
3105
  }
3345
3106
  return null;
3346
3107
  }
3347
- function metadata(node, event) {
3108
+ function metadata$2(node, event) {
3348
3109
  // If the node is null, we return a reserved value for id: 0. Valid assignment of id begins from 1+.
3349
3110
  var output = { id: 0, hash: null, privacy: 2 /* Text */, node: node };
3350
3111
  if (node) {
@@ -3354,7 +3115,7 @@ function metadata(node, event) {
3354
3115
  output.hash = value.hash;
3355
3116
  output.privacy = value.metadata.privacy;
3356
3117
  if (value.region) {
3357
- track$3(value.region, event);
3118
+ track$4(value.region, event);
3358
3119
  }
3359
3120
  }
3360
3121
  }
@@ -3363,8 +3124,8 @@ function metadata(node, event) {
3363
3124
 
3364
3125
  function encode$2 (type) {
3365
3126
  return __awaiter(this, void 0, void 0, function () {
3366
- var t, tokens, i, entry, pTarget, i, entry, cTarget, cHash, r, u, i, entry, iTarget, s, startTarget, endTarget, i, entry, sTarget, i, entry, v;
3367
- return __generator(this, function (_a) {
3127
+ 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;
3128
+ return __generator(this, function (_p) {
3368
3129
  t = time();
3369
3130
  tokens = [t, type];
3370
3131
  switch (type) {
@@ -3377,9 +3138,9 @@ function encode$2 (type) {
3377
3138
  case 18 /* TouchEnd */:
3378
3139
  case 19 /* TouchMove */:
3379
3140
  case 20 /* TouchCancel */:
3380
- for (i = 0; i < state$2.length; i++) {
3381
- entry = state$2[i];
3382
- pTarget = metadata(entry.data.target, entry.event);
3141
+ for (_i = 0, _a = state$3; _i < _a.length; _i++) {
3142
+ entry = _a[_i];
3143
+ pTarget = metadata$2(entry.data.target, entry.event);
3383
3144
  if (pTarget.id > 0) {
3384
3145
  tokens = [entry.time, entry.event];
3385
3146
  tokens.push(pTarget.id);
@@ -3389,12 +3150,12 @@ function encode$2 (type) {
3389
3150
  track$7(entry.event, entry.data.x, entry.data.y);
3390
3151
  }
3391
3152
  }
3392
- reset$a();
3153
+ reset$b();
3393
3154
  break;
3394
3155
  case 9 /* Click */:
3395
- for (i = 0; i < state$4.length; i++) {
3396
- entry = state$4[i];
3397
- cTarget = metadata(entry.data.target, entry.event);
3156
+ for (_b = 0, _c = state$6; _b < _c.length; _b++) {
3157
+ entry = _c[_b];
3158
+ cTarget = metadata$2(entry.data.target, entry.event);
3398
3159
  tokens = [entry.time, entry.event];
3399
3160
  cHash = cTarget.hash.join("." /* Dot */);
3400
3161
  tokens.push(cTarget.id);
@@ -3409,52 +3170,65 @@ function encode$2 (type) {
3409
3170
  tokens.push(entry.data.link);
3410
3171
  tokens.push(cHash);
3411
3172
  queue(tokens);
3412
- track$1(entry.time, entry.event, cHash, entry.data.x, entry.data.y, entry.data.reaction, entry.data.context);
3173
+ track$2(entry.time, entry.event, cHash, entry.data.x, entry.data.y, entry.data.reaction, entry.data.context);
3413
3174
  }
3414
- reset$c();
3175
+ reset$e();
3176
+ break;
3177
+ case 38 /* Clipboard */:
3178
+ for (_d = 0, _e = state$5; _d < _e.length; _d++) {
3179
+ entry = _e[_d];
3180
+ tokens = [entry.time, entry.event];
3181
+ target = metadata$2(entry.data.target, entry.event);
3182
+ if (target.id > 0) {
3183
+ tokens.push(target.id);
3184
+ tokens.push(entry.data.action);
3185
+ queue(tokens);
3186
+ }
3187
+ }
3188
+ reset$d();
3415
3189
  break;
3416
3190
  case 11 /* Resize */:
3417
- r = data$6;
3191
+ r = data$8;
3418
3192
  tokens.push(r.width);
3419
3193
  tokens.push(r.height);
3420
3194
  track$7(type, r.width, r.height);
3421
- reset$9();
3195
+ reset$a();
3422
3196
  queue(tokens);
3423
3197
  break;
3424
3198
  case 26 /* Unload */:
3425
- u = data$4;
3199
+ u = data$6;
3426
3200
  tokens.push(u.name);
3427
3201
  reset$6();
3428
3202
  queue(tokens);
3429
3203
  break;
3430
3204
  case 27 /* Input */:
3431
- for (i = 0; i < state$3.length; i++) {
3432
- entry = state$3[i];
3433
- iTarget = metadata(entry.data.target, entry.event);
3205
+ for (_f = 0, _g = state$4; _f < _g.length; _f++) {
3206
+ entry = _g[_f];
3207
+ iTarget = metadata$2(entry.data.target, entry.event);
3434
3208
  tokens = [entry.time, entry.event];
3435
3209
  tokens.push(iTarget.id);
3436
3210
  tokens.push(entry.data.value);
3437
3211
  queue(tokens);
3438
3212
  }
3439
- reset$b();
3213
+ reset$c();
3440
3214
  break;
3441
3215
  case 21 /* Selection */:
3442
- s = data$5;
3216
+ s = data$7;
3443
3217
  if (s) {
3444
- startTarget = metadata(s.start, type);
3445
- endTarget = metadata(s.end, type);
3218
+ startTarget = metadata$2(s.start, type);
3219
+ endTarget = metadata$2(s.end, type);
3446
3220
  tokens.push(startTarget.id);
3447
3221
  tokens.push(s.startOffset);
3448
3222
  tokens.push(endTarget.id);
3449
3223
  tokens.push(s.endOffset);
3450
- reset$7();
3224
+ reset$8();
3451
3225
  queue(tokens);
3452
3226
  }
3453
3227
  break;
3454
3228
  case 10 /* Scroll */:
3455
- for (i = 0; i < state$1.length; i++) {
3456
- entry = state$1[i];
3457
- sTarget = metadata(entry.data.target, entry.event);
3229
+ for (_h = 0, _j = state$2; _h < _j.length; _h++) {
3230
+ entry = _j[_h];
3231
+ sTarget = metadata$2(entry.data.target, entry.event);
3458
3232
  if (sTarget.id > 0) {
3459
3233
  tokens = [entry.time, entry.event];
3460
3234
  tokens.push(sTarget.id);
@@ -3464,11 +3238,23 @@ function encode$2 (type) {
3464
3238
  track$7(entry.event, entry.data.x, entry.data.y);
3465
3239
  }
3466
3240
  }
3467
- reset$8();
3241
+ reset$9();
3242
+ break;
3243
+ case 39 /* Submit */:
3244
+ for (_k = 0, _l = state$1; _k < _l.length; _k++) {
3245
+ entry = _l[_k];
3246
+ tokens = [entry.time, entry.event];
3247
+ target = metadata$2(entry.data.target, entry.event);
3248
+ if (target.id > 0) {
3249
+ tokens.push(target.id);
3250
+ queue(tokens);
3251
+ }
3252
+ }
3253
+ reset$7();
3468
3254
  break;
3469
3255
  case 22 /* Timeline */:
3470
- for (i = 0; i < updates$1.length; i++) {
3471
- entry = updates$1[i];
3256
+ for (_m = 0, _o = updates$1; _m < _o.length; _m++) {
3257
+ entry = _o[_m];
3472
3258
  tokens = [entry.time, entry.event];
3473
3259
  tokens.push(entry.data.type);
3474
3260
  tokens.push(entry.data.hash);
@@ -3481,7 +3267,7 @@ function encode$2 (type) {
3481
3267
  reset$4();
3482
3268
  break;
3483
3269
  case 28 /* Visibility */:
3484
- v = data$3;
3270
+ v = data$5;
3485
3271
  tokens.push(v.visible);
3486
3272
  queue(tokens);
3487
3273
  visibility(t, v.visible);
@@ -3495,14 +3281,14 @@ function encode$2 (type) {
3495
3281
 
3496
3282
  var state = [];
3497
3283
  var updates$1 = [];
3498
- function start$b() {
3284
+ function start$d() {
3499
3285
  state = [];
3500
3286
  reset$4();
3501
3287
  }
3502
3288
  function reset$4() {
3503
3289
  updates$1 = [];
3504
3290
  }
3505
- function track$1(time, event, hash, x, y, reaction, context) {
3291
+ function track$2(time, event, hash, x, y, reaction, context) {
3506
3292
  if (reaction === void 0) { reaction = 1 /* True */; }
3507
3293
  if (context === void 0) { context = 0 /* Self */; }
3508
3294
  state.push({
@@ -3522,10 +3308,10 @@ function track$1(time, event, hash, x, y, reaction, context) {
3522
3308
  // We would still need to capture the last scroll position as part of the baseline event, even when timeline will be empty.
3523
3309
  track$7(event, x, y);
3524
3310
  }
3525
- function compute$3() {
3311
+ function compute$4() {
3526
3312
  var temp = [];
3527
3313
  updates$1 = [];
3528
- var max = data$h.start + data$h.duration;
3314
+ var max = data$1.start + data$1.duration;
3529
3315
  var min = Math.max(max - 2000 /* TimelineSpan */, 0);
3530
3316
  for (var _i = 0, state_1 = state; _i < state_1.length; _i++) {
3531
3317
  var s = state_1[_i];
@@ -3539,7 +3325,7 @@ function compute$3() {
3539
3325
  state = temp; // Drop events less than the min time
3540
3326
  encode$2(22 /* Timeline */);
3541
3327
  }
3542
- function stop$a() {
3328
+ function stop$c() {
3543
3329
  state = [];
3544
3330
  reset$4();
3545
3331
  }
@@ -3552,8 +3338,8 @@ var timeout = null;
3552
3338
  var transit;
3553
3339
  var active$1;
3554
3340
  var queuedTime = 0;
3555
- var track;
3556
- function start$a() {
3341
+ var track$1;
3342
+ function start$c() {
3557
3343
  active$1 = true;
3558
3344
  discoverBytes = 0;
3559
3345
  playbackBytes = 0;
@@ -3561,7 +3347,7 @@ function start$a() {
3561
3347
  playback = [];
3562
3348
  analysis = [];
3563
3349
  transit = {};
3564
- track = null;
3350
+ track$1 = null;
3565
3351
  }
3566
3352
  function queue(tokens, transmit) {
3567
3353
  if (transmit === void 0) { transmit = true; }
@@ -3581,6 +3367,8 @@ function queue(tokens, transmit) {
3581
3367
  analysis.push(event_1);
3582
3368
  break;
3583
3369
  }
3370
+ // Increment event count metric
3371
+ count$1(25 /* EventCount */);
3584
3372
  // Following two checks are precautionary and act as a fail safe mechanism to get out of unexpected situations.
3585
3373
  // Check 1: If for any reason the upload hasn't happened after waiting for 2x the config.delay time,
3586
3374
  // reset the timer. This allows Clarity to attempt an upload again.
@@ -3594,15 +3382,15 @@ function queue(tokens, transmit) {
3594
3382
  // We enrich the data going out with the existing upload. In these cases, call to upload comes with 'transmit' set to false.
3595
3383
  if (transmit && timeout === null) {
3596
3384
  if (type !== 25 /* Ping */) {
3597
- reset$j();
3385
+ reset$m();
3598
3386
  }
3599
3387
  timeout = setTimeout(upload, gap);
3600
3388
  queuedTime = now;
3601
- check$3(playbackBytes);
3389
+ check$2(playbackBytes);
3602
3390
  }
3603
3391
  }
3604
3392
  }
3605
- function stop$9() {
3393
+ function stop$b() {
3606
3394
  clearTimeout(timeout);
3607
3395
  upload(true);
3608
3396
  discoverBytes = 0;
@@ -3611,7 +3399,7 @@ function stop$9() {
3611
3399
  playback = [];
3612
3400
  analysis = [];
3613
3401
  transit = {};
3614
- track = null;
3402
+ track$1 = null;
3615
3403
  active$1 = false;
3616
3404
  }
3617
3405
  function upload(final) {
@@ -3622,15 +3410,15 @@ function upload(final) {
3622
3410
  switch (_b.label) {
3623
3411
  case 0:
3624
3412
  timeout = null;
3625
- sendPlaybackBytes = config$1.lean === false && playbackBytes > 0 && (playbackBytes < 1048576 /* MaxFirstPayloadBytes */ || data$h.sequence > 0);
3413
+ sendPlaybackBytes = config$1.lean === false && playbackBytes > 0 && (playbackBytes < 1048576 /* MaxFirstPayloadBytes */ || data$1.sequence > 0);
3626
3414
  if (sendPlaybackBytes) {
3627
3415
  max(1 /* Playback */, 1 /* True */);
3628
3416
  }
3629
3417
  // CAUTION: Ensure "transmit" is set to false in the queue function for following events
3630
3418
  // Otherwise you run a risk of infinite loop.
3419
+ compute$5();
3631
3420
  compute$4();
3632
- compute$3();
3633
- compute$7();
3421
+ compute$8();
3634
3422
  last = final === true;
3635
3423
  e = JSON.stringify(envelope(last));
3636
3424
  a = "[" + analysis.join() + "]";
@@ -3647,7 +3435,7 @@ function upload(final) {
3647
3435
  case 3:
3648
3436
  zipped = _a;
3649
3437
  sum(2 /* TotalBytes */, zipped ? zipped.length : payload.length);
3650
- send(payload, zipped, data$h.sequence, last);
3438
+ send(payload, zipped, data$1.sequence, last);
3651
3439
  // Clear out events now that payload has been dispatched
3652
3440
  analysis = [];
3653
3441
  if (sendPlaybackBytes) {
@@ -3696,7 +3484,7 @@ function send(payload, zipped, sequence, beacon) {
3696
3484
  var xhr_1 = new XMLHttpRequest();
3697
3485
  xhr_1.open("POST", url);
3698
3486
  if (sequence !== null) {
3699
- xhr_1.onreadystatechange = function () { measure(check$2)(xhr_1, sequence); };
3487
+ xhr_1.onreadystatechange = function () { measure(check$3)(xhr_1, sequence); };
3700
3488
  }
3701
3489
  xhr_1.withCredentials = true;
3702
3490
  if (zipped) {
@@ -3716,7 +3504,7 @@ function send(payload, zipped, sequence, beacon) {
3716
3504
  done(sequence);
3717
3505
  }
3718
3506
  }
3719
- function check$2(xhr, sequence) {
3507
+ function check$3(xhr, sequence) {
3720
3508
  var transitData = transit[sequence];
3721
3509
  if (xhr && xhr.readyState === 4 /* Done */ && transitData) {
3722
3510
  // Attempt send payload again (as configured in settings) if we do not receive a success (2XX) response code back from the server
@@ -3724,7 +3512,7 @@ function check$2(xhr, sequence) {
3724
3512
  // We re-attempt in all cases except when server explicitly rejects our request with 4XX error
3725
3513
  if (xhr.status >= 400 && xhr.status < 500) {
3726
3514
  // In case of a 4XX response from the server, we bail out instead of trying again
3727
- trigger$1(6 /* Server */);
3515
+ trigger(6 /* Server */);
3728
3516
  }
3729
3517
  else {
3730
3518
  // Browser will send status = 0 when it refuses to put network request over the wire
@@ -3742,7 +3530,7 @@ function check$2(xhr, sequence) {
3742
3530
  }
3743
3531
  }
3744
3532
  else {
3745
- track = { sequence: sequence, attempts: transitData.attempts, status: xhr.status };
3533
+ track$1 = { sequence: sequence, attempts: transitData.attempts, status: xhr.status };
3746
3534
  // Send back an event only if we were not successful in our first attempt
3747
3535
  if (transitData.attempts > 1) {
3748
3536
  encode$1(2 /* Upload */);
@@ -3756,7 +3544,7 @@ function check$2(xhr, sequence) {
3756
3544
  // And, right before we terminate the session, we will attempt one last time to see if we can use
3757
3545
  // different transport option (sendBeacon vs. XHR) to get this data to the server for analysis purposes
3758
3546
  send(transitData.data, null, sequence, true);
3759
- trigger$1(3 /* Retry */);
3547
+ trigger(3 /* Retry */);
3760
3548
  }
3761
3549
  // Signal that this request completed successfully
3762
3550
  if (xhr.status >= 200 && xhr.status <= 208) {
@@ -3776,7 +3564,7 @@ function done(sequence) {
3776
3564
  function delay() {
3777
3565
  // Progressively increase delay as we continue to send more payloads from the client to the server
3778
3566
  // If we are not uploading data to a server, and instead invoking UploadCallback, in that case keep returning configured value
3779
- var gap = config$1.lean === false && discoverBytes > 0 ? 100 /* MinUploadDelay */ : data$h.sequence * config$1.delay;
3567
+ var gap = config$1.lean === false && discoverBytes > 0 ? 100 /* MinUploadDelay */ : data$1.sequence * config$1.delay;
3780
3568
  return typeof config$1.upload === "string" /* String */ ? Math.max(Math.min(gap, 30000 /* MaxUploadDelay */), 100 /* MinUploadDelay */) : config$1.delay;
3781
3569
  }
3782
3570
  function response(payload) {
@@ -3784,7 +3572,7 @@ function response(payload) {
3784
3572
  switch (key) {
3785
3573
  case "END" /* End */:
3786
3574
  // Clear out session storage and end the session so we can start fresh the next time
3787
- trigger$1(6 /* Server */);
3575
+ trigger(6 /* Server */);
3788
3576
  break;
3789
3577
  case "UPGRADE" /* Upgrade */:
3790
3578
  // Upgrade current session to send back playback information
@@ -3798,7 +3586,7 @@ function encode$1 (event) {
3798
3586
  var tokens = [t, event];
3799
3587
  switch (event) {
3800
3588
  case 4 /* Baseline */:
3801
- var b = state$7;
3589
+ var b = state$9;
3802
3590
  if (b) {
3803
3591
  tokens = [b.time, b.event];
3804
3592
  tokens.push(b.data.visible);
@@ -3813,45 +3601,45 @@ function encode$1 (event) {
3813
3601
  tokens.push(b.data.activityTime);
3814
3602
  queue(tokens, false);
3815
3603
  }
3816
- reset$n();
3604
+ reset$o();
3817
3605
  break;
3818
3606
  case 25 /* Ping */:
3819
- tokens.push(data$e.gap);
3607
+ tokens.push(data$g.gap);
3820
3608
  queue(tokens);
3821
3609
  break;
3822
3610
  case 35 /* Limit */:
3823
- tokens.push(data$g.check);
3611
+ tokens.push(data$4.check);
3824
3612
  queue(tokens, false);
3825
3613
  break;
3826
3614
  case 3 /* Upgrade */:
3827
- tokens.push(data$c.key);
3615
+ tokens.push(data$e.key);
3828
3616
  queue(tokens);
3829
3617
  break;
3830
3618
  case 2 /* Upload */:
3831
- tokens.push(track.sequence);
3832
- tokens.push(track.attempts);
3833
- tokens.push(track.status);
3619
+ tokens.push(track$1.sequence);
3620
+ tokens.push(track$1.attempts);
3621
+ tokens.push(track$1.status);
3834
3622
  queue(tokens, false);
3835
3623
  break;
3836
3624
  case 24 /* Custom */:
3837
- tokens.push(data$k.key);
3838
- tokens.push(data$k.value);
3625
+ tokens.push(data$i.key);
3626
+ tokens.push(data$i.value);
3839
3627
  queue(tokens);
3840
3628
  break;
3841
3629
  case 34 /* Variable */:
3842
- var variableKeys = Object.keys(data$j);
3630
+ var variableKeys = Object.keys(data$d);
3843
3631
  if (variableKeys.length > 0) {
3844
3632
  for (var _i = 0, variableKeys_1 = variableKeys; _i < variableKeys_1.length; _i++) {
3845
3633
  var v = variableKeys_1[_i];
3846
3634
  tokens.push(v);
3847
- tokens.push(data$j[v]);
3635
+ tokens.push(data$d[v]);
3848
3636
  }
3849
- reset$m();
3637
+ reset$k();
3850
3638
  queue(tokens, false);
3851
3639
  }
3852
3640
  break;
3853
3641
  case 0 /* Metric */:
3854
- var metricKeys = Object.keys(updates);
3642
+ var metricKeys = Object.keys(updates$3);
3855
3643
  if (metricKeys.length > 0) {
3856
3644
  for (var _a = 0, metricKeys_1 = metricKeys; _a < metricKeys_1.length; _a++) {
3857
3645
  var m = metricKeys_1[_a];
@@ -3859,99 +3647,441 @@ function encode$1 (event) {
3859
3647
  tokens.push(key);
3860
3648
  // For computation, we need microseconds precision that performance.now() API offers
3861
3649
  // However, for data over the wire, we round it off to milliseconds precision.
3862
- tokens.push(Math.round(updates[m]));
3650
+ tokens.push(Math.round(updates$3[m]));
3863
3651
  }
3864
- reset$3();
3652
+ reset$n();
3865
3653
  queue(tokens, false);
3866
3654
  }
3867
3655
  break;
3868
3656
  case 1 /* Dimension */:
3869
- var dimensionKeys = Object.keys(updates$3);
3657
+ var dimensionKeys = Object.keys(updates);
3870
3658
  if (dimensionKeys.length > 0) {
3871
3659
  for (var _b = 0, dimensionKeys_1 = dimensionKeys; _b < dimensionKeys_1.length; _b++) {
3872
3660
  var d = dimensionKeys_1[_b];
3873
3661
  var key = parseInt(d, 10);
3874
3662
  tokens.push(key);
3875
- tokens.push(updates$3[d]);
3663
+ tokens.push(updates[d]);
3876
3664
  }
3877
- reset$k();
3665
+ reset$3();
3878
3666
  queue(tokens, false);
3879
3667
  }
3880
3668
  break;
3881
3669
  case 36 /* Summary */:
3882
- var eventKeys = Object.keys(data$d);
3670
+ var eventKeys = Object.keys(data$f);
3883
3671
  if (eventKeys.length > 0) {
3884
3672
  for (var _c = 0, eventKeys_1 = eventKeys; _c < eventKeys_1.length; _c++) {
3885
3673
  var e = eventKeys_1[_c];
3886
3674
  var key = parseInt(e, 10);
3887
3675
  tokens.push(key);
3888
- tokens.push([].concat.apply([], data$d[e]));
3676
+ tokens.push([].concat.apply([], data$f[e]));
3889
3677
  }
3890
- reset$i();
3678
+ reset$l();
3891
3679
  queue(tokens, false);
3892
3680
  }
3893
3681
  break;
3894
3682
  }
3895
3683
  }
3896
3684
 
3897
- var data$2 = null;
3685
+ var data$4;
3686
+ function start$b() {
3687
+ data$4 = { check: 0 /* None */ };
3688
+ }
3689
+ function check$2(bytes) {
3690
+ if (data$4.check === 0 /* None */) {
3691
+ var reason = data$4.check;
3692
+ reason = data$1.sequence >= 128 /* PayloadLimit */ ? 1 /* Payload */ : reason;
3693
+ reason = time() > 7200000 /* ShutdownLimit */ ? 2 /* Shutdown */ : reason;
3694
+ reason = bytes > 10485760 /* PlaybackBytesLimit */ ? 2 /* Shutdown */ : reason;
3695
+ if (reason !== data$4.check) {
3696
+ trigger(reason);
3697
+ }
3698
+ }
3699
+ }
3700
+ function trigger(reason) {
3701
+ data$4.check = reason;
3702
+ clear();
3703
+ stop();
3704
+ }
3705
+ function compute$3() {
3706
+ if (data$4.check !== 0 /* None */) {
3707
+ encode$1(35 /* Limit */);
3708
+ }
3709
+ }
3710
+ function stop$a() {
3711
+ data$4 = null;
3712
+ }
3713
+
3714
+ var data$3 = null;
3898
3715
  var updates = null;
3899
- function start$9() {
3900
- data$2 = {};
3716
+ function start$a() {
3717
+ data$3 = {};
3901
3718
  updates = {};
3902
- count$1(5 /* InvokeCount */);
3903
3719
  }
3904
- function stop$8() {
3905
- data$2 = {};
3720
+ function stop$9() {
3721
+ data$3 = {};
3722
+ updates = {};
3723
+ }
3724
+ function log(dimension, value) {
3725
+ // Check valid value before moving ahead
3726
+ if (value) {
3727
+ // Ensure received value is casted into a string if it wasn't a string to begin with
3728
+ value = "" + value;
3729
+ if (!(dimension in data$3)) {
3730
+ data$3[dimension] = [];
3731
+ }
3732
+ if (data$3[dimension].indexOf(value) < 0) {
3733
+ data$3[dimension].push(value);
3734
+ // If this is a new value, track it as part of updates object
3735
+ // This allows us to only send back new values in subsequent payloads
3736
+ if (!(dimension in updates)) {
3737
+ updates[dimension] = [];
3738
+ }
3739
+ updates[dimension].push(value);
3740
+ // Limit check to ensure we have a cap on number of dimensions we can collect
3741
+ if (data$3[dimension].length > 128 /* CollectionLimit */) {
3742
+ trigger(5 /* Collection */);
3743
+ }
3744
+ }
3745
+ }
3746
+ }
3747
+ function compute$2() {
3748
+ encode$1(1 /* Dimension */);
3749
+ }
3750
+ function reset$3() {
3906
3751
  updates = {};
3752
+ }
3753
+
3754
+ var data$2 = null;
3755
+ var callback = null;
3756
+ var rootDomain = null;
3757
+ function start$9() {
3758
+ callback = null;
3759
+ rootDomain = null;
3760
+ var ua = navigator && "userAgent" in navigator ? navigator.userAgent : "" /* Empty */;
3761
+ var title = document && document.title ? document.title : "" /* Empty */;
3762
+ // Populate ids for this page
3763
+ var s = session();
3764
+ var u = user();
3765
+ data$2 = {
3766
+ projectId: config$1.projectId || hash(location.host),
3767
+ userId: u.id,
3768
+ sessionId: s.session,
3769
+ pageNum: s.count
3770
+ };
3771
+ // Override configuration based on what's in the session storage, unless it is blank (e.g. using upload callback, like in devtools)
3772
+ config$1.lean = config$1.track && s.upgrade !== null ? s.upgrade === 0 /* False */ : config$1.lean;
3773
+ config$1.upload = config$1.track && typeof config$1.upload === "string" /* String */ && s.upload && s.upload.length > "https://" /* HTTPS */.length ? s.upload : config$1.upload;
3774
+ // Log dimensions
3775
+ log(0 /* UserAgent */, ua);
3776
+ log(3 /* PageTitle */, title);
3777
+ log(1 /* Url */, location.href);
3778
+ log(2 /* Referrer */, document.referrer);
3779
+ log(15 /* TabId */, tab());
3780
+ log(16 /* PageLanguage */, document.documentElement.lang);
3781
+ log(17 /* DocumentDirection */, document.dir);
3782
+ if (navigator) {
3783
+ log(9 /* Language */, navigator.userLanguage || navigator.language);
3784
+ max(26 /* Automation */, navigator.webdriver ? 1 /* True */ : 0 /* False */);
3785
+ userAgentData();
3786
+ }
3787
+ // Metrics
3788
+ max(0 /* ClientTimestamp */, s.ts);
3789
+ max(1 /* Playback */, 0 /* False */);
3790
+ if (screen) {
3791
+ max(14 /* ScreenWidth */, Math.round(screen.width));
3792
+ max(15 /* ScreenHeight */, Math.round(screen.height));
3793
+ max(16 /* ColorDepth */, Math.round(screen.colorDepth));
3794
+ }
3795
+ // Read cookies specified in configuration
3796
+ for (var _i = 0, _a = config$1.cookies; _i < _a.length; _i++) {
3797
+ var key = _a[_i];
3798
+ var value = getCookie(key);
3799
+ if (value) {
3800
+ set(key, value);
3801
+ }
3802
+ }
3803
+ // Track ids using a cookie if configuration allows it
3804
+ track(u);
3805
+ }
3806
+ function userAgentData() {
3807
+ if (navigator["userAgentData"] && navigator["userAgentData"].getHighEntropyValues) {
3808
+ navigator["userAgentData"].getHighEntropyValues(["model",
3809
+ "platform",
3810
+ "platformVersion",
3811
+ "uaFullVersion"])
3812
+ .then(function (ua) {
3813
+ var _a;
3814
+ log(22 /* Platform */, ua.platform);
3815
+ log(23 /* PlatformVersion */, ua.platformVersion);
3816
+ (_a = ua.brands) === null || _a === void 0 ? void 0 : _a.forEach(function (brand) {
3817
+ log(24 /* Brand */, brand.name + "~" /* Tilde */ + brand.version);
3818
+ });
3819
+ log(25 /* Model */, ua.model);
3820
+ max(27 /* Mobile */, ua.mobile ? 1 /* True */ : 0 /* False */);
3821
+ });
3822
+ }
3823
+ }
3824
+ function stop$8() {
3825
+ callback = null;
3826
+ rootDomain = null;
3827
+ data$2 = null;
3828
+ }
3829
+ function metadata(cb, wait) {
3830
+ if (wait === void 0) { wait = true; }
3831
+ if (data$2 && wait === false) {
3832
+ // Immediately invoke the callback if the caller explicitly doesn't want to wait for the upgrade confirmation
3833
+ cb(data$2, !config$1.lean);
3834
+ }
3835
+ else {
3836
+ // Save the callback for future reference; so we can inform the caller when page gets upgraded and we have a valid playback flag
3837
+ callback = cb;
3838
+ }
3839
+ }
3840
+ function id() {
3841
+ return data$2 ? [data$2.userId, data$2.sessionId, data$2.pageNum].join("." /* Dot */) : "" /* Empty */;
3842
+ }
3843
+ function consent() {
3844
+ if (active()) {
3845
+ config$1.track = true;
3846
+ track(user(), 1 /* True */);
3847
+ }
3848
+ }
3849
+ function clear() {
3850
+ // Clear any stored information in the cookie that tracks session information so we can restart fresh the next time
3851
+ setCookie("_clsk" /* SessionKey */, "" /* Empty */, 0);
3852
+ }
3853
+ function tab() {
3854
+ var id = shortid();
3855
+ if (config$1.track && supported(window, "sessionStorage" /* SessionStorage */)) {
3856
+ var value = sessionStorage.getItem("_cltk" /* TabKey */);
3857
+ id = value ? value : id;
3858
+ sessionStorage.setItem("_cltk" /* TabKey */, id);
3859
+ }
3860
+ return id;
3861
+ }
3862
+ function save() {
3863
+ var ts = Math.round(Date.now());
3864
+ var upgrade = config$1.lean ? 0 /* False */ : 1 /* True */;
3865
+ var upload = config$1.upload && typeof config$1.upload === "string" /* String */ ? config$1.upload.replace("https://" /* HTTPS */, "" /* Empty */) : "" /* Empty */;
3866
+ if (upgrade && callback) {
3867
+ callback(data$2, !config$1.lean);
3868
+ }
3869
+ setCookie("_clsk" /* SessionKey */, [data$2.sessionId, ts, data$2.pageNum, upgrade, upload].join("|" /* Pipe */), 1 /* SessionExpire */);
3870
+ }
3871
+ function supported(target, api) {
3872
+ try {
3873
+ return !!target[api];
3874
+ }
3875
+ catch (_a) {
3876
+ return false;
3877
+ }
3878
+ }
3879
+ function track(u, consent) {
3880
+ if (consent === void 0) { consent = null; }
3881
+ // If consent is not explicitly specified, infer it from the user object
3882
+ consent = consent === null ? u.consent : consent;
3883
+ // Convert time precision into days to reduce number of bytes we have to write in a cookie
3884
+ // E.g. Math.ceil(1628735962643 / (24*60*60*1000)) => 18852 (days) => ejo in base36 (13 bytes => 3 bytes)
3885
+ var end = Math.ceil((Date.now() + (365 /* Expire */ * 86400000 /* Day */)) / 86400000 /* Day */);
3886
+ // To avoid cookie churn, write user id cookie only once every day
3887
+ if (u.expiry === null || Math.abs(end - u.expiry) >= 1 /* CookieInterval */ || u.consent !== consent) {
3888
+ setCookie("_clck" /* CookieKey */, [data$2.userId, 1 /* CookieVersion */, end.toString(36), consent].join("|" /* Pipe */), 365 /* Expire */);
3889
+ }
3907
3890
  }
3908
- function count$1(metric, increment) {
3909
- if (increment === void 0) { increment = 1; }
3910
- if (!(metric in data$2)) {
3911
- data$2[metric] = 0;
3891
+ function shortid() {
3892
+ var id = Math.floor(Math.random() * Math.pow(2, 32));
3893
+ if (window && window.crypto && window.crypto.getRandomValues && Uint32Array) {
3894
+ id = window.crypto.getRandomValues(new Uint32Array(1))[0];
3912
3895
  }
3913
- if (!(metric in updates)) {
3914
- updates[metric] = 0;
3896
+ return id.toString(36);
3897
+ }
3898
+ function session() {
3899
+ var output = { session: shortid(), ts: Math.round(Date.now()), count: 1, upgrade: null, upload: "" /* Empty */ };
3900
+ var value = getCookie("_clsk" /* SessionKey */);
3901
+ if (value) {
3902
+ var parts = value.split("|" /* Pipe */);
3903
+ // Making it backward & forward compatible by using greater than comparison (v0.6.21)
3904
+ // In future version, we can reduce the parts length to be 5 where the last part contains the full upload URL
3905
+ if (parts.length >= 5 && output.ts - num(parts[1]) < 1800000 /* SessionTimeout */) {
3906
+ output.session = parts[0];
3907
+ output.count = num(parts[2]) + 1;
3908
+ output.upgrade = num(parts[3]);
3909
+ output.upload = parts.length >= 6 ? "" + "https://" /* HTTPS */ + parts[5] + "/" + parts[4] : "" + "https://" /* HTTPS */ + parts[4];
3910
+ }
3915
3911
  }
3916
- data$2[metric] += increment;
3917
- updates[metric] += increment;
3912
+ return output;
3918
3913
  }
3919
- function sum(metric, value) {
3920
- if (value !== null) {
3921
- if (!(metric in data$2)) {
3922
- data$2[metric] = 0;
3914
+ function num(string, base) {
3915
+ if (base === void 0) { base = 10; }
3916
+ return parseInt(string, base);
3917
+ }
3918
+ function user() {
3919
+ var output = { id: shortid(), expiry: null, consent: 0 /* False */ };
3920
+ var cookie = getCookie("_clck" /* CookieKey */);
3921
+ if (cookie && cookie.length > 0) {
3922
+ // Splitting and looking up first part for forward compatibility, in case we wish to store additional information in a cookie
3923
+ var parts = cookie.split("|" /* Pipe */);
3924
+ // For backward compatibility introduced in v0.6.18; following code can be removed with future iterations
3925
+ // Count number of times Clarity's user cookie crumb appears in document.cookie (could be on different sub-domains e.g. www.domain.com and .domain.com)
3926
+ var count = 0;
3927
+ for (var _i = 0, _a = document.cookie.split(";" /* Semicolon */); _i < _a.length; _i++) {
3928
+ var c = _a[_i];
3929
+ count += c.split("=" /* Equals */)[0].trim() === "_clck" /* CookieKey */ ? 1 : 0;
3930
+ }
3931
+ // Check if we either got version-less cookie value or saw multiple copies of the user cookie crumbs
3932
+ // In both these cases, we go ahead and delete the existing cookie set on current domain
3933
+ if (parts.length === 1 || count > 1) {
3934
+ var deleted = "" + ";" /* Semicolon */ + "expires=" /* Expires */ + (new Date(0)).toUTCString() + ";path=/" /* Path */;
3935
+ // First, delete current user cookie which might be set on current sub-domain vs. root domain
3936
+ document.cookie = "_clck" /* CookieKey */ + "=" + deleted;
3937
+ // Second, same thing for current session cookie so it can be re-written later with the root domain
3938
+ document.cookie = "_clsk" /* SessionKey */ + "=" + deleted;
3939
+ }
3940
+ // End code for backward compatibility
3941
+ // Read version information and timestamp from cookie, if available
3942
+ if (parts.length > 2) {
3943
+ output.expiry = num(parts[2], 36);
3923
3944
  }
3924
- if (!(metric in updates)) {
3925
- updates[metric] = 0;
3945
+ // Check if we have explicit consent to track this user
3946
+ if (parts.length > 3 && num(parts[3]) === 1) {
3947
+ output.consent = 1 /* True */;
3926
3948
  }
3927
- data$2[metric] += value;
3928
- updates[metric] += value;
3949
+ // Set track configuration to true for this user if we have explicit consent, regardless of project setting
3950
+ config$1.track = config$1.track || output.consent === 1 /* True */;
3951
+ // Get user id from cookie only if we tracking is enabled, otherwise fallback to a random id
3952
+ output.id = config$1.track ? parts[0] : output.id;
3929
3953
  }
3954
+ return output;
3930
3955
  }
3931
- function max(metric, value) {
3932
- // Ensure that we do not process null or NaN values
3933
- if (value !== null && isNaN(value) === false) {
3934
- if (!(metric in data$2)) {
3935
- data$2[metric] = 0;
3956
+ function getCookie(key) {
3957
+ if (supported(document, "cookie" /* Cookie */)) {
3958
+ var cookies = document.cookie.split(";" /* Semicolon */);
3959
+ if (cookies) {
3960
+ for (var i = 0; i < cookies.length; i++) {
3961
+ var pair = cookies[i].split("=" /* Equals */);
3962
+ if (pair.length > 1 && pair[0] && pair[0].trim() === key) {
3963
+ return pair[1];
3964
+ }
3965
+ }
3966
+ }
3967
+ }
3968
+ return null;
3969
+ }
3970
+ function setCookie(key, value, time) {
3971
+ if (config$1.track && ((navigator && navigator.cookieEnabled) || supported(document, "cookie" /* Cookie */))) {
3972
+ var expiry = new Date();
3973
+ expiry.setDate(expiry.getDate() + time);
3974
+ var expires = expiry ? "expires=" /* Expires */ + expiry.toUTCString() : "" /* Empty */;
3975
+ var cookie = key + "=" + value + ";" /* Semicolon */ + expires + ";path=/" /* Path */;
3976
+ try {
3977
+ // Attempt to get the root domain only once and fall back to writing cookie on the current domain.
3978
+ if (rootDomain === null) {
3979
+ var hostname = location.hostname ? location.hostname.split("." /* Dot */) : [];
3980
+ // Walk backwards on a domain and attempt to set a cookie, until successful
3981
+ for (var i = hostname.length - 1; i >= 0; i--) {
3982
+ rootDomain = "." + hostname[i] + (rootDomain ? rootDomain : "" /* Empty */);
3983
+ // We do not wish to attempt writing a cookie on the absolute last part of the domain, e.g. .com or .net.
3984
+ // So we start attempting after second-last part, e.g. .domain.com (PASS) or .co.uk (FAIL)
3985
+ if (i < hostname.length - 1) {
3986
+ // Write the cookie on the current computed top level domain
3987
+ document.cookie = "" + cookie + ";" /* Semicolon */ + "domain=" /* Domain */ + rootDomain;
3988
+ // Once written, check if the cookie exists and its value matches exactly with what we intended to set
3989
+ // Checking for exact value match helps us eliminate a corner case where the cookie may already be present with a different value
3990
+ // If the check is successful, no more action is required and we can return from the function since rootDomain cookie is already set
3991
+ // If the check fails, continue with the for loop until we can successfully set and verify the cookie
3992
+ if (getCookie(key) === value) {
3993
+ return;
3994
+ }
3995
+ }
3996
+ }
3997
+ // Finally, if we were not successful and gone through all the options, play it safe and reset rootDomain to be empty
3998
+ // This forces our code to fall back to always writing cookie to the current domain
3999
+ rootDomain = "" /* Empty */;
4000
+ }
3936
4001
  }
3937
- if (value > data$2[metric] || data$2[metric] === 0) {
3938
- updates[metric] = value;
3939
- data$2[metric] = value;
4002
+ catch (_a) {
4003
+ rootDomain = "" /* Empty */;
3940
4004
  }
4005
+ document.cookie = rootDomain ? "" + cookie + ";" /* Semicolon */ + "domain=" /* Domain */ + rootDomain : cookie;
3941
4006
  }
4007
+ }
4008
+
4009
+ var data$1 = null;
4010
+ function start$8() {
4011
+ var m = data$2;
4012
+ data$1 = {
4013
+ version: version$1,
4014
+ sequence: 0,
4015
+ start: 0,
4016
+ duration: 0,
4017
+ projectId: m.projectId,
4018
+ userId: m.userId,
4019
+ sessionId: m.sessionId,
4020
+ pageNum: m.pageNum,
4021
+ upload: 0 /* Async */,
4022
+ end: 0 /* False */
4023
+ };
3942
4024
  }
3943
- function compute$2() {
3944
- encode$1(0 /* Metric */);
4025
+ function stop$7() {
4026
+ data$1 = null;
3945
4027
  }
3946
- function reset$3() {
3947
- updates = {};
4028
+ function envelope(last) {
4029
+ data$1.start = data$1.start + data$1.duration;
4030
+ data$1.duration = time() - data$1.start;
4031
+ data$1.sequence++;
4032
+ data$1.upload = last && "sendBeacon" in navigator ? 1 /* Beacon */ : 0 /* Async */;
4033
+ data$1.end = last ? 1 /* True */ : 0 /* False */;
4034
+ return [
4035
+ data$1.version,
4036
+ data$1.sequence,
4037
+ data$1.start,
4038
+ data$1.duration,
4039
+ data$1.projectId,
4040
+ data$1.userId,
4041
+ data$1.sessionId,
4042
+ data$1.pageNum,
4043
+ data$1.upload,
4044
+ data$1.end
4045
+ ];
4046
+ }
4047
+
4048
+ var history$1;
4049
+ function reset$2() {
4050
+ history$1 = [];
4051
+ }
4052
+ function report(e) {
4053
+ // Do not report the same message twice for the same page
4054
+ if (history$1 && history$1.indexOf(e.message) === -1) {
4055
+ var url = config$1.report;
4056
+ if (url && url.length > 0) {
4057
+ var payload = { v: data$1.version, p: data$1.projectId, u: data$1.userId, s: data$1.sessionId, n: data$1.pageNum };
4058
+ if (e.message) {
4059
+ payload.m = e.message;
4060
+ }
4061
+ if (e.stack) {
4062
+ payload.e = e.stack;
4063
+ }
4064
+ // Using POST request instead of a GET request (img-src) to not violate existing CSP rules
4065
+ // Since, Clarity already uses XHR to upload data, we stick with similar POST mechanism for reporting too
4066
+ var xhr = new XMLHttpRequest();
4067
+ xhr.open("POST", url);
4068
+ xhr.send(JSON.stringify(payload));
4069
+ history$1.push(e.message);
4070
+ }
4071
+ }
4072
+ return e;
3948
4073
  }
3949
4074
 
3950
4075
  // tslint:disable-next-line: ban-types
3951
4076
  function measure (method) {
3952
4077
  return function () {
3953
4078
  var start = performance.now();
3954
- method.apply(this, arguments);
4079
+ try {
4080
+ method.apply(this, arguments);
4081
+ }
4082
+ catch (ex) {
4083
+ throw report(ex);
4084
+ }
3955
4085
  var duration = performance.now() - start;
3956
4086
  sum(4 /* TotalCost */, duration);
3957
4087
  if (duration > 30 /* LongTask */) {
@@ -3973,7 +4103,7 @@ function bind(target, event, listener, capture) {
3973
4103
  }
3974
4104
  catch ( /* do nothing */_a) { /* do nothing */ }
3975
4105
  }
3976
- function reset$2() {
4106
+ function reset$1() {
3977
4107
  // Walk through existing list of bindings and remove them all
3978
4108
  for (var _i = 0, bindings_1 = bindings; _i < bindings_1.length; _i++) {
3979
4109
  var binding = bindings_1[_i];
@@ -3990,7 +4120,7 @@ var pushState = null;
3990
4120
  var replaceState = null;
3991
4121
  var url = null;
3992
4122
  var count = 0;
3993
- function start$8() {
4123
+ function start$7() {
3994
4124
  url = getCurrentUrl();
3995
4125
  count = 0;
3996
4126
  bind(window, "popstate", compute$1);
@@ -4017,7 +4147,7 @@ function start$8() {
4017
4147
  }
4018
4148
  function check$1() {
4019
4149
  if (count++ > 20 /* CallStackDepth */) {
4020
- log(4 /* CallStackDepth */, 0 /* Info */);
4150
+ log$1(4 /* CallStackDepth */, 0 /* Info */);
4021
4151
  return false;
4022
4152
  }
4023
4153
  return true;
@@ -4033,7 +4163,7 @@ function compute$1() {
4033
4163
  function getCurrentUrl() {
4034
4164
  return location.href ? location.href.replace(location.hash, "" /* Empty */) : location.href;
4035
4165
  }
4036
- function stop$7() {
4166
+ function stop$6() {
4037
4167
  // Restore original function definition of history.pushState
4038
4168
  if (pushState !== null) {
4039
4169
  history.pushState = pushState;
@@ -4049,19 +4179,19 @@ function stop$7() {
4049
4179
  }
4050
4180
 
4051
4181
  var status = false;
4052
- function start$7() {
4182
+ function start$6() {
4053
4183
  status = true;
4054
4184
  start$E();
4055
- reset$h();
4185
+ reset$j();
4186
+ reset$1();
4056
4187
  reset$2();
4057
- reset$l();
4058
- start$8();
4188
+ start$7();
4059
4189
  }
4060
- function stop$6() {
4061
- stop$7();
4062
- reset$l();
4190
+ function stop$5() {
4191
+ stop$6();
4063
4192
  reset$2();
4064
- reset$h();
4193
+ reset$1();
4194
+ reset$j();
4065
4195
  stop$B();
4066
4196
  status = false;
4067
4197
  }
@@ -4115,26 +4245,24 @@ function restart() {
4115
4245
  event("clarity" /* Clarity */, "restart" /* Restart */);
4116
4246
  }
4117
4247
 
4118
- function start$6() {
4119
- start$p();
4248
+ function start$5() {
4249
+ start$t();
4120
4250
  start$s();
4121
- start$o();
4122
4251
  }
4123
- function stop$5() {
4124
- stop$p();
4125
- stop$n();
4252
+ function stop$4() {
4253
+ stop$r();
4126
4254
  }
4127
4255
 
4128
4256
  var diagnostic = /*#__PURE__*/Object.freeze({
4129
4257
  __proto__: null,
4130
- start: start$6,
4131
- stop: stop$5
4258
+ start: start$5,
4259
+ stop: stop$4
4132
4260
  });
4133
4261
 
4134
- function start$5() {
4262
+ function start$4() {
4135
4263
  schedule$1(discover, 1 /* High */).then(function () {
4136
- measure(compute$6)();
4137
- measure(compute$4)();
4264
+ measure(compute$7)();
4265
+ measure(compute$5)();
4138
4266
  });
4139
4267
  }
4140
4268
  function discover() {
@@ -4145,70 +4273,44 @@ function discover() {
4145
4273
  case 0:
4146
4274
  ts = time();
4147
4275
  timer = { id: id(), cost: 3 /* LayoutCost */ };
4148
- start$t(timer);
4276
+ start$w(timer);
4149
4277
  return [4 /*yield*/, traverse(document, timer, 0 /* Discover */)];
4150
4278
  case 1:
4151
4279
  _a.sent();
4152
4280
  return [4 /*yield*/, encode$4(5 /* Discover */, timer, ts)];
4153
4281
  case 2:
4154
4282
  _a.sent();
4155
- stop$q(timer);
4283
+ stop$t(timer);
4156
4284
  return [2 /*return*/];
4157
4285
  }
4158
4286
  });
4159
4287
  });
4160
4288
  }
4161
4289
 
4162
- function start$4() {
4290
+ function start$3() {
4163
4291
  // The order below is important
4164
4292
  // and is determined by interdependencies of modules
4165
- start$r();
4166
- start$m();
4167
- start$n();
4168
- start$c();
4169
- start$5();
4293
+ start$v();
4170
4294
  start$q();
4295
+ start$r();
4296
+ start$e();
4297
+ start$4();
4298
+ start$u();
4171
4299
  }
4172
- function stop$4() {
4173
- stop$l();
4174
- stop$m();
4175
- stop$b();
4176
- stop$o();
4300
+ function stop$3() {
4301
+ stop$p();
4302
+ stop$q();
4303
+ stop$d();
4304
+ stop$s();
4177
4305
  end();
4178
4306
  }
4179
4307
 
4180
4308
  var layout = /*#__PURE__*/Object.freeze({
4181
4309
  __proto__: null,
4182
- start: start$4,
4183
- stop: stop$4
4310
+ start: start$3,
4311
+ stop: stop$3
4184
4312
  });
4185
4313
 
4186
- var data$1 = null;
4187
- function reset$1() {
4188
- data$1 = null;
4189
- }
4190
- function compute(entry) {
4191
- data$1 = {
4192
- fetchStart: Math.round(entry.fetchStart),
4193
- connectStart: Math.round(entry.connectStart),
4194
- connectEnd: Math.round(entry.connectEnd),
4195
- requestStart: Math.round(entry.requestStart),
4196
- responseStart: Math.round(entry.responseStart),
4197
- responseEnd: Math.round(entry.responseEnd),
4198
- domInteractive: Math.round(entry.domInteractive),
4199
- domComplete: Math.round(entry.domComplete),
4200
- loadEventStart: Math.round(entry.loadEventStart),
4201
- loadEventEnd: Math.round(entry.loadEventEnd),
4202
- redirectCount: Math.round(entry.redirectCount),
4203
- size: entry.transferSize ? entry.transferSize : 0,
4204
- type: entry.type,
4205
- protocol: entry.nextHopProtocol,
4206
- encodedSize: entry.encodedBodySize ? entry.encodedBodySize : 0,
4207
- decodedSize: entry.decodedBodySize ? entry.decodedBodySize : 0
4208
- };
4209
- encode(29 /* Navigation */);
4210
- }
4211
-
4212
4314
  function encode (type) {
4213
4315
  return __awaiter(this, void 0, void 0, function () {
4214
4316
  var t, tokens;
@@ -4216,68 +4318,56 @@ function encode (type) {
4216
4318
  t = time();
4217
4319
  tokens = [t, type];
4218
4320
  switch (type) {
4219
- case 30 /* Connection */:
4220
- tokens.push(data.downlink);
4221
- tokens.push(data.rtt);
4222
- tokens.push(data.saveData);
4321
+ case 29 /* Navigation */:
4322
+ tokens.push(data.fetchStart);
4323
+ tokens.push(data.connectStart);
4324
+ tokens.push(data.connectEnd);
4325
+ tokens.push(data.requestStart);
4326
+ tokens.push(data.responseStart);
4327
+ tokens.push(data.responseEnd);
4328
+ tokens.push(data.domInteractive);
4329
+ tokens.push(data.domComplete);
4330
+ tokens.push(data.loadEventStart);
4331
+ tokens.push(data.loadEventEnd);
4332
+ tokens.push(data.redirectCount);
4333
+ tokens.push(data.size);
4223
4334
  tokens.push(data.type);
4335
+ tokens.push(data.protocol);
4336
+ tokens.push(data.encodedSize);
4337
+ tokens.push(data.decodedSize);
4224
4338
  reset();
4225
4339
  queue(tokens, false);
4226
4340
  break;
4227
- case 29 /* Navigation */:
4228
- tokens.push(data$1.fetchStart);
4229
- tokens.push(data$1.connectStart);
4230
- tokens.push(data$1.connectEnd);
4231
- tokens.push(data$1.requestStart);
4232
- tokens.push(data$1.responseStart);
4233
- tokens.push(data$1.responseEnd);
4234
- tokens.push(data$1.domInteractive);
4235
- tokens.push(data$1.domComplete);
4236
- tokens.push(data$1.loadEventStart);
4237
- tokens.push(data$1.loadEventEnd);
4238
- tokens.push(data$1.redirectCount);
4239
- tokens.push(data$1.size);
4240
- tokens.push(data$1.type);
4241
- tokens.push(data$1.protocol);
4242
- tokens.push(data$1.encodedSize);
4243
- tokens.push(data$1.decodedSize);
4244
- reset$1();
4245
- queue(tokens, false);
4246
- break;
4247
4341
  }
4248
4342
  return [2 /*return*/];
4249
4343
  });
4250
4344
  });
4251
4345
  }
4252
4346
 
4253
- // Reference: https://wicg.github.io/netinfo/
4254
- var data;
4255
- function start$3() {
4256
- // Check if the client supports Navigator.Connection: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/connection
4257
- // This is an experimental API so we go a bit deeper in our check and ensure that values returned are valid
4258
- if (navigator &&
4259
- "connection" in navigator &&
4260
- "downlink" in navigator["connection"] &&
4261
- typeof navigator["connection"]["downlink"] === "number") {
4262
- navigator["connection"].addEventListener("change", recompute);
4263
- recompute();
4264
- }
4265
- }
4266
- function recompute() {
4267
- var connection = navigator["connection"];
4268
- data = {
4269
- downlink: connection.downlink,
4270
- rtt: connection.rtt,
4271
- saveData: connection.saveData ? 1 /* True */ : 0 /* False */,
4272
- type: connection.effectiveType
4273
- };
4274
- encode(30 /* Connection */);
4275
- }
4347
+ var data = null;
4276
4348
  function reset() {
4277
4349
  data = null;
4278
4350
  }
4279
- function stop$3() {
4280
- reset();
4351
+ function compute(entry) {
4352
+ data = {
4353
+ fetchStart: Math.round(entry.fetchStart),
4354
+ connectStart: Math.round(entry.connectStart),
4355
+ connectEnd: Math.round(entry.connectEnd),
4356
+ requestStart: Math.round(entry.requestStart),
4357
+ responseStart: Math.round(entry.responseStart),
4358
+ responseEnd: Math.round(entry.responseEnd),
4359
+ domInteractive: Math.round(entry.domInteractive),
4360
+ domComplete: Math.round(entry.domComplete),
4361
+ loadEventStart: Math.round(entry.loadEventStart),
4362
+ loadEventEnd: Math.round(entry.loadEventEnd),
4363
+ redirectCount: Math.round(entry.redirectCount),
4364
+ size: entry.transferSize ? entry.transferSize : 0,
4365
+ type: entry.type,
4366
+ protocol: entry.nextHopProtocol,
4367
+ encodedSize: entry.encodedBodySize ? entry.encodedBodySize : 0,
4368
+ decodedSize: entry.decodedBodySize ? entry.decodedBodySize : 0
4369
+ };
4370
+ encode(29 /* Navigation */);
4281
4371
  }
4282
4372
 
4283
4373
  var observer;
@@ -4296,7 +4386,7 @@ function start$2() {
4296
4386
  }
4297
4387
  }
4298
4388
  else {
4299
- log(3 /* PerformanceObserver */, 0 /* Info */);
4389
+ log$1(3 /* PerformanceObserver */, 0 /* Info */);
4300
4390
  }
4301
4391
  }
4302
4392
  function observe() {
@@ -4324,7 +4414,7 @@ function observe() {
4324
4414
  }
4325
4415
  }
4326
4416
  catch (_a) {
4327
- log(3 /* PerformanceObserver */, 1 /* Warning */);
4417
+ log$1(3 /* PerformanceObserver */, 1 /* Warning */);
4328
4418
  }
4329
4419
  }
4330
4420
  function handle(entries) {
@@ -4339,7 +4429,7 @@ function process(entries) {
4339
4429
  compute(entry);
4340
4430
  break;
4341
4431
  case "resource" /* Resource */:
4342
- log$1(4 /* NetworkHosts */, host(entry.name));
4432
+ log(4 /* NetworkHosts */, host(entry.name));
4343
4433
  break;
4344
4434
  case "longtask" /* LongTask */:
4345
4435
  count$1(7 /* LongTaskCount */);
@@ -4376,14 +4466,12 @@ function host(url) {
4376
4466
  }
4377
4467
 
4378
4468
  function start$1() {
4379
- reset$1();
4380
- start$3();
4469
+ reset();
4381
4470
  start$2();
4382
4471
  }
4383
4472
  function stop$1() {
4384
4473
  stop$2();
4385
- stop$3();
4386
- reset$1();
4474
+ reset();
4387
4475
  }
4388
4476
 
4389
4477
  var performance$1 = /*#__PURE__*/Object.freeze({
@@ -4398,8 +4486,8 @@ function start(config$1) {
4398
4486
  // Check that browser supports required APIs and we do not attempt to start Clarity multiple times
4399
4487
  if (check()) {
4400
4488
  config(config$1);
4401
- start$7();
4402
- start$u();
4489
+ start$6();
4490
+ start$x();
4403
4491
  modules.forEach(function (x) { return measure(x.start)(); });
4404
4492
  }
4405
4493
  }
@@ -4425,8 +4513,8 @@ function stop() {
4425
4513
  if (active()) {
4426
4514
  // Stop modules in the reverse order of their initialization
4427
4515
  modules.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
4428
- stop$r();
4429
- stop$6();
4516
+ stop$u();
4517
+ stop$5();
4430
4518
  }
4431
4519
  }
4432
4520
 
@@ -4442,7 +4530,7 @@ var clarity = /*#__PURE__*/Object.freeze({
4442
4530
  identify: identify,
4443
4531
  set: set,
4444
4532
  upgrade: upgrade,
4445
- metadata: metadata$1
4533
+ metadata: metadata
4446
4534
  });
4447
4535
 
4448
4536
  var helper = { hash: hash, selector: selector, get: get, getNode: getNode, lookup: lookup };