clarity-js 0.7.32 → 0.7.33
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 +70 -39
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +70 -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/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.33";
|
|
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
|
}
|
|
@@ -1658,9 +1664,9 @@ function reset$k() {
|
|
|
1658
1664
|
}
|
|
1659
1665
|
function start$x() {
|
|
1660
1666
|
reset$k();
|
|
1661
|
-
compute$
|
|
1667
|
+
compute$9();
|
|
1662
1668
|
}
|
|
1663
|
-
function compute$
|
|
1669
|
+
function compute$9() {
|
|
1664
1670
|
var body = document.body;
|
|
1665
1671
|
var d = document.documentElement;
|
|
1666
1672
|
var bodyClientWidth = body ? body.clientWidth : null;
|
|
@@ -1718,7 +1724,7 @@ function checkDocumentStyles(documentNode) {
|
|
|
1718
1724
|
}
|
|
1719
1725
|
max(36 /* Metric.ConstructedStyles */, 1);
|
|
1720
1726
|
}
|
|
1721
|
-
function compute$
|
|
1727
|
+
function compute$8() {
|
|
1722
1728
|
checkDocumentStyles(document);
|
|
1723
1729
|
}
|
|
1724
1730
|
function reset$j() {
|
|
@@ -1925,9 +1931,9 @@ function encode$4 (type, timer, ts) {
|
|
|
1925
1931
|
tokens.push(value.id * factor);
|
|
1926
1932
|
if (value.parent && active) {
|
|
1927
1933
|
tokens.push(value.parent);
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1934
|
+
if (value.previous) {
|
|
1935
|
+
tokens.push(value.previous);
|
|
1936
|
+
}
|
|
1931
1937
|
}
|
|
1932
1938
|
tokens.push(suspend ? "*M" /* Constant.SuspendMutationTag */ : data[key]);
|
|
1933
1939
|
if (box && box.length === 2) {
|
|
@@ -2035,7 +2041,7 @@ function track$4(id, event) {
|
|
|
2035
2041
|
// Process updates to this region, if applicable
|
|
2036
2042
|
process$6(node, data, interaction, data.visibility);
|
|
2037
2043
|
}
|
|
2038
|
-
function compute$
|
|
2044
|
+
function compute$7() {
|
|
2039
2045
|
// Process any regions where we couldn't resolve an "id" for at the time of last intersection observer event
|
|
2040
2046
|
// This could happen in cases where elements are not yet processed by Clarity's virtual DOM but browser reports a change, regardless.
|
|
2041
2047
|
// For those cases we add them to the queue and re-process them below
|
|
@@ -2475,6 +2481,8 @@ function stop$m() {
|
|
|
2475
2481
|
}
|
|
2476
2482
|
|
|
2477
2483
|
var state$2 = [];
|
|
2484
|
+
var initialTop = null;
|
|
2485
|
+
var initialBottom = null;
|
|
2478
2486
|
var timeout$3 = null;
|
|
2479
2487
|
function start$n() {
|
|
2480
2488
|
state$2 = [];
|
|
@@ -2507,11 +2515,13 @@ function recompute$4(event) {
|
|
|
2507
2515
|
var yOffset = width > height ? height * 0.15 : height * 0.2;
|
|
2508
2516
|
var startYPosition = yOffset;
|
|
2509
2517
|
var endYPosition = height - yOffset;
|
|
2510
|
-
var top =
|
|
2511
|
-
var bottom =
|
|
2518
|
+
var top = getPositionNode(xPosition, startYPosition);
|
|
2519
|
+
var bottom = getPositionNode(xPosition, endYPosition);
|
|
2512
2520
|
var current = { time: time(event), event: 10 /* Event.Scroll */, data: { target: element, x: x, y: y, top: top, bottom: bottom } };
|
|
2513
2521
|
// We don't send any scroll events if this is the first event and the current position is top (0,0)
|
|
2514
2522
|
if ((event === null && x === 0 && y === 0) || (x === null || y === null)) {
|
|
2523
|
+
initialTop = top;
|
|
2524
|
+
initialBottom = bottom;
|
|
2515
2525
|
return;
|
|
2516
2526
|
}
|
|
2517
2527
|
var length = state$2.length;
|
|
@@ -2523,8 +2533,8 @@ function recompute$4(event) {
|
|
|
2523
2533
|
clearTimeout(timeout$3);
|
|
2524
2534
|
timeout$3 = setTimeout(process$3, 500 /* Setting.LookAhead */, 10 /* Event.Scroll */);
|
|
2525
2535
|
}
|
|
2526
|
-
function
|
|
2527
|
-
var _a, _b
|
|
2536
|
+
function getPositionNode(x, y) {
|
|
2537
|
+
var _a, _b;
|
|
2528
2538
|
var node;
|
|
2529
2539
|
if ("caretPositionFromPoint" in document) {
|
|
2530
2540
|
node = (_a = document.caretPositionFromPoint(x, y)) === null || _a === void 0 ? void 0 : _a.offsetNode;
|
|
@@ -2538,10 +2548,12 @@ function getPositionHash(x, y) {
|
|
|
2538
2548
|
if (node && node.nodeType === Node.TEXT_NODE) {
|
|
2539
2549
|
node = node.parentNode;
|
|
2540
2550
|
}
|
|
2541
|
-
return
|
|
2551
|
+
return node;
|
|
2542
2552
|
}
|
|
2543
2553
|
function reset$a() {
|
|
2544
2554
|
state$2 = [];
|
|
2555
|
+
initialTop = null;
|
|
2556
|
+
initialBottom = null;
|
|
2545
2557
|
}
|
|
2546
2558
|
function process$3(event) {
|
|
2547
2559
|
schedule$1(encode$3.bind(this, event));
|
|
@@ -2551,9 +2563,22 @@ function similar(last, current) {
|
|
|
2551
2563
|
var dy = last.data.y - current.data.y;
|
|
2552
2564
|
return (dx * dx + dy * dy < 20 /* Setting.Distance */ * 20 /* Setting.Distance */) && (current.time - last.time < 25 /* Setting.Interval */);
|
|
2553
2565
|
}
|
|
2566
|
+
function compute$6() {
|
|
2567
|
+
var _a, _b;
|
|
2568
|
+
if (initialTop) {
|
|
2569
|
+
var top_1 = metadata$2(initialTop, null);
|
|
2570
|
+
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 */));
|
|
2571
|
+
}
|
|
2572
|
+
if (initialBottom) {
|
|
2573
|
+
var bottom = metadata$2(initialBottom, null);
|
|
2574
|
+
log(32 /* Dimension.InitialScrollBottom */, (_b = bottom === null || bottom === void 0 ? void 0 : bottom.hash) === null || _b === void 0 ? void 0 : _b.join("." /* Constant.Dot */));
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2554
2577
|
function stop$l() {
|
|
2555
2578
|
clearTimeout(timeout$3);
|
|
2556
2579
|
state$2 = [];
|
|
2580
|
+
initialTop = null;
|
|
2581
|
+
initialBottom = null;
|
|
2557
2582
|
}
|
|
2558
2583
|
|
|
2559
2584
|
var data$a = null;
|
|
@@ -2775,7 +2800,7 @@ function num$1(input, scale) {
|
|
|
2775
2800
|
return null;
|
|
2776
2801
|
}
|
|
2777
2802
|
|
|
2778
|
-
var IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last"];
|
|
2803
|
+
var IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last", "aria-label"];
|
|
2779
2804
|
var newlineRegex = /[\r\n]+/g;
|
|
2780
2805
|
function processNode (node, source, timestamp) {
|
|
2781
2806
|
var _a;
|
|
@@ -3169,8 +3194,8 @@ function handle$1(m) {
|
|
|
3169
3194
|
track$7(6 /* Event.Mutation */, now);
|
|
3170
3195
|
mutations.push({ time: now, mutations: m });
|
|
3171
3196
|
schedule$1(process$1, 1 /* Priority.High */).then(function () {
|
|
3172
|
-
setTimeout(compute$
|
|
3173
|
-
measure(compute$
|
|
3197
|
+
setTimeout(compute$9);
|
|
3198
|
+
measure(compute$7)();
|
|
3174
3199
|
});
|
|
3175
3200
|
}
|
|
3176
3201
|
function process$1() {
|
|
@@ -3202,7 +3227,7 @@ function process$1() {
|
|
|
3202
3227
|
return [3 /*break*/, 6];
|
|
3203
3228
|
}
|
|
3204
3229
|
target = mutation.target;
|
|
3205
|
-
type = track$3(mutation, timer, instance, record.time);
|
|
3230
|
+
type = config$1.throttleDom ? track$3(mutation, timer, instance, record.time) : mutation.type;
|
|
3206
3231
|
if (type && target && target.ownerDocument) {
|
|
3207
3232
|
parse$1(target.ownerDocument);
|
|
3208
3233
|
}
|
|
@@ -3246,7 +3271,8 @@ function track$3(m, timer, instance, timestamp) {
|
|
|
3246
3271
|
var value = m.target ? get(m.target.parentNode) : null;
|
|
3247
3272
|
// Check if the parent is already discovered and that the parent is not the document root
|
|
3248
3273
|
if (value && value.data.tag !== "HTML" /* Constant.HTML */) {
|
|
3249
|
-
|
|
3274
|
+
// calculate inactive period based on the timestamp of the mutation not when the mutation is processed
|
|
3275
|
+
var inactive = timestamp > activePeriod;
|
|
3250
3276
|
var target = get(m.target);
|
|
3251
3277
|
var element = target && target.selector ? target.selector.join() : m.target.nodeName;
|
|
3252
3278
|
var parent_1 = value.selector ? value.selector.join() : "" /* Constant.Empty */;
|
|
@@ -3393,7 +3419,7 @@ function metadata$2(node, event, text) {
|
|
|
3393
3419
|
function encode$3 (type, ts) {
|
|
3394
3420
|
if (ts === void 0) { ts = null; }
|
|
3395
3421
|
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;
|
|
3422
|
+
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
3423
|
return __generator(this, function (_r) {
|
|
3398
3424
|
t = ts || time();
|
|
3399
3425
|
tokens = [t, type];
|
|
@@ -3499,13 +3525,17 @@ function encode$3 (type, ts) {
|
|
|
3499
3525
|
for (_h = 0, _j = state$2; _h < _j.length; _h++) {
|
|
3500
3526
|
entry = _j[_h];
|
|
3501
3527
|
sTarget = metadata$2(entry.data.target, entry.event);
|
|
3528
|
+
top_1 = metadata$2(entry.data.top, entry.event);
|
|
3529
|
+
bottom = metadata$2(entry.data.bottom, entry.event);
|
|
3530
|
+
sTopHash = (top_1 === null || top_1 === void 0 ? void 0 : top_1.hash) ? top_1.hash.join("." /* Constant.Dot */) : "" /* Constant.Empty */;
|
|
3531
|
+
sBottomHash = (bottom === null || bottom === void 0 ? void 0 : bottom.hash) ? bottom.hash.join("." /* Constant.Dot */) : "" /* Constant.Empty */;
|
|
3502
3532
|
if (sTarget.id > 0) {
|
|
3503
3533
|
tokens = [entry.time, entry.event];
|
|
3504
3534
|
tokens.push(sTarget.id);
|
|
3505
3535
|
tokens.push(entry.data.x);
|
|
3506
3536
|
tokens.push(entry.data.y);
|
|
3507
|
-
tokens.push(
|
|
3508
|
-
tokens.push(
|
|
3537
|
+
tokens.push(sTopHash);
|
|
3538
|
+
tokens.push(sBottomHash);
|
|
3509
3539
|
queue(tokens);
|
|
3510
3540
|
track$8(entry.event, entry.data.x, entry.data.y, entry.time);
|
|
3511
3541
|
}
|
|
@@ -3707,10 +3737,10 @@ function upload(final) {
|
|
|
3707
3737
|
}
|
|
3708
3738
|
// CAUTION: Ensure "transmit" is set to false in the queue function for following events
|
|
3709
3739
|
// Otherwise you run a risk of infinite loop.
|
|
3710
|
-
compute$6();
|
|
3711
|
-
compute$5();
|
|
3712
|
-
compute$9();
|
|
3713
3740
|
compute$7();
|
|
3741
|
+
compute$5();
|
|
3742
|
+
compute$a();
|
|
3743
|
+
compute$8();
|
|
3714
3744
|
last = final === true;
|
|
3715
3745
|
e = JSON.stringify(envelope(last));
|
|
3716
3746
|
a = "[".concat(analysis.join(), "]");
|
|
@@ -4929,7 +4959,8 @@ var diagnostic = /*#__PURE__*/Object.freeze({
|
|
|
4929
4959
|
|
|
4930
4960
|
function start$4() {
|
|
4931
4961
|
schedule$1(discover, 1 /* Priority.High */).then(function () {
|
|
4932
|
-
measure(compute$
|
|
4962
|
+
measure(compute$9)();
|
|
4963
|
+
measure(compute$7)();
|
|
4933
4964
|
measure(compute$6)();
|
|
4934
4965
|
});
|
|
4935
4966
|
}
|