clarity-js 0.7.32 → 0.7.34
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.extended.js +1 -1
- package/build/clarity.insight.js +1 -1
- package/build/clarity.js +75 -39
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +75 -39
- package/build/clarity.performance.js +1 -1
- package/package.json +1 -1
- package/src/core/config.ts +2 -1
- package/src/core/time.ts +7 -2
- package/src/core/version.ts +1 -1
- package/src/interaction/encode.ts +6 -2
- package/src/interaction/scroll.ts +30 -8
- package/src/layout/discover.ts +2 -1
- package/src/layout/dom.ts +5 -0
- package/src/layout/encode.ts +4 -2
- package/src/layout/mutation.ts +4 -2
- package/src/layout/node.ts +1 -1
- package/types/core.d.ts +1 -0
- package/types/data.d.ts +3 -1
- package/types/interaction.d.ts +2 -2
package/build/clarity.js
CHANGED
|
@@ -133,7 +133,8 @@ var config$1 = {
|
|
|
133
133
|
upgrade: null,
|
|
134
134
|
action: null,
|
|
135
135
|
dob: null,
|
|
136
|
-
delayDom: false
|
|
136
|
+
delayDom: false,
|
|
137
|
+
throttleDom: true
|
|
137
138
|
};
|
|
138
139
|
|
|
139
140
|
function api(method) {
|
|
@@ -145,18 +146,23 @@ function api(method) {
|
|
|
145
146
|
|
|
146
147
|
var startTime = 0;
|
|
147
148
|
function start$I() {
|
|
148
|
-
startTime = performance.now();
|
|
149
|
+
startTime = performance.now() + performance.timeOrigin;
|
|
149
150
|
}
|
|
151
|
+
// event.timestamp is number of milliseconds elapsed since the document was loaded
|
|
152
|
+
// since iframes can be loaded later the event timestamp is not the same as performance.now()
|
|
153
|
+
// converting everything to absolute time by adding timeorigin of the event view
|
|
154
|
+
// to synchronize times before calculating the difference with start time
|
|
150
155
|
function time(event) {
|
|
151
156
|
if (event === void 0) { event = null; }
|
|
152
157
|
var ts = event && event.timeStamp > 0 ? event.timeStamp : performance.now();
|
|
153
|
-
|
|
158
|
+
var origin = event && event.view ? event.view.performance.timeOrigin : performance.timeOrigin;
|
|
159
|
+
return Math.max(Math.round(ts + origin - startTime), 0);
|
|
154
160
|
}
|
|
155
161
|
function stop$F() {
|
|
156
162
|
startTime = 0;
|
|
157
163
|
}
|
|
158
164
|
|
|
159
|
-
var version$1 = "0.7.
|
|
165
|
+
var version$1 = "0.7.34";
|
|
160
166
|
|
|
161
167
|
// tslint:disable: no-bitwise
|
|
162
168
|
function hash (input, precision) {
|
|
@@ -429,7 +435,7 @@ function visibility(t, visible) {
|
|
|
429
435
|
}
|
|
430
436
|
update$2 = true;
|
|
431
437
|
}
|
|
432
|
-
function compute$
|
|
438
|
+
function compute$e() {
|
|
433
439
|
if (update$2) {
|
|
434
440
|
encode$1(4 /* Event.Baseline */);
|
|
435
441
|
}
|
|
@@ -441,7 +447,7 @@ function stop$E() {
|
|
|
441
447
|
var baseline = /*#__PURE__*/Object.freeze({
|
|
442
448
|
__proto__: null,
|
|
443
449
|
activity: activity,
|
|
444
|
-
compute: compute$
|
|
450
|
+
compute: compute$e,
|
|
445
451
|
reset: reset$s,
|
|
446
452
|
start: start$H,
|
|
447
453
|
get state () { return state$c; },
|
|
@@ -513,7 +519,7 @@ function max(metric, value) {
|
|
|
513
519
|
}
|
|
514
520
|
}
|
|
515
521
|
}
|
|
516
|
-
function compute$
|
|
522
|
+
function compute$d() {
|
|
517
523
|
encode$1(0 /* Event.Metric */);
|
|
518
524
|
}
|
|
519
525
|
function reset$r() {
|
|
@@ -591,7 +597,7 @@ function track$7(event, time) {
|
|
|
591
597
|
}
|
|
592
598
|
}
|
|
593
599
|
}
|
|
594
|
-
function compute$
|
|
600
|
+
function compute$c() {
|
|
595
601
|
encode$1(36 /* Event.Summary */);
|
|
596
602
|
}
|
|
597
603
|
function reset$p() {
|
|
@@ -600,7 +606,7 @@ function reset$p() {
|
|
|
600
606
|
|
|
601
607
|
var summary = /*#__PURE__*/Object.freeze({
|
|
602
608
|
__proto__: null,
|
|
603
|
-
compute: compute$
|
|
609
|
+
compute: compute$c,
|
|
604
610
|
get data () { return data$g; },
|
|
605
611
|
reset: reset$p,
|
|
606
612
|
start: start$E,
|
|
@@ -755,7 +761,7 @@ function log$2(variable, value) {
|
|
|
755
761
|
data$e[variable] = validValues;
|
|
756
762
|
}
|
|
757
763
|
}
|
|
758
|
-
function compute$
|
|
764
|
+
function compute$b() {
|
|
759
765
|
encode$1(34 /* Event.Variable */);
|
|
760
766
|
}
|
|
761
767
|
function reset$o() {
|
|
@@ -796,7 +802,7 @@ function detect(input) {
|
|
|
796
802
|
|
|
797
803
|
var variable = /*#__PURE__*/Object.freeze({
|
|
798
804
|
__proto__: null,
|
|
799
|
-
compute: compute$
|
|
805
|
+
compute: compute$b,
|
|
800
806
|
get data () { return data$e; },
|
|
801
807
|
identify: identify,
|
|
802
808
|
reset: reset$o,
|
|
@@ -905,12 +911,12 @@ function stop$y() {
|
|
|
905
911
|
modules$1.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
|
|
906
912
|
stop$D();
|
|
907
913
|
}
|
|
908
|
-
function compute$
|
|
909
|
-
compute$
|
|
910
|
-
compute$
|
|
914
|
+
function compute$a() {
|
|
915
|
+
compute$b();
|
|
916
|
+
compute$e();
|
|
911
917
|
compute$2();
|
|
918
|
+
compute$d();
|
|
912
919
|
compute$c();
|
|
913
|
-
compute$b();
|
|
914
920
|
compute$3();
|
|
915
921
|
compute$4();
|
|
916
922
|
}
|
|
@@ -1354,6 +1360,11 @@ function remove(id, source) {
|
|
|
1354
1360
|
}
|
|
1355
1361
|
}
|
|
1356
1362
|
function removeNodeFromNodesMap(id) {
|
|
1363
|
+
// Shadow dom roots shouldn't be deleted,
|
|
1364
|
+
// we should keep listening to the mutations there even they're not rendered in the DOM.
|
|
1365
|
+
if (nodesMap.get(id).nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1357
1368
|
nodesMap.delete(id);
|
|
1358
1369
|
var value = id in values ? values[id] : null;
|
|
1359
1370
|
if (value && value.children) {
|
|
@@ -1658,9 +1669,9 @@ function reset$k() {
|
|
|
1658
1669
|
}
|
|
1659
1670
|
function start$x() {
|
|
1660
1671
|
reset$k();
|
|
1661
|
-
compute$
|
|
1672
|
+
compute$9();
|
|
1662
1673
|
}
|
|
1663
|
-
function compute$
|
|
1674
|
+
function compute$9() {
|
|
1664
1675
|
var body = document.body;
|
|
1665
1676
|
var d = document.documentElement;
|
|
1666
1677
|
var bodyClientWidth = body ? body.clientWidth : null;
|
|
@@ -1718,7 +1729,7 @@ function checkDocumentStyles(documentNode) {
|
|
|
1718
1729
|
}
|
|
1719
1730
|
max(36 /* Metric.ConstructedStyles */, 1);
|
|
1720
1731
|
}
|
|
1721
|
-
function compute$
|
|
1732
|
+
function compute$8() {
|
|
1722
1733
|
checkDocumentStyles(document);
|
|
1723
1734
|
}
|
|
1724
1735
|
function reset$j() {
|
|
@@ -1925,9 +1936,9 @@ function encode$4 (type, timer, ts) {
|
|
|
1925
1936
|
tokens.push(value.id * factor);
|
|
1926
1937
|
if (value.parent && active) {
|
|
1927
1938
|
tokens.push(value.parent);
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1939
|
+
if (value.previous) {
|
|
1940
|
+
tokens.push(value.previous);
|
|
1941
|
+
}
|
|
1931
1942
|
}
|
|
1932
1943
|
tokens.push(suspend ? "*M" /* Constant.SuspendMutationTag */ : data[key]);
|
|
1933
1944
|
if (box && box.length === 2) {
|
|
@@ -2035,7 +2046,7 @@ function track$4(id, event) {
|
|
|
2035
2046
|
// Process updates to this region, if applicable
|
|
2036
2047
|
process$6(node, data, interaction, data.visibility);
|
|
2037
2048
|
}
|
|
2038
|
-
function compute$
|
|
2049
|
+
function compute$7() {
|
|
2039
2050
|
// Process any regions where we couldn't resolve an "id" for at the time of last intersection observer event
|
|
2040
2051
|
// This could happen in cases where elements are not yet processed by Clarity's virtual DOM but browser reports a change, regardless.
|
|
2041
2052
|
// For those cases we add them to the queue and re-process them below
|
|
@@ -2475,6 +2486,8 @@ function stop$m() {
|
|
|
2475
2486
|
}
|
|
2476
2487
|
|
|
2477
2488
|
var state$2 = [];
|
|
2489
|
+
var initialTop = null;
|
|
2490
|
+
var initialBottom = null;
|
|
2478
2491
|
var timeout$3 = null;
|
|
2479
2492
|
function start$n() {
|
|
2480
2493
|
state$2 = [];
|
|
@@ -2507,11 +2520,13 @@ function recompute$4(event) {
|
|
|
2507
2520
|
var yOffset = width > height ? height * 0.15 : height * 0.2;
|
|
2508
2521
|
var startYPosition = yOffset;
|
|
2509
2522
|
var endYPosition = height - yOffset;
|
|
2510
|
-
var top =
|
|
2511
|
-
var bottom =
|
|
2523
|
+
var top = getPositionNode(xPosition, startYPosition);
|
|
2524
|
+
var bottom = getPositionNode(xPosition, endYPosition);
|
|
2512
2525
|
var current = { time: time(event), event: 10 /* Event.Scroll */, data: { target: element, x: x, y: y, top: top, bottom: bottom } };
|
|
2513
2526
|
// We don't send any scroll events if this is the first event and the current position is top (0,0)
|
|
2514
2527
|
if ((event === null && x === 0 && y === 0) || (x === null || y === null)) {
|
|
2528
|
+
initialTop = top;
|
|
2529
|
+
initialBottom = bottom;
|
|
2515
2530
|
return;
|
|
2516
2531
|
}
|
|
2517
2532
|
var length = state$2.length;
|
|
@@ -2523,8 +2538,8 @@ function recompute$4(event) {
|
|
|
2523
2538
|
clearTimeout(timeout$3);
|
|
2524
2539
|
timeout$3 = setTimeout(process$3, 500 /* Setting.LookAhead */, 10 /* Event.Scroll */);
|
|
2525
2540
|
}
|
|
2526
|
-
function
|
|
2527
|
-
var _a, _b
|
|
2541
|
+
function getPositionNode(x, y) {
|
|
2542
|
+
var _a, _b;
|
|
2528
2543
|
var node;
|
|
2529
2544
|
if ("caretPositionFromPoint" in document) {
|
|
2530
2545
|
node = (_a = document.caretPositionFromPoint(x, y)) === null || _a === void 0 ? void 0 : _a.offsetNode;
|
|
@@ -2538,10 +2553,12 @@ function getPositionHash(x, y) {
|
|
|
2538
2553
|
if (node && node.nodeType === Node.TEXT_NODE) {
|
|
2539
2554
|
node = node.parentNode;
|
|
2540
2555
|
}
|
|
2541
|
-
return
|
|
2556
|
+
return node;
|
|
2542
2557
|
}
|
|
2543
2558
|
function reset$a() {
|
|
2544
2559
|
state$2 = [];
|
|
2560
|
+
initialTop = null;
|
|
2561
|
+
initialBottom = null;
|
|
2545
2562
|
}
|
|
2546
2563
|
function process$3(event) {
|
|
2547
2564
|
schedule$1(encode$3.bind(this, event));
|
|
@@ -2551,9 +2568,22 @@ function similar(last, current) {
|
|
|
2551
2568
|
var dy = last.data.y - current.data.y;
|
|
2552
2569
|
return (dx * dx + dy * dy < 20 /* Setting.Distance */ * 20 /* Setting.Distance */) && (current.time - last.time < 25 /* Setting.Interval */);
|
|
2553
2570
|
}
|
|
2571
|
+
function compute$6() {
|
|
2572
|
+
var _a, _b;
|
|
2573
|
+
if (initialTop) {
|
|
2574
|
+
var top_1 = metadata$2(initialTop, null);
|
|
2575
|
+
log(31 /* Dimension.InitialScrollTop */, (_a = top_1 === null || top_1 === void 0 ? void 0 : top_1.hash) === null || _a === void 0 ? void 0 : _a.join("." /* Constant.Dot */));
|
|
2576
|
+
}
|
|
2577
|
+
if (initialBottom) {
|
|
2578
|
+
var bottom = metadata$2(initialBottom, null);
|
|
2579
|
+
log(32 /* Dimension.InitialScrollBottom */, (_b = bottom === null || bottom === void 0 ? void 0 : bottom.hash) === null || _b === void 0 ? void 0 : _b.join("." /* Constant.Dot */));
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2554
2582
|
function stop$l() {
|
|
2555
2583
|
clearTimeout(timeout$3);
|
|
2556
2584
|
state$2 = [];
|
|
2585
|
+
initialTop = null;
|
|
2586
|
+
initialBottom = null;
|
|
2557
2587
|
}
|
|
2558
2588
|
|
|
2559
2589
|
var data$a = null;
|
|
@@ -2775,7 +2805,7 @@ function num$1(input, scale) {
|
|
|
2775
2805
|
return null;
|
|
2776
2806
|
}
|
|
2777
2807
|
|
|
2778
|
-
var IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last"];
|
|
2808
|
+
var IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last", "aria-label"];
|
|
2779
2809
|
var newlineRegex = /[\r\n]+/g;
|
|
2780
2810
|
function processNode (node, source, timestamp) {
|
|
2781
2811
|
var _a;
|
|
@@ -3169,8 +3199,8 @@ function handle$1(m) {
|
|
|
3169
3199
|
track$7(6 /* Event.Mutation */, now);
|
|
3170
3200
|
mutations.push({ time: now, mutations: m });
|
|
3171
3201
|
schedule$1(process$1, 1 /* Priority.High */).then(function () {
|
|
3172
|
-
setTimeout(compute$
|
|
3173
|
-
measure(compute$
|
|
3202
|
+
setTimeout(compute$9);
|
|
3203
|
+
measure(compute$7)();
|
|
3174
3204
|
});
|
|
3175
3205
|
}
|
|
3176
3206
|
function process$1() {
|
|
@@ -3202,7 +3232,7 @@ function process$1() {
|
|
|
3202
3232
|
return [3 /*break*/, 6];
|
|
3203
3233
|
}
|
|
3204
3234
|
target = mutation.target;
|
|
3205
|
-
type = track$3(mutation, timer, instance, record.time);
|
|
3235
|
+
type = config$1.throttleDom ? track$3(mutation, timer, instance, record.time) : mutation.type;
|
|
3206
3236
|
if (type && target && target.ownerDocument) {
|
|
3207
3237
|
parse$1(target.ownerDocument);
|
|
3208
3238
|
}
|
|
@@ -3246,7 +3276,8 @@ function track$3(m, timer, instance, timestamp) {
|
|
|
3246
3276
|
var value = m.target ? get(m.target.parentNode) : null;
|
|
3247
3277
|
// Check if the parent is already discovered and that the parent is not the document root
|
|
3248
3278
|
if (value && value.data.tag !== "HTML" /* Constant.HTML */) {
|
|
3249
|
-
|
|
3279
|
+
// calculate inactive period based on the timestamp of the mutation not when the mutation is processed
|
|
3280
|
+
var inactive = timestamp > activePeriod;
|
|
3250
3281
|
var target = get(m.target);
|
|
3251
3282
|
var element = target && target.selector ? target.selector.join() : m.target.nodeName;
|
|
3252
3283
|
var parent_1 = value.selector ? value.selector.join() : "" /* Constant.Empty */;
|
|
@@ -3393,7 +3424,7 @@ function metadata$2(node, event, text) {
|
|
|
3393
3424
|
function encode$3 (type, ts) {
|
|
3394
3425
|
if (ts === void 0) { ts = null; }
|
|
3395
3426
|
return __awaiter(this, void 0, void 0, function () {
|
|
3396
|
-
var t, tokens, _i, _a, entry, pTarget, _b, _c, entry, cTarget, cHash, _d, _e, entry, target, r, u, _f, _g, entry, iTarget, s, startTarget, endTarget, _h, _j, entry, sTarget, _k, _l, entry, target, _m, _o, entry, target, _p, _q, entry, v;
|
|
3427
|
+
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, top_1, bottom, sTopHash, sBottomHash, _k, _l, entry, target, _m, _o, entry, target, _p, _q, entry, v;
|
|
3397
3428
|
return __generator(this, function (_r) {
|
|
3398
3429
|
t = ts || time();
|
|
3399
3430
|
tokens = [t, type];
|
|
@@ -3499,13 +3530,17 @@ function encode$3 (type, ts) {
|
|
|
3499
3530
|
for (_h = 0, _j = state$2; _h < _j.length; _h++) {
|
|
3500
3531
|
entry = _j[_h];
|
|
3501
3532
|
sTarget = metadata$2(entry.data.target, entry.event);
|
|
3533
|
+
top_1 = metadata$2(entry.data.top, entry.event);
|
|
3534
|
+
bottom = metadata$2(entry.data.bottom, entry.event);
|
|
3535
|
+
sTopHash = (top_1 === null || top_1 === void 0 ? void 0 : top_1.hash) ? top_1.hash.join("." /* Constant.Dot */) : "" /* Constant.Empty */;
|
|
3536
|
+
sBottomHash = (bottom === null || bottom === void 0 ? void 0 : bottom.hash) ? bottom.hash.join("." /* Constant.Dot */) : "" /* Constant.Empty */;
|
|
3502
3537
|
if (sTarget.id > 0) {
|
|
3503
3538
|
tokens = [entry.time, entry.event];
|
|
3504
3539
|
tokens.push(sTarget.id);
|
|
3505
3540
|
tokens.push(entry.data.x);
|
|
3506
3541
|
tokens.push(entry.data.y);
|
|
3507
|
-
tokens.push(
|
|
3508
|
-
tokens.push(
|
|
3542
|
+
tokens.push(sTopHash);
|
|
3543
|
+
tokens.push(sBottomHash);
|
|
3509
3544
|
queue(tokens);
|
|
3510
3545
|
track$8(entry.event, entry.data.x, entry.data.y, entry.time);
|
|
3511
3546
|
}
|
|
@@ -3707,10 +3742,10 @@ function upload(final) {
|
|
|
3707
3742
|
}
|
|
3708
3743
|
// CAUTION: Ensure "transmit" is set to false in the queue function for following events
|
|
3709
3744
|
// Otherwise you run a risk of infinite loop.
|
|
3710
|
-
compute$6();
|
|
3711
|
-
compute$5();
|
|
3712
|
-
compute$9();
|
|
3713
3745
|
compute$7();
|
|
3746
|
+
compute$5();
|
|
3747
|
+
compute$a();
|
|
3748
|
+
compute$8();
|
|
3714
3749
|
last = final === true;
|
|
3715
3750
|
e = JSON.stringify(envelope(last));
|
|
3716
3751
|
a = "[".concat(analysis.join(), "]");
|
|
@@ -4929,7 +4964,8 @@ var diagnostic = /*#__PURE__*/Object.freeze({
|
|
|
4929
4964
|
|
|
4930
4965
|
function start$4() {
|
|
4931
4966
|
schedule$1(discover, 1 /* Priority.High */).then(function () {
|
|
4932
|
-
measure(compute$
|
|
4967
|
+
measure(compute$9)();
|
|
4968
|
+
measure(compute$7)();
|
|
4933
4969
|
measure(compute$6)();
|
|
4934
4970
|
});
|
|
4935
4971
|
}
|