@gem-sdk/clarity-js 0.8.94
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/CHANGELOG.md +8 -0
- package/README.md +1 -0
- package/build/clarity.extended.js +1 -0
- package/build/clarity.insight.js +1 -0
- package/build/clarity.js +7148 -0
- package/build/clarity.livechat.js +1 -0
- package/build/clarity.min.js +1 -0
- package/build/clarity.module.js +7144 -0
- package/build/clarity.performance.js +1 -0
- package/build/dynamic/clarity.crisp.js +1 -0
- package/build/dynamic/clarity.tidio.js +1 -0
- package/package.json +49 -0
- package/rollup.config.ts +161 -0
- package/src/clarity.ts +72 -0
- package/src/core/api.ts +8 -0
- package/src/core/config.ts +35 -0
- package/src/core/copy.ts +3 -0
- package/src/core/dynamic.ts +68 -0
- package/src/core/event.ts +53 -0
- package/src/core/hash.ts +19 -0
- package/src/core/history.ts +82 -0
- package/src/core/index.ts +81 -0
- package/src/core/measure.ts +19 -0
- package/src/core/report.ts +28 -0
- package/src/core/scrub.ts +201 -0
- package/src/core/task.ts +181 -0
- package/src/core/throttle.ts +46 -0
- package/src/core/time.ts +26 -0
- package/src/core/timeout.ts +10 -0
- package/src/core/version.ts +2 -0
- package/src/custom/README.md +44 -0
- package/src/custom/dialog.ts +69 -0
- package/src/custom/index.ts +6 -0
- package/src/data/baseline.ts +162 -0
- package/src/data/compress.ts +31 -0
- package/src/data/consent.ts +84 -0
- package/src/data/cookie.ts +90 -0
- package/src/data/custom.ts +23 -0
- package/src/data/dimension.ts +53 -0
- package/src/data/encode.ts +155 -0
- package/src/data/envelope.ts +53 -0
- package/src/data/extract.ts +217 -0
- package/src/data/gemx-upload.ts +51 -0
- package/src/data/gemx.ts +35 -0
- package/src/data/index.ts +57 -0
- package/src/data/limit.ts +44 -0
- package/src/data/metadata.ts +340 -0
- package/src/data/metric.ts +51 -0
- package/src/data/ping.ts +36 -0
- package/src/data/signal.ts +30 -0
- package/src/data/summary.ts +34 -0
- package/src/data/token.ts +39 -0
- package/src/data/upgrade.ts +44 -0
- package/src/data/upload.ts +375 -0
- package/src/data/util.ts +18 -0
- package/src/data/variable.ts +84 -0
- package/src/diagnostic/encode.ts +40 -0
- package/src/diagnostic/fraud.ts +37 -0
- package/src/diagnostic/index.ts +13 -0
- package/src/diagnostic/internal.ts +28 -0
- package/src/diagnostic/script.ts +35 -0
- package/src/dynamic/agent/blank.ts +2 -0
- package/src/dynamic/agent/crisp.ts +40 -0
- package/src/dynamic/agent/encode.ts +25 -0
- package/src/dynamic/agent/index.ts +8 -0
- package/src/dynamic/agent/livechat.ts +58 -0
- package/src/dynamic/agent/tidio.ts +44 -0
- package/src/global.ts +6 -0
- package/src/index.ts +10 -0
- package/src/insight/blank.ts +14 -0
- package/src/insight/encode.ts +64 -0
- package/src/insight/snapshot.ts +115 -0
- package/src/interaction/change.ts +38 -0
- package/src/interaction/click.ts +256 -0
- package/src/interaction/clipboard.ts +32 -0
- package/src/interaction/encode.ts +217 -0
- package/src/interaction/focus.ts +25 -0
- package/src/interaction/index.ts +66 -0
- package/src/interaction/input.ts +66 -0
- package/src/interaction/pageshow.ts +35 -0
- package/src/interaction/pointer.ts +137 -0
- package/src/interaction/resize.ts +50 -0
- package/src/interaction/scroll.ts +134 -0
- package/src/interaction/selection.ts +66 -0
- package/src/interaction/submit.ts +30 -0
- package/src/interaction/timeline.ts +69 -0
- package/src/interaction/unload.ts +32 -0
- package/src/interaction/visibility.ts +28 -0
- package/src/layout/animation.ts +133 -0
- package/src/layout/constants.ts +13 -0
- package/src/layout/custom.ts +48 -0
- package/src/layout/discover.ts +31 -0
- package/src/layout/document.ts +46 -0
- package/src/layout/dom.ts +444 -0
- package/src/layout/encode.ts +157 -0
- package/src/layout/gemx-snapshot.ts +84 -0
- package/src/layout/index.ts +47 -0
- package/src/layout/mutation.ts +424 -0
- package/src/layout/node.ts +302 -0
- package/src/layout/offset.ts +19 -0
- package/src/layout/region.ts +151 -0
- package/src/layout/schema.ts +63 -0
- package/src/layout/selector.ts +113 -0
- package/src/layout/style.ts +160 -0
- package/src/layout/target.ts +34 -0
- package/src/layout/traverse.ts +28 -0
- package/src/performance/blank.ts +10 -0
- package/src/performance/encode.ts +31 -0
- package/src/performance/index.ts +12 -0
- package/src/performance/interaction.ts +125 -0
- package/src/performance/navigation.ts +31 -0
- package/src/performance/observer.ts +112 -0
- package/src/queue.ts +33 -0
- package/test/consentv2.test.ts +1309 -0
- package/test/hash.test.ts +68 -0
- package/test/time.test.ts +42 -0
- package/tsconfig.json +12 -0
- package/tslint.json +33 -0
- package/types/agent.d.ts +39 -0
- package/types/core.d.ts +156 -0
- package/types/data.d.ts +611 -0
- package/types/diagnostic.d.ts +24 -0
- package/types/global.d.ts +43 -0
- package/types/index.d.ts +46 -0
- package/types/interaction.d.ts +187 -0
- package/types/layout.d.ts +271 -0
- package/types/performance.d.ts +34 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { expect, test } from "@playwright/test";
|
|
2
|
+
import hash from "@src/core/hash";
|
|
3
|
+
|
|
4
|
+
test.describe("Core Utilities - Hash", () => {
|
|
5
|
+
test("hash function should generate consistent hash for same input", () => {
|
|
6
|
+
const input = "test-string";
|
|
7
|
+
const hash1 = hash(input);
|
|
8
|
+
const hash2 = hash(input);
|
|
9
|
+
|
|
10
|
+
expect(hash1).toBe(hash2);
|
|
11
|
+
expect(hash1).toBeTruthy();
|
|
12
|
+
expect(typeof hash1).toBe("string");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("hash function should generate different hashes for different inputs", () => {
|
|
16
|
+
const hash1 = hash("input1");
|
|
17
|
+
const hash2 = hash("input2");
|
|
18
|
+
const hash3 = hash("completely-different-input");
|
|
19
|
+
|
|
20
|
+
expect(hash1).not.toBe(hash2);
|
|
21
|
+
expect(hash2).not.toBe(hash3);
|
|
22
|
+
expect(hash1).not.toBe(hash3);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("hash function should respect precision parameter", () => {
|
|
26
|
+
const input = "test-precision";
|
|
27
|
+
const hashNoPrecision = hash(input);
|
|
28
|
+
const hash16 = hash(input, 16);
|
|
29
|
+
const hash8 = hash(input, 8);
|
|
30
|
+
|
|
31
|
+
expect(hashNoPrecision).toBeTruthy();
|
|
32
|
+
expect(hash16).toBeTruthy();
|
|
33
|
+
expect(hash8).toBeTruthy();
|
|
34
|
+
|
|
35
|
+
// Hash with precision should be different from no precision
|
|
36
|
+
expect(hashNoPrecision).not.toBe(hash16);
|
|
37
|
+
|
|
38
|
+
// Verify precision limits: 2^16 = 65536, 2^8 = 256
|
|
39
|
+
const hash16Num = parseInt(hash16, 36);
|
|
40
|
+
const hash8Num = parseInt(hash8, 36);
|
|
41
|
+
expect(hash16Num).toBeLessThan(65536);
|
|
42
|
+
expect(hash8Num).toBeLessThan(256);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("hash function should handle empty strings", () => {
|
|
46
|
+
const result = hash("");
|
|
47
|
+
expect(result).toBeTruthy();
|
|
48
|
+
expect(typeof result).toBe("string");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("hash function should handle special characters", () => {
|
|
52
|
+
const hash1 = hash("test@example.com");
|
|
53
|
+
const hash2 = hash("test#$%^&*()");
|
|
54
|
+
const hash3 = hash("🎉🎊✨");
|
|
55
|
+
|
|
56
|
+
expect(hash1).toBeTruthy();
|
|
57
|
+
expect(hash2).toBeTruthy();
|
|
58
|
+
expect(hash3).toBeTruthy();
|
|
59
|
+
expect(hash1).not.toBe(hash2);
|
|
60
|
+
expect(hash2).not.toBe(hash3);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("hash function should produce base36 output", () => {
|
|
64
|
+
const result = hash("test-base36");
|
|
65
|
+
// Base36 should only contain 0-9 and a-z
|
|
66
|
+
expect(/^[0-9a-z]+$/.test(result)).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { expect, test } from "@playwright/test";
|
|
2
|
+
import { start, stop, time } from "@src/core/time";
|
|
3
|
+
|
|
4
|
+
test.describe("Time Utilities", () => {
|
|
5
|
+
test("time module should start and stop", () => {
|
|
6
|
+
start();
|
|
7
|
+
const time1 = time();
|
|
8
|
+
|
|
9
|
+
expect(time1).toBeGreaterThanOrEqual(0);
|
|
10
|
+
|
|
11
|
+
stop();
|
|
12
|
+
const time2 = time();
|
|
13
|
+
|
|
14
|
+
// After stop, time should still work but use different baseline
|
|
15
|
+
expect(time2).toBeGreaterThanOrEqual(0);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("time function should track elapsed time", async () => {
|
|
19
|
+
start();
|
|
20
|
+
const time1 = time();
|
|
21
|
+
|
|
22
|
+
// Wait a bit
|
|
23
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
24
|
+
|
|
25
|
+
const time2 = time();
|
|
26
|
+
|
|
27
|
+
expect(time2).toBeGreaterThan(time1);
|
|
28
|
+
expect(time2 - time1).toBeGreaterThanOrEqual(50);
|
|
29
|
+
|
|
30
|
+
stop();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("time function should handle null event parameter", () => {
|
|
34
|
+
start();
|
|
35
|
+
const result = time(null);
|
|
36
|
+
|
|
37
|
+
expect(result).toBeGreaterThanOrEqual(0);
|
|
38
|
+
expect(typeof result).toBe("number");
|
|
39
|
+
|
|
40
|
+
stop();
|
|
41
|
+
});
|
|
42
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"paths": {
|
|
6
|
+
"@src/*": ["src/*"],
|
|
7
|
+
"@clarity-types/*": ["types/*"]
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"include":["src/**/*.ts", "types/**/*.d.ts", "test/**/*.ts", "rollup.config.ts"],
|
|
11
|
+
"exclude": ["node_modules", "build"]
|
|
12
|
+
}
|
package/tslint.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
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/agent.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const enum Action {
|
|
2
|
+
AgentOnline,
|
|
3
|
+
AgentOffline,
|
|
4
|
+
AgentHidden,
|
|
5
|
+
AgentMaximized,
|
|
6
|
+
AgentMinimized,
|
|
7
|
+
AgentMessage,
|
|
8
|
+
HumanMessage,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const enum AuthorType {
|
|
12
|
+
Agent = "agent",
|
|
13
|
+
Customer = "customer",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const enum Visibility {
|
|
17
|
+
Maximized = "maximized",
|
|
18
|
+
Minimized = "minimized",
|
|
19
|
+
Hidden = "hidden",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const enum Availability {
|
|
23
|
+
Online = "online",
|
|
24
|
+
Offline = "offline",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface VisibilityEvent {
|
|
28
|
+
visibility: Visibility;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface AvailabilityEvent {
|
|
32
|
+
availability: Availability;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface NewEvent {
|
|
36
|
+
author: {
|
|
37
|
+
type: AuthorType;
|
|
38
|
+
};
|
|
39
|
+
}
|
package/types/core.d.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as Data from "./data";
|
|
2
|
+
|
|
3
|
+
type TaskFunction = () => Promise<void>;
|
|
4
|
+
type TaskResolve = () => void;
|
|
5
|
+
type UploadCallback = (data: string, type?: string) => void;
|
|
6
|
+
type Region = [number /* RegionId */, string /* Query Selector */];
|
|
7
|
+
type Checksum = [number /* FraudId */, string /* Query Selector */];
|
|
8
|
+
|
|
9
|
+
/* Enum */
|
|
10
|
+
|
|
11
|
+
export const enum Priority {
|
|
12
|
+
Normal = 0,
|
|
13
|
+
High = 1
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const enum Time {
|
|
17
|
+
Second = 1000,
|
|
18
|
+
Minute = 60 * 1000,
|
|
19
|
+
Hour = 60 * 60 * 1000,
|
|
20
|
+
Day = 24 * 60 * 60 * 1000
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const enum Task {
|
|
24
|
+
Wait = 0,
|
|
25
|
+
Run = 1,
|
|
26
|
+
Stop = 2
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const enum ExtractSource {
|
|
30
|
+
Javascript = 0,
|
|
31
|
+
Cookie = 1,
|
|
32
|
+
Text = 2,
|
|
33
|
+
Fragment = 3,
|
|
34
|
+
Hash = 4
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const enum Type {
|
|
38
|
+
Array = 1,
|
|
39
|
+
Object = 2,
|
|
40
|
+
Simple = 3
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type Syntax = {
|
|
44
|
+
name: string,
|
|
45
|
+
type: Type,
|
|
46
|
+
condition: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const enum Privacy {
|
|
50
|
+
None = 0,
|
|
51
|
+
Sensitive = 1,
|
|
52
|
+
Text = 2,
|
|
53
|
+
TextImage = 3,
|
|
54
|
+
Exclude = 4,
|
|
55
|
+
Snapshot = 5
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Helper Interfaces */
|
|
59
|
+
|
|
60
|
+
export interface Module {
|
|
61
|
+
start: () => void;
|
|
62
|
+
stop: () => void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface Tasks {
|
|
66
|
+
[key: number]: TaskInfo;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface TaskInfo {
|
|
70
|
+
start: number;
|
|
71
|
+
calls: number;
|
|
72
|
+
yield: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface Timer {
|
|
76
|
+
id: string;
|
|
77
|
+
cost: Data.Metric;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface RequestIdleCallbackOptions {
|
|
81
|
+
timeout: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface RequestIdleCallbackDeadline {
|
|
85
|
+
didTimeout: boolean;
|
|
86
|
+
timeRemaining: (() => number);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface AsyncTask {
|
|
90
|
+
task: TaskFunction;
|
|
91
|
+
resolve: TaskResolve;
|
|
92
|
+
id: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface OffsetDistance {
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface BrowserEvent {
|
|
101
|
+
event: string;
|
|
102
|
+
listener: EventListener;
|
|
103
|
+
options: {
|
|
104
|
+
capture: boolean;
|
|
105
|
+
passive: boolean;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface Report {
|
|
110
|
+
v: string; // Version
|
|
111
|
+
p: string; // Project Id
|
|
112
|
+
u: string; // User Id
|
|
113
|
+
s: string; // Session Id
|
|
114
|
+
n: number; // Page Number
|
|
115
|
+
m?: string; // Message, optional
|
|
116
|
+
e?: string; // Error Stack, optional
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface Config {
|
|
120
|
+
projectId?: string;
|
|
121
|
+
delay?: number;
|
|
122
|
+
lean?: boolean;
|
|
123
|
+
lite?: boolean;
|
|
124
|
+
track?: boolean;
|
|
125
|
+
content?: boolean;
|
|
126
|
+
drop?: string[];
|
|
127
|
+
mask?: string[];
|
|
128
|
+
unmask?: string[];
|
|
129
|
+
regions?: Region[];
|
|
130
|
+
cookies?: string[];
|
|
131
|
+
fraud?: boolean;
|
|
132
|
+
checksum?: Checksum[];
|
|
133
|
+
report?: string;
|
|
134
|
+
upload?: string | UploadCallback;
|
|
135
|
+
fallback?: string;
|
|
136
|
+
upgrade?: (key: string) => void;
|
|
137
|
+
action?: (key: string) => void;
|
|
138
|
+
dob?: number;
|
|
139
|
+
delayDom?: boolean;
|
|
140
|
+
throttleDom?: boolean;
|
|
141
|
+
conversions?: boolean;
|
|
142
|
+
includeSubdomains?: boolean;
|
|
143
|
+
modules?: string[];
|
|
144
|
+
diagnostics?: boolean;
|
|
145
|
+
externalSession?: boolean;
|
|
146
|
+
userId?: string;
|
|
147
|
+
sessionId?: string;
|
|
148
|
+
mode?: "gemx" | "all";
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export const enum Constant {
|
|
152
|
+
Zone = "Zone",
|
|
153
|
+
Symbol = "__symbol__",
|
|
154
|
+
AddEventListener = "addEventListener",
|
|
155
|
+
RemoveEventListener = "removeEventListener"
|
|
156
|
+
}
|