clarity-js 0.8.12 → 0.8.14
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 +4609 -4762
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +4609 -4762
- package/build/clarity.performance.js +1 -1
- package/package.json +69 -76
- package/rollup.config.ts +88 -84
- package/src/clarity.ts +29 -35
- package/src/core/api.ts +1 -8
- package/src/core/config.ts +2 -2
- package/src/core/event.ts +32 -36
- package/src/core/hash.ts +6 -5
- package/src/core/history.ts +11 -10
- package/src/core/index.ts +11 -21
- package/src/core/measure.ts +5 -9
- package/src/core/report.ts +6 -10
- package/src/core/scrub.ts +27 -30
- package/src/core/task.ts +45 -73
- package/src/core/time.ts +3 -3
- package/src/core/timeout.ts +2 -2
- package/src/core/version.ts +1 -1
- package/src/data/baseline.ts +55 -60
- package/src/data/consent.ts +22 -4
- package/src/data/custom.ts +13 -8
- package/src/data/dimension.ts +7 -11
- package/src/data/encode.ts +38 -36
- package/src/data/envelope.ts +38 -38
- package/src/data/extract.ts +77 -86
- package/src/data/index.ts +9 -11
- package/src/data/limit.ts +1 -1
- package/src/data/metadata.ts +319 -305
- package/src/data/metric.ts +8 -18
- package/src/data/ping.ts +4 -8
- package/src/data/signal.ts +18 -18
- package/src/data/summary.ts +4 -6
- package/src/data/token.ts +8 -10
- package/src/data/upgrade.ts +3 -7
- package/src/data/upload.ts +49 -100
- package/src/data/variable.ts +20 -27
- package/src/diagnostic/encode.ts +2 -2
- package/src/diagnostic/fraud.ts +4 -3
- package/src/diagnostic/internal.ts +5 -11
- package/src/diagnostic/script.ts +8 -12
- package/src/global.ts +1 -1
- package/src/insight/blank.ts +4 -4
- package/src/insight/encode.ts +17 -23
- package/src/insight/snapshot.ts +37 -57
- package/src/interaction/change.ts +6 -9
- package/src/interaction/click.ts +28 -34
- package/src/interaction/clipboard.ts +2 -2
- package/src/interaction/encode.ts +31 -35
- package/src/interaction/input.ts +9 -11
- package/src/interaction/pointer.ts +30 -41
- package/src/interaction/resize.ts +5 -5
- package/src/interaction/scroll.ts +17 -20
- package/src/interaction/selection.ts +8 -12
- package/src/interaction/submit.ts +2 -2
- package/src/interaction/timeline.ts +9 -13
- package/src/interaction/unload.ts +1 -1
- package/src/interaction/visibility.ts +2 -2
- package/src/layout/animation.ts +41 -47
- package/src/layout/discover.ts +5 -5
- package/src/layout/document.ts +19 -31
- package/src/layout/dom.ts +91 -141
- package/src/layout/encode.ts +37 -52
- package/src/layout/mutation.ts +318 -321
- package/src/layout/node.ts +81 -104
- package/src/layout/offset.ts +6 -7
- package/src/layout/region.ts +43 -66
- package/src/layout/schema.ts +8 -15
- package/src/layout/selector.ts +25 -47
- package/src/layout/style.ts +37 -45
- package/src/layout/target.ts +10 -14
- package/src/layout/traverse.ts +11 -17
- package/src/performance/blank.ts +1 -1
- package/src/performance/encode.ts +4 -4
- package/src/performance/interaction.ts +70 -58
- package/src/performance/navigation.ts +2 -2
- package/src/performance/observer.ts +26 -59
- package/src/queue.ts +9 -16
- package/tsconfig.json +1 -1
- package/tslint.json +32 -25
- package/types/core.d.ts +13 -13
- package/types/data.d.ts +48 -32
- package/types/diagnostic.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/interaction.d.ts +4 -5
- package/types/layout.d.ts +21 -36
- package/types/performance.d.ts +5 -6
- package/.lintstagedrc.yml +0 -3
- package/biome.json +0 -43
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Code, Constant, Dimension, Metric,
|
|
1
|
+
import { Code, Constant, Dimension, Metric, Severity, PerformanceEventTiming } from "@clarity-types/data";
|
|
2
2
|
import { FunctionNames } from "@clarity-types/performance";
|
|
3
3
|
import config from "@src/core/config";
|
|
4
4
|
import { bind } from "@src/core/event";
|
|
@@ -7,40 +7,27 @@ import { setTimeout } from "@src/core/timeout";
|
|
|
7
7
|
import * as dimension from "@src/data/dimension";
|
|
8
8
|
import * as metric from "@src/data/metric";
|
|
9
9
|
import * as internal from "@src/diagnostic/internal";
|
|
10
|
-
import * as interaction from "@src/performance/interaction";
|
|
11
10
|
import * as navigation from "@src/performance/navigation";
|
|
11
|
+
import * as interaction from "@src/performance/interaction";
|
|
12
12
|
|
|
13
13
|
let observer: PerformanceObserver;
|
|
14
|
-
const types: string[] = [
|
|
15
|
-
Constant.Navigation,
|
|
16
|
-
Constant.Resource,
|
|
17
|
-
Constant.LongTask,
|
|
18
|
-
Constant.FID,
|
|
19
|
-
Constant.CLS,
|
|
20
|
-
Constant.LCP,
|
|
21
|
-
Constant.PerformanceEventTiming,
|
|
22
|
-
];
|
|
14
|
+
const types: string[] = [Constant.Navigation, Constant.Resource, Constant.LongTask, Constant.FID, Constant.CLS, Constant.LCP, Constant.PerformanceEventTiming];
|
|
23
15
|
|
|
24
16
|
export function start(): void {
|
|
25
17
|
// Capture connection properties, if available
|
|
26
18
|
if (navigator && "connection" in navigator) {
|
|
27
|
-
|
|
28
|
-
dimension.log(Dimension.ConnectionType, navigator.connection["effectiveType"]);
|
|
19
|
+
dimension.log(Dimension.ConnectionType, navigator["connection"]["effectiveType"]);
|
|
29
20
|
}
|
|
30
21
|
|
|
31
22
|
// Check the browser support performance observer as a pre-requisite for any performance measurement
|
|
32
|
-
if (window
|
|
23
|
+
if (window["PerformanceObserver"] && PerformanceObserver.supportedEntryTypes) {
|
|
33
24
|
// Start monitoring performance data after page has finished loading.
|
|
34
25
|
// If the document.readyState is not yet complete, we intentionally call observe using a setTimeout.
|
|
35
26
|
// This allows us to capture loadEventEnd on navigation timeline.
|
|
36
27
|
if (document.readyState !== "complete") {
|
|
37
28
|
bind(window, "load", setTimeout.bind(this, observe, 0));
|
|
38
|
-
} else {
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
internal.log(Code.PerformanceObserver, Severity.Info);
|
|
43
|
-
}
|
|
29
|
+
} else { observe(); }
|
|
30
|
+
} else { internal.log(Code.PerformanceObserver, Severity.Info); }
|
|
44
31
|
}
|
|
45
32
|
|
|
46
33
|
function observe(): void {
|
|
@@ -48,27 +35,21 @@ function observe(): void {
|
|
|
48
35
|
// Some browsers will throw an error for unsupported entryType, e.g. "layout-shift"
|
|
49
36
|
// In those cases, we log it as a warning and continue with rest of the Clarity processing
|
|
50
37
|
try {
|
|
51
|
-
if (observer) {
|
|
52
|
-
observer.disconnect();
|
|
53
|
-
}
|
|
38
|
+
if (observer) { observer.disconnect(); }
|
|
54
39
|
observer = new PerformanceObserver(measure(handle) as PerformanceObserverCallback);
|
|
55
40
|
// Reference: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/observe
|
|
56
41
|
// "buffered" flag indicates whether buffered entries should be queued into the observer's buffer.
|
|
57
42
|
// It must only be used only with the "type" option, and cannot be used with entryTypes.
|
|
58
43
|
// This is why we need to individually "observe" each supported type
|
|
59
|
-
for (
|
|
44
|
+
for (let x of types) {
|
|
60
45
|
if (PerformanceObserver.supportedEntryTypes.indexOf(x) >= 0) {
|
|
61
46
|
// Initialize CLS with a value of zero. It's possible (and recommended) for sites to not have any cumulative layout shift.
|
|
62
47
|
// In those cases, we want to still initialize the metric in Clarity
|
|
63
|
-
if (x === Constant.CLS) {
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
observer.observe({ type: x, buffered: true });
|
|
48
|
+
if (x === Constant.CLS) { metric.sum(Metric.CumulativeLayoutShift, 0); }
|
|
49
|
+
observer.observe({type: x, buffered: true});
|
|
67
50
|
}
|
|
68
51
|
}
|
|
69
|
-
} catch {
|
|
70
|
-
internal.log(Code.PerformanceObserver, Severity.Warning);
|
|
71
|
-
}
|
|
52
|
+
} catch { internal.log(Code.PerformanceObserver, Severity.Warning); }
|
|
72
53
|
}
|
|
73
54
|
|
|
74
55
|
function handle(entries: PerformanceObserverEntryList): void {
|
|
@@ -77,65 +58,51 @@ function handle(entries: PerformanceObserverEntryList): void {
|
|
|
77
58
|
}
|
|
78
59
|
|
|
79
60
|
function process(entries: PerformanceEntryList): void {
|
|
80
|
-
|
|
61
|
+
let visible = "visibilityState" in document ? document.visibilityState === "visible" : true;
|
|
81
62
|
for (let i = 0; i < entries.length; i++) {
|
|
82
|
-
|
|
63
|
+
let entry = entries[i];
|
|
83
64
|
switch (entry.entryType) {
|
|
84
65
|
case Constant.Navigation:
|
|
85
66
|
navigation.compute(entry as PerformanceNavigationTiming);
|
|
86
67
|
break;
|
|
87
|
-
case Constant.Resource:
|
|
88
|
-
|
|
68
|
+
case Constant.Resource:
|
|
69
|
+
let name = entry.name;
|
|
89
70
|
dimension.log(Dimension.NetworkHosts, host(name));
|
|
90
|
-
if (name === config.upload || name === config.fallback) {
|
|
91
|
-
metric.max(Metric.UploadTime, entry.duration);
|
|
92
|
-
}
|
|
71
|
+
if (name === config.upload || name === config.fallback) { metric.max(Metric.UploadTime, entry.duration); }
|
|
93
72
|
break;
|
|
94
|
-
}
|
|
95
73
|
case Constant.LongTask:
|
|
96
74
|
metric.count(Metric.LongTaskCount);
|
|
97
75
|
break;
|
|
98
76
|
case Constant.FID:
|
|
99
|
-
|
|
100
|
-
if (visible && (entry as any).processingStart) {
|
|
101
|
-
// biome-ignore lint/suspicious/noExplicitAny: not all browsers support processingstart
|
|
102
|
-
metric.max(Metric.FirstInputDelay, (entry as any).processingStart - entry.startTime);
|
|
103
|
-
}
|
|
77
|
+
if (visible) { metric.max(Metric.FirstInputDelay, entry["processingStart"] - entry.startTime); }
|
|
104
78
|
break;
|
|
105
79
|
case Constant.PerformanceEventTiming:
|
|
106
|
-
if (visible &&
|
|
107
|
-
|
|
80
|
+
if (visible && 'PerformanceEventTiming' in window && 'interactionId' in PerformanceEventTiming.prototype)
|
|
81
|
+
{
|
|
82
|
+
interaction.processInteractionEntry(entry as PerformanceEventTiming);
|
|
108
83
|
// Logging it as dimension because we're always looking for the last value.
|
|
109
|
-
dimension.log(Dimension.InteractionNextPaint, interaction.estimateP98LongestInteraction().toString());
|
|
84
|
+
dimension.log(Dimension.InteractionNextPaint, interaction.estimateP98LongestInteraction().toString());
|
|
110
85
|
}
|
|
111
86
|
break;
|
|
112
87
|
case Constant.CLS:
|
|
113
88
|
// Scale the value to avoid sending back floating point number
|
|
114
|
-
|
|
115
|
-
if (visible && !(entry as any).hadRecentInput) {
|
|
116
|
-
// biome-ignore lint/suspicious/noExplicitAny: not all browsers support layoutshift value
|
|
117
|
-
metric.sum(Metric.CumulativeLayoutShift, (entry as any).value * 1000);
|
|
118
|
-
}
|
|
89
|
+
if (visible && !entry["hadRecentInput"]) { metric.sum(Metric.CumulativeLayoutShift, entry["value"] * 1000); }
|
|
119
90
|
break;
|
|
120
91
|
case Constant.LCP:
|
|
121
|
-
if (visible) {
|
|
122
|
-
metric.max(Metric.LargestPaint, entry.startTime);
|
|
123
|
-
}
|
|
92
|
+
if (visible) { metric.max(Metric.LargestPaint, entry.startTime); }
|
|
124
93
|
break;
|
|
125
94
|
}
|
|
126
95
|
}
|
|
127
96
|
}
|
|
128
97
|
|
|
129
98
|
export function stop(): void {
|
|
130
|
-
if (observer) {
|
|
131
|
-
observer.disconnect();
|
|
132
|
-
}
|
|
99
|
+
if (observer) { observer.disconnect(); }
|
|
133
100
|
observer = null;
|
|
134
101
|
interaction.resetInteractions();
|
|
135
102
|
}
|
|
136
103
|
|
|
137
104
|
function host(url: string): string {
|
|
138
|
-
|
|
105
|
+
let a = document.createElement("a");
|
|
139
106
|
a.href = url;
|
|
140
107
|
return a.host;
|
|
141
108
|
}
|
package/src/queue.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { Constant } from "@clarity-types/data";
|
|
2
2
|
import * as clarity from "@src/clarity";
|
|
3
3
|
|
|
4
|
-
const w = window;
|
|
4
|
+
const w = window;
|
|
5
5
|
const c = Constant.Clarity;
|
|
6
6
|
|
|
7
7
|
export function setup() {
|
|
8
|
-
// Start queuing up calls while Clarity is inactive and we are in a browser enviornment
|
|
8
|
+
// Start queuing up calls while Clarity is inactive and we are in a browser enviornment
|
|
9
9
|
if (typeof w !== "undefined") {
|
|
10
|
-
w[c] = (
|
|
11
|
-
|
|
12
|
-
w[c].q = [];
|
|
13
|
-
}
|
|
14
|
-
w[c].q.push(args);
|
|
10
|
+
w[c] = function() {
|
|
11
|
+
(w[c].q = w[c].q || []).push(arguments);
|
|
15
12
|
// if the start function was called, don't queue it and instead process the queue
|
|
16
|
-
|
|
13
|
+
arguments[0] === "start" && w[c].q.unshift(w[c].q.pop()) && process();
|
|
17
14
|
};
|
|
18
15
|
}
|
|
19
16
|
}
|
|
@@ -21,20 +18,16 @@ export function setup() {
|
|
|
21
18
|
export function process() {
|
|
22
19
|
if (typeof w !== "undefined") {
|
|
23
20
|
// Do not execute or reset global "clarity" variable if a version of Clarity is already running on the page
|
|
24
|
-
if (w[c]
|
|
25
|
-
return console.warn("Error CL001: Multiple Clarity tags detected.");
|
|
26
|
-
}
|
|
21
|
+
if (w[c] && w[c].v) { return console.warn("Error CL001: Multiple Clarity tags detected."); }
|
|
27
22
|
|
|
28
23
|
// Expose clarity in a browser environment
|
|
29
24
|
// To be efficient about queuing up operations while Clarity is wiring up, we expose clarity.*(args) => clarity(*, args);
|
|
30
25
|
// This allows us to reprocess any calls that we missed once Clarity is available on the page
|
|
31
26
|
// Once Clarity script bundle is loaded on the page, we also initialize a "v" property that holds current version
|
|
32
27
|
// We use the presence or absence of "v" to determine if we are attempting to run a duplicate instance
|
|
33
|
-
|
|
34
|
-
w[c] = (method: string, ...args): void
|
|
28
|
+
let queue = w[c] ? (w[c].q || []) : [];
|
|
29
|
+
w[c] = function(method: string, ...args: any[]): void { return clarity[method](...args); }
|
|
35
30
|
w[c].v = clarity.version;
|
|
36
|
-
while (queue.length > 0) {
|
|
37
|
-
w[c](...queue.shift());
|
|
38
|
-
}
|
|
31
|
+
while (queue.length > 0) { w[c](...queue.shift()); }
|
|
39
32
|
}
|
|
40
33
|
}
|
package/tsconfig.json
CHANGED
package/tslint.json
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"extends": "tslint:recommended",
|
|
3
|
+
"rules": {
|
|
4
|
+
"max-line-length": [
|
|
5
|
+
true,
|
|
6
|
+
140
|
|
7
|
+
],
|
|
8
|
+
"no-console": [
|
|
9
|
+
false
|
|
10
|
+
],
|
|
11
|
+
"no-string-literal": false,
|
|
12
|
+
"prefer-const": false,
|
|
13
|
+
"prefer-for-of": false,
|
|
14
|
+
"object-literal-sort-keys": false,
|
|
15
|
+
"one-variable-per-declaration": false,
|
|
16
|
+
"trailing-comma": [
|
|
17
|
+
false
|
|
18
|
+
],
|
|
19
|
+
"variable-name": false,
|
|
20
|
+
"interface-name": false,
|
|
21
|
+
"interface-over-type-literal": false,
|
|
22
|
+
"only-arrow-functions": false,
|
|
23
|
+
"typedef": [
|
|
24
|
+
true,
|
|
25
|
+
"call-signature",
|
|
26
|
+
"parameter",
|
|
27
|
+
"property-declaration",
|
|
28
|
+
"member-variable-declaration",
|
|
29
|
+
"object-destructuring",
|
|
30
|
+
"array-destructuring"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
package/types/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Data from "./data";
|
|
2
2
|
|
|
3
3
|
type TaskFunction = () => Promise<void>;
|
|
4
4
|
type TaskResolve = () => void;
|
|
@@ -10,20 +10,20 @@ type Checksum = [number /* FraudId */, string /* Query Selector */];
|
|
|
10
10
|
|
|
11
11
|
export const enum Priority {
|
|
12
12
|
Normal = 0,
|
|
13
|
-
High = 1
|
|
13
|
+
High = 1
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export const enum Time {
|
|
17
17
|
Second = 1000,
|
|
18
18
|
Minute = 60 * 1000,
|
|
19
19
|
Hour = 60 * 60 * 1000,
|
|
20
|
-
Day = 24 * 60 * 60 * 1000
|
|
20
|
+
Day = 24 * 60 * 60 * 1000
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const enum Task {
|
|
24
24
|
Wait = 0,
|
|
25
25
|
Run = 1,
|
|
26
|
-
Stop = 2
|
|
26
|
+
Stop = 2
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export const enum ExtractSource {
|
|
@@ -31,20 +31,20 @@ export const enum ExtractSource {
|
|
|
31
31
|
Cookie = 1,
|
|
32
32
|
Text = 2,
|
|
33
33
|
Fragment = 3,
|
|
34
|
-
Hash = 4
|
|
34
|
+
Hash = 4
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export const enum Type {
|
|
38
38
|
Array = 1,
|
|
39
39
|
Object = 2,
|
|
40
|
-
Simple = 3
|
|
40
|
+
Simple = 3
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export type Syntax = {
|
|
44
|
-
name: string
|
|
45
|
-
type: Type
|
|
46
|
-
condition: string
|
|
47
|
-
}
|
|
44
|
+
name: string,
|
|
45
|
+
type: Type,
|
|
46
|
+
condition: string
|
|
47
|
+
}
|
|
48
48
|
|
|
49
49
|
export const enum Privacy {
|
|
50
50
|
None = 0,
|
|
@@ -52,7 +52,7 @@ export const enum Privacy {
|
|
|
52
52
|
Text = 2,
|
|
53
53
|
TextImage = 3,
|
|
54
54
|
Exclude = 4,
|
|
55
|
-
Snapshot = 5
|
|
55
|
+
Snapshot = 5
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/* Helper Interfaces */
|
|
@@ -83,7 +83,7 @@ export interface RequestIdleCallbackOptions {
|
|
|
83
83
|
|
|
84
84
|
export interface RequestIdleCallbackDeadline {
|
|
85
85
|
didTimeout: boolean;
|
|
86
|
-
timeRemaining: () => number;
|
|
86
|
+
timeRemaining: (() => number);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export interface AsyncTask {
|
|
@@ -146,5 +146,5 @@ export const enum Constant {
|
|
|
146
146
|
Zone = "Zone",
|
|
147
147
|
Symbol = "__symbol__",
|
|
148
148
|
AddEventListener = "addEventListener",
|
|
149
|
-
RemoveEventListener = "removeEventListener"
|
|
149
|
+
RemoveEventListener = "removeEventListener"
|
|
150
150
|
}
|
package/types/data.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Time } from "@clarity-types/core";
|
|
2
|
-
export type Target = number | Node;
|
|
3
|
-
export type Token = string | number | number[] | string[] | (string | number)[];
|
|
2
|
+
export type Target = (number | Node);
|
|
3
|
+
export type Token = (string | number | number[] | string[] | (string | number)[]);
|
|
4
|
+
export type DecodedToken = (any | any[]);
|
|
4
5
|
|
|
5
|
-
export type MetadataCallback = (data: Metadata, playback: boolean) => void;
|
|
6
|
+
export type MetadataCallback = (data: Metadata, playback: boolean, consentStatus?: ConsentState) => void;
|
|
6
7
|
export interface MetadataCallbackOptions {
|
|
7
|
-
callback: MetadataCallback
|
|
8
|
-
wait: boolean
|
|
9
|
-
recall: boolean
|
|
10
|
-
called: boolean
|
|
8
|
+
callback: MetadataCallback,
|
|
9
|
+
wait: boolean,
|
|
10
|
+
recall: boolean,
|
|
11
|
+
called: boolean,
|
|
12
|
+
consentInfo: boolean
|
|
11
13
|
}
|
|
12
|
-
export type SignalCallback = (data: ClaritySignal) => void
|
|
14
|
+
export type SignalCallback = (data: ClaritySignal) => void
|
|
13
15
|
|
|
14
16
|
/* Enum */
|
|
15
17
|
export const enum Event {
|
|
@@ -70,6 +72,7 @@ export const enum Event {
|
|
|
70
72
|
Animation = 44,
|
|
71
73
|
StyleSheetAdoption = 45,
|
|
72
74
|
StyleSheetUpdate = 46,
|
|
75
|
+
Consent = 47,
|
|
73
76
|
|
|
74
77
|
// Apps specific events
|
|
75
78
|
WebViewDiscover = 100,
|
|
@@ -79,7 +82,7 @@ export const enum Event {
|
|
|
79
82
|
Keystrokes = 104,
|
|
80
83
|
BackGesture = 105,
|
|
81
84
|
WebViewStatus = 106,
|
|
82
|
-
AppInstallReferrer = 107
|
|
85
|
+
AppInstallReferrer = 107
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
export const enum Metric {
|
|
@@ -131,6 +134,7 @@ export const enum Metric {
|
|
|
131
134
|
*/
|
|
132
135
|
InteractionNextPaint = 37,
|
|
133
136
|
HistoryClear = 38,
|
|
137
|
+
AngularZone = 39,
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
export const enum Dimension {
|
|
@@ -171,7 +175,7 @@ export const enum Dimension {
|
|
|
171
175
|
Timezone = 34,
|
|
172
176
|
TimezoneOffset = 35,
|
|
173
177
|
Consent = 36,
|
|
174
|
-
InteractionNextPaint = 37
|
|
178
|
+
InteractionNextPaint = 37
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
export const enum Check {
|
|
@@ -182,7 +186,7 @@ export const enum Check {
|
|
|
182
186
|
Bytes = 4,
|
|
183
187
|
Collection = 5,
|
|
184
188
|
Server = 6,
|
|
185
|
-
Page = 7
|
|
189
|
+
Page = 7
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
export const enum Code {
|
|
@@ -200,48 +204,43 @@ export const enum Code {
|
|
|
200
204
|
Config = 8,
|
|
201
205
|
FunctionExecutionTime = 9,
|
|
202
206
|
LeanLimit = 10,
|
|
203
|
-
AngularZone = 11,
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
export const enum Severity {
|
|
207
210
|
Info = 0,
|
|
208
211
|
Warning = 1,
|
|
209
212
|
Error = 2,
|
|
210
|
-
Fatal = 3
|
|
213
|
+
Fatal = 3
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
export const enum Upload {
|
|
214
217
|
Async = 0,
|
|
215
|
-
Beacon = 1
|
|
218
|
+
Beacon = 1
|
|
216
219
|
}
|
|
217
220
|
|
|
218
221
|
export const enum BooleanFlag {
|
|
219
222
|
False = 0,
|
|
220
|
-
True = 1
|
|
223
|
+
True = 1
|
|
221
224
|
}
|
|
222
225
|
|
|
223
226
|
export const enum IframeStatus {
|
|
224
227
|
Unknown = 0,
|
|
225
228
|
TopFrame = 1,
|
|
226
|
-
Iframe = 2
|
|
229
|
+
Iframe = 2
|
|
227
230
|
}
|
|
228
231
|
|
|
229
232
|
export const enum Setting {
|
|
230
233
|
Expire = 365, // 1 Year
|
|
231
234
|
SessionExpire = 1, // 1 Day
|
|
232
235
|
CookieVersion = 2, // Increment this version every time there's a cookie schema change
|
|
233
|
-
// biome-ignore lint/style/useLiteralEnumMembers: Time.Minute is a const enum, it is compiled to a number
|
|
234
236
|
SessionTimeout = 30 * Time.Minute, // 30 minutes
|
|
235
237
|
CookieInterval = 1, // 1 Day
|
|
236
|
-
// biome-ignore lint/style/useLiteralEnumMembers: Time.Minute is a const enum, it is compiled to a number
|
|
237
238
|
PingInterval = 1 * Time.Minute, // 1 Minute
|
|
238
|
-
// biome-ignore lint/style/useLiteralEnumMembers: Time.Minute is a const enum, it is compiled to a number
|
|
239
239
|
PingTimeout = 5 * Time.Minute, // 5 Minutes
|
|
240
240
|
SummaryInterval = 100, // Same events within 100ms will be collapsed into single summary
|
|
241
241
|
ClickText = 25, // Maximum number of characters to send as part of Click event's text field
|
|
242
242
|
PayloadLimit = 128, // Do not allow more than specified payloads per page
|
|
243
243
|
PageLimit = 128, // Do not allow more than 128 pages in a session
|
|
244
|
-
// biome-ignore lint/style/useLiteralEnumMembers: Time.Hour is a const enum, it is compiled to a number
|
|
245
244
|
ShutdownLimit = 2 * Time.Hour, // Shutdown instrumentation after specified time
|
|
246
245
|
RetryLimit = 1, // Maximum number of attempts to upload a payload before giving up
|
|
247
246
|
PlaybackBytesLimit = 10 * 1024 * 1024, // 10MB
|
|
@@ -260,7 +259,6 @@ export const enum Setting {
|
|
|
260
259
|
MegaByte = 1024 * 1024, // 1MB
|
|
261
260
|
UploadFactor = 3, // Slow down sequence by specified factor
|
|
262
261
|
MinUploadDelay = 100, // Minimum time before we are ready to flush events to the server
|
|
263
|
-
// biome-ignore lint/style/useLiteralEnumMembers: Time.Second is a const enum, it is compiled to a number
|
|
264
262
|
MaxUploadDelay = 30 * Time.Second, // Do flush out payload once every 30s,
|
|
265
263
|
ExtractLimit = 10000, // Do not extract more than 10000 characters
|
|
266
264
|
ChecksumPrecision = 28, // n-bit integer to represent token hash
|
|
@@ -275,11 +273,11 @@ export const enum Character {
|
|
|
275
273
|
Blank = 32,
|
|
276
274
|
Tab = 9,
|
|
277
275
|
NewLine = 10,
|
|
278
|
-
Return = 13
|
|
276
|
+
Return = 13
|
|
279
277
|
}
|
|
280
278
|
|
|
281
279
|
export const enum ApplicationPlatform {
|
|
282
|
-
WebApp = 0
|
|
280
|
+
WebApp = 0
|
|
283
281
|
}
|
|
284
282
|
|
|
285
283
|
export const enum Constant {
|
|
@@ -351,6 +349,8 @@ export const enum Constant {
|
|
|
351
349
|
SHA256 = "SHA-256",
|
|
352
350
|
Electron = "Electron",
|
|
353
351
|
Caret = "^",
|
|
352
|
+
Granted = "granted",
|
|
353
|
+
Denied = "denied",
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
export const enum XMLReadyState {
|
|
@@ -358,21 +358,26 @@ export const enum XMLReadyState {
|
|
|
358
358
|
Opened = 1,
|
|
359
359
|
Headers_Recieved = 2,
|
|
360
360
|
Loading = 3,
|
|
361
|
-
Done = 4
|
|
361
|
+
Done = 4
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export const enum ConsentSource{
|
|
365
|
+
Implicit = 0,
|
|
366
|
+
API = 1
|
|
362
367
|
}
|
|
363
368
|
|
|
364
369
|
/* Helper Interfaces */
|
|
365
370
|
|
|
366
371
|
export interface Payload {
|
|
367
|
-
e: Token[] /* Envelope
|
|
368
|
-
a: Token[][] /* Events that are used for data analysis
|
|
369
|
-
p: Token[][] /* Events that are primarily used for session playback
|
|
372
|
+
e: Token[]; /* Envelope */
|
|
373
|
+
a: Token[][]; /* Events that are used for data analysis */
|
|
374
|
+
p: Token[][]; /* Events that are primarily used for session playback */
|
|
370
375
|
}
|
|
371
376
|
|
|
372
377
|
export interface EncodedPayload {
|
|
373
|
-
e: string /* Envelope
|
|
374
|
-
a: string /* Analytics Payload
|
|
375
|
-
p: string /* Playback Payload
|
|
378
|
+
e: string; /* Envelope */
|
|
379
|
+
a: string; /* Analytics Payload */
|
|
380
|
+
p: string; /* Playback Payload */
|
|
376
381
|
}
|
|
377
382
|
|
|
378
383
|
export interface Metadata {
|
|
@@ -505,8 +510,8 @@ export interface UploadData {
|
|
|
505
510
|
}
|
|
506
511
|
|
|
507
512
|
export interface ClaritySignal {
|
|
508
|
-
type: string
|
|
509
|
-
value?: number
|
|
513
|
+
type: string
|
|
514
|
+
value?: number
|
|
510
515
|
}
|
|
511
516
|
|
|
512
517
|
export interface PerformanceEventTiming extends PerformanceEntry {
|
|
@@ -518,3 +523,14 @@ export interface Interaction {
|
|
|
518
523
|
id: number;
|
|
519
524
|
latency: number;
|
|
520
525
|
}
|
|
526
|
+
|
|
527
|
+
export interface ConsentState {
|
|
528
|
+
ad_Storage?: string;
|
|
529
|
+
analytics_Storage?: string;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export interface ConsentData {
|
|
533
|
+
source: ConsentSource;
|
|
534
|
+
ad_Storage: BooleanFlag;
|
|
535
|
+
analytics_Storage: BooleanFlag;
|
|
536
|
+
}
|
package/types/diagnostic.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ interface Clarity {
|
|
|
12
12
|
resume: () => void;
|
|
13
13
|
upgrade: (key: string) => void;
|
|
14
14
|
consent: () => void;
|
|
15
|
+
consentv2: () => void;
|
|
15
16
|
event: (name: string, value: string) => void;
|
|
16
17
|
set: (variable: string, value: string | string[]) => void;
|
|
17
18
|
identify: (userId: string, sessionId?: string, pageId?: string, userHint?: string) => void;
|
package/types/interaction.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BooleanFlag } from "@clarity-types/data";
|
|
2
2
|
import { Time } from "./core";
|
|
3
|
-
import
|
|
3
|
+
import { Event, Target } from "./data";
|
|
4
4
|
|
|
5
5
|
/* Enum */
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ export const enum BrowsingContext {
|
|
|
8
8
|
Self = 0,
|
|
9
9
|
Blank = 1,
|
|
10
10
|
Parent = 2,
|
|
11
|
-
Top = 3
|
|
11
|
+
Top = 3
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const enum Setting {
|
|
@@ -18,14 +18,13 @@ export const enum Setting {
|
|
|
18
18
|
ScrollInterval = 50, // 25 milliseconds
|
|
19
19
|
PointerInterval = 25, // 25 milliseconds
|
|
20
20
|
Throttle = 25, // 25 milliseconds
|
|
21
|
-
// biome-ignore lint/style/useLiteralEnumMembers: Time.Second is a const enum, it is compiled to a number
|
|
22
21
|
TimelineSpan = 2 * Time.Second, // 2 seconds
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
export const enum Clipboard {
|
|
26
25
|
Cut = 0,
|
|
27
26
|
Copy = 1,
|
|
28
|
-
Paste = 2
|
|
27
|
+
Paste = 2
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
/* Helper Interfaces */
|