clarity-js 0.7.1 → 0.7.3
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.insight.js +1 -0
- package/build/clarity.js +126 -90
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +126 -88
- package/package.json +15 -13
- package/rollup.config.ts +29 -5
- package/src/clarity.ts +7 -1
- package/src/core/blank.ts +9 -0
- package/src/core/version.ts +1 -1
- package/src/diagnostic/index.ts +3 -3
- package/src/global.ts +3 -19
- package/src/interaction/encode.ts +12 -12
- package/src/layout/mutation.ts +11 -7
- package/src/performance/observer.ts +1 -6
- package/src/queue.ts +31 -0
- package/tsconfig.json +1 -1
- package/types/data.d.ts +3 -0
- package/types/layout.d.ts +1 -1
package/build/clarity.module.js
CHANGED
|
@@ -1,79 +1,130 @@
|
|
|
1
1
|
var dom = /*#__PURE__*/Object.freeze({
|
|
2
2
|
__proto__: null,
|
|
3
|
-
get start () { return start$i; },
|
|
4
|
-
get stop () { return stop$g; },
|
|
5
|
-
get parse () { return parse$1; },
|
|
6
|
-
get getId () { return getId; },
|
|
7
3
|
get add () { return add; },
|
|
8
|
-
get
|
|
9
|
-
get
|
|
10
|
-
get iframe () { return iframe; },
|
|
11
|
-
get hashText () { return hashText; },
|
|
4
|
+
get get () { return get; },
|
|
5
|
+
get getId () { return getId; },
|
|
12
6
|
get getNode () { return getNode; },
|
|
13
7
|
get getValue () { return getValue; },
|
|
14
|
-
get get () { return get; },
|
|
15
|
-
get lookup () { return lookup; },
|
|
16
8
|
get has () { return has; },
|
|
9
|
+
get hashText () { return hashText; },
|
|
10
|
+
get iframe () { return iframe; },
|
|
11
|
+
get lookup () { return lookup; },
|
|
12
|
+
get parse () { return parse$1; },
|
|
13
|
+
get sameorigin () { return sameorigin; },
|
|
14
|
+
get start () { return start$i; },
|
|
15
|
+
get stop () { return stop$g; },
|
|
16
|
+
get update () { return update$1; },
|
|
17
17
|
get updates () { return updates$2; }
|
|
18
18
|
});
|
|
19
19
|
var upload$1 = /*#__PURE__*/Object.freeze({
|
|
20
20
|
__proto__: null,
|
|
21
|
-
get track () { return track$1; },
|
|
22
|
-
get start () { return start$f; },
|
|
23
21
|
get queue () { return queue; },
|
|
24
|
-
get
|
|
22
|
+
get start () { return start$f; },
|
|
23
|
+
get stop () { return stop$d; },
|
|
24
|
+
get track () { return track$1; }
|
|
25
25
|
});
|
|
26
26
|
var extract = /*#__PURE__*/Object.freeze({
|
|
27
27
|
__proto__: null,
|
|
28
|
-
get data () { return data$5; },
|
|
29
|
-
get keys () { return keys; },
|
|
30
|
-
get fragments () { return fragments; },
|
|
31
|
-
get start () { return start$c; },
|
|
32
28
|
get clone () { return clone; },
|
|
33
29
|
get compute () { return compute$4; },
|
|
30
|
+
get data () { return data$5; },
|
|
31
|
+
get fragments () { return fragments; },
|
|
32
|
+
get keys () { return keys; },
|
|
34
33
|
get reset () { return reset$4; },
|
|
35
|
-
get
|
|
36
|
-
get stop () { return stop$b; }
|
|
34
|
+
get start () { return start$c; },
|
|
35
|
+
get stop () { return stop$b; },
|
|
36
|
+
get update () { return update; }
|
|
37
37
|
});
|
|
38
38
|
var limit = /*#__PURE__*/Object.freeze({
|
|
39
39
|
__proto__: null,
|
|
40
|
-
get data () { return data$4; },
|
|
41
|
-
get start () { return start$b; },
|
|
42
40
|
get check () { return check$2; },
|
|
43
|
-
get trigger () { return trigger; },
|
|
44
41
|
get compute () { return compute$3; },
|
|
45
|
-
get
|
|
42
|
+
get data () { return data$4; },
|
|
43
|
+
get start () { return start$b; },
|
|
44
|
+
get stop () { return stop$a; },
|
|
45
|
+
get trigger () { return trigger; }
|
|
46
46
|
});
|
|
47
47
|
var dimension = /*#__PURE__*/Object.freeze({
|
|
48
48
|
__proto__: null,
|
|
49
|
+
get compute () { return compute$2; },
|
|
49
50
|
get data () { return data$3; },
|
|
50
|
-
get
|
|
51
|
+
get log () { return log; },
|
|
52
|
+
get reset () { return reset$3; },
|
|
51
53
|
get start () { return start$a; },
|
|
52
54
|
get stop () { return stop$9; },
|
|
53
|
-
get
|
|
54
|
-
get compute () { return compute$2; },
|
|
55
|
-
get reset () { return reset$3; }
|
|
55
|
+
get updates () { return updates; }
|
|
56
56
|
});
|
|
57
57
|
var metadata$1 = /*#__PURE__*/Object.freeze({
|
|
58
58
|
__proto__: null,
|
|
59
|
-
get data () { return data$2; },
|
|
60
59
|
get callbacks () { return callbacks; },
|
|
61
|
-
get start () { return start$9; },
|
|
62
|
-
get stop () { return stop$8; },
|
|
63
|
-
get metadata () { return metadata; },
|
|
64
|
-
get id () { return id; },
|
|
65
|
-
get consent () { return consent; },
|
|
66
60
|
get clear () { return clear; },
|
|
67
|
-
get
|
|
61
|
+
get consent () { return consent; },
|
|
62
|
+
get data () { return data$2; },
|
|
63
|
+
get id () { return id; },
|
|
64
|
+
get metadata () { return metadata; },
|
|
65
|
+
get save () { return save; },
|
|
66
|
+
get start () { return start$9; },
|
|
67
|
+
get stop () { return stop$8; }
|
|
68
68
|
});
|
|
69
69
|
var envelope$1 = /*#__PURE__*/Object.freeze({
|
|
70
70
|
__proto__: null,
|
|
71
71
|
get data () { return data$1; },
|
|
72
|
+
get envelope () { return envelope; },
|
|
72
73
|
get start () { return start$8; },
|
|
73
|
-
get stop () { return stop$7; }
|
|
74
|
-
|
|
74
|
+
get stop () { return stop$7; }
|
|
75
|
+
});
|
|
76
|
+
var clarity = /*#__PURE__*/Object.freeze({
|
|
77
|
+
__proto__: null,
|
|
78
|
+
get consent () { return consent; },
|
|
79
|
+
get event () { return event; },
|
|
80
|
+
get hashText () { return hashText; },
|
|
81
|
+
get identify () { return identify; },
|
|
82
|
+
get metadata () { return metadata; },
|
|
83
|
+
get pause () { return pause; },
|
|
84
|
+
get resume () { return resume; },
|
|
85
|
+
get set () { return set; },
|
|
86
|
+
get start () { return start; },
|
|
87
|
+
get stop () { return stop; },
|
|
88
|
+
get upgrade () { return upgrade; },
|
|
89
|
+
get version () { return version$1; }
|
|
75
90
|
});
|
|
76
91
|
|
|
92
|
+
var w = window;
|
|
93
|
+
var c = "clarity" /* Constant.Clarity */;
|
|
94
|
+
function setup() {
|
|
95
|
+
// Start queuing up calls while Clarity is inactive and we are in a browser enviornment
|
|
96
|
+
if (typeof w !== "undefined") {
|
|
97
|
+
w[c] = function () {
|
|
98
|
+
(w[c].q = w[c].q || []).push(arguments);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function process$7() {
|
|
103
|
+
if (typeof w !== "undefined") {
|
|
104
|
+
// Do not execute or reset global "clarity" variable if a version of Clarity is already running on the page
|
|
105
|
+
if (w[c] && w[c].v) {
|
|
106
|
+
return console.warn("Error CL001: Multiple Clarity tags detected.");
|
|
107
|
+
}
|
|
108
|
+
// Expose clarity in a browser environment
|
|
109
|
+
// To be efficient about queuing up operations while Clarity is wiring up, we expose clarity.*(args) => clarity(*, args);
|
|
110
|
+
// This allows us to reprocess any calls that we missed once Clarity is available on the page
|
|
111
|
+
// Once Clarity script bundle is loaded on the page, we also initialize a "v" property that holds current version
|
|
112
|
+
// We use the presence or absence of "v" to determine if we are attempting to run a duplicate instance
|
|
113
|
+
var queue = w[c] ? (w[c].q || []) : [];
|
|
114
|
+
w[c] = function (method) {
|
|
115
|
+
var args = [];
|
|
116
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
117
|
+
args[_i - 1] = arguments[_i];
|
|
118
|
+
}
|
|
119
|
+
return clarity[method].apply(clarity, args);
|
|
120
|
+
};
|
|
121
|
+
w[c].v = version$1;
|
|
122
|
+
while (queue.length > 0) {
|
|
123
|
+
w[c].apply(w, queue.shift());
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
77
128
|
var config$1 = {
|
|
78
129
|
projectId: null,
|
|
79
130
|
delay: 1 * 1000 /* Time.Second */,
|
|
@@ -115,7 +166,7 @@ function stop$C() {
|
|
|
115
166
|
startTime = 0;
|
|
116
167
|
}
|
|
117
168
|
|
|
118
|
-
var version$1 = "0.7.
|
|
169
|
+
var version$1 = "0.7.3";
|
|
119
170
|
|
|
120
171
|
// tslint:disable: no-bitwise
|
|
121
172
|
function hash (input, precision) {
|
|
@@ -363,14 +414,14 @@ function stop$B() {
|
|
|
363
414
|
|
|
364
415
|
var baseline = /*#__PURE__*/Object.freeze({
|
|
365
416
|
__proto__: null,
|
|
366
|
-
get state () { return state$a; },
|
|
367
|
-
start: start$F,
|
|
368
|
-
reset: reset$q,
|
|
369
|
-
track: track$7,
|
|
370
417
|
activity: activity,
|
|
371
|
-
visibility: visibility,
|
|
372
418
|
compute: compute$c,
|
|
373
|
-
|
|
419
|
+
reset: reset$q,
|
|
420
|
+
start: start$F,
|
|
421
|
+
get state () { return state$a; },
|
|
422
|
+
stop: stop$B,
|
|
423
|
+
track: track$7,
|
|
424
|
+
visibility: visibility
|
|
374
425
|
});
|
|
375
426
|
|
|
376
427
|
var data$j = null;
|
|
@@ -481,8 +532,8 @@ function stop$z() {
|
|
|
481
532
|
var ping$1 = /*#__PURE__*/Object.freeze({
|
|
482
533
|
__proto__: null,
|
|
483
534
|
get data () { return data$h; },
|
|
484
|
-
start: start$D,
|
|
485
535
|
reset: reset$o,
|
|
536
|
+
start: start$D,
|
|
486
537
|
stop: stop$z
|
|
487
538
|
});
|
|
488
539
|
|
|
@@ -519,12 +570,12 @@ function reset$n() {
|
|
|
519
570
|
|
|
520
571
|
var summary = /*#__PURE__*/Object.freeze({
|
|
521
572
|
__proto__: null,
|
|
573
|
+
compute: compute$a,
|
|
522
574
|
get data () { return data$g; },
|
|
575
|
+
reset: reset$n,
|
|
523
576
|
start: start$C,
|
|
524
577
|
stop: stop$y,
|
|
525
|
-
track: track$6
|
|
526
|
-
compute: compute$a,
|
|
527
|
-
reset: reset$n
|
|
578
|
+
track: track$6
|
|
528
579
|
});
|
|
529
580
|
|
|
530
581
|
var data$f = null;
|
|
@@ -560,8 +611,8 @@ var upgrade$1 = /*#__PURE__*/Object.freeze({
|
|
|
560
611
|
__proto__: null,
|
|
561
612
|
get data () { return data$f; },
|
|
562
613
|
start: start$B,
|
|
563
|
-
|
|
564
|
-
|
|
614
|
+
stop: stop$x,
|
|
615
|
+
upgrade: upgrade
|
|
565
616
|
});
|
|
566
617
|
|
|
567
618
|
var data$e = null;
|
|
@@ -606,12 +657,12 @@ function stop$w() {
|
|
|
606
657
|
|
|
607
658
|
var variable = /*#__PURE__*/Object.freeze({
|
|
608
659
|
__proto__: null,
|
|
660
|
+
compute: compute$9,
|
|
609
661
|
get data () { return data$e; },
|
|
610
|
-
start: start$A,
|
|
611
|
-
set: set,
|
|
612
662
|
identify: identify,
|
|
613
|
-
compute: compute$9,
|
|
614
663
|
reset: reset$m,
|
|
664
|
+
set: set,
|
|
665
|
+
start: start$A,
|
|
615
666
|
stop: stop$w
|
|
616
667
|
});
|
|
617
668
|
|
|
@@ -646,7 +697,7 @@ function __generator(thisArg, body) {
|
|
|
646
697
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
647
698
|
function step(op) {
|
|
648
699
|
if (f) throw new TypeError("Generator is already executing.");
|
|
649
|
-
while (_) try {
|
|
700
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
650
701
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
651
702
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
652
703
|
switch (op[0]) {
|
|
@@ -864,8 +915,8 @@ function filter(value) {
|
|
|
864
915
|
|
|
865
916
|
var selector = /*#__PURE__*/Object.freeze({
|
|
866
917
|
__proto__: null,
|
|
867
|
-
|
|
868
|
-
|
|
918
|
+
get: get$1,
|
|
919
|
+
reset: reset$l
|
|
869
920
|
});
|
|
870
921
|
|
|
871
922
|
// Track the start time to be able to compute duration at the end of the task
|
|
@@ -1812,9 +1863,9 @@ function observe$4(root) {
|
|
|
1812
1863
|
|
|
1813
1864
|
var interaction = /*#__PURE__*/Object.freeze({
|
|
1814
1865
|
__proto__: null,
|
|
1866
|
+
observe: observe$4,
|
|
1815
1867
|
start: start$k,
|
|
1816
|
-
stop: stop$i
|
|
1817
|
-
observe: observe$4
|
|
1868
|
+
stop: stop$i
|
|
1818
1869
|
});
|
|
1819
1870
|
|
|
1820
1871
|
var digitsRegex = /[^0-9\.]/g;
|
|
@@ -2254,7 +2305,7 @@ function handle$1(m) {
|
|
|
2254
2305
|
}
|
|
2255
2306
|
function process$2() {
|
|
2256
2307
|
return __awaiter(this, void 0, void 0, function () {
|
|
2257
|
-
var timer, record, _i, _a, mutation, state, target, type, value;
|
|
2308
|
+
var timer, record, instance, _i, _a, mutation, state, target, type, value;
|
|
2258
2309
|
return __generator(this, function (_b) {
|
|
2259
2310
|
switch (_b.label) {
|
|
2260
2311
|
case 0:
|
|
@@ -2264,6 +2315,7 @@ function process$2() {
|
|
|
2264
2315
|
case 1:
|
|
2265
2316
|
if (!(mutations.length > 0)) return [3 /*break*/, 8];
|
|
2266
2317
|
record = mutations.shift();
|
|
2318
|
+
instance = time();
|
|
2267
2319
|
_i = 0, _a = record.mutations;
|
|
2268
2320
|
_b.label = 2;
|
|
2269
2321
|
case 2:
|
|
@@ -2280,7 +2332,7 @@ function process$2() {
|
|
|
2280
2332
|
return [3 /*break*/, 6];
|
|
2281
2333
|
}
|
|
2282
2334
|
target = mutation.target;
|
|
2283
|
-
type = track$5(mutation, timer);
|
|
2335
|
+
type = track$5(mutation, timer, instance);
|
|
2284
2336
|
if (type && target && target.ownerDocument) {
|
|
2285
2337
|
parse$1(target.ownerDocument);
|
|
2286
2338
|
}
|
|
@@ -2320,7 +2372,7 @@ function process$2() {
|
|
|
2320
2372
|
});
|
|
2321
2373
|
});
|
|
2322
2374
|
}
|
|
2323
|
-
function track$5(m, timer) {
|
|
2375
|
+
function track$5(m, timer, instance) {
|
|
2324
2376
|
var value = m.target ? get(m.target.parentNode) : null;
|
|
2325
2377
|
// Check if the parent is already discovered and that the parent is not the document root
|
|
2326
2378
|
if (value && value.data.tag !== "HTML" /* Constant.HTML */) {
|
|
@@ -2333,19 +2385,20 @@ function track$5(m, timer) {
|
|
|
2333
2385
|
// In those cases, IDs will change however the selector (which is relative to DOM xPath) remains the same
|
|
2334
2386
|
var key = [parent_1, element, m.attributeName, names(m.addedNodes), names(m.removedNodes)].join();
|
|
2335
2387
|
// Initialize an entry if it doesn't already exist
|
|
2336
|
-
history$4[key] = key in history$4 ? history$4[key] : [0];
|
|
2388
|
+
history$4[key] = key in history$4 ? history$4[key] : [0, instance];
|
|
2337
2389
|
var h = history$4[key];
|
|
2338
2390
|
// Lookup any pending nodes queued up for removal, and process them now if we suspended a mutation before
|
|
2339
2391
|
if (inactive === false && h[0] >= 10 /* Setting.MutationSuspendThreshold */) {
|
|
2340
|
-
processNodeList(h[
|
|
2392
|
+
processNodeList(h[2], 2 /* Source.ChildListRemove */, timer);
|
|
2341
2393
|
}
|
|
2342
2394
|
// Update the counter
|
|
2343
|
-
h[0] = inactive ? h[0] + 1 : 1;
|
|
2395
|
+
h[0] = inactive ? (h[1] === instance ? h[0] : h[0] + 1) : 1;
|
|
2396
|
+
h[1] = instance;
|
|
2344
2397
|
// Return updated mutation type based on if we have already hit the threshold or not
|
|
2345
2398
|
if (h[0] === 10 /* Setting.MutationSuspendThreshold */) {
|
|
2346
2399
|
// Store a reference to removedNodes so we can process them later
|
|
2347
2400
|
// when we resume mutations again on user interactions
|
|
2348
|
-
h[
|
|
2401
|
+
h[2] = m.removedNodes;
|
|
2349
2402
|
return "suspend" /* Constant.Suspend */;
|
|
2350
2403
|
}
|
|
2351
2404
|
else if (h[0] > 10 /* Setting.MutationSuspendThreshold */) {
|
|
@@ -4457,9 +4510,9 @@ function stop$3() {
|
|
|
4457
4510
|
|
|
4458
4511
|
var layout = /*#__PURE__*/Object.freeze({
|
|
4459
4512
|
__proto__: null,
|
|
4513
|
+
hashText: hashText,
|
|
4460
4514
|
start: start$3,
|
|
4461
|
-
stop: stop$3
|
|
4462
|
-
hashText: hashText
|
|
4515
|
+
stop: stop$3
|
|
4463
4516
|
});
|
|
4464
4517
|
|
|
4465
4518
|
function encode (type) {
|
|
@@ -4611,11 +4664,6 @@ function process(entries) {
|
|
|
4611
4664
|
break;
|
|
4612
4665
|
}
|
|
4613
4666
|
}
|
|
4614
|
-
if (performance && "memory" /* Constant.Memory */ in performance && performance["memory" /* Constant.Memory */].usedJSHeapSize) {
|
|
4615
|
-
// Track consumed memory (MBs) where "memory" API is available
|
|
4616
|
-
// Reference: https://developer.mozilla.org/en-US/docs/Web/API/Performance/memory
|
|
4617
|
-
max(30 /* Metric.UsedMemory */, Math.abs(performance["memory" /* Constant.Memory */].usedJSHeapSize / 1048576 /* Setting.MegaByte */));
|
|
4618
|
-
}
|
|
4619
4667
|
}
|
|
4620
4668
|
function stop$2() {
|
|
4621
4669
|
if (observer) {
|
|
@@ -4653,6 +4701,11 @@ function start(config$1) {
|
|
|
4653
4701
|
start$6();
|
|
4654
4702
|
start$z();
|
|
4655
4703
|
modules.forEach(function (x) { return measure(x.start)(); });
|
|
4704
|
+
// If it's an internal call to start, without explicit configuration,
|
|
4705
|
+
// re-process any newly accumulated items in the queue
|
|
4706
|
+
if (config$1 === null) {
|
|
4707
|
+
process$7();
|
|
4708
|
+
}
|
|
4656
4709
|
}
|
|
4657
4710
|
}
|
|
4658
4711
|
// By default Clarity is asynchronous and will yield by looking for requestIdleCallback.
|
|
@@ -4675,29 +4728,14 @@ function resume() {
|
|
|
4675
4728
|
}
|
|
4676
4729
|
function stop() {
|
|
4677
4730
|
if (active()) {
|
|
4678
|
-
// Stop modules in the reverse order of their initialization
|
|
4731
|
+
// Stop modules in the reverse order of their initialization and start queuing up items again
|
|
4679
4732
|
modules.slice().reverse().forEach(function (x) { return measure(x.stop)(); });
|
|
4680
4733
|
stop$v();
|
|
4681
4734
|
stop$5();
|
|
4735
|
+
setup();
|
|
4682
4736
|
}
|
|
4683
4737
|
}
|
|
4684
4738
|
|
|
4685
|
-
var clarity = /*#__PURE__*/Object.freeze({
|
|
4686
|
-
__proto__: null,
|
|
4687
|
-
version: version$1,
|
|
4688
|
-
start: start,
|
|
4689
|
-
pause: pause,
|
|
4690
|
-
resume: resume,
|
|
4691
|
-
stop: stop,
|
|
4692
|
-
consent: consent,
|
|
4693
|
-
event: event,
|
|
4694
|
-
identify: identify,
|
|
4695
|
-
set: set,
|
|
4696
|
-
upgrade: upgrade,
|
|
4697
|
-
metadata: metadata,
|
|
4698
|
-
hashText: hashText
|
|
4699
|
-
});
|
|
4700
|
-
|
|
4701
4739
|
var helper = { hash: hash, selector: selector, get: get, getNode: getNode, lookup: lookup };
|
|
4702
4740
|
var version = version$1;
|
|
4703
4741
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clarity-js",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "An analytics library that uses web page interactions to generate aggregated insights",
|
|
5
5
|
"author": "Microsoft Corp.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "build/clarity.js",
|
|
8
8
|
"module": "build/clarity.module.js",
|
|
9
9
|
"unpkg": "build/clarity.min.js",
|
|
10
|
+
"insight": "build/clarity.insight.js",
|
|
10
11
|
"types": "types/index.d.ts",
|
|
11
12
|
"keywords": [
|
|
12
13
|
"clarity",
|
|
@@ -26,28 +27,29 @@
|
|
|
26
27
|
"url": "https://github.com/microsoft/clarity/issues"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@rollup/plugin-
|
|
30
|
-
"@rollup/plugin-
|
|
30
|
+
"@rollup/plugin-alias": "^4.0.0",
|
|
31
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
32
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
33
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
34
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
31
35
|
"@types/chai": "^4.2.21",
|
|
32
|
-
"@types/mocha": "^
|
|
36
|
+
"@types/mocha": "^10.0.0",
|
|
33
37
|
"@types/resize-observer-browser": "^0.1.6",
|
|
34
38
|
"chai": "^4.2.0",
|
|
35
|
-
"del-cli": "^
|
|
36
|
-
"husky": "^
|
|
37
|
-
"lint-staged": "^
|
|
38
|
-
"mocha": "^
|
|
39
|
+
"del-cli": "^5.0.0",
|
|
40
|
+
"husky": "^8.0.0",
|
|
41
|
+
"lint-staged": "^13.1.0",
|
|
42
|
+
"mocha": "^10.2.0",
|
|
39
43
|
"playwright": "^1.6.2",
|
|
40
|
-
"rollup": "^
|
|
41
|
-
"
|
|
42
|
-
"rollup-plugin-typescript2": "^0.30.0",
|
|
43
|
-
"ts-mocha": "^8.0.0",
|
|
44
|
+
"rollup": "^3.0.0",
|
|
45
|
+
"ts-mocha": "^10.0.0",
|
|
44
46
|
"tslib": "^2.3.0",
|
|
45
47
|
"tslint": "^6.1.3",
|
|
46
48
|
"typescript": "^4.3.5"
|
|
47
49
|
},
|
|
48
50
|
"scripts": {
|
|
49
51
|
"build": "yarn build:clean && yarn build:main",
|
|
50
|
-
"build:main": "rollup -c rollup.config.ts",
|
|
52
|
+
"build:main": "rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript",
|
|
51
53
|
"build:clean": "del-cli build/*",
|
|
52
54
|
"test": "ts-mocha -p test/tsconfig.test.json test/**/*.test.ts",
|
|
53
55
|
"tslint": "tslint --project ./",
|
package/rollup.config.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import alias from "@rollup/plugin-alias";
|
|
1
2
|
import commonjs from "@rollup/plugin-commonjs";
|
|
2
3
|
import resolve from "@rollup/plugin-node-resolve";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import pkg from "./package.json";
|
|
4
|
+
import terser from "@rollup/plugin-terser";
|
|
5
|
+
import typescript from "@rollup/plugin-typescript";
|
|
6
|
+
import pkg from "./package.json" assert { type: 'json' };
|
|
6
7
|
|
|
7
8
|
export default [
|
|
8
9
|
{
|
|
@@ -13,7 +14,7 @@ export default [
|
|
|
13
14
|
],
|
|
14
15
|
plugins: [
|
|
15
16
|
resolve(),
|
|
16
|
-
typescript(
|
|
17
|
+
typescript(),
|
|
17
18
|
commonjs({ include: ["node_modules/**"] })
|
|
18
19
|
],
|
|
19
20
|
onwarn(message, warn) {
|
|
@@ -30,7 +31,30 @@ export default [
|
|
|
30
31
|
},
|
|
31
32
|
plugins: [
|
|
32
33
|
resolve(),
|
|
33
|
-
typescript(
|
|
34
|
+
typescript(),
|
|
35
|
+
terser({output: {comments: false}}),
|
|
36
|
+
commonjs({ include: ["node_modules/**"] })
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
input: "src/global.ts",
|
|
41
|
+
output: [ { file: pkg.insight, format: "iife", exports: "named" } ],
|
|
42
|
+
onwarn(message, warn) {
|
|
43
|
+
if (message.code === 'CIRCULAR_DEPENDENCY') { return; }
|
|
44
|
+
warn(message);
|
|
45
|
+
},
|
|
46
|
+
plugins: [
|
|
47
|
+
alias({
|
|
48
|
+
entries: [
|
|
49
|
+
{ find: '@src/interaction/change', replacement: '@src/core/blank' },
|
|
50
|
+
{ find: '@src/interaction/clipboard', replacement: '@src/core/blank' },
|
|
51
|
+
{ find: '@src/interaction/input', replacement: '@src/core/blank' },
|
|
52
|
+
{ find: '@src/interaction/pointer', replacement: '@src/core/blank' },
|
|
53
|
+
{ find: '@src/interaction/selection', replacement: '@src/core/blank' }
|
|
54
|
+
]
|
|
55
|
+
}),
|
|
56
|
+
resolve(),
|
|
57
|
+
typescript(),
|
|
34
58
|
terser({output: {comments: false}}),
|
|
35
59
|
commonjs({ include: ["node_modules/**"] })
|
|
36
60
|
]
|
package/src/clarity.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Config, Module } from "@clarity-types/core";
|
|
2
2
|
import { Constant } from "@clarity-types/data";
|
|
3
|
+
import * as queue from "@src/queue";
|
|
3
4
|
import * as core from "@src/core";
|
|
4
5
|
import measure from "@src/core/measure";
|
|
5
6
|
import * as task from "@src/core/task";
|
|
@@ -22,6 +23,10 @@ export function start(config: Config = null): void {
|
|
|
22
23
|
core.start();
|
|
23
24
|
data.start();
|
|
24
25
|
modules.forEach(x => measure(x.start)());
|
|
26
|
+
|
|
27
|
+
// If it's an internal call to start, without explicit configuration,
|
|
28
|
+
// re-process any newly accumulated items in the queue
|
|
29
|
+
if (config === null) { queue.process(); }
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
|
|
@@ -47,9 +52,10 @@ export function resume(): void {
|
|
|
47
52
|
|
|
48
53
|
export function stop(): void {
|
|
49
54
|
if (core.active()) {
|
|
50
|
-
// Stop modules in the reverse order of their initialization
|
|
55
|
+
// Stop modules in the reverse order of their initialization and start queuing up items again
|
|
51
56
|
modules.slice().reverse().forEach(x => measure(x.stop)());
|
|
52
57
|
data.stop();
|
|
53
58
|
core.stop();
|
|
59
|
+
queue.setup();
|
|
54
60
|
}
|
|
55
61
|
}
|
package/src/core/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let version = "0.7.
|
|
1
|
+
let version = "0.7.3";
|
|
2
2
|
export default version;
|
package/src/diagnostic/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fraud from "
|
|
2
|
-
import * as internal from "
|
|
3
|
-
import * as script from "
|
|
1
|
+
import * as fraud from "@src/diagnostic/fraud";
|
|
2
|
+
import * as internal from "@src/diagnostic/internal";
|
|
3
|
+
import * as script from "@src/diagnostic/script";
|
|
4
4
|
|
|
5
5
|
export function start(): void {
|
|
6
6
|
fraud.start();
|
package/src/global.ts
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as queue from "@src/queue";
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
// To be efficient about queuing up operations while Clarity is wiring up, we expose clarity.*(args) => clarity(*, args);
|
|
5
|
-
// This allows us to reprocess any calls that we missed once Clarity is available on the page
|
|
6
|
-
// Once Clarity script bundle is loaded on the page, we also initialize a "v" property that holds current version
|
|
7
|
-
// We use the presence or absence of "v" to determine if we are attempting to run a duplicate instance
|
|
3
|
+
// Process anything that was queued up before the script loaded
|
|
8
4
|
(function(): void {
|
|
9
|
-
|
|
10
|
-
const w = window as any;
|
|
11
|
-
const c = 'clarity';
|
|
12
|
-
|
|
13
|
-
// Do not execute or reset global "clarity" variable if a version of Clarity is already running on the page
|
|
14
|
-
if (w[c] && w[c].v) { return console.warn("Error CL001: Multiple Clarity tags detected."); }
|
|
15
|
-
|
|
16
|
-
// Re-wire global "clarity" variable to map it to current instance of Clarity
|
|
17
|
-
const queue = w[c] ? (w[c].q || []) : [];
|
|
18
|
-
w[c] = function(method: string, ...args: any[]): void { return clarity[method](...args); }
|
|
19
|
-
w[c].v = clarity.version;
|
|
20
|
-
while (queue.length > 0) { w[c](...queue.shift()); }
|
|
21
|
-
}
|
|
5
|
+
queue.process();
|
|
22
6
|
})();
|
|
@@ -4,18 +4,18 @@ import { time } from "@src/core/time";
|
|
|
4
4
|
import * as baseline from "@src/data/baseline";
|
|
5
5
|
import { queue } from "@src/data/upload";
|
|
6
6
|
import { metadata } from "@src/layout/target";
|
|
7
|
-
import * as change from "
|
|
8
|
-
import * as click from "
|
|
9
|
-
import * as clipboard from "
|
|
10
|
-
import * as input from "
|
|
11
|
-
import * as pointer from "
|
|
12
|
-
import * as resize from "
|
|
13
|
-
import * as scroll from "
|
|
14
|
-
import * as selection from "
|
|
15
|
-
import * as submit from "
|
|
16
|
-
import * as timeline from "
|
|
17
|
-
import * as unload from "
|
|
18
|
-
import * as visibility from "
|
|
7
|
+
import * as change from "@src/interaction/change";
|
|
8
|
+
import * as click from "@src/interaction/click";
|
|
9
|
+
import * as clipboard from "@src/interaction/clipboard";
|
|
10
|
+
import * as input from "@src/interaction/input";
|
|
11
|
+
import * as pointer from "@src/interaction/pointer";
|
|
12
|
+
import * as resize from "@src/interaction/resize";
|
|
13
|
+
import * as scroll from "@src/interaction/scroll";
|
|
14
|
+
import * as selection from "@src/interaction/selection";
|
|
15
|
+
import * as submit from "@src/interaction/submit";
|
|
16
|
+
import * as timeline from "@src/interaction/timeline";
|
|
17
|
+
import * as unload from "@src/interaction/unload";
|
|
18
|
+
import * as visibility from "@src/interaction/visibility";
|
|
19
19
|
|
|
20
20
|
export default async function (type: Event, ts: number = null): Promise<void> {
|
|
21
21
|
let t = ts || time();
|