clarity-js 0.7.48 → 0.7.50
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 +84 -56
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +84 -56
- package/build/clarity.performance.js +1 -1
- package/package.json +1 -1
- package/src/core/version.ts +1 -1
- package/src/data/consent.ts +21 -0
- package/src/data/metadata.ts +11 -1
- package/src/data/upgrade.ts +1 -0
- package/src/data/upload.ts +4 -1
- package/src/interaction/encode.ts +1 -0
- package/src/interaction/pointer.ts +6 -1
- package/types/data.d.ts +14 -3
- package/types/interaction.d.ts +1 -0
package/src/data/metadata.ts
CHANGED
|
@@ -8,6 +8,7 @@ import * as scrub from "@src/core/scrub";
|
|
|
8
8
|
import * as dimension from "@src/data/dimension";
|
|
9
9
|
import * as metric from "@src/data/metric";
|
|
10
10
|
import { set } from "@src/data/variable";
|
|
11
|
+
import * as trackConsent from "@src/data/consent";
|
|
11
12
|
|
|
12
13
|
export let data: Metadata = null;
|
|
13
14
|
export let callbacks: MetadataCallbackOptions[] = [];
|
|
@@ -74,6 +75,9 @@ export function start(): void {
|
|
|
74
75
|
if (value) { set(key, value); }
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
// Track consent config
|
|
79
|
+
trackConsent.config(config.track);
|
|
80
|
+
|
|
77
81
|
// Track ids using a cookie if configuration allows it
|
|
78
82
|
track(u);
|
|
79
83
|
}
|
|
@@ -130,6 +134,8 @@ export function consent(status: boolean = true): void {
|
|
|
130
134
|
if (core.active()) {
|
|
131
135
|
config.track = true;
|
|
132
136
|
track(user(), BooleanFlag.True);
|
|
137
|
+
save();
|
|
138
|
+
trackConsent.consent();
|
|
133
139
|
}
|
|
134
140
|
}
|
|
135
141
|
|
|
@@ -148,12 +154,16 @@ function tab(): string {
|
|
|
148
154
|
return id;
|
|
149
155
|
}
|
|
150
156
|
|
|
157
|
+
export function callback(): void {
|
|
158
|
+
let upgrade = config.lean ? BooleanFlag.False : BooleanFlag.True;
|
|
159
|
+
processCallback(upgrade);
|
|
160
|
+
}
|
|
161
|
+
|
|
151
162
|
export function save(): void {
|
|
152
163
|
if (!data) return;
|
|
153
164
|
let ts = Math.round(Date.now());
|
|
154
165
|
let upload = config.upload && typeof config.upload === Constant.String ? (config.upload as string).replace(Constant.HTTPS, Constant.Empty) : Constant.Empty;
|
|
155
166
|
let upgrade = config.lean ? BooleanFlag.False : BooleanFlag.True;
|
|
156
|
-
processCallback(upgrade);
|
|
157
167
|
setCookie(Constant.SessionKey, [data.sessionId, ts, data.pageNum, upgrade, upload].join(Constant.Pipe), Setting.SessionExpire);
|
|
158
168
|
}
|
|
159
169
|
|
package/src/data/upgrade.ts
CHANGED
package/src/data/upload.ts
CHANGED
|
@@ -241,7 +241,10 @@ function check(xhr: XMLHttpRequest, sequence: number): void {
|
|
|
241
241
|
|
|
242
242
|
function done(sequence: number): void {
|
|
243
243
|
// If we everything went successfully, and it is the first sequence, save this session for future reference
|
|
244
|
-
if (sequence === 1) {
|
|
244
|
+
if (sequence === 1) {
|
|
245
|
+
metadata.save();
|
|
246
|
+
metadata.callback();
|
|
247
|
+
}
|
|
245
248
|
}
|
|
246
249
|
|
|
247
250
|
function delay(): number {
|
|
@@ -37,6 +37,7 @@ export default async function (type: Event, ts: number = null): Promise<void> {
|
|
|
37
37
|
tokens.push(pTarget.id);
|
|
38
38
|
tokens.push(entry.data.x);
|
|
39
39
|
tokens.push(entry.data.y);
|
|
40
|
+
if (entry.data.id !== undefined) { tokens.push(entry.data.id); }
|
|
40
41
|
queue(tokens);
|
|
41
42
|
baseline.track(entry.event, entry.data.x, entry.data.y);
|
|
42
43
|
}
|
|
@@ -58,8 +58,13 @@ function touch(event: Event, root: Node, evt: TouchEvent): void {
|
|
|
58
58
|
x = x && frame ? x + Math.round(frame.offsetLeft) : x;
|
|
59
59
|
y = y && frame ? y + Math.round(frame.offsetTop) : y;
|
|
60
60
|
|
|
61
|
+
// identifier is 0-based, unique for each touch point and resets when all fingers are lifted
|
|
62
|
+
// that is not a part of the spec, but it is how it is implemented in browsers
|
|
63
|
+
// tested in Chromium-based browsers as well as Firefox
|
|
64
|
+
const id = "identifier" in entry ? entry["identifier"] : undefined;
|
|
65
|
+
|
|
61
66
|
// Check for null values before processing this event
|
|
62
|
-
if (x !== null && y !== null) { handler({ time: t, event, data: { target: target(evt), x, y } }); }
|
|
67
|
+
if (x !== null && y !== null) { handler({ time: t, event, data: { target: target(evt), x, y, id } }); }
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
}
|
package/types/data.d.ts
CHANGED
|
@@ -70,7 +70,17 @@ export const enum Event {
|
|
|
70
70
|
Snapshot = 43,
|
|
71
71
|
Animation = 44,
|
|
72
72
|
StyleSheetAdoption = 45,
|
|
73
|
-
StyleSheetUpdate = 46
|
|
73
|
+
StyleSheetUpdate = 46,
|
|
74
|
+
|
|
75
|
+
// Apps specific events
|
|
76
|
+
WebViewDiscover = 100,
|
|
77
|
+
WebViewMutation = 101,
|
|
78
|
+
MutationError = 102,
|
|
79
|
+
FragmentVisibility = 103,
|
|
80
|
+
Keystrokes = 104,
|
|
81
|
+
BackGesture = 105,
|
|
82
|
+
WebViewStatus = 106,
|
|
83
|
+
AppInstallReferrer = 107
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
export const enum Metric {
|
|
@@ -153,7 +163,8 @@ export const enum Dimension {
|
|
|
153
163
|
InitialScrollBottom = 32,
|
|
154
164
|
AncestorOrigins = 33,
|
|
155
165
|
Timezone = 34,
|
|
156
|
-
TimezoneOffset = 35
|
|
166
|
+
TimezoneOffset = 35,
|
|
167
|
+
Consent = 36
|
|
157
168
|
}
|
|
158
169
|
|
|
159
170
|
export const enum Check {
|
|
@@ -237,7 +248,7 @@ export const enum Setting {
|
|
|
237
248
|
MinUploadDelay = 100, // Minimum time before we are ready to flush events to the server
|
|
238
249
|
MaxUploadDelay = 30 * Time.Second, // Do flush out payload once every 30s,
|
|
239
250
|
ExtractLimit = 10000, // Do not extract more than 10000 characters
|
|
240
|
-
ChecksumPrecision =
|
|
251
|
+
ChecksumPrecision = 28, // n-bit integer to represent token hash
|
|
241
252
|
UploadTimeout = 15000 // Timeout in ms for XHR requests
|
|
242
253
|
}
|
|
243
254
|
|