@crelora/mark 0.2.1 → 0.2.2
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/README.md +9 -3
- package/dist/browser.es.js +543 -415
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.umd.js +1 -1
- package/dist/browser.umd.js.map +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.es.js +58 -44
- package/dist/node.es.js.map +1 -1
- package/dist/types/browser/Mark.d.ts +1 -3
- package/dist/types/browser/pageEngagement.d.ts +8 -0
- package/dist/types/browser/pageLifecycle.d.ts +15 -0
- package/dist/types/browser/pageMetrics.d.ts +5 -0
- package/dist/types/browser/pageScrollDepth.d.ts +4 -0
- package/dist/types/core/MarkCore.d.ts +5 -0
- package/dist/types/types.d.ts +9 -0
- package/package.json +1 -1
package/dist/browser.es.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const O = "https://ingest.onelence.com";
|
|
2
|
+
class p extends Error {
|
|
3
3
|
status;
|
|
4
4
|
retryAfterMs;
|
|
5
|
-
constructor(
|
|
6
|
-
super(
|
|
5
|
+
constructor(e, t = {}) {
|
|
6
|
+
super(e), this.name = "TransportError", this.status = t.status, this.retryAfterMs = t.retryAfterMs;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return !(typeof
|
|
9
|
+
function H(r) {
|
|
10
|
+
return !(typeof r != "number" || r < 400 || r >= 500 || r === 408 || r === 429);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
if (!
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
const
|
|
17
|
-
if (Number.isFinite(
|
|
18
|
-
return Math.floor(
|
|
19
|
-
const i = Date.parse(
|
|
12
|
+
function V(r) {
|
|
13
|
+
if (!r) return;
|
|
14
|
+
const e = r.trim();
|
|
15
|
+
if (!e) return;
|
|
16
|
+
const t = Number(e);
|
|
17
|
+
if (Number.isFinite(t) && t >= 0)
|
|
18
|
+
return Math.floor(t * 1e3);
|
|
19
|
+
const i = Date.parse(e);
|
|
20
20
|
if (Number.isFinite(i)) {
|
|
21
21
|
const n = i - Date.now();
|
|
22
22
|
return n > 0 ? n : 0;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
class
|
|
27
|
-
constructor(
|
|
28
|
-
this.transport =
|
|
25
|
+
const z = 5, $ = 300, M = 15e3, j = 2880 * 60 * 1e3;
|
|
26
|
+
class Y {
|
|
27
|
+
constructor(e, t = {}) {
|
|
28
|
+
this.transport = e, this.maxAttempts = t.maxAttempts ?? z, this.baseBackoffMs = t.baseBackoffMs ?? $, this.maxBackoffMs = t.maxBackoffMs ?? M, this.maxItemAgeMs = t.maxItemAgeMs ?? j, this.debug = t.debug ?? !1, this.loadPersisted = t.loadPersisted, this.savePersisted = t.savePersisted, this.onError = t.onError;
|
|
29
29
|
const i = this.loadPersisted?.() ?? [];
|
|
30
30
|
if (i.length > 0) {
|
|
31
31
|
const n = Date.now();
|
|
32
|
-
for (const
|
|
33
|
-
const
|
|
34
|
-
if (n -
|
|
32
|
+
for (const o of i) {
|
|
33
|
+
const a = o.enqueuedAt ?? n;
|
|
34
|
+
if (n - a > this.maxItemAgeMs) {
|
|
35
35
|
this.dropped += 1;
|
|
36
36
|
continue;
|
|
37
37
|
}
|
|
38
|
-
this.queue.push({ ...
|
|
38
|
+
this.queue.push({ ...o, enqueuedAt: a });
|
|
39
39
|
}
|
|
40
40
|
this.persist();
|
|
41
41
|
}
|
|
@@ -53,10 +53,10 @@ class U {
|
|
|
53
53
|
loadPersisted;
|
|
54
54
|
savePersisted;
|
|
55
55
|
onError;
|
|
56
|
-
enqueue(
|
|
56
|
+
enqueue(e, t) {
|
|
57
57
|
this.queue.push({
|
|
58
|
-
path:
|
|
59
|
-
data:
|
|
58
|
+
path: e,
|
|
59
|
+
data: t,
|
|
60
60
|
attempts: 0,
|
|
61
61
|
nextAttemptAt: Date.now(),
|
|
62
62
|
enqueuedAt: Date.now()
|
|
@@ -71,13 +71,13 @@ class U {
|
|
|
71
71
|
*/
|
|
72
72
|
drainViaBeacon() {
|
|
73
73
|
if (this.queue.length === 0) return;
|
|
74
|
-
const
|
|
74
|
+
const e = this.queue.splice(0, this.queue.length);
|
|
75
75
|
this.persist();
|
|
76
|
-
for (const
|
|
77
|
-
const i = { ...
|
|
76
|
+
for (const t of e) {
|
|
77
|
+
const i = { ...t.data };
|
|
78
78
|
delete i.__prefer_beacon;
|
|
79
79
|
try {
|
|
80
|
-
this.transport.send(
|
|
80
|
+
this.transport.send(t.path, i, { preferBeacon: !0 });
|
|
81
81
|
} catch {
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -98,46 +98,46 @@ class U {
|
|
|
98
98
|
}
|
|
99
99
|
evictExpired() {
|
|
100
100
|
if (this.queue.length === 0) return;
|
|
101
|
-
const
|
|
101
|
+
const t = Date.now() - this.maxItemAgeMs;
|
|
102
102
|
let i = 0;
|
|
103
103
|
for (let n = this.queue.length - 1; n >= 0; n -= 1)
|
|
104
|
-
this.queue[n].enqueuedAt <=
|
|
104
|
+
this.queue[n].enqueuedAt <= t && (this.queue.splice(n, 1), this.dropped += 1, i += 1);
|
|
105
105
|
i > 0 && this.persist();
|
|
106
106
|
}
|
|
107
|
-
async process(
|
|
107
|
+
async process(e = !1) {
|
|
108
108
|
if (!this.flushing) {
|
|
109
109
|
this.flushing = !0;
|
|
110
110
|
try {
|
|
111
111
|
for (this.evictExpired(); this.queue.length > 0; ) {
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
112
|
+
const t = this.queue[0];
|
|
113
|
+
if (!e && t.nextAttemptAt > Date.now())
|
|
114
114
|
break;
|
|
115
115
|
try {
|
|
116
|
-
const i = { ...
|
|
117
|
-
delete i.__prefer_beacon, await this.transport.send(
|
|
116
|
+
const i = { ...t.data }, n = i.__prefer_beacon === !0;
|
|
117
|
+
delete i.__prefer_beacon, await this.transport.send(t.path, i, { preferBeacon: n }), this.queue.shift(), this.sent += 1, this.persist();
|
|
118
118
|
} catch (i) {
|
|
119
|
-
this.failed += 1, this.onError?.(i,
|
|
120
|
-
const n = i instanceof
|
|
121
|
-
if (
|
|
122
|
-
this.queue.shift(), this.dropped += 1, this.persist(), this.debug && console.error("[Mark] Dropping event after non-retriable status", n,
|
|
119
|
+
this.failed += 1, this.onError?.(i, t.data);
|
|
120
|
+
const n = i instanceof p ? i.status : void 0;
|
|
121
|
+
if (H(n)) {
|
|
122
|
+
this.queue.shift(), this.dropped += 1, this.persist(), this.debug && console.error("[Mark] Dropping event after non-retriable status", n, t.path);
|
|
123
123
|
continue;
|
|
124
124
|
}
|
|
125
|
-
if (
|
|
126
|
-
this.queue.shift(), this.dropped += 1, this.persist(), this.debug && console.error("[Mark] Dropping event after max retries",
|
|
125
|
+
if (t.attempts += 1, t.attempts >= this.maxAttempts) {
|
|
126
|
+
this.queue.shift(), this.dropped += 1, this.persist(), this.debug && console.error("[Mark] Dropping event after max retries", t.path, i);
|
|
127
127
|
continue;
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
let
|
|
131
|
-
if (typeof
|
|
132
|
-
|
|
129
|
+
const o = i instanceof p ? i.retryAfterMs : void 0;
|
|
130
|
+
let a;
|
|
131
|
+
if (typeof o == "number")
|
|
132
|
+
a = Math.min(this.maxBackoffMs, Math.max(0, o));
|
|
133
133
|
else {
|
|
134
|
-
const
|
|
135
|
-
|
|
134
|
+
const c = Math.random() * this.baseBackoffMs;
|
|
135
|
+
a = Math.min(
|
|
136
136
|
this.maxBackoffMs,
|
|
137
|
-
this.baseBackoffMs * 2 ** (
|
|
137
|
+
this.baseBackoffMs * 2 ** (t.attempts - 1) + c
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
t.nextAttemptAt = Date.now() + a, this.persist();
|
|
141
141
|
break;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -147,7 +147,7 @@ class U {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
const
|
|
150
|
+
const Q = /* @__PURE__ */ new Set(["event_name", "user_id", "consent_state", "source", "is_conversion"]), W = /* @__PURE__ */ new Set([
|
|
151
151
|
"user_id",
|
|
152
152
|
"visitor_id",
|
|
153
153
|
"click_id",
|
|
@@ -156,13 +156,13 @@ const k = /* @__PURE__ */ new Set(["event_name", "user_id", "consent_state", "so
|
|
|
156
156
|
"consent_state",
|
|
157
157
|
"source"
|
|
158
158
|
]);
|
|
159
|
-
class
|
|
160
|
-
constructor(
|
|
161
|
-
this.deps =
|
|
162
|
-
endpoint:
|
|
163
|
-
...
|
|
164
|
-
include_page_context:
|
|
165
|
-
}, this.consentRequirement =
|
|
159
|
+
class G {
|
|
160
|
+
constructor(e, t) {
|
|
161
|
+
this.deps = t, this.validateConfig(e), this.config = {
|
|
162
|
+
endpoint: e.endpoint ?? O,
|
|
163
|
+
...e,
|
|
164
|
+
include_page_context: e.include_page_context ?? !0
|
|
165
|
+
}, this.consentRequirement = e.require_consent ?? !1, this.siteId = e.site_id, this.siteHost = e.site_host, this.sessionTimeoutMs = e.session_timeout_ms ?? 1800 * 1e3, this.queue = new Y(this.deps.transport, {
|
|
166
166
|
debug: this.config.debug,
|
|
167
167
|
loadPersisted: () => this.deps.storage.getOutbox?.() ?? [],
|
|
168
168
|
savePersisted: (i) => this.deps.storage.setOutbox?.(i),
|
|
@@ -194,32 +194,32 @@ class L {
|
|
|
194
194
|
kickQueue() {
|
|
195
195
|
this.queue.flush();
|
|
196
196
|
}
|
|
197
|
-
track(
|
|
198
|
-
return this.trackInternal(
|
|
197
|
+
track(e, t = {}) {
|
|
198
|
+
return this.trackInternal(e, t, !1);
|
|
199
199
|
}
|
|
200
|
-
trackInternal(
|
|
201
|
-
if (!
|
|
200
|
+
trackInternal(e, t = {}, i = !1, n) {
|
|
201
|
+
if (!e)
|
|
202
202
|
return this.config.debug && console.warn("[Mark] track called without event name"), !1;
|
|
203
203
|
if (!this.hasConsent() || this.isDntBlocked())
|
|
204
204
|
return this.config.debug && console.warn("[Mark] Tracking blocked due to consent requirement."), !1;
|
|
205
205
|
if (!i && !this.shouldSampleTrack())
|
|
206
206
|
return !0;
|
|
207
|
-
const
|
|
208
|
-
"query" in
|
|
209
|
-
const
|
|
210
|
-
event_name:
|
|
207
|
+
const o = this.sanitizeTrackData(t), a = { ...o };
|
|
208
|
+
"query" in a && delete a.query, "site_id" in a && delete a.site_id, "site_host" in a && delete a.site_host;
|
|
209
|
+
const c = {
|
|
210
|
+
event_name: e,
|
|
211
211
|
message_id: this.createMessageId(),
|
|
212
|
-
...this.getIdentityFields(
|
|
213
|
-
...
|
|
212
|
+
...this.getIdentityFields(o),
|
|
213
|
+
...a
|
|
214
214
|
};
|
|
215
|
-
i && (
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
const d = this.config.before_send ? this.config.before_send(
|
|
219
|
-
return d ? (this.ensureSession(), this.config.batching?.enabled && !i && !n?.preferBeacon ? (this.enqueueBatch(d), !0) : (this.queue.enqueue("/event", { ...d, __prefer_beacon: n?.preferBeacon === !0 }), !0)) : !0;
|
|
220
|
-
}
|
|
221
|
-
identify(
|
|
222
|
-
if (!
|
|
215
|
+
i && (c.is_conversion = !0);
|
|
216
|
+
const f = o.site_id ?? this.siteId, l = o.site_host ?? this.siteHost;
|
|
217
|
+
f && (c.site_id = f), l && (c.site_host = l), this.config.include_page_context && typeof window < "u" && (this.applyPageContext(c), !l && c.site && (c.site_host = c.site)), this.applyInternalFlag(c, o.is_internal);
|
|
218
|
+
const d = this.config.before_send ? this.config.before_send(c) : c;
|
|
219
|
+
return d ? (this.ensureSession(), this.applySessionFields(d), this.config.batching?.enabled && !i && !n?.preferBeacon ? (this.enqueueBatch(d), !0) : (this.queue.enqueue("/event", { ...d, __prefer_beacon: n?.preferBeacon === !0 }), !0)) : !0;
|
|
220
|
+
}
|
|
221
|
+
identify(e, t = {}) {
|
|
222
|
+
if (!e) {
|
|
223
223
|
this.config.debug && console.warn("[Mark] identify called without userId");
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
@@ -227,22 +227,22 @@ class L {
|
|
|
227
227
|
this.config.debug && console.warn("[Mark] Identify blocked due to consent requirement.");
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
this.deps.storage.update({ user_id:
|
|
230
|
+
this.deps.storage.update({ user_id: e });
|
|
231
231
|
const i = {
|
|
232
|
-
user_id:
|
|
232
|
+
user_id: e,
|
|
233
233
|
message_id: this.createMessageId(),
|
|
234
|
-
...this.sanitizeIdentifyTraits(
|
|
234
|
+
...this.sanitizeIdentifyTraits(t),
|
|
235
235
|
...this.getIdentityFields()
|
|
236
236
|
};
|
|
237
237
|
this.siteId && (i.site_id = this.siteId), this.siteHost && (i.site_host = this.siteHost), this.applyInternalFlag(i);
|
|
238
238
|
const n = this.config.before_send ? this.config.before_send(i) : i;
|
|
239
|
-
n && this.queue.enqueue("/identify", n);
|
|
239
|
+
n && (this.ensureSession(), this.applySessionFields(n), this.queue.enqueue("/identify", n));
|
|
240
240
|
}
|
|
241
|
-
conversion(
|
|
242
|
-
return this.trackInternal(
|
|
241
|
+
conversion(e, t = {}) {
|
|
242
|
+
return this.trackInternal(e, t, !0);
|
|
243
243
|
}
|
|
244
|
-
trackWithOptions(
|
|
245
|
-
return this.trackInternal(
|
|
244
|
+
trackWithOptions(e, t = {}, i) {
|
|
245
|
+
return this.trackInternal(e, t, !1, i);
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
248
|
* Returns the current visitor ID from storage, if any.
|
|
@@ -251,12 +251,12 @@ class L {
|
|
|
251
251
|
getVisitorId() {
|
|
252
252
|
return this.deps.storage.getVisitorId();
|
|
253
253
|
}
|
|
254
|
-
setConsent(
|
|
255
|
-
const
|
|
256
|
-
this.deps.storage.setConsentStatus(
|
|
254
|
+
setConsent(e) {
|
|
255
|
+
const t = this.deps.storage.getConsentStatus();
|
|
256
|
+
this.deps.storage.setConsentStatus(e), e === "denied" ? (this.deps.storage.clearAttribution?.(), this.deps.storage.clearCookieVisitorId?.(), this.deps.storage.setInternal?.(!1)) : e === "granted" && t === "denied" && this.config.rotate_visitor_on_consent_change && this.deps.storage.rotateVisitorId?.();
|
|
257
257
|
const i = {
|
|
258
258
|
visitor_id: this.deps.storage.getVisitorId(),
|
|
259
|
-
consent_state:
|
|
259
|
+
consent_state: e,
|
|
260
260
|
source: "sdk",
|
|
261
261
|
message_id: this.createMessageId()
|
|
262
262
|
};
|
|
@@ -286,8 +286,8 @@ class L {
|
|
|
286
286
|
* it survives reloads, and is cleared by `reset()` and by
|
|
287
287
|
* `setConsent('denied')`.
|
|
288
288
|
*/
|
|
289
|
-
setInternal(
|
|
290
|
-
this.deps.storage.setInternal?.(!!
|
|
289
|
+
setInternal(e) {
|
|
290
|
+
this.deps.storage.setInternal?.(!!e);
|
|
291
291
|
}
|
|
292
292
|
/**
|
|
293
293
|
* Returns the currently persisted internal-traffic flag, if any.
|
|
@@ -309,59 +309,73 @@ class L {
|
|
|
309
309
|
* Explicit `is_internal: false` on a single event wins over the visitor flag
|
|
310
310
|
* so individual calls can opt out.
|
|
311
311
|
*/
|
|
312
|
-
applyInternalFlag(
|
|
313
|
-
if (
|
|
314
|
-
delete
|
|
312
|
+
applyInternalFlag(e, t) {
|
|
313
|
+
if (t === !1) {
|
|
314
|
+
delete e.is_internal;
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
const i = this.deps.storage.getInternal?.() === !0;
|
|
318
|
-
|
|
318
|
+
t === !0 || i ? e.is_internal = !0 : delete e.is_internal;
|
|
319
319
|
}
|
|
320
|
-
getIdentityFields(
|
|
321
|
-
const
|
|
322
|
-
|
|
320
|
+
getIdentityFields(e) {
|
|
321
|
+
const t = e?.visitor_id ?? this.deps.storage.getVisitorId(), i = e?.user_id ?? this.deps.storage.getUserId?.(), n = e?.click_id ?? this.deps.storage.getLastClickId(), o = e?.campaign_id ?? this.deps.storage.getCampaignId(), a = e?.session_id ?? this.deps.storage.getSessionId?.(), c = this.deps.storage.getQueryParams() ?? {}, f = e?.query ?? {}, l = { ...c, ...f }, d = {};
|
|
322
|
+
t && (d.visitor_id = t), i && (d.user_id = i), n && (d.click_id = n), o && (d.campaign_id = o), a && (d.session_id = a);
|
|
323
|
+
const h = this.deps.storage.getSessionStartedAt?.();
|
|
324
|
+
return a && h && (d.session_started_at = h, d.session_elapsed_ms = Date.now() - Date.parse(h)), Object.keys(l).length > 0 && (d.query = l), d;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Patches session fields after ensureSession when the first event in a session was built
|
|
328
|
+
* before rotation created an id. Rotation events keep the previous session_id from identity.
|
|
329
|
+
*/
|
|
330
|
+
applySessionFields(e) {
|
|
331
|
+
if (!e.session_id) {
|
|
332
|
+
const i = this.deps.storage.getSessionId?.(), n = this.deps.storage.getSessionStartedAt?.();
|
|
333
|
+
i && (e.session_id = i), n && (e.session_started_at = n);
|
|
334
|
+
}
|
|
335
|
+
const t = e.session_started_at;
|
|
336
|
+
e.session_id && typeof t == "string" && (e.session_elapsed_ms = Date.now() - Date.parse(t));
|
|
323
337
|
}
|
|
324
338
|
hasConsent() {
|
|
325
339
|
if (this.config.consent_source?.type === "tcf" && typeof window < "u" && !this.tcfCachedAllowed)
|
|
326
340
|
return !1;
|
|
327
341
|
if (!this.consentRequirement)
|
|
328
342
|
return !0;
|
|
329
|
-
const
|
|
330
|
-
return this.consentRequirement === "auto",
|
|
343
|
+
const t = this.deps.storage.getConsentStatus();
|
|
344
|
+
return this.consentRequirement === "auto", t === "granted";
|
|
331
345
|
}
|
|
332
|
-
sanitizeTrackData(
|
|
333
|
-
const
|
|
334
|
-
for (const [i, n] of Object.entries(
|
|
335
|
-
|
|
336
|
-
return
|
|
346
|
+
sanitizeTrackData(e) {
|
|
347
|
+
const t = {};
|
|
348
|
+
for (const [i, n] of Object.entries(e))
|
|
349
|
+
Q.has(i) || (t[i] = n);
|
|
350
|
+
return t;
|
|
337
351
|
}
|
|
338
|
-
sanitizeIdentifyTraits(
|
|
339
|
-
const
|
|
340
|
-
for (const [i, n] of Object.entries(
|
|
341
|
-
|
|
342
|
-
return
|
|
352
|
+
sanitizeIdentifyTraits(e) {
|
|
353
|
+
const t = {};
|
|
354
|
+
for (const [i, n] of Object.entries(e))
|
|
355
|
+
W.has(i) || (t[i] = n);
|
|
356
|
+
return t;
|
|
343
357
|
}
|
|
344
|
-
validateConfig(
|
|
345
|
-
if (!
|
|
358
|
+
validateConfig(e) {
|
|
359
|
+
if (!e.key || !e.key.trim())
|
|
346
360
|
throw new Error("[Mark] `key` must be a non-empty string.");
|
|
347
|
-
if (
|
|
361
|
+
if (e.endpoint)
|
|
348
362
|
try {
|
|
349
|
-
new URL(
|
|
363
|
+
new URL(e.endpoint);
|
|
350
364
|
} catch {
|
|
351
365
|
throw new Error("[Mark] `endpoint` must be a valid absolute URL.");
|
|
352
366
|
}
|
|
353
|
-
if (typeof
|
|
367
|
+
if (typeof e.site_id == "string" && !e.site_id.trim())
|
|
354
368
|
throw new Error("[Mark] `site_id` cannot be an empty string.");
|
|
355
|
-
if (typeof
|
|
369
|
+
if (typeof e.site_host == "string" && !e.site_host.trim())
|
|
356
370
|
throw new Error("[Mark] `site_host` cannot be an empty string.");
|
|
357
371
|
}
|
|
358
|
-
applyPageContext(
|
|
359
|
-
typeof document > "u" || (
|
|
372
|
+
applyPageContext(e) {
|
|
373
|
+
typeof document > "u" || (e.site || (e.site = window.location.host), e.page || (e.page = window.location.pathname), e.title || (e.title = document.title), !e.referrer && document.referrer && (e.referrer = this.scrubReferrer(document.referrer)));
|
|
360
374
|
}
|
|
361
|
-
enqueueBatch(
|
|
362
|
-
this.batchedEvents.push(
|
|
363
|
-
const
|
|
364
|
-
if (this.batchedEvents.length >=
|
|
375
|
+
enqueueBatch(e) {
|
|
376
|
+
this.batchedEvents.push(e);
|
|
377
|
+
const t = this.config.batching?.max_size ?? 20;
|
|
378
|
+
if (this.batchedEvents.length >= t) {
|
|
365
379
|
this.flushBatch();
|
|
366
380
|
return;
|
|
367
381
|
}
|
|
@@ -374,27 +388,27 @@ class L {
|
|
|
374
388
|
}
|
|
375
389
|
flushBatch() {
|
|
376
390
|
if (this.batchedEvents.length === 0) return;
|
|
377
|
-
const
|
|
378
|
-
this.queue.enqueue(
|
|
391
|
+
const e = this.config.batching?.endpoint_path ?? "/events", t = this.batchedEvents.splice(0, this.batchedEvents.length);
|
|
392
|
+
this.queue.enqueue(e, { events: t, message_id: this.createMessageId() });
|
|
379
393
|
}
|
|
380
394
|
createMessageId() {
|
|
381
395
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `msg_${Date.now()}_${Math.random().toString(16).slice(2)}`;
|
|
382
396
|
}
|
|
383
397
|
ensureSession() {
|
|
384
|
-
const
|
|
385
|
-
if (!
|
|
386
|
-
const
|
|
398
|
+
const e = Date.now(), t = this.deps.storage.getSessionId?.(), i = this.deps.storage.getLastActivityAt?.(), n = i ? Date.parse(i) : 0;
|
|
399
|
+
if (!t || !n || e - n >= this.sessionTimeoutMs || this.crossedUtcDay(n, e)) {
|
|
400
|
+
const a = this.createMessageId(), c = new Date(e).toISOString();
|
|
387
401
|
this.deps.storage.update({
|
|
388
|
-
session_id:
|
|
389
|
-
session_started_at:
|
|
390
|
-
last_activity_at:
|
|
402
|
+
session_id: a,
|
|
403
|
+
session_started_at: c,
|
|
404
|
+
last_activity_at: c
|
|
391
405
|
});
|
|
392
406
|
return;
|
|
393
407
|
}
|
|
394
|
-
this.deps.storage.update({ last_activity_at: new Date(
|
|
408
|
+
this.deps.storage.update({ last_activity_at: new Date(e).toISOString() });
|
|
395
409
|
}
|
|
396
|
-
crossedUtcDay(
|
|
397
|
-
const i = new Date(
|
|
410
|
+
crossedUtcDay(e, t) {
|
|
411
|
+
const i = new Date(e), n = new Date(t);
|
|
398
412
|
return i.getUTCFullYear() !== n.getUTCFullYear() || i.getUTCMonth() !== n.getUTCMonth() || i.getUTCDate() !== n.getUTCDate();
|
|
399
413
|
}
|
|
400
414
|
shouldSampleTrack() {
|
|
@@ -403,17 +417,17 @@ class L {
|
|
|
403
417
|
isDntBlocked() {
|
|
404
418
|
if (!this.config.honor_dnt || typeof navigator > "u")
|
|
405
419
|
return !1;
|
|
406
|
-
const
|
|
407
|
-
return
|
|
420
|
+
const e = navigator.doNotTrack, t = navigator.globalPrivacyControl;
|
|
421
|
+
return e === "1" || t === !0;
|
|
408
422
|
}
|
|
409
|
-
scrubReferrer(
|
|
423
|
+
scrubReferrer(e) {
|
|
410
424
|
try {
|
|
411
|
-
const
|
|
412
|
-
if (typeof window > "u") return
|
|
425
|
+
const t = new URL(e);
|
|
426
|
+
if (typeof window > "u") return e;
|
|
413
427
|
const i = new URL(window.location.href);
|
|
414
|
-
return
|
|
428
|
+
return t.origin !== i.origin ? (t.search = "", t.toString()) : e;
|
|
415
429
|
} catch {
|
|
416
|
-
return
|
|
430
|
+
return e;
|
|
417
431
|
}
|
|
418
432
|
}
|
|
419
433
|
warnMisconfiguredSiteHost() {
|
|
@@ -429,26 +443,26 @@ class L {
|
|
|
429
443
|
* poll briefly (CMPs commonly load asynchronously) and give up after ~2s.
|
|
430
444
|
*/
|
|
431
445
|
subscribeTcf() {
|
|
432
|
-
const
|
|
433
|
-
if (
|
|
434
|
-
const
|
|
446
|
+
const e = this.config.consent_source;
|
|
447
|
+
if (e?.type !== "tcf" || typeof window > "u") return;
|
|
448
|
+
const t = e.purposes, i = (n) => {
|
|
435
449
|
try {
|
|
436
|
-
const
|
|
437
|
-
if (typeof
|
|
450
|
+
const o = window;
|
|
451
|
+
if (typeof o.__tcfapi != "function") {
|
|
438
452
|
n > 0 && setTimeout(() => i(n - 1), 200);
|
|
439
453
|
return;
|
|
440
454
|
}
|
|
441
|
-
|
|
442
|
-
if (!
|
|
455
|
+
o.__tcfapi("addEventListener", 2, (a, c) => {
|
|
456
|
+
if (!c || !a) {
|
|
443
457
|
this.tcfCachedAllowed = !1;
|
|
444
458
|
return;
|
|
445
459
|
}
|
|
446
|
-
if (
|
|
460
|
+
if (a.gdprApplies === !1) {
|
|
447
461
|
this.tcfCachedAllowed = !0;
|
|
448
462
|
return;
|
|
449
463
|
}
|
|
450
|
-
const
|
|
451
|
-
this.tcfCachedAllowed =
|
|
464
|
+
const f = a.purpose?.consents ?? {};
|
|
465
|
+
this.tcfCachedAllowed = t.every((l) => f[String(l)] === !0);
|
|
452
466
|
});
|
|
453
467
|
} catch {
|
|
454
468
|
this.tcfCachedAllowed = !1;
|
|
@@ -457,15 +471,15 @@ class L {
|
|
|
457
471
|
i(10);
|
|
458
472
|
}
|
|
459
473
|
}
|
|
460
|
-
class
|
|
474
|
+
class J {
|
|
461
475
|
config;
|
|
462
476
|
endpoint;
|
|
463
477
|
pending = /* @__PURE__ */ new Set();
|
|
464
|
-
constructor(
|
|
465
|
-
this.config =
|
|
478
|
+
constructor(e) {
|
|
479
|
+
this.config = e, this.endpoint = e.endpoint ?? O;
|
|
466
480
|
}
|
|
467
|
-
async send(
|
|
468
|
-
const n = this.sendInternal(
|
|
481
|
+
async send(e, t, i) {
|
|
482
|
+
const n = this.sendInternal(e, t, i);
|
|
469
483
|
this.pending.add(n);
|
|
470
484
|
try {
|
|
471
485
|
await n;
|
|
@@ -476,71 +490,71 @@ class R {
|
|
|
476
490
|
async flush() {
|
|
477
491
|
this.pending.size !== 0 && await Promise.allSettled(Array.from(this.pending));
|
|
478
492
|
}
|
|
479
|
-
async sendInternal(
|
|
480
|
-
const n = this.joinUrl(this.endpoint,
|
|
493
|
+
async sendInternal(e, t, i) {
|
|
494
|
+
const n = this.joinUrl(this.endpoint, e), o = this.config.key, a = {
|
|
481
495
|
"Content-Type": "application/json",
|
|
482
|
-
[
|
|
496
|
+
[o.startsWith("sk_") ? "x-secret-key" : "x-publishable-key"]: o
|
|
483
497
|
};
|
|
484
|
-
this.config.debug && console.log("[Mark] Sending", n,
|
|
485
|
-
const
|
|
498
|
+
this.config.debug && console.log("[Mark] Sending", n, t);
|
|
499
|
+
const c = JSON.stringify(t);
|
|
486
500
|
if (i?.preferBeacon && typeof navigator < "u" && typeof navigator.sendBeacon == "function") {
|
|
487
|
-
const
|
|
488
|
-
if (navigator.sendBeacon(n,
|
|
501
|
+
const u = new Blob([c], { type: "application/json" });
|
|
502
|
+
if (navigator.sendBeacon(n, u))
|
|
489
503
|
return;
|
|
490
504
|
}
|
|
491
505
|
if (typeof fetch != "function")
|
|
492
|
-
throw this.config.debug && console.error("[Mark] Global fetch is not available in this runtime."), new
|
|
493
|
-
const
|
|
506
|
+
throw this.config.debug && console.error("[Mark] Global fetch is not available in this runtime."), new p("[Mark] Global fetch is not available in this runtime.");
|
|
507
|
+
const f = this.config.request_timeout_ms ?? 1e4, l = new AbortController();
|
|
494
508
|
let d = !1;
|
|
495
|
-
const
|
|
509
|
+
const h = setTimeout(() => {
|
|
496
510
|
d = !0, l.abort();
|
|
497
|
-
},
|
|
511
|
+
}, f);
|
|
498
512
|
try {
|
|
499
|
-
const
|
|
513
|
+
const u = await fetch(n, {
|
|
500
514
|
method: "POST",
|
|
501
|
-
headers:
|
|
502
|
-
body:
|
|
515
|
+
headers: a,
|
|
516
|
+
body: c,
|
|
503
517
|
keepalive: !0,
|
|
504
518
|
signal: l.signal
|
|
505
519
|
});
|
|
506
|
-
if (!
|
|
507
|
-
const g = await this.readErrorSnippet(
|
|
520
|
+
if (!u.ok) {
|
|
521
|
+
const g = await this.readErrorSnippet(u), P = V(u.headers.get("Retry-After"));
|
|
508
522
|
throw this.config.debug && console.error("[Mark] Request rejected", {
|
|
509
523
|
url: n,
|
|
510
|
-
status:
|
|
511
|
-
statusText:
|
|
524
|
+
status: u.status,
|
|
525
|
+
statusText: u.statusText,
|
|
512
526
|
body: g,
|
|
513
|
-
retryAfterMs:
|
|
514
|
-
}), new
|
|
515
|
-
`[Mark] Request rejected with status ${
|
|
516
|
-
{ status:
|
|
527
|
+
retryAfterMs: P
|
|
528
|
+
}), new p(
|
|
529
|
+
`[Mark] Request rejected with status ${u.status}: ${g}`,
|
|
530
|
+
{ status: u.status, retryAfterMs: P }
|
|
517
531
|
);
|
|
518
532
|
}
|
|
519
|
-
} catch (
|
|
520
|
-
if (this.config.debug && console.error("[Mark] Failed to send", n,
|
|
521
|
-
throw
|
|
533
|
+
} catch (u) {
|
|
534
|
+
if (this.config.debug && console.error("[Mark] Failed to send", n, u), u instanceof p)
|
|
535
|
+
throw u;
|
|
522
536
|
if (d)
|
|
523
|
-
throw new
|
|
524
|
-
const g =
|
|
525
|
-
throw new
|
|
537
|
+
throw new p(`[Mark] Request timed out after ${f}ms`, { status: 408 });
|
|
538
|
+
const g = u instanceof Error ? u.message : String(u);
|
|
539
|
+
throw new p(`[Mark] Network error: ${g}`);
|
|
526
540
|
} finally {
|
|
527
|
-
clearTimeout(
|
|
541
|
+
clearTimeout(h);
|
|
528
542
|
}
|
|
529
543
|
}
|
|
530
|
-
joinUrl(
|
|
531
|
-
const i =
|
|
544
|
+
joinUrl(e, t) {
|
|
545
|
+
const i = e.replace(/\/+$/, ""), n = t.replace(/^\/+/, "");
|
|
532
546
|
return `${i}/${n}`;
|
|
533
547
|
}
|
|
534
|
-
async readErrorSnippet(
|
|
548
|
+
async readErrorSnippet(e) {
|
|
535
549
|
try {
|
|
536
|
-
return (await
|
|
550
|
+
return (await e.text()).slice(0, 300);
|
|
537
551
|
} catch {
|
|
538
552
|
return "";
|
|
539
553
|
}
|
|
540
554
|
}
|
|
541
555
|
}
|
|
542
|
-
const
|
|
543
|
-
class
|
|
556
|
+
const X = "crelora_mark_data", Z = "crelora_mark_outbox", T = "crelora_mark_vid";
|
|
557
|
+
class ee {
|
|
544
558
|
data;
|
|
545
559
|
storageKey;
|
|
546
560
|
outboxKey;
|
|
@@ -548,8 +562,8 @@ class H {
|
|
|
548
562
|
bridgeFrame;
|
|
549
563
|
bridgeReady = !1;
|
|
550
564
|
bridgeOrigin;
|
|
551
|
-
constructor(
|
|
552
|
-
if (this.options =
|
|
565
|
+
constructor(e) {
|
|
566
|
+
if (this.options = e ?? {}, this.storageKey = this.options.storageKey ?? X, this.outboxKey = this.options.outboxKey ?? Z, typeof window > "u") {
|
|
553
567
|
this.data = {};
|
|
554
568
|
return;
|
|
555
569
|
}
|
|
@@ -585,14 +599,14 @@ class H {
|
|
|
585
599
|
getInternal() {
|
|
586
600
|
return this.data.is_internal;
|
|
587
601
|
}
|
|
588
|
-
setInternal(
|
|
589
|
-
|
|
602
|
+
setInternal(e) {
|
|
603
|
+
e ? this.update({ is_internal: !0 }) : this.update({ is_internal: void 0 });
|
|
590
604
|
}
|
|
591
|
-
update(
|
|
592
|
-
this.data = { ...this.data, ...
|
|
605
|
+
update(e) {
|
|
606
|
+
this.data = { ...this.data, ...e }, this.save();
|
|
593
607
|
}
|
|
594
|
-
setConsentStatus(
|
|
595
|
-
this.data.consent_status =
|
|
608
|
+
setConsentStatus(e) {
|
|
609
|
+
this.data.consent_status = e, this.save();
|
|
596
610
|
}
|
|
597
611
|
clearAttribution() {
|
|
598
612
|
this.update({
|
|
@@ -602,7 +616,7 @@ class H {
|
|
|
602
616
|
});
|
|
603
617
|
}
|
|
604
618
|
clearCookieVisitorId() {
|
|
605
|
-
this.setCookie(
|
|
619
|
+
this.setCookie(T, "", -1);
|
|
606
620
|
}
|
|
607
621
|
rotateVisitorId() {
|
|
608
622
|
this.update({ visitor_id: this.generateUUID() });
|
|
@@ -610,18 +624,18 @@ class H {
|
|
|
610
624
|
getOutbox() {
|
|
611
625
|
if (typeof window > "u") return [];
|
|
612
626
|
try {
|
|
613
|
-
const
|
|
614
|
-
if (!
|
|
615
|
-
const
|
|
616
|
-
return Array.isArray(
|
|
627
|
+
const e = localStorage.getItem(this.outboxKey);
|
|
628
|
+
if (!e) return [];
|
|
629
|
+
const t = JSON.parse(e);
|
|
630
|
+
return Array.isArray(t) ? t : [];
|
|
617
631
|
} catch {
|
|
618
632
|
return [];
|
|
619
633
|
}
|
|
620
634
|
}
|
|
621
|
-
setOutbox(
|
|
635
|
+
setOutbox(e) {
|
|
622
636
|
if (!(typeof window > "u"))
|
|
623
637
|
try {
|
|
624
|
-
localStorage.setItem(this.outboxKey, JSON.stringify(
|
|
638
|
+
localStorage.setItem(this.outboxKey, JSON.stringify(e.slice(-200)));
|
|
625
639
|
} catch {
|
|
626
640
|
}
|
|
627
641
|
}
|
|
@@ -629,13 +643,13 @@ class H {
|
|
|
629
643
|
if (typeof window > "u")
|
|
630
644
|
return {};
|
|
631
645
|
try {
|
|
632
|
-
const
|
|
633
|
-
if (
|
|
634
|
-
return JSON.parse(
|
|
646
|
+
const t = localStorage.getItem(this.storageKey);
|
|
647
|
+
if (t)
|
|
648
|
+
return JSON.parse(t);
|
|
635
649
|
} catch {
|
|
636
650
|
}
|
|
637
|
-
const
|
|
638
|
-
return
|
|
651
|
+
const e = this.getCookie(T);
|
|
652
|
+
return e ? { visitor_id: e } : {};
|
|
639
653
|
}
|
|
640
654
|
save() {
|
|
641
655
|
if (!(typeof window > "u")) {
|
|
@@ -643,27 +657,27 @@ class H {
|
|
|
643
657
|
localStorage.setItem(this.storageKey, JSON.stringify(this.data));
|
|
644
658
|
} catch {
|
|
645
659
|
}
|
|
646
|
-
this.data.visitor_id && this.isCookieEnabled() && (this.setCookie(
|
|
660
|
+
this.data.visitor_id && this.isCookieEnabled() && (this.setCookie(T, this.data.visitor_id, 365), this.options.bridge?.url && this.bridgeReady && this.postBridgeMessage({
|
|
647
661
|
type: "MARK_SYNC_UPDATE",
|
|
648
662
|
visitorId: this.data.visitor_id
|
|
649
663
|
}));
|
|
650
664
|
}
|
|
651
665
|
}
|
|
652
|
-
getCookie(
|
|
666
|
+
getCookie(e) {
|
|
653
667
|
if (typeof document > "u")
|
|
654
668
|
return null;
|
|
655
669
|
try {
|
|
656
|
-
const
|
|
657
|
-
if (
|
|
670
|
+
const t = document.cookie.match(new RegExp(`(^| )${e}=([^;]+)`));
|
|
671
|
+
if (t) return t[2];
|
|
658
672
|
} catch {
|
|
659
673
|
}
|
|
660
674
|
return null;
|
|
661
675
|
}
|
|
662
|
-
setCookie(
|
|
676
|
+
setCookie(e, t, i) {
|
|
663
677
|
if (!(typeof document > "u"))
|
|
664
678
|
try {
|
|
665
|
-
const n = new Date(Date.now() + i * 24 * 60 * 60 * 1e3),
|
|
666
|
-
document.cookie = `${
|
|
679
|
+
const n = new Date(Date.now() + i * 24 * 60 * 60 * 1e3), o = this.options.cookie_domain ? `;domain=${this.options.cookie_domain}` : "";
|
|
680
|
+
document.cookie = `${e}=${t};expires=${n.toUTCString()};path=/;SameSite=Lax${o}`;
|
|
667
681
|
} catch {
|
|
668
682
|
}
|
|
669
683
|
}
|
|
@@ -671,75 +685,75 @@ class H {
|
|
|
671
685
|
if (typeof crypto < "u" && crypto.randomUUID)
|
|
672
686
|
return crypto.randomUUID();
|
|
673
687
|
if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") {
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
const
|
|
677
|
-
return `${
|
|
688
|
+
const e = crypto.getRandomValues(new Uint8Array(16));
|
|
689
|
+
e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
|
|
690
|
+
const t = Array.from(e, (i) => i.toString(16).padStart(2, "0")).join("");
|
|
691
|
+
return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
|
|
678
692
|
}
|
|
679
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (
|
|
680
|
-
const
|
|
681
|
-
return (
|
|
693
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
694
|
+
const t = (Date.now() + Math.random() * 16) % 16 | 0;
|
|
695
|
+
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
682
696
|
});
|
|
683
697
|
}
|
|
684
698
|
isCookieEnabled() {
|
|
685
699
|
return this.options.mode ? this.options.mode === "single" || this.options.mode === "subdomain" : !0;
|
|
686
700
|
}
|
|
687
|
-
setupBridge(
|
|
701
|
+
setupBridge(e) {
|
|
688
702
|
if (typeof document > "u") return;
|
|
689
|
-
let
|
|
703
|
+
let t;
|
|
690
704
|
try {
|
|
691
|
-
|
|
705
|
+
t = new URL(e.url, window.location.href);
|
|
692
706
|
} catch {
|
|
693
707
|
return;
|
|
694
708
|
}
|
|
695
|
-
this.bridgeOrigin =
|
|
696
|
-
const i =
|
|
709
|
+
this.bridgeOrigin = t.origin, this.bridgeFrame = document.createElement("iframe"), this.bridgeFrame.style.display = "none", this.bridgeFrame.setAttribute("aria-hidden", "true"), this.bridgeFrame.src = t.toString();
|
|
710
|
+
const i = e.timeout_ms ?? 3e3, n = setTimeout(() => {
|
|
697
711
|
window.removeEventListener("message", this.handleBridgeMessage);
|
|
698
712
|
}, i);
|
|
699
713
|
window.addEventListener("message", this.handleBridgeMessage);
|
|
700
|
-
const
|
|
714
|
+
const o = () => {
|
|
701
715
|
this.bridgeFrame && document.body && document.body.appendChild(this.bridgeFrame);
|
|
702
716
|
};
|
|
703
|
-
document.body ?
|
|
717
|
+
document.body ? o() : document.addEventListener("DOMContentLoaded", o, { once: !0 }), this.bridgeFrame.addEventListener("load", () => {
|
|
704
718
|
clearTimeout(n), this.bridgeReady = !0, this.postBridgeMessage({
|
|
705
719
|
type: "MARK_SYNC_REQUEST",
|
|
706
720
|
visitorId: this.data.visitor_id
|
|
707
721
|
});
|
|
708
722
|
});
|
|
709
723
|
}
|
|
710
|
-
handleBridgeMessage = (
|
|
711
|
-
if (!this.bridgeFrame?.contentWindow ||
|
|
724
|
+
handleBridgeMessage = (e) => {
|
|
725
|
+
if (!this.bridgeFrame?.contentWindow || e.source !== this.bridgeFrame.contentWindow || !this.isDomainAllowed(e.origin))
|
|
712
726
|
return;
|
|
713
|
-
const
|
|
714
|
-
!
|
|
727
|
+
const t = e.data;
|
|
728
|
+
!t || !t.type || t.type === "MARK_SYNC_RESPONSE" && t.visitorId && t.visitorId !== this.data.visitor_id && (this.data.visitor_id = t.visitorId, this.save());
|
|
715
729
|
};
|
|
716
|
-
postBridgeMessage(
|
|
717
|
-
this.bridgeFrame?.contentWindow && this.bridgeFrame.contentWindow.postMessage(
|
|
730
|
+
postBridgeMessage(e) {
|
|
731
|
+
this.bridgeFrame?.contentWindow && this.bridgeFrame.contentWindow.postMessage(e, this.bridgeOrigin ?? "*");
|
|
718
732
|
}
|
|
719
|
-
isDomainAllowed(
|
|
733
|
+
isDomainAllowed(e) {
|
|
720
734
|
try {
|
|
721
|
-
const
|
|
735
|
+
const t = new URL(e);
|
|
722
736
|
if (this.options.allowed_domains?.length)
|
|
723
737
|
return this.options.allowed_domains.some(
|
|
724
|
-
(n) =>
|
|
738
|
+
(n) => t.hostname === n || t.hostname.endsWith(`.${n}`)
|
|
725
739
|
);
|
|
726
740
|
if (!this.bridgeOrigin)
|
|
727
741
|
return !1;
|
|
728
742
|
const i = new URL(this.bridgeOrigin);
|
|
729
|
-
return
|
|
743
|
+
return t.hostname === i.hostname;
|
|
730
744
|
} catch {
|
|
731
745
|
return !1;
|
|
732
746
|
}
|
|
733
747
|
}
|
|
734
|
-
handleStorageEvent = (
|
|
735
|
-
if (!(
|
|
748
|
+
handleStorageEvent = (e) => {
|
|
749
|
+
if (!(e.key !== this.storageKey || typeof e.newValue != "string"))
|
|
736
750
|
try {
|
|
737
|
-
this.data = JSON.parse(
|
|
751
|
+
this.data = JSON.parse(e.newValue);
|
|
738
752
|
} catch {
|
|
739
753
|
}
|
|
740
754
|
};
|
|
741
755
|
}
|
|
742
|
-
const
|
|
756
|
+
const te = [
|
|
743
757
|
"click_id",
|
|
744
758
|
"ch_click_id",
|
|
745
759
|
"gclid",
|
|
@@ -751,7 +765,7 @@ const O = [
|
|
|
751
765
|
"ttclid",
|
|
752
766
|
"twclid",
|
|
753
767
|
"li_fat_id"
|
|
754
|
-
],
|
|
768
|
+
], ie = ["cid", "campaign_id"], ne = [
|
|
755
769
|
"utm_source",
|
|
756
770
|
"utm_medium",
|
|
757
771
|
"utm_campaign",
|
|
@@ -773,101 +787,232 @@ const O = [
|
|
|
773
787
|
"ttclid",
|
|
774
788
|
"twclid",
|
|
775
789
|
"li_fat_id"
|
|
776
|
-
],
|
|
790
|
+
], se = {
|
|
777
791
|
referral: "ref",
|
|
778
792
|
affiliate_id: "ref",
|
|
779
793
|
ch_click_id: "click_id",
|
|
780
794
|
cid: "campaign_id"
|
|
781
|
-
},
|
|
782
|
-
function
|
|
783
|
-
const
|
|
784
|
-
return n && (
|
|
795
|
+
}, re = ["email", "phone", "token", "auth", "password", "code"], oe = 30, ae = 256;
|
|
796
|
+
function L(r, e = {}) {
|
|
797
|
+
const t = new URLSearchParams(r), i = de(t), n = U(i, te), o = U(i, ie), a = ce(t, e), c = {};
|
|
798
|
+
return n && (c.last_click_id = n), o && (c.campaign_id = o), Object.keys(a).length > 0 && (c.query_params = a), c;
|
|
785
799
|
}
|
|
786
|
-
function
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
),
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
),
|
|
794
|
-
...
|
|
795
|
-
...
|
|
800
|
+
function ce(r, e) {
|
|
801
|
+
const t = {}, i = new Set(R(e.query_param_denylist, re)), n = B(
|
|
802
|
+
e.max_captured_query_params,
|
|
803
|
+
oe
|
|
804
|
+
), o = B(
|
|
805
|
+
e.max_query_param_value_length,
|
|
806
|
+
ae
|
|
807
|
+
), c = e.capture_all_query_params ?? !1 ? null : /* @__PURE__ */ new Set([
|
|
808
|
+
...ne.map(I),
|
|
809
|
+
...R(e.capture_query_params, [])
|
|
796
810
|
]);
|
|
797
|
-
for (const [
|
|
798
|
-
const d =
|
|
811
|
+
for (const [f, l] of r.entries()) {
|
|
812
|
+
const d = I(f);
|
|
799
813
|
if (!d)
|
|
800
814
|
continue;
|
|
801
|
-
const
|
|
802
|
-
if (i.has(d) || i.has(
|
|
815
|
+
const h = se[d] ?? d;
|
|
816
|
+
if (i.has(d) || i.has(h) || c && !c.has(d))
|
|
803
817
|
continue;
|
|
804
|
-
const
|
|
805
|
-
if (
|
|
806
|
-
if (!(
|
|
818
|
+
const u = l.trim();
|
|
819
|
+
if (u) {
|
|
820
|
+
if (!(h in t) && Object.keys(t).length >= n)
|
|
807
821
|
break;
|
|
808
|
-
|
|
822
|
+
t[h] = u.slice(0, o);
|
|
809
823
|
}
|
|
810
824
|
}
|
|
811
|
-
return
|
|
825
|
+
return t;
|
|
812
826
|
}
|
|
813
|
-
function
|
|
814
|
-
for (const
|
|
815
|
-
const i =
|
|
827
|
+
function U(r, e) {
|
|
828
|
+
for (const t of e) {
|
|
829
|
+
const i = I(t), n = r[i]?.trim();
|
|
816
830
|
if (n)
|
|
817
831
|
return n;
|
|
818
832
|
}
|
|
819
833
|
}
|
|
820
|
-
function
|
|
821
|
-
const
|
|
822
|
-
for (const [
|
|
823
|
-
const n =
|
|
824
|
-
!n || n in
|
|
834
|
+
function de(r) {
|
|
835
|
+
const e = {};
|
|
836
|
+
for (const [t, i] of r.entries()) {
|
|
837
|
+
const n = I(t);
|
|
838
|
+
!n || n in e || (e[n] = i);
|
|
825
839
|
}
|
|
826
|
-
return
|
|
840
|
+
return e;
|
|
827
841
|
}
|
|
828
|
-
function
|
|
829
|
-
return
|
|
842
|
+
function I(r) {
|
|
843
|
+
return r.trim().toLowerCase();
|
|
830
844
|
}
|
|
831
|
-
function
|
|
832
|
-
const
|
|
833
|
-
for (const n of
|
|
845
|
+
function R(r, e) {
|
|
846
|
+
const t = r ?? e, i = /* @__PURE__ */ new Set();
|
|
847
|
+
for (const n of t) {
|
|
834
848
|
if (typeof n != "string") continue;
|
|
835
|
-
const
|
|
836
|
-
|
|
849
|
+
const o = I(n);
|
|
850
|
+
o && i.add(o);
|
|
837
851
|
}
|
|
838
852
|
return Array.from(i);
|
|
839
853
|
}
|
|
840
|
-
function
|
|
841
|
-
if (typeof
|
|
842
|
-
return
|
|
843
|
-
const
|
|
844
|
-
return
|
|
854
|
+
function B(r, e) {
|
|
855
|
+
if (typeof r != "number" || !Number.isFinite(r))
|
|
856
|
+
return e;
|
|
857
|
+
const t = Math.floor(r);
|
|
858
|
+
return t < 0 ? e : t;
|
|
845
859
|
}
|
|
846
|
-
function
|
|
847
|
-
return
|
|
860
|
+
function E(r) {
|
|
861
|
+
return r.length > 1 && r.endsWith("/") ? r.slice(0, -1) : r;
|
|
848
862
|
}
|
|
849
|
-
function
|
|
850
|
-
if (!
|
|
863
|
+
function ue(r) {
|
|
864
|
+
if (!r || r === "?")
|
|
851
865
|
return "";
|
|
852
|
-
const
|
|
853
|
-
if (!
|
|
866
|
+
const e = r.startsWith("?") ? r.slice(1) : r;
|
|
867
|
+
if (!e)
|
|
854
868
|
return "";
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
i.push([
|
|
858
|
-
}), i.sort(([
|
|
859
|
-
const d =
|
|
860
|
-
return d !== 0 ? d :
|
|
869
|
+
const t = new URLSearchParams(e), i = [];
|
|
870
|
+
t.forEach((a, c) => {
|
|
871
|
+
i.push([c, a]);
|
|
872
|
+
}), i.sort(([a, c], [f, l]) => {
|
|
873
|
+
const d = a.localeCompare(f);
|
|
874
|
+
return d !== 0 ? d : c.localeCompare(l);
|
|
861
875
|
});
|
|
862
876
|
const n = new URLSearchParams();
|
|
863
|
-
for (const [
|
|
864
|
-
n.append(
|
|
865
|
-
const
|
|
866
|
-
return
|
|
877
|
+
for (const [a, c] of i)
|
|
878
|
+
n.append(a, c);
|
|
879
|
+
const o = n.toString();
|
|
880
|
+
return o === "" ? "" : `?${o}`;
|
|
881
|
+
}
|
|
882
|
+
function C(r) {
|
|
883
|
+
const e = E(r.pathname), t = ue(r.search);
|
|
884
|
+
return `${r.origin}${e}${t}${r.hash}`;
|
|
885
|
+
}
|
|
886
|
+
let x = !1, m = null;
|
|
887
|
+
const w = [], y = [], _ = [];
|
|
888
|
+
let b = null, v = null, A = null, S = null;
|
|
889
|
+
function k() {
|
|
890
|
+
if (typeof window > "u") return;
|
|
891
|
+
const r = C(window.location);
|
|
892
|
+
if (r === m) return;
|
|
893
|
+
const e = { previousKey: m, nextKey: r };
|
|
894
|
+
for (const t of w)
|
|
895
|
+
t(e);
|
|
896
|
+
m = r;
|
|
897
|
+
for (const t of y)
|
|
898
|
+
t(e);
|
|
899
|
+
}
|
|
900
|
+
function le() {
|
|
901
|
+
for (const r of _)
|
|
902
|
+
r();
|
|
903
|
+
}
|
|
904
|
+
function fe(r = {}) {
|
|
905
|
+
if (x || typeof window > "u" || typeof document > "u")
|
|
906
|
+
return;
|
|
907
|
+
x = !0;
|
|
908
|
+
const e = r.trackRouteChanges ?? !0;
|
|
909
|
+
m = C(window.location), S = le, window.addEventListener("pagehide", S), e && (b = history.pushState, v = history.replaceState, history.pushState = function(...t) {
|
|
910
|
+
const i = b.apply(this, t);
|
|
911
|
+
return k(), i;
|
|
912
|
+
}, history.replaceState = function(...t) {
|
|
913
|
+
const i = v.apply(this, t);
|
|
914
|
+
return k(), i;
|
|
915
|
+
}, A = k, window.addEventListener("popstate", A));
|
|
916
|
+
}
|
|
917
|
+
function he(r) {
|
|
918
|
+
return w.push(r), () => {
|
|
919
|
+
const e = w.indexOf(r);
|
|
920
|
+
e >= 0 && w.splice(e, 1);
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
function q(r) {
|
|
924
|
+
return y.push(r), () => {
|
|
925
|
+
const e = y.indexOf(r);
|
|
926
|
+
e >= 0 && y.splice(e, 1);
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
function ge(r) {
|
|
930
|
+
return _.push(r), () => {
|
|
931
|
+
const e = _.indexOf(r);
|
|
932
|
+
e >= 0 && _.splice(e, 1);
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
function pe() {
|
|
936
|
+
!x || typeof window > "u" || (b && (history.pushState = b), v && (history.replaceState = v), A && window.removeEventListener("popstate", A), S && window.removeEventListener("pagehide", S), b = null, v = null, A = null, S = null, w.length = 0, y.length = 0, _.length = 0, m = null, x = !1);
|
|
937
|
+
}
|
|
938
|
+
let D = 0;
|
|
939
|
+
function N() {
|
|
940
|
+
D = 0;
|
|
941
|
+
}
|
|
942
|
+
function me() {
|
|
943
|
+
return D;
|
|
944
|
+
}
|
|
945
|
+
function we() {
|
|
946
|
+
if (typeof document > "u" || typeof window > "u")
|
|
947
|
+
return 0;
|
|
948
|
+
const r = document.documentElement, e = window.scrollY || r.scrollTop, t = Math.max(1, r.scrollHeight - window.innerHeight);
|
|
949
|
+
return Math.min(100, Math.round(e / t * 100));
|
|
867
950
|
}
|
|
868
|
-
function
|
|
869
|
-
const
|
|
870
|
-
return
|
|
951
|
+
function K() {
|
|
952
|
+
const r = we();
|
|
953
|
+
return r > D && (D = r), r;
|
|
954
|
+
}
|
|
955
|
+
const ye = [25, 50, 75, 100];
|
|
956
|
+
function _e(r, e = ye) {
|
|
957
|
+
if (typeof window > "u") return;
|
|
958
|
+
const t = /* @__PURE__ */ new Set(), i = () => {
|
|
959
|
+
t.clear(), N();
|
|
960
|
+
};
|
|
961
|
+
i(), q(() => {
|
|
962
|
+
i();
|
|
963
|
+
}), window.addEventListener(
|
|
964
|
+
"scroll",
|
|
965
|
+
() => {
|
|
966
|
+
const n = K();
|
|
967
|
+
for (const o of e)
|
|
968
|
+
n >= o && !t.has(o) && (t.add(o), r.track("scroll_depth", { percent: o }));
|
|
969
|
+
},
|
|
970
|
+
{ passive: !0 }
|
|
971
|
+
);
|
|
972
|
+
}
|
|
973
|
+
const F = 1e4;
|
|
974
|
+
function be(r) {
|
|
975
|
+
return r === !0 ? { minActiveMs: F, useBeacon: !0 } : {
|
|
976
|
+
minActiveMs: r.min_active_ms ?? F,
|
|
977
|
+
useBeacon: r.use_beacon !== !1
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
function ve(r, e) {
|
|
981
|
+
if (typeof window > "u" || typeof document > "u") return;
|
|
982
|
+
let t = Date.now(), i = 0, n = document.visibilityState === "visible" ? Date.now() : null, o = E(window.location.pathname), a = !1;
|
|
983
|
+
const c = () => {
|
|
984
|
+
n !== null && (i += Date.now() - n, n = null);
|
|
985
|
+
}, f = () => {
|
|
986
|
+
document.visibilityState === "visible" && n === null && (n = Date.now());
|
|
987
|
+
}, l = (h) => {
|
|
988
|
+
if (!a) {
|
|
989
|
+
a = !0;
|
|
990
|
+
try {
|
|
991
|
+
if (c(), K(), i < e.minActiveMs)
|
|
992
|
+
return;
|
|
993
|
+
const u = Date.now() - t, g = {
|
|
994
|
+
page: o,
|
|
995
|
+
active_time_ms: i,
|
|
996
|
+
total_time_ms: u,
|
|
997
|
+
max_scroll_percent: me()
|
|
998
|
+
};
|
|
999
|
+
e.useBeacon && h ? r.trackWithOptions("page_engagement", g, { preferBeacon: !0 }) : r.track("page_engagement", g);
|
|
1000
|
+
} finally {
|
|
1001
|
+
a = !1;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}, d = () => {
|
|
1005
|
+
t = Date.now(), i = 0, o = E(window.location.pathname), N(), f();
|
|
1006
|
+
};
|
|
1007
|
+
d(), he(() => {
|
|
1008
|
+
l(!0), c();
|
|
1009
|
+
}), q(() => {
|
|
1010
|
+
d();
|
|
1011
|
+
}), ge(() => {
|
|
1012
|
+
l(!0);
|
|
1013
|
+
}), document.addEventListener("visibilitychange", () => {
|
|
1014
|
+
document.visibilityState === "hidden" ? c() : f();
|
|
1015
|
+
});
|
|
871
1016
|
}
|
|
872
1017
|
class s {
|
|
873
1018
|
static client = null;
|
|
@@ -877,60 +1022,57 @@ class s {
|
|
|
877
1022
|
static lastPageviewDedupeKey = null;
|
|
878
1023
|
static emitAutoPageview = null;
|
|
879
1024
|
static pendingAttribution = {};
|
|
880
|
-
static originalPushState = null;
|
|
881
|
-
static originalReplaceState = null;
|
|
882
|
-
static popstateHandler = null;
|
|
883
1025
|
static beaconDrainHandler = null;
|
|
884
1026
|
static visibilityHandler = null;
|
|
885
1027
|
static onlineHandler = null;
|
|
886
1028
|
static kickTimer = null;
|
|
887
|
-
static init(
|
|
1029
|
+
static init(e) {
|
|
888
1030
|
if (!s.client) {
|
|
889
|
-
const
|
|
890
|
-
s.client = new
|
|
1031
|
+
const t = new ee(e.cross_domain), i = new J(e);
|
|
1032
|
+
s.client = new G(e, { storage: t, transport: i }), s.storage = t, s.config = e, s.refreshAttribution(t, e), typeof window < "u" && (s.installPageLifecycleIfNeeded(e), e.autocapture?.pageview && s.installPageviewTracking(e, t), s.installExtendedAutocapture(e), s.installLifecycleFlushing());
|
|
891
1033
|
}
|
|
892
1034
|
return s.client;
|
|
893
1035
|
}
|
|
894
1036
|
static installLifecycleFlushing() {
|
|
895
1037
|
if (typeof window > "u" || s.beaconDrainHandler) return;
|
|
896
|
-
const
|
|
1038
|
+
const e = () => {
|
|
897
1039
|
s.client?.drainViaBeacon();
|
|
898
|
-
},
|
|
899
|
-
typeof document < "u" && document.visibilityState === "hidden" &&
|
|
1040
|
+
}, t = () => {
|
|
1041
|
+
typeof document < "u" && document.visibilityState === "hidden" && e();
|
|
900
1042
|
}, i = () => {
|
|
901
1043
|
s.client?.kickQueue();
|
|
902
1044
|
};
|
|
903
|
-
s.beaconDrainHandler =
|
|
1045
|
+
s.beaconDrainHandler = e, s.visibilityHandler = t, s.onlineHandler = i, typeof document < "u" && typeof document.addEventListener == "function" && document.addEventListener("visibilitychange", t), typeof window.addEventListener == "function" && (window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), window.addEventListener("online", i)), typeof setInterval == "function" && (s.kickTimer = setInterval(() => {
|
|
904
1046
|
s.client?.kickQueue();
|
|
905
1047
|
}, 3e4));
|
|
906
1048
|
}
|
|
907
|
-
static track(
|
|
1049
|
+
static track(e, t = {}) {
|
|
908
1050
|
if (!s.client) {
|
|
909
1051
|
s.config?.debug && console.warn("[Mark] Not initialized. Call init() first.");
|
|
910
1052
|
return;
|
|
911
1053
|
}
|
|
912
|
-
s.client.track(
|
|
1054
|
+
s.client.track(e, t);
|
|
913
1055
|
}
|
|
914
|
-
static identify(
|
|
1056
|
+
static identify(e, t = {}) {
|
|
915
1057
|
if (!s.client) {
|
|
916
1058
|
s.config?.debug && console.warn("[Mark] Not initialized. Call init() first.");
|
|
917
1059
|
return;
|
|
918
1060
|
}
|
|
919
|
-
s.client.identify(
|
|
1061
|
+
s.client.identify(e, t);
|
|
920
1062
|
}
|
|
921
|
-
static conversion(
|
|
1063
|
+
static conversion(e, t = {}) {
|
|
922
1064
|
if (!s.client) {
|
|
923
1065
|
s.config?.debug && console.warn("[Mark] Not initialized. Call init() first.");
|
|
924
1066
|
return;
|
|
925
1067
|
}
|
|
926
|
-
s.client.conversion(
|
|
1068
|
+
s.client.conversion(e, t);
|
|
927
1069
|
}
|
|
928
|
-
static setConsent(
|
|
1070
|
+
static setConsent(e) {
|
|
929
1071
|
if (!s.client) {
|
|
930
1072
|
s.config?.debug && console.warn("[Mark] Not initialized. Call init() first.");
|
|
931
1073
|
return;
|
|
932
1074
|
}
|
|
933
|
-
s.client.setConsent(
|
|
1075
|
+
s.client.setConsent(e), e === "granted" && (s.flushPendingAttribution(), s.emitAutoPageview?.());
|
|
934
1076
|
}
|
|
935
1077
|
/**
|
|
936
1078
|
* Returns the current visitor ID when available.
|
|
@@ -959,12 +1101,12 @@ class s {
|
|
|
959
1101
|
* if (params.get('onelence_internal') === '1') Mark.setInternal(true);
|
|
960
1102
|
* if (params.get('onelence_internal') === '0') Mark.setInternal(false);
|
|
961
1103
|
*/
|
|
962
|
-
static setInternal(
|
|
1104
|
+
static setInternal(e) {
|
|
963
1105
|
if (!s.client) {
|
|
964
1106
|
s.config?.debug && console.warn("[Mark] Not initialized. Call init() first.");
|
|
965
1107
|
return;
|
|
966
1108
|
}
|
|
967
|
-
s.client.setInternal(
|
|
1109
|
+
s.client.setInternal(e);
|
|
968
1110
|
}
|
|
969
1111
|
static getInternal() {
|
|
970
1112
|
return s.client?.getInternal() ?? !1;
|
|
@@ -976,123 +1118,109 @@ class s {
|
|
|
976
1118
|
return s.client?.getStats() ?? { queued: 0, sent: 0, failed: 0, dropped: 0 };
|
|
977
1119
|
}
|
|
978
1120
|
static destroy() {
|
|
979
|
-
typeof window > "u" || (
|
|
1121
|
+
typeof window > "u" || (pe(), s.beaconDrainHandler && (window.removeEventListener("pagehide", s.beaconDrainHandler), window.removeEventListener("beforeunload", s.beaconDrainHandler)), s.visibilityHandler && typeof document < "u" && document.removeEventListener("visibilitychange", s.visibilityHandler), s.onlineHandler && window.removeEventListener("online", s.onlineHandler), s.kickTimer && clearInterval(s.kickTimer), s.beaconDrainHandler = null, s.visibilityHandler = null, s.onlineHandler = null, s.kickTimer = null, s.pageviewTrackerInstalled = !1);
|
|
1122
|
+
}
|
|
1123
|
+
static installPageLifecycleIfNeeded(e) {
|
|
1124
|
+
const t = e.autocapture;
|
|
1125
|
+
if (!(!!t?.pageview || !!t?.scroll_depth || !!t?.page_engagement)) return;
|
|
1126
|
+
const n = e.track_route_changes ?? !0;
|
|
1127
|
+
fe({ trackRouteChanges: n });
|
|
980
1128
|
}
|
|
981
|
-
static installPageviewTracking(
|
|
1129
|
+
static installPageviewTracking(e, t) {
|
|
982
1130
|
if (s.pageviewTrackerInstalled) return;
|
|
983
1131
|
s.pageviewTrackerInstalled = !0;
|
|
984
1132
|
const i = () => {
|
|
985
1133
|
if (!s.client) return;
|
|
986
|
-
s.refreshAttribution(
|
|
987
|
-
const
|
|
988
|
-
if (
|
|
1134
|
+
s.refreshAttribution(t, e);
|
|
1135
|
+
const o = C(window.location);
|
|
1136
|
+
if (o === s.lastPageviewDedupeKey) return;
|
|
989
1137
|
s.client.track("page_view", {
|
|
990
1138
|
site: window.location.host,
|
|
991
|
-
page:
|
|
1139
|
+
page: E(window.location.pathname),
|
|
992
1140
|
title: document.title,
|
|
993
1141
|
referrer: document.referrer || void 0
|
|
994
|
-
}) && (s.lastPageviewDedupeKey =
|
|
1142
|
+
}) && (s.lastPageviewDedupeKey = o);
|
|
995
1143
|
};
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}, history.replaceState = function(...a) {
|
|
1002
|
-
const u = o.apply(this, a);
|
|
1003
|
-
return i(), u;
|
|
1004
|
-
}, s.popstateHandler = i, window.addEventListener("popstate", i);
|
|
1005
|
-
}
|
|
1006
|
-
static refreshAttribution(t, e) {
|
|
1144
|
+
s.emitAutoPageview = i, i(), (e.track_route_changes ?? !0) && q(() => {
|
|
1145
|
+
i();
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
static refreshAttribution(e, t) {
|
|
1007
1149
|
if (typeof window > "u")
|
|
1008
1150
|
return;
|
|
1009
|
-
const i =
|
|
1151
|
+
const i = L(window.location.search, t);
|
|
1010
1152
|
if (Object.keys(i).length !== 0) {
|
|
1011
|
-
if (s.shouldPersistAttribution(
|
|
1153
|
+
if (s.shouldPersistAttribution(e, t)) {
|
|
1012
1154
|
const n = s.mergeAttributionUpdates(s.pendingAttribution, i);
|
|
1013
|
-
|
|
1155
|
+
e.update(n), s.pendingAttribution = {};
|
|
1014
1156
|
return;
|
|
1015
1157
|
}
|
|
1016
1158
|
s.pendingAttribution = s.mergeAttributionUpdates(s.pendingAttribution, i);
|
|
1017
1159
|
}
|
|
1018
1160
|
}
|
|
1019
1161
|
static flushPendingAttribution() {
|
|
1020
|
-
const
|
|
1021
|
-
if (!
|
|
1162
|
+
const e = s.storage, t = s.config;
|
|
1163
|
+
if (!e || !t || typeof window > "u")
|
|
1022
1164
|
return;
|
|
1023
|
-
const i =
|
|
1024
|
-
Object.keys(n).length > 0 &&
|
|
1165
|
+
const i = L(window.location.search, t), n = s.mergeAttributionUpdates(s.pendingAttribution, i);
|
|
1166
|
+
Object.keys(n).length > 0 && e.update(n), s.pendingAttribution = {};
|
|
1025
1167
|
}
|
|
1026
|
-
static shouldPersistAttribution(
|
|
1027
|
-
return
|
|
1168
|
+
static shouldPersistAttribution(e, t) {
|
|
1169
|
+
return t.require_consent ?? !1 ? e.getConsentStatus() === "granted" : !0;
|
|
1028
1170
|
}
|
|
1029
|
-
static mergeAttributionUpdates(
|
|
1171
|
+
static mergeAttributionUpdates(e, t) {
|
|
1030
1172
|
return {
|
|
1031
|
-
...t,
|
|
1032
1173
|
...e,
|
|
1174
|
+
...t,
|
|
1033
1175
|
query_params: {
|
|
1034
|
-
...
|
|
1035
|
-
...
|
|
1176
|
+
...e.query_params ?? {},
|
|
1177
|
+
...t.query_params ?? {}
|
|
1036
1178
|
}
|
|
1037
1179
|
};
|
|
1038
1180
|
}
|
|
1039
|
-
static installExtendedAutocapture(
|
|
1181
|
+
static installExtendedAutocapture(e) {
|
|
1040
1182
|
if (!s.client || typeof document > "u") return;
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
href: o.href || void 0
|
|
1054
|
-
});
|
|
1055
|
-
}), e.form_submit && document.addEventListener("submit", (i) => {
|
|
1056
|
-
const n = i.target;
|
|
1057
|
-
n && s.client?.track("form_submit", {
|
|
1058
|
-
form_id: n.id || void 0,
|
|
1059
|
-
form_name: n.name || void 0,
|
|
1060
|
-
action: n.action || void 0
|
|
1061
|
-
});
|
|
1062
|
-
}), e.outbound_link && document.addEventListener("click", (i) => {
|
|
1063
|
-
const n = i.target?.closest("a[href]");
|
|
1064
|
-
if (!(!n || !n.href))
|
|
1065
|
-
try {
|
|
1066
|
-
const r = new URL(n.href, window.location.href), o = new URL(window.location.href);
|
|
1067
|
-
r.origin !== o.origin && s.client?.trackWithOptions("outbound_link_click", { href: r.toString() }, { preferBeacon: !0 });
|
|
1068
|
-
} catch {
|
|
1069
|
-
}
|
|
1070
|
-
}), e.scroll_depth) {
|
|
1071
|
-
const i = [25, 50, 75, 100], n = /* @__PURE__ */ new Set();
|
|
1072
|
-
window.addEventListener(
|
|
1073
|
-
"scroll",
|
|
1074
|
-
() => {
|
|
1075
|
-
const r = document.documentElement, o = window.scrollY || r.scrollTop, a = Math.max(1, r.scrollHeight - window.innerHeight), u = Math.min(100, Math.round(o / a * 100));
|
|
1076
|
-
for (const l of i)
|
|
1077
|
-
u >= l && !n.has(l) && (n.add(l), s.client?.track("scroll_depth", { percent: l }));
|
|
1078
|
-
},
|
|
1079
|
-
{ passive: !0 }
|
|
1080
|
-
);
|
|
1081
|
-
}
|
|
1082
|
-
e.web_vitals && import("./web-vitals-CrnTllyu.js").then((i) => {
|
|
1083
|
-
const n = (r) => {
|
|
1084
|
-
s.client?.track("web_vital", {
|
|
1085
|
-
metric: r.name,
|
|
1086
|
-
value: r.value,
|
|
1087
|
-
rating: r.rating,
|
|
1088
|
-
metric_id: r.id
|
|
1089
|
-
});
|
|
1090
|
-
};
|
|
1091
|
-
i.onLCP(n), i.onCLS(n), i.onINP(n), i.onTTFB(n);
|
|
1092
|
-
}).catch(() => {
|
|
1093
|
-
t.debug && console.warn("[Mark] web-vitals package not available; skipping autocapture.web_vitals.");
|
|
1183
|
+
const t = e.autocapture;
|
|
1184
|
+
t && (t.click && document.addEventListener("click", (i) => {
|
|
1185
|
+
const n = i.target;
|
|
1186
|
+
if (!n) return;
|
|
1187
|
+
const o = typeof t.click == "object" ? t.click.selector : void 0, a = o ? n.closest(o) : n.closest("[data-mark-event]");
|
|
1188
|
+
if (!a) return;
|
|
1189
|
+
const c = a.getAttribute("data-mark-event") || "click";
|
|
1190
|
+
s.client?.track(c, {
|
|
1191
|
+
element_id: a.id || void 0,
|
|
1192
|
+
element_classes: a.className || void 0,
|
|
1193
|
+
text: a.textContent?.trim().slice(0, 120) || void 0,
|
|
1194
|
+
href: a.href || void 0
|
|
1094
1195
|
});
|
|
1095
|
-
}
|
|
1196
|
+
}), t.form_submit && document.addEventListener("submit", (i) => {
|
|
1197
|
+
const n = i.target;
|
|
1198
|
+
n && s.client?.track("form_submit", {
|
|
1199
|
+
form_id: n.id || void 0,
|
|
1200
|
+
form_name: n.name || void 0,
|
|
1201
|
+
action: n.action || void 0
|
|
1202
|
+
});
|
|
1203
|
+
}), t.outbound_link && document.addEventListener("click", (i) => {
|
|
1204
|
+
const n = i.target?.closest("a[href]");
|
|
1205
|
+
if (!(!n || !n.href))
|
|
1206
|
+
try {
|
|
1207
|
+
const o = new URL(n.href, window.location.href), a = new URL(window.location.href);
|
|
1208
|
+
o.origin !== a.origin && s.client?.trackWithOptions("outbound_link_click", { href: o.toString() }, { preferBeacon: !0 });
|
|
1209
|
+
} catch {
|
|
1210
|
+
}
|
|
1211
|
+
}), t.scroll_depth && s.client && _e(s.client), t.page_engagement && s.client && ve(s.client, be(t.page_engagement)), t.web_vitals && import("./web-vitals-CrnTllyu.js").then((i) => {
|
|
1212
|
+
const n = (o) => {
|
|
1213
|
+
s.client?.track("web_vital", {
|
|
1214
|
+
metric: o.name,
|
|
1215
|
+
value: o.value,
|
|
1216
|
+
rating: o.rating,
|
|
1217
|
+
metric_id: o.id
|
|
1218
|
+
});
|
|
1219
|
+
};
|
|
1220
|
+
i.onLCP(n), i.onCLS(n), i.onINP(n), i.onTTFB(n);
|
|
1221
|
+
}).catch(() => {
|
|
1222
|
+
e.debug && console.warn("[Mark] web-vitals package not available; skipping autocapture.web_vitals.");
|
|
1223
|
+
}));
|
|
1096
1224
|
}
|
|
1097
1225
|
}
|
|
1098
1226
|
typeof window < "u" && (window.Mark = s);
|