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