@aranova/tracking-react 0.24.0 → 0.25.0
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 +1 -1
- package/dist/client.d.mts +366 -0
- package/dist/client.d.ts +366 -0
- package/dist/client.js +3710 -0
- package/dist/client.js.map +1 -0
- package/dist/client.mjs +3680 -0
- package/dist/client.mjs.map +1 -0
- package/dist/index.d.mts +9 -1726
- package/dist/index.d.ts +9 -1726
- package/dist/index.js +17 -2041
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -2034
- package/dist/index.mjs.map +1 -1
- package/dist/ingest-typed-BioxtBJD.d.mts +1365 -0
- package/dist/ingest-typed-C-SPiigr.d.ts +1365 -0
- package/dist/{phone-utils-FTQnybMz.d.mts → phone-utils-BVzSNBf1.d.mts} +8 -4
- package/dist/{phone-utils-FTQnybMz.d.ts → phone-utils-BVzSNBf1.d.ts} +8 -4
- package/dist/phone.d.mts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/phone.js.map +1 -1
- package/dist/phone.mjs.map +1 -1
- package/dist/{sales-BwWnvl8L.d.mts → sales-BIij04IG.d.ts} +2 -190
- package/dist/{sales-BwWnvl8L.d.ts → sales-C3B0BOBQ.d.mts} +2 -190
- package/dist/sales.d.mts +2 -1
- package/dist/sales.d.ts +2 -1
- package/dist/tracking-config-runtime-BnUlS_Ae.d.mts +190 -0
- package/dist/tracking-config-runtime-BnUlS_Ae.d.ts +190 -0
- package/package.json +18 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
AdPlatformTracking,
|
|
4
|
+
ConsentBanner,
|
|
5
|
+
createTracking,
|
|
6
|
+
GoogleAdsTracking,
|
|
7
|
+
useConsent,
|
|
8
|
+
useConsentState,
|
|
9
|
+
useCookiePreferences,
|
|
10
|
+
useGclid,
|
|
11
|
+
useTrackingParams
|
|
12
|
+
} from "@aranova/tracking-react/client";
|
|
6
13
|
|
|
7
14
|
// ../tracking-core/src/phone.ts
|
|
8
15
|
import { AsYouType, parsePhoneNumberFromString } from "libphonenumber-js";
|
|
@@ -46,44 +53,12 @@ function formatPhoneAsTyped(raw, country) {
|
|
|
46
53
|
|
|
47
54
|
// ../tracking-core/src/user-data.ts
|
|
48
55
|
var EMAIL_SHAPE = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
|
|
49
|
-
var EMAIL_NAME_HINT = /e[-_]?mail/i;
|
|
50
|
-
var PHONE_NAME_HINT = /(^|[^a-z])(phone|tel|mobile|cell)/i;
|
|
51
56
|
var stash = { email: null, phoneNumber: null };
|
|
52
57
|
function normalizeEmail(raw) {
|
|
53
58
|
if (typeof raw !== "string") return null;
|
|
54
59
|
const cleaned = raw.trim().toLowerCase();
|
|
55
60
|
return EMAIL_SHAPE.test(cleaned) ? cleaned : null;
|
|
56
61
|
}
|
|
57
|
-
function fieldText(field, key) {
|
|
58
|
-
const value = field[key];
|
|
59
|
-
return typeof value === "string" ? value : "";
|
|
60
|
-
}
|
|
61
|
-
function extractUserDataFromFormFields(fields, country) {
|
|
62
|
-
const result = { email: null, phoneNumber: null };
|
|
63
|
-
if (!Array.isArray(fields)) return result;
|
|
64
|
-
const passes = [
|
|
65
|
-
(field, _hint, type) => fieldText(field, "type").toLowerCase() === type,
|
|
66
|
-
(field, hint) => hint.test(fieldText(field, "name")) || hint.test(fieldText(field, "label"))
|
|
67
|
-
];
|
|
68
|
-
for (const matches of passes) {
|
|
69
|
-
for (const raw of fields) {
|
|
70
|
-
if (raw === null || typeof raw !== "object") continue;
|
|
71
|
-
const field = raw;
|
|
72
|
-
if (typeof field.value !== "string" || field.value.length === 0) continue;
|
|
73
|
-
if (result.email === null && matches(field, EMAIL_NAME_HINT, "email")) {
|
|
74
|
-
result.email = normalizeEmail(field.value);
|
|
75
|
-
}
|
|
76
|
-
if (result.phoneNumber === null && matches(field, PHONE_NAME_HINT, "tel")) {
|
|
77
|
-
try {
|
|
78
|
-
result.phoneNumber = toE164(field.value, country);
|
|
79
|
-
} catch {
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (result.email !== null && result.phoneNumber !== null) break;
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
62
|
function stashUserData(data, country) {
|
|
88
63
|
const email = normalizeEmail(data.email);
|
|
89
64
|
let phoneNumber = null;
|
|
@@ -99,16 +74,6 @@ function stashUserData(data, country) {
|
|
|
99
74
|
phoneNumber: phoneNumber ?? stash.phoneNumber
|
|
100
75
|
};
|
|
101
76
|
}
|
|
102
|
-
function stashUserDataFromFormFields(fields, country) {
|
|
103
|
-
try {
|
|
104
|
-
const extracted = extractUserDataFromFormFields(fields, country);
|
|
105
|
-
stash = {
|
|
106
|
-
email: extracted.email ?? stash.email,
|
|
107
|
-
phoneNumber: extracted.phoneNumber ?? stash.phoneNumber
|
|
108
|
-
};
|
|
109
|
-
} catch {
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
77
|
function clearStashedUserData() {
|
|
113
78
|
stash = { email: null, phoneNumber: null };
|
|
114
79
|
}
|
|
@@ -380,12 +345,6 @@ function getCookieValueFromDocument(key) {
|
|
|
380
345
|
function setTrackingCookie(key, value, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
|
|
381
346
|
persistCookieValue(key, value, maxAgeSeconds);
|
|
382
347
|
}
|
|
383
|
-
function mergeTrackingParams(primary, fallback) {
|
|
384
|
-
return TRACKING_PARAM_KEYS.reduce((merged, key) => {
|
|
385
|
-
merged[key] = primary[key] ?? fallback[key];
|
|
386
|
-
return merged;
|
|
387
|
-
}, createEmptyTrackingParams());
|
|
388
|
-
}
|
|
389
348
|
function persistTrackingParamsFromSearchParams(searchParams, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
|
|
390
349
|
const trackingValues = getTrackingQueryValues(searchParams);
|
|
391
350
|
Object.entries(trackingValues).forEach(([key, value]) => {
|
|
@@ -457,133 +416,16 @@ function loadGtagScript(gtagId) {
|
|
|
457
416
|
script.setAttribute(TRACKING_SCRIPT_ATTRIBUTE, marker);
|
|
458
417
|
document.head.append(script);
|
|
459
418
|
}
|
|
460
|
-
function initializeGtag(gtagId) {
|
|
461
|
-
const gtag = ensureGtagFunction();
|
|
462
|
-
gtag("js", /* @__PURE__ */ new Date());
|
|
463
|
-
gtag("config", gtagId);
|
|
464
|
-
}
|
|
465
|
-
function bootstrapGoogleAdsTracking(gtagId) {
|
|
466
|
-
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
467
|
-
if (!isValidGtagId(gtagId)) return;
|
|
468
|
-
applyDefaultConsentState();
|
|
469
|
-
loadGtagScript(gtagId);
|
|
470
|
-
initializeGtag(gtagId);
|
|
471
|
-
}
|
|
472
|
-
function bootstrapMultipleGtags(gtagIds) {
|
|
473
|
-
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
474
|
-
const ids = Object.values(gtagIds).filter(
|
|
475
|
-
(id) => typeof id === "string" && isValidGtagId(id)
|
|
476
|
-
);
|
|
477
|
-
if (ids.length === 0) return;
|
|
478
|
-
applyDefaultConsentState();
|
|
479
|
-
loadGtagScript(ids[0]);
|
|
480
|
-
const gtag = ensureGtagFunction();
|
|
481
|
-
gtag("js", /* @__PURE__ */ new Date());
|
|
482
|
-
for (const id of ids) {
|
|
483
|
-
gtag("config", id);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
419
|
|
|
487
420
|
// ../tracking-core/src/fbq.ts
|
|
488
|
-
var FB_EVENTS_SCRIPT_HOST = "https://connect.facebook.net/en_US/fbevents.js";
|
|
489
421
|
var FBC_COOKIE = "_fbc";
|
|
490
422
|
var FBP_COOKIE = "_fbp";
|
|
491
|
-
var META_PIXEL_ID_PATTERN = /^\d{15,16}$/;
|
|
492
|
-
function isValidMetaPixelId(id) {
|
|
493
|
-
return META_PIXEL_ID_PATTERN.test(id);
|
|
494
|
-
}
|
|
495
|
-
function computeFbSubdomainIndex(hostname) {
|
|
496
|
-
const labels = hostname.split(".").filter(Boolean);
|
|
497
|
-
return Math.max(0, labels.length - 1);
|
|
498
|
-
}
|
|
499
|
-
function buildFbc(fbclid, now, hostname) {
|
|
500
|
-
const host = hostname ?? (typeof window === "undefined" ? "" : window.location.hostname);
|
|
501
|
-
return `fb.${computeFbSubdomainIndex(host)}.${now}.${fbclid}`;
|
|
502
|
-
}
|
|
503
423
|
function getFbcCookie() {
|
|
504
424
|
return readCookieValue(FBC_COOKIE);
|
|
505
425
|
}
|
|
506
426
|
function getFbpCookie() {
|
|
507
427
|
return readCookieValue(FBP_COOKIE);
|
|
508
428
|
}
|
|
509
|
-
function readFbclidFromUrl() {
|
|
510
|
-
if (typeof window === "undefined") return null;
|
|
511
|
-
try {
|
|
512
|
-
const value = new URL(window.location.href).searchParams.get("fbclid");
|
|
513
|
-
return value && value.trim().length > 0 ? value : null;
|
|
514
|
-
} catch {
|
|
515
|
-
return null;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
function captureFbc(now = typeof Date === "undefined" ? 0 : Date.now()) {
|
|
519
|
-
if (typeof window === "undefined") return;
|
|
520
|
-
if (getFbcCookie()) return;
|
|
521
|
-
const fbclid = readFbclidFromUrl() ?? readCookieValue("fbclid");
|
|
522
|
-
if (!fbclid) return;
|
|
523
|
-
persistCookieValue(FBC_COOKIE, buildFbc(fbclid, now), TRACKING_COOKIE_MAX_AGE_SECONDS);
|
|
524
|
-
}
|
|
525
|
-
function getScriptMarker2(id) {
|
|
526
|
-
return `aranova-${id}`;
|
|
527
|
-
}
|
|
528
|
-
function ensureFbqFunction() {
|
|
529
|
-
const w = window;
|
|
530
|
-
if (typeof w.fbq === "function") return w.fbq;
|
|
531
|
-
const fbq = function(...args) {
|
|
532
|
-
if (fbq.callMethod) fbq.callMethod.apply(fbq, args);
|
|
533
|
-
else fbq.queue.push(args);
|
|
534
|
-
};
|
|
535
|
-
fbq.push = fbq;
|
|
536
|
-
fbq.loaded = true;
|
|
537
|
-
fbq.version = "2.0";
|
|
538
|
-
fbq.queue = [];
|
|
539
|
-
w.fbq = fbq;
|
|
540
|
-
if (!w._fbq) w._fbq = fbq;
|
|
541
|
-
return fbq;
|
|
542
|
-
}
|
|
543
|
-
function applyDefaultMetaConsentState() {
|
|
544
|
-
ensureFbqFunction()("consent", getConsentState() === "denied" ? "revoke" : "grant");
|
|
545
|
-
}
|
|
546
|
-
function loadFbeventsScript() {
|
|
547
|
-
if (typeof document === "undefined") return;
|
|
548
|
-
const marker = getScriptMarker2("fbq-loader");
|
|
549
|
-
const existing = document.querySelector(
|
|
550
|
-
`script[${TRACKING_SCRIPT_ATTRIBUTE}="${marker}"]`
|
|
551
|
-
);
|
|
552
|
-
if (existing) return;
|
|
553
|
-
const script = document.createElement("script");
|
|
554
|
-
script.async = true;
|
|
555
|
-
script.src = FB_EVENTS_SCRIPT_HOST;
|
|
556
|
-
script.setAttribute(TRACKING_SCRIPT_ATTRIBUTE, marker);
|
|
557
|
-
document.head.append(script);
|
|
558
|
-
}
|
|
559
|
-
function initializeMetaPixel(pixelId) {
|
|
560
|
-
const fbq = ensureFbqFunction();
|
|
561
|
-
fbq("init", pixelId);
|
|
562
|
-
fbq("track", "PageView");
|
|
563
|
-
}
|
|
564
|
-
function bootstrapMetaPixel(pixelId) {
|
|
565
|
-
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
566
|
-
if (!isValidMetaPixelId(pixelId)) return;
|
|
567
|
-
applyDefaultMetaConsentState();
|
|
568
|
-
loadFbeventsScript();
|
|
569
|
-
initializeMetaPixel(pixelId);
|
|
570
|
-
captureFbc();
|
|
571
|
-
}
|
|
572
|
-
function bootstrapMultiplePixels(pixelIds) {
|
|
573
|
-
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
574
|
-
const ids = Object.values(pixelIds).filter(
|
|
575
|
-
(id) => typeof id === "string" && isValidMetaPixelId(id)
|
|
576
|
-
);
|
|
577
|
-
if (ids.length === 0) return;
|
|
578
|
-
applyDefaultMetaConsentState();
|
|
579
|
-
loadFbeventsScript();
|
|
580
|
-
const fbq = ensureFbqFunction();
|
|
581
|
-
for (const id of ids) {
|
|
582
|
-
fbq("init", id);
|
|
583
|
-
}
|
|
584
|
-
fbq("track", "PageView");
|
|
585
|
-
captureFbc();
|
|
586
|
-
}
|
|
587
429
|
|
|
588
430
|
// ../tracking-core/src/landing.ts
|
|
589
431
|
var LANDING_STORAGE_KEY = "_aranova_track_landing";
|
|
@@ -858,9 +700,9 @@ function resolveConversionConfig(options) {
|
|
|
858
700
|
}
|
|
859
701
|
}
|
|
860
702
|
function notifyResolved() {
|
|
861
|
-
const
|
|
703
|
+
const listeners = [...resolveListeners];
|
|
862
704
|
resolveListeners.clear();
|
|
863
|
-
for (const listener of
|
|
705
|
+
for (const listener of listeners) {
|
|
864
706
|
try {
|
|
865
707
|
listener();
|
|
866
708
|
} catch {
|
|
@@ -1425,124 +1267,8 @@ function getTrackingConfigRuntime(ref, fetchImpl) {
|
|
|
1425
1267
|
return runtime;
|
|
1426
1268
|
}
|
|
1427
1269
|
|
|
1428
|
-
// ../tracking-core/src/resources/conversion-autofire.ts
|
|
1429
|
-
function currentPath() {
|
|
1430
|
-
return typeof window === "undefined" ? "" : window.location.pathname;
|
|
1431
|
-
}
|
|
1432
|
-
var MAX_BUFFERED_EVENTS = 50;
|
|
1433
|
-
function createConversionAutoFire(store) {
|
|
1434
|
-
const pending = [];
|
|
1435
|
-
let subscribed = false;
|
|
1436
|
-
function fireMatching(eventType, metadata, transactionScope) {
|
|
1437
|
-
for (const goal of store.listGoals()) {
|
|
1438
|
-
if (goal.kind !== "event" || !goal.firing) continue;
|
|
1439
|
-
if (!automaticThresholdMet(goal, eventType, metadata)) continue;
|
|
1440
|
-
const transactionId = getAutomaticTransactionId(transactionScope, goal.key, currentPath());
|
|
1441
|
-
if ("queueAutomaticEvent" in store) {
|
|
1442
|
-
store.fireConversion(goal.key, {
|
|
1443
|
-
transactionId
|
|
1444
|
-
});
|
|
1445
|
-
continue;
|
|
1446
|
-
}
|
|
1447
|
-
const firing = goal.firing;
|
|
1448
|
-
const cents = firing.value_cents ?? null;
|
|
1449
|
-
const currency = firing.currency ?? null;
|
|
1450
|
-
fireConversionWithConsent({
|
|
1451
|
-
sendTo: firing.send_to,
|
|
1452
|
-
value: cents != null && currency ? fromMinor(cents, currency) : null,
|
|
1453
|
-
currency,
|
|
1454
|
-
transactionId
|
|
1455
|
-
});
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
return {
|
|
1459
|
-
onAutomaticEvent(eventType, metadata, transactionScope) {
|
|
1460
|
-
if ("queueAutomaticEvent" in store) {
|
|
1461
|
-
store.queueAutomaticEvent(eventType, metadata, currentPath(), transactionScope);
|
|
1462
|
-
return;
|
|
1463
|
-
}
|
|
1464
|
-
if (store.isReady()) {
|
|
1465
|
-
fireMatching(eventType, metadata, transactionScope);
|
|
1466
|
-
return;
|
|
1467
|
-
}
|
|
1468
|
-
if (pending.length < MAX_BUFFERED_EVENTS) {
|
|
1469
|
-
pending.push({ eventType, metadata, transactionScope });
|
|
1470
|
-
}
|
|
1471
|
-
if (!subscribed) {
|
|
1472
|
-
subscribed = true;
|
|
1473
|
-
store.onResolve(() => {
|
|
1474
|
-
const buffered = pending.splice(0);
|
|
1475
|
-
for (const event of buffered) {
|
|
1476
|
-
fireMatching(event.eventType, event.metadata, event.transactionScope);
|
|
1477
|
-
}
|
|
1478
|
-
});
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
};
|
|
1482
|
-
}
|
|
1483
|
-
function withConversionAutoFire(client, autoFire) {
|
|
1484
|
-
return {
|
|
1485
|
-
...client,
|
|
1486
|
-
trackEvent: (input) => {
|
|
1487
|
-
client.trackEvent(input);
|
|
1488
|
-
try {
|
|
1489
|
-
autoFire.onAutomaticEvent(input.eventType, input.metadata ?? {}, client.getSessionId());
|
|
1490
|
-
} catch {
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
1270
|
// ../tracking-core/src/session.ts
|
|
1497
|
-
var VISITOR_STORAGE_KEY = "aranova_tracking_visitor";
|
|
1498
|
-
var SESSION_STORAGE_KEY = "aranova_tracking_session";
|
|
1499
1271
|
var SESSION_IDLE_MS = 30 * 60 * 1e3;
|
|
1500
|
-
function safeUuid() {
|
|
1501
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function")
|
|
1502
|
-
return crypto.randomUUID();
|
|
1503
|
-
return `${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}-${Math.random().toString(16).slice(2)}`;
|
|
1504
|
-
}
|
|
1505
|
-
function readLocalStorage(key) {
|
|
1506
|
-
try {
|
|
1507
|
-
return window.localStorage.getItem(key);
|
|
1508
|
-
} catch {
|
|
1509
|
-
return null;
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
function writeLocalStorage(key, value) {
|
|
1513
|
-
try {
|
|
1514
|
-
window.localStorage.setItem(key, value);
|
|
1515
|
-
} catch {
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
function getVisitorId() {
|
|
1519
|
-
if (typeof window === "undefined") return safeUuid();
|
|
1520
|
-
const existing = readLocalStorage(VISITOR_STORAGE_KEY);
|
|
1521
|
-
if (existing && existing.length > 0) return existing;
|
|
1522
|
-
const fresh = safeUuid();
|
|
1523
|
-
writeLocalStorage(VISITOR_STORAGE_KEY, fresh);
|
|
1524
|
-
return fresh;
|
|
1525
|
-
}
|
|
1526
|
-
function getOrRotateSessionId(now = Date.now()) {
|
|
1527
|
-
if (typeof window === "undefined") return { id: safeUuid(), isNew: true };
|
|
1528
|
-
const raw = readLocalStorage(SESSION_STORAGE_KEY);
|
|
1529
|
-
if (raw) {
|
|
1530
|
-
try {
|
|
1531
|
-
const parsed = JSON.parse(raw);
|
|
1532
|
-
if (typeof parsed.id === "string" && typeof parsed.last_event_at === "number") {
|
|
1533
|
-
if (now - parsed.last_event_at <= SESSION_IDLE_MS) {
|
|
1534
|
-
const refreshed = { id: parsed.id, last_event_at: now };
|
|
1535
|
-
writeLocalStorage(SESSION_STORAGE_KEY, JSON.stringify(refreshed));
|
|
1536
|
-
return { id: parsed.id, isNew: false };
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
} catch {
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
const fresh = { id: safeUuid(), last_event_at: now };
|
|
1543
|
-
writeLocalStorage(SESSION_STORAGE_KEY, JSON.stringify(fresh));
|
|
1544
|
-
return { id: fresh.id, isNew: true };
|
|
1545
|
-
}
|
|
1546
1272
|
|
|
1547
1273
|
// ../tracking-core/src/events/page-view.ts
|
|
1548
1274
|
import { z } from "zod";
|
|
@@ -1564,533 +1290,12 @@ var pageViewMetadataSchema = z.object({
|
|
|
1564
1290
|
}).strict();
|
|
1565
1291
|
var pageViewConfigSchema = z.object({}).strict();
|
|
1566
1292
|
|
|
1567
|
-
// ../tracking-core/src/page-view.ts
|
|
1568
|
-
var LAST_FIRED_URL_STORAGE_KEY = "aranova_tracking_last_fired_url";
|
|
1569
|
-
var lastFiredUrl = null;
|
|
1570
|
-
var lastFiredUrlHydrated = false;
|
|
1571
|
-
function readSessionStorage(key) {
|
|
1572
|
-
try {
|
|
1573
|
-
if (typeof window === "undefined") return null;
|
|
1574
|
-
return window.sessionStorage.getItem(key);
|
|
1575
|
-
} catch {
|
|
1576
|
-
return null;
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
function writeSessionStorage(key, value) {
|
|
1580
|
-
try {
|
|
1581
|
-
if (typeof window === "undefined") return;
|
|
1582
|
-
window.sessionStorage.setItem(key, value);
|
|
1583
|
-
} catch {
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
function getLastFiredUrl() {
|
|
1587
|
-
if (!lastFiredUrlHydrated) {
|
|
1588
|
-
lastFiredUrlHydrated = true;
|
|
1589
|
-
const stored = readSessionStorage(LAST_FIRED_URL_STORAGE_KEY);
|
|
1590
|
-
if (stored !== null) lastFiredUrl = stored;
|
|
1591
|
-
}
|
|
1592
|
-
return lastFiredUrl;
|
|
1593
|
-
}
|
|
1594
|
-
function setLastFiredUrl(url) {
|
|
1595
|
-
lastFiredUrl = url;
|
|
1596
|
-
lastFiredUrlHydrated = true;
|
|
1597
|
-
writeSessionStorage(LAST_FIRED_URL_STORAGE_KEY, url);
|
|
1598
|
-
}
|
|
1599
|
-
function buildPageViewMetadata(referrerOverride) {
|
|
1600
|
-
if (typeof window === "undefined" || typeof document === "undefined") return null;
|
|
1601
|
-
return pageViewMetadataSchema.parse({
|
|
1602
|
-
page: {
|
|
1603
|
-
title: document.title || null,
|
|
1604
|
-
path: window.location.pathname,
|
|
1605
|
-
search: window.location.search,
|
|
1606
|
-
hash: window.location.hash
|
|
1607
|
-
},
|
|
1608
|
-
referrer: referrerOverride !== void 0 ? referrerOverride : document.referrer || null,
|
|
1609
|
-
viewport: { w: window.innerWidth, h: window.innerHeight }
|
|
1610
|
-
});
|
|
1611
|
-
}
|
|
1612
|
-
function fireManualPageView(client) {
|
|
1613
|
-
if (typeof window === "undefined") return;
|
|
1614
|
-
const currentHref = window.location.href;
|
|
1615
|
-
const previousFiredUrl = getLastFiredUrl();
|
|
1616
|
-
const internalReferrer = previousFiredUrl !== null && previousFiredUrl !== currentHref ? previousFiredUrl : null;
|
|
1617
|
-
const externalReferrer = typeof document !== "undefined" ? document.referrer || null : null;
|
|
1618
|
-
const referrer = internalReferrer ?? externalReferrer;
|
|
1619
|
-
const metadata = buildPageViewMetadata(referrer);
|
|
1620
|
-
client.trackEvent({
|
|
1621
|
-
eventType: "page_view",
|
|
1622
|
-
pageUrl: currentHref,
|
|
1623
|
-
metadata
|
|
1624
|
-
});
|
|
1625
|
-
if (currentHref !== previousFiredUrl) {
|
|
1626
|
-
setLastFiredUrl(currentHref);
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
function attachBfcacheRestore(client) {
|
|
1630
|
-
if (typeof window === "undefined") return () => {
|
|
1631
|
-
};
|
|
1632
|
-
function handlePageShow(event) {
|
|
1633
|
-
if (!event.persisted) return;
|
|
1634
|
-
fireManualPageView(client);
|
|
1635
|
-
}
|
|
1636
|
-
window.addEventListener("pageshow", handlePageShow);
|
|
1637
|
-
return () => {
|
|
1638
|
-
window.removeEventListener("pageshow", handlePageShow);
|
|
1639
|
-
};
|
|
1640
|
-
}
|
|
1641
|
-
function attachAutoPageView(client, options = {}) {
|
|
1642
|
-
if (typeof window === "undefined" || typeof history === "undefined") {
|
|
1643
|
-
return () => {
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
let lastPath = window.location.pathname + window.location.search;
|
|
1647
|
-
function maybeFire() {
|
|
1648
|
-
const current = window.location.pathname + window.location.search;
|
|
1649
|
-
if (current === lastPath) return;
|
|
1650
|
-
lastPath = current;
|
|
1651
|
-
fireManualPageView(client);
|
|
1652
|
-
}
|
|
1653
|
-
const originalPushState = history.pushState.bind(history);
|
|
1654
|
-
const originalReplaceState = history.replaceState.bind(history);
|
|
1655
|
-
function patchedPushState(...args) {
|
|
1656
|
-
originalPushState(...args);
|
|
1657
|
-
setTimeout(maybeFire, 0);
|
|
1658
|
-
}
|
|
1659
|
-
function patchedReplaceState(...args) {
|
|
1660
|
-
originalReplaceState(...args);
|
|
1661
|
-
setTimeout(maybeFire, 0);
|
|
1662
|
-
}
|
|
1663
|
-
function handlePageShow(event) {
|
|
1664
|
-
if (!event.persisted) return;
|
|
1665
|
-
fireManualPageView(client);
|
|
1666
|
-
}
|
|
1667
|
-
history.pushState = patchedPushState;
|
|
1668
|
-
history.replaceState = patchedReplaceState;
|
|
1669
|
-
window.addEventListener("popstate", maybeFire);
|
|
1670
|
-
window.addEventListener("pageshow", handlePageShow);
|
|
1671
|
-
if (!options.skipInitial) fireManualPageView(client);
|
|
1672
|
-
return () => {
|
|
1673
|
-
history.pushState = originalPushState;
|
|
1674
|
-
history.replaceState = originalReplaceState;
|
|
1675
|
-
window.removeEventListener("popstate", maybeFire);
|
|
1676
|
-
window.removeEventListener("pageshow", handlePageShow);
|
|
1677
|
-
};
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
// ../tracking-core/src/heartbeat.ts
|
|
1681
|
-
function serializeValue(value) {
|
|
1682
|
-
if (value instanceof RegExp) return value.source;
|
|
1683
|
-
if (Array.isArray(value)) return value.map(serializeValue);
|
|
1684
|
-
if (value !== null && typeof value === "object") {
|
|
1685
|
-
const out = {};
|
|
1686
|
-
for (const [k, v] of Object.entries(value)) {
|
|
1687
|
-
out[k] = serializeValue(v);
|
|
1688
|
-
}
|
|
1689
|
-
return out;
|
|
1690
|
-
}
|
|
1691
|
-
return value;
|
|
1692
|
-
}
|
|
1693
|
-
function buildHeartbeatMetadata(surface, sdkVersion, packageName, triggers, gtagIds = null) {
|
|
1694
|
-
const automaticNames = triggers ? Object.keys(triggers.automatic) : [];
|
|
1695
|
-
const manualNames = triggers?.manual ? Object.keys(triggers.manual) : [];
|
|
1696
|
-
let triggerConfig = null;
|
|
1697
|
-
if (triggers) {
|
|
1698
|
-
const cfg = {};
|
|
1699
|
-
for (const [name, config] of Object.entries(triggers.automatic)) {
|
|
1700
|
-
const serialized = serializeValue(config);
|
|
1701
|
-
if (Object.keys(serialized).length > 0) {
|
|
1702
|
-
cfg[name] = serialized;
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
if (triggers.manual) {
|
|
1706
|
-
for (const [name, config] of Object.entries(triggers.manual)) {
|
|
1707
|
-
if (config === void 0) continue;
|
|
1708
|
-
const serialized = serializeValue(config);
|
|
1709
|
-
if (Object.keys(serialized).length > 0) {
|
|
1710
|
-
cfg[name] = serialized;
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
if (Object.keys(cfg).length > 0) {
|
|
1715
|
-
triggerConfig = cfg;
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
return {
|
|
1719
|
-
sdk_version: sdkVersion ?? "unknown",
|
|
1720
|
-
package_name: packageName,
|
|
1721
|
-
surface,
|
|
1722
|
-
triggers: {
|
|
1723
|
-
automatic: automaticNames,
|
|
1724
|
-
manual: manualNames
|
|
1725
|
-
},
|
|
1726
|
-
trigger_config: triggerConfig,
|
|
1727
|
-
configured_gtag_ids: gtagIds
|
|
1728
|
-
};
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
1293
|
// ../tracking-core/src/ingest.ts
|
|
1732
|
-
var DEFAULT_FLUSH_INTERVAL_MS = 2e3;
|
|
1733
|
-
var DEFAULT_MAX_QUEUE_SIZE = 10;
|
|
1734
|
-
var HARD_MAX_BATCH = 50;
|
|
1735
|
-
var MAX_RETRY_BACKOFF_MS = 6e4;
|
|
1736
|
-
var MAX_BUFFERED_EVENTS2 = 200;
|
|
1737
|
-
var RETRY_BUFFER_KEY_PREFIX = "aranova_tracking_pending_v1";
|
|
1738
1294
|
var API_KEY_HEADER = "X-Aranova-Api-Key";
|
|
1739
1295
|
var SDK_VERSION_HEADER = "X-Aranova-Sdk-Version";
|
|
1740
1296
|
var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
|
|
1741
1297
|
var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
|
|
1742
1298
|
var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
|
|
1743
|
-
function buildContext(surface, sdkVersion, packageName, environment, activeGtagIds) {
|
|
1744
|
-
return {
|
|
1745
|
-
surface,
|
|
1746
|
-
sdk_version: sdkVersion,
|
|
1747
|
-
package_name: packageName,
|
|
1748
|
-
site_origin: typeof window === "undefined" ? null : window.location.origin,
|
|
1749
|
-
page_title: typeof document === "undefined" ? null : document.title || null,
|
|
1750
|
-
referrer: typeof document === "undefined" ? null : document.referrer || null,
|
|
1751
|
-
environment,
|
|
1752
|
-
active_gtag_ids: activeGtagIds,
|
|
1753
|
-
// Rebuilt per flush (this runs inside the payload builder), so a client
|
|
1754
|
-
// constructed later on a deeper route still gets reported.
|
|
1755
|
-
capabilities: getRegisteredCapabilities()
|
|
1756
|
-
};
|
|
1757
|
-
}
|
|
1758
|
-
function readTrackingParams() {
|
|
1759
|
-
if (typeof window === "undefined") return createEmptyTrackingParams();
|
|
1760
|
-
try {
|
|
1761
|
-
captureTrackingParamsFromLocation();
|
|
1762
|
-
} catch {
|
|
1763
|
-
}
|
|
1764
|
-
return getTrackingParamsFromCookieReader(getCookieValueFromDocument);
|
|
1765
|
-
}
|
|
1766
|
-
function consentSnapshot() {
|
|
1767
|
-
try {
|
|
1768
|
-
const choice = getConsentChoice();
|
|
1769
|
-
return {
|
|
1770
|
-
state: choice.state,
|
|
1771
|
-
source: choice.source,
|
|
1772
|
-
updated_at: choice.updatedAt,
|
|
1773
|
-
expires_at: choice.expiresAt
|
|
1774
|
-
};
|
|
1775
|
-
} catch {
|
|
1776
|
-
return null;
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
async function postWithFetch(url, body, apiKey, identity, keepalive) {
|
|
1780
|
-
if (typeof fetch !== "function") return "drop";
|
|
1781
|
-
try {
|
|
1782
|
-
const response = await fetch(url, {
|
|
1783
|
-
method: "POST",
|
|
1784
|
-
headers: {
|
|
1785
|
-
"Content-Type": "application/json",
|
|
1786
|
-
[API_KEY_HEADER]: apiKey,
|
|
1787
|
-
[SDK_VERSION_HEADER]: identity.sdkVersion,
|
|
1788
|
-
[SDK_PACKAGE_HEADER]: identity.packageName,
|
|
1789
|
-
[SDK_SURFACE_HEADER]: identity.surface,
|
|
1790
|
-
[SDK_ENVIRONMENT_HEADER]: identity.environment
|
|
1791
|
-
},
|
|
1792
|
-
body,
|
|
1793
|
-
keepalive,
|
|
1794
|
-
// CORS is open on the tracking endpoint; never send cookies.
|
|
1795
|
-
credentials: "omit",
|
|
1796
|
-
mode: "cors"
|
|
1797
|
-
});
|
|
1798
|
-
if (response.ok) return "ok";
|
|
1799
|
-
if (response.status === 408 || response.status === 429 || response.status >= 500) {
|
|
1800
|
-
return "retry";
|
|
1801
|
-
}
|
|
1802
|
-
return "drop";
|
|
1803
|
-
} catch {
|
|
1804
|
-
return "retry";
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
function retryBufferKey(apiKey, endpoint) {
|
|
1808
|
-
return `${RETRY_BUFFER_KEY_PREFIX}:${apiKey}:${endpoint}`;
|
|
1809
|
-
}
|
|
1810
|
-
function readPendingBatches(key) {
|
|
1811
|
-
if (typeof window === "undefined") return [];
|
|
1812
|
-
try {
|
|
1813
|
-
const raw = window.localStorage.getItem(key);
|
|
1814
|
-
if (!raw) return [];
|
|
1815
|
-
const parsed = JSON.parse(raw);
|
|
1816
|
-
if (!Array.isArray(parsed)) return [];
|
|
1817
|
-
return parsed.filter(
|
|
1818
|
-
(entry) => typeof entry === "object" && entry !== null && "session" in entry && Array.isArray(entry.events)
|
|
1819
|
-
);
|
|
1820
|
-
} catch {
|
|
1821
|
-
return [];
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
function writePendingBatches(key, batches) {
|
|
1825
|
-
if (typeof window === "undefined") return;
|
|
1826
|
-
try {
|
|
1827
|
-
if (batches.length === 0) window.localStorage.removeItem(key);
|
|
1828
|
-
else window.localStorage.setItem(key, JSON.stringify(batches));
|
|
1829
|
-
} catch {
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
function trimToBufferCap(batches) {
|
|
1833
|
-
let total = batches.reduce((sum, batch) => sum + batch.events.length, 0);
|
|
1834
|
-
const trimmed = batches.slice();
|
|
1835
|
-
while (total > MAX_BUFFERED_EVENTS2 && trimmed.length > 1) {
|
|
1836
|
-
const dropped = trimmed.shift();
|
|
1837
|
-
total -= dropped ? dropped.events.length : 0;
|
|
1838
|
-
}
|
|
1839
|
-
return trimmed;
|
|
1840
|
-
}
|
|
1841
|
-
var globalClient = null;
|
|
1842
|
-
var globalClientKey = null;
|
|
1843
|
-
function clientConfigKey(config) {
|
|
1844
|
-
return `${config.apiKey}@${config.endpoint}#${config.surface}`;
|
|
1845
|
-
}
|
|
1846
|
-
function getOrCreateTrackingClient(config) {
|
|
1847
|
-
const key = clientConfigKey(config);
|
|
1848
|
-
if (globalClient !== null && globalClientKey === key) {
|
|
1849
|
-
return globalClient;
|
|
1850
|
-
}
|
|
1851
|
-
if (globalClient !== null) {
|
|
1852
|
-
globalClient.destroy();
|
|
1853
|
-
}
|
|
1854
|
-
globalClient = createTrackingClient(config);
|
|
1855
|
-
globalClientKey = key;
|
|
1856
|
-
return globalClient;
|
|
1857
|
-
}
|
|
1858
|
-
var clientCaptureRegistry = /* @__PURE__ */ new WeakMap();
|
|
1859
|
-
function attachClientCapturesOnce(client, build) {
|
|
1860
|
-
let entry = clientCaptureRegistry.get(client);
|
|
1861
|
-
if (entry === void 0) {
|
|
1862
|
-
entry = { detach: build(), refCount: 0 };
|
|
1863
|
-
clientCaptureRegistry.set(client, entry);
|
|
1864
|
-
}
|
|
1865
|
-
entry.refCount += 1;
|
|
1866
|
-
let released = false;
|
|
1867
|
-
return () => {
|
|
1868
|
-
if (released) return;
|
|
1869
|
-
released = true;
|
|
1870
|
-
const current = clientCaptureRegistry.get(client);
|
|
1871
|
-
if (current === void 0) return;
|
|
1872
|
-
current.refCount -= 1;
|
|
1873
|
-
if (current.refCount <= 0) {
|
|
1874
|
-
current.detach();
|
|
1875
|
-
clientCaptureRegistry.delete(client);
|
|
1876
|
-
}
|
|
1877
|
-
};
|
|
1878
|
-
}
|
|
1879
|
-
function createTrackingClient(config) {
|
|
1880
|
-
const flushIntervalMs = config.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;
|
|
1881
|
-
const maxQueueSize = Math.min(config.maxQueueSize ?? DEFAULT_MAX_QUEUE_SIZE, HARD_MAX_BATCH);
|
|
1882
|
-
const sdkVersion = config.sdkVersion ?? null;
|
|
1883
|
-
const packageName = config.packageName ?? null;
|
|
1884
|
-
const environment = config.environment ?? "production";
|
|
1885
|
-
const activeGtagIds = config.activeGtagIds ?? null;
|
|
1886
|
-
const endpointBase = config.endpoint.replace(/\/$/, "");
|
|
1887
|
-
const eventsUrl = `${endpointBase}/events`;
|
|
1888
|
-
const identityHeaders2 = {
|
|
1889
|
-
sdkVersion: sdkVersion ?? "",
|
|
1890
|
-
packageName: packageName ?? "",
|
|
1891
|
-
surface: config.surface,
|
|
1892
|
-
environment
|
|
1893
|
-
};
|
|
1894
|
-
let queue = [];
|
|
1895
|
-
let flushTimer = null;
|
|
1896
|
-
const bufferKey = retryBufferKey(config.apiKey, endpointBase);
|
|
1897
|
-
let pending = readPendingBatches(bufferKey);
|
|
1898
|
-
let flushChain = Promise.resolve();
|
|
1899
|
-
let retryAttempt = 0;
|
|
1900
|
-
let firstPage = null;
|
|
1901
|
-
let initialParams = createEmptyTrackingParams();
|
|
1902
|
-
let destroyed = false;
|
|
1903
|
-
const visitorId = getVisitorId();
|
|
1904
|
-
const initialSession = getOrRotateSessionId();
|
|
1905
|
-
let sessionId = initialSession.id;
|
|
1906
|
-
if (typeof window !== "undefined") {
|
|
1907
|
-
firstPage = window.location.href;
|
|
1908
|
-
try {
|
|
1909
|
-
initialParams = captureTrackingParamsFromLocation();
|
|
1910
|
-
} catch {
|
|
1911
|
-
}
|
|
1912
|
-
getOrCaptureLandingParams(sessionId);
|
|
1913
|
-
try {
|
|
1914
|
-
captureFbc();
|
|
1915
|
-
} catch {
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
function enqueueHeartbeat() {
|
|
1919
|
-
const metadata = buildHeartbeatMetadata(
|
|
1920
|
-
config.surface,
|
|
1921
|
-
sdkVersion,
|
|
1922
|
-
packageName,
|
|
1923
|
-
config.triggers ?? null,
|
|
1924
|
-
activeGtagIds
|
|
1925
|
-
);
|
|
1926
|
-
queue.push({
|
|
1927
|
-
event_type: "sdk_heartbeat",
|
|
1928
|
-
page_url: typeof window === "undefined" ? null : window.location.href,
|
|
1929
|
-
metadata,
|
|
1930
|
-
occurred_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1931
|
-
});
|
|
1932
|
-
}
|
|
1933
|
-
if (initialSession.isNew) {
|
|
1934
|
-
enqueueHeartbeat();
|
|
1935
|
-
}
|
|
1936
|
-
if (pending.length > 0) {
|
|
1937
|
-
scheduleFlush();
|
|
1938
|
-
}
|
|
1939
|
-
function buildSessionPayload() {
|
|
1940
|
-
const rotated = getOrRotateSessionId();
|
|
1941
|
-
if (rotated.isNew && rotated.id !== sessionId) {
|
|
1942
|
-
enqueueHeartbeat();
|
|
1943
|
-
}
|
|
1944
|
-
sessionId = rotated.id;
|
|
1945
|
-
const params = mergeTrackingParams(readTrackingParams(), initialParams);
|
|
1946
|
-
const context = buildContext(
|
|
1947
|
-
config.surface,
|
|
1948
|
-
sdkVersion,
|
|
1949
|
-
packageName,
|
|
1950
|
-
environment,
|
|
1951
|
-
activeGtagIds
|
|
1952
|
-
);
|
|
1953
|
-
return {
|
|
1954
|
-
session_id: sessionId,
|
|
1955
|
-
visitor_id: visitorId,
|
|
1956
|
-
gclid: params.gclid,
|
|
1957
|
-
wbraid: params.wbraid,
|
|
1958
|
-
gbraid: params.gbraid,
|
|
1959
|
-
ylpcid: params.ylpcid,
|
|
1960
|
-
fbclid: params.fbclid,
|
|
1961
|
-
fbc: getFbcCookie(),
|
|
1962
|
-
fbp: getFbpCookie(),
|
|
1963
|
-
utm_source: params.utm_source,
|
|
1964
|
-
utm_medium: params.utm_medium,
|
|
1965
|
-
utm_campaign: params.utm_campaign,
|
|
1966
|
-
utm_term: params.utm_term,
|
|
1967
|
-
utm_content: params.utm_content,
|
|
1968
|
-
// Landing params for the CURRENT session id — captured on the spot when
|
|
1969
|
-
// the session just rotated (the current URL is the rotated session's
|
|
1970
|
-
// landing), reused from the stored record otherwise. Keys are omitted
|
|
1971
|
-
// entirely when the landing isn't observable (SSR).
|
|
1972
|
-
...buildLandingPayloadFields(sessionId),
|
|
1973
|
-
first_page: firstPage,
|
|
1974
|
-
consent_state: consentSnapshot(),
|
|
1975
|
-
context
|
|
1976
|
-
};
|
|
1977
|
-
}
|
|
1978
|
-
function scheduleFlush(delayMs = flushIntervalMs) {
|
|
1979
|
-
if (flushTimer !== null || destroyed) return;
|
|
1980
|
-
flushTimer = setTimeout(() => {
|
|
1981
|
-
flushTimer = null;
|
|
1982
|
-
void flush();
|
|
1983
|
-
}, delayMs);
|
|
1984
|
-
}
|
|
1985
|
-
function clearScheduledFlush() {
|
|
1986
|
-
if (flushTimer !== null) {
|
|
1987
|
-
clearTimeout(flushTimer);
|
|
1988
|
-
flushTimer = null;
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
function bufferQueued() {
|
|
1992
|
-
if (queue.length === 0) return;
|
|
1993
|
-
const events = queue.slice(0, HARD_MAX_BATCH);
|
|
1994
|
-
queue = queue.slice(events.length);
|
|
1995
|
-
pending = trimToBufferCap([...pending, { session: buildSessionPayload(), events }]);
|
|
1996
|
-
writePendingBatches(bufferKey, pending);
|
|
1997
|
-
}
|
|
1998
|
-
function flush() {
|
|
1999
|
-
flushChain = flushChain.then(runFlush).catch(() => {
|
|
2000
|
-
});
|
|
2001
|
-
return flushChain;
|
|
2002
|
-
}
|
|
2003
|
-
async function runFlush() {
|
|
2004
|
-
if (destroyed) return;
|
|
2005
|
-
clearScheduledFlush();
|
|
2006
|
-
bufferQueued();
|
|
2007
|
-
if (pending.length === 0) return;
|
|
2008
|
-
try {
|
|
2009
|
-
while (pending.length > 0) {
|
|
2010
|
-
const batch = pending[0];
|
|
2011
|
-
const body = { session: batch.session, events: batch.events };
|
|
2012
|
-
const outcome = await postWithFetch(
|
|
2013
|
-
eventsUrl,
|
|
2014
|
-
JSON.stringify(body),
|
|
2015
|
-
config.apiKey,
|
|
2016
|
-
identityHeaders2,
|
|
2017
|
-
false
|
|
2018
|
-
);
|
|
2019
|
-
if (outcome === "retry") {
|
|
2020
|
-
retryAttempt += 1;
|
|
2021
|
-
return;
|
|
2022
|
-
}
|
|
2023
|
-
pending = pending.slice(1);
|
|
2024
|
-
writePendingBatches(bufferKey, pending);
|
|
2025
|
-
retryAttempt = 0;
|
|
2026
|
-
}
|
|
2027
|
-
} finally {
|
|
2028
|
-
if (pending.length > 0) {
|
|
2029
|
-
const backoff = Math.min(flushIntervalMs * 2 ** retryAttempt, MAX_RETRY_BACKOFF_MS);
|
|
2030
|
-
scheduleFlush(backoff);
|
|
2031
|
-
} else if (queue.length > 0) {
|
|
2032
|
-
scheduleFlush();
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
function trackEvent(input) {
|
|
2037
|
-
if (destroyed) return;
|
|
2038
|
-
if (!input || typeof input.eventType !== "string" || input.eventType.length === 0) return;
|
|
2039
|
-
if (input.eventType === "form_submit" && getConsentState() !== "denied") {
|
|
2040
|
-
try {
|
|
2041
|
-
const fields = input.metadata?.form?.fields;
|
|
2042
|
-
if (fields) stashUserDataFromFormFields(fields, config.phone?.defaultCountry);
|
|
2043
|
-
} catch {
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
const occurredAt = input.occurredAt instanceof Date ? input.occurredAt.toISOString() : typeof input.occurredAt === "string" ? input.occurredAt : (/* @__PURE__ */ new Date()).toISOString();
|
|
2047
|
-
queue.push({
|
|
2048
|
-
event_type: input.eventType,
|
|
2049
|
-
page_url: input.pageUrl ?? (typeof window === "undefined" ? null : window.location.href),
|
|
2050
|
-
metadata: input.metadata ?? null,
|
|
2051
|
-
occurred_at: occurredAt
|
|
2052
|
-
});
|
|
2053
|
-
if (queue.length >= maxQueueSize) {
|
|
2054
|
-
void flush();
|
|
2055
|
-
} else {
|
|
2056
|
-
scheduleFlush();
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
2059
|
-
function flushOnUnload() {
|
|
2060
|
-
bufferQueued();
|
|
2061
|
-
clearScheduledFlush();
|
|
2062
|
-
if (pending.length === 0) return;
|
|
2063
|
-
const batch = pending[0];
|
|
2064
|
-
pending = pending.slice(1);
|
|
2065
|
-
writePendingBatches(bufferKey, pending);
|
|
2066
|
-
const body = { session: batch.session, events: batch.events };
|
|
2067
|
-
void postWithFetch(eventsUrl, JSON.stringify(body), config.apiKey, identityHeaders2, true);
|
|
2068
|
-
}
|
|
2069
|
-
if (typeof window !== "undefined") {
|
|
2070
|
-
window.addEventListener("pagehide", flushOnUnload);
|
|
2071
|
-
window.addEventListener("visibilitychange", () => {
|
|
2072
|
-
if (document.visibilityState === "hidden") flushOnUnload();
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2075
|
-
return {
|
|
2076
|
-
trackEvent,
|
|
2077
|
-
flush,
|
|
2078
|
-
flushBeacon: flushOnUnload,
|
|
2079
|
-
getSessionId: () => sessionId,
|
|
2080
|
-
getVisitorId: () => visitorId,
|
|
2081
|
-
destroy: () => {
|
|
2082
|
-
destroyed = true;
|
|
2083
|
-
if (queue.length > 0) {
|
|
2084
|
-
flushOnUnload();
|
|
2085
|
-
}
|
|
2086
|
-
clearScheduledFlush();
|
|
2087
|
-
queue = [];
|
|
2088
|
-
if (typeof window !== "undefined") {
|
|
2089
|
-
window.removeEventListener("pagehide", flushOnUnload);
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
};
|
|
2093
|
-
}
|
|
2094
1299
|
|
|
2095
1300
|
// ../tracking-core/src/events/cta-click.ts
|
|
2096
1301
|
import { z as z2 } from "zod";
|
|
@@ -2419,641 +1624,6 @@ var EVENT_REGISTRY = {
|
|
|
2419
1624
|
var ALL_AUTOMATIC_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "automatic").map(([name]) => name);
|
|
2420
1625
|
var ALL_MANUAL_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.kind === "manual").map(([name]) => name);
|
|
2421
1626
|
var ALL_LEAD_EVENT_NAMES = Object.entries(EVENT_REGISTRY).filter(([, def]) => def.semantics.outcomeRole === "lead").map(([name]) => name);
|
|
2422
|
-
function getEventDefinition(name) {
|
|
2423
|
-
return EVENT_REGISTRY[name];
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2426
|
-
// ../tracking-core/src/ingest-typed.ts
|
|
2427
|
-
function createTypedClient(raw, registry, options = {}) {
|
|
2428
|
-
const debug = options.debug ?? false;
|
|
2429
|
-
if (registry.manual?.form_submit) registerCapability("form_capture");
|
|
2430
|
-
return {
|
|
2431
|
-
trackEvent(eventType, metadata, opts) {
|
|
2432
|
-
if (debug) {
|
|
2433
|
-
const def = getEventDefinition(eventType);
|
|
2434
|
-
def.metadataSchema.parse(metadata);
|
|
2435
|
-
}
|
|
2436
|
-
raw.trackEvent({
|
|
2437
|
-
eventType,
|
|
2438
|
-
metadata,
|
|
2439
|
-
pageUrl: opts?.pageUrl ?? null,
|
|
2440
|
-
occurredAt: opts?.occurredAt ?? null
|
|
2441
|
-
});
|
|
2442
|
-
},
|
|
2443
|
-
flush: raw.flush.bind(raw),
|
|
2444
|
-
getSessionId: raw.getSessionId.bind(raw),
|
|
2445
|
-
getVisitorId: raw.getVisitorId.bind(raw)
|
|
2446
|
-
};
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
|
-
// ../tracking-core/src/triggers/time-on-site.ts
|
|
2450
|
-
function attachTimeOnSite(client, config) {
|
|
2451
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2452
|
-
return () => {
|
|
2453
|
-
};
|
|
2454
|
-
}
|
|
2455
|
-
const thresholdMs = config.thresholdSeconds * 1e3;
|
|
2456
|
-
let accumulatedMs = 0;
|
|
2457
|
-
let activeSince = document.visibilityState === "visible" ? Date.now() : null;
|
|
2458
|
-
let timer = null;
|
|
2459
|
-
let fired = false;
|
|
2460
|
-
function fire() {
|
|
2461
|
-
if (fired) return;
|
|
2462
|
-
fired = true;
|
|
2463
|
-
client.trackEvent({
|
|
2464
|
-
eventType: "time_on_site",
|
|
2465
|
-
metadata: {
|
|
2466
|
-
duration_ms: thresholdMs,
|
|
2467
|
-
page: { path: window.location.pathname }
|
|
2468
|
-
},
|
|
2469
|
-
pageUrl: window.location.href,
|
|
2470
|
-
occurredAt: null
|
|
2471
|
-
});
|
|
2472
|
-
}
|
|
2473
|
-
function scheduleNext() {
|
|
2474
|
-
if (fired || activeSince === null) return;
|
|
2475
|
-
const remaining = thresholdMs - accumulatedMs;
|
|
2476
|
-
if (remaining <= 0) {
|
|
2477
|
-
fire();
|
|
2478
|
-
return;
|
|
2479
|
-
}
|
|
2480
|
-
timer = setTimeout(fire, remaining);
|
|
2481
|
-
}
|
|
2482
|
-
function clearTimer() {
|
|
2483
|
-
if (timer !== null) {
|
|
2484
|
-
clearTimeout(timer);
|
|
2485
|
-
timer = null;
|
|
2486
|
-
}
|
|
2487
|
-
}
|
|
2488
|
-
function onVisibilityChange() {
|
|
2489
|
-
if (fired) return;
|
|
2490
|
-
if (document.visibilityState === "hidden") {
|
|
2491
|
-
if (activeSince !== null) {
|
|
2492
|
-
accumulatedMs += Date.now() - activeSince;
|
|
2493
|
-
activeSince = null;
|
|
2494
|
-
}
|
|
2495
|
-
clearTimer();
|
|
2496
|
-
} else {
|
|
2497
|
-
activeSince = Date.now();
|
|
2498
|
-
scheduleNext();
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
2502
|
-
scheduleNext();
|
|
2503
|
-
return () => {
|
|
2504
|
-
clearTimer();
|
|
2505
|
-
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2506
|
-
};
|
|
2507
|
-
}
|
|
2508
|
-
|
|
2509
|
-
// ../tracking-core/src/triggers/specific-page-visit.ts
|
|
2510
|
-
function attachSpecificPageVisit(client, config) {
|
|
2511
|
-
if (typeof window === "undefined" || typeof history === "undefined") {
|
|
2512
|
-
return () => {
|
|
2513
|
-
};
|
|
2514
|
-
}
|
|
2515
|
-
const { pages } = config;
|
|
2516
|
-
const firedSet = /* @__PURE__ */ new Set();
|
|
2517
|
-
function check() {
|
|
2518
|
-
const path = window.location.pathname;
|
|
2519
|
-
for (const { name, pathPattern } of pages) {
|
|
2520
|
-
pathPattern.lastIndex = 0;
|
|
2521
|
-
if (!pathPattern.test(path)) continue;
|
|
2522
|
-
const key = `${name}:${path}`;
|
|
2523
|
-
if (firedSet.has(key)) continue;
|
|
2524
|
-
firedSet.add(key);
|
|
2525
|
-
client.trackEvent({
|
|
2526
|
-
eventType: "specific_page_visit",
|
|
2527
|
-
metadata: { page_name: name, page: { path } },
|
|
2528
|
-
pageUrl: window.location.href,
|
|
2529
|
-
occurredAt: null
|
|
2530
|
-
});
|
|
2531
|
-
}
|
|
2532
|
-
}
|
|
2533
|
-
const originalPushState = history.pushState.bind(history);
|
|
2534
|
-
const originalReplaceState = history.replaceState.bind(history);
|
|
2535
|
-
function patchedPushState(...args) {
|
|
2536
|
-
originalPushState(...args);
|
|
2537
|
-
setTimeout(check, 0);
|
|
2538
|
-
}
|
|
2539
|
-
function patchedReplaceState(...args) {
|
|
2540
|
-
originalReplaceState(...args);
|
|
2541
|
-
setTimeout(check, 0);
|
|
2542
|
-
}
|
|
2543
|
-
history.pushState = patchedPushState;
|
|
2544
|
-
history.replaceState = patchedReplaceState;
|
|
2545
|
-
window.addEventListener("popstate", check);
|
|
2546
|
-
check();
|
|
2547
|
-
return () => {
|
|
2548
|
-
history.pushState = originalPushState;
|
|
2549
|
-
history.replaceState = originalReplaceState;
|
|
2550
|
-
window.removeEventListener("popstate", check);
|
|
2551
|
-
};
|
|
2552
|
-
}
|
|
2553
|
-
|
|
2554
|
-
// ../tracking-core/src/triggers/navigation.ts
|
|
2555
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
2556
|
-
var restorePatch = null;
|
|
2557
|
-
function notify() {
|
|
2558
|
-
for (const listener of listeners) listener();
|
|
2559
|
-
}
|
|
2560
|
-
function notifyDeferred() {
|
|
2561
|
-
setTimeout(notify, 0);
|
|
2562
|
-
}
|
|
2563
|
-
function installPatch() {
|
|
2564
|
-
const originalPushState = history.pushState;
|
|
2565
|
-
const originalReplaceState = history.replaceState;
|
|
2566
|
-
function patchedPushState(...args) {
|
|
2567
|
-
originalPushState.apply(this, args);
|
|
2568
|
-
notifyDeferred();
|
|
2569
|
-
}
|
|
2570
|
-
function patchedReplaceState(...args) {
|
|
2571
|
-
originalReplaceState.apply(this, args);
|
|
2572
|
-
notifyDeferred();
|
|
2573
|
-
}
|
|
2574
|
-
history.pushState = patchedPushState;
|
|
2575
|
-
history.replaceState = patchedReplaceState;
|
|
2576
|
-
window.addEventListener("popstate", notify);
|
|
2577
|
-
restorePatch = () => {
|
|
2578
|
-
history.pushState = originalPushState;
|
|
2579
|
-
history.replaceState = originalReplaceState;
|
|
2580
|
-
window.removeEventListener("popstate", notify);
|
|
2581
|
-
restorePatch = null;
|
|
2582
|
-
};
|
|
2583
|
-
}
|
|
2584
|
-
function onHistoryChange(listener) {
|
|
2585
|
-
if (listeners.size === 0) installPatch();
|
|
2586
|
-
listeners.add(listener);
|
|
2587
|
-
return () => {
|
|
2588
|
-
if (!listeners.delete(listener)) return;
|
|
2589
|
-
if (listeners.size === 0) restorePatch?.();
|
|
2590
|
-
};
|
|
2591
|
-
}
|
|
2592
|
-
|
|
2593
|
-
// ../tracking-core/src/triggers/scroll-measurement.ts
|
|
2594
|
-
var BOTTOM_EPSILON_PX = 2;
|
|
2595
|
-
function measureScrollPercent() {
|
|
2596
|
-
const root = document.scrollingElement ?? document.documentElement;
|
|
2597
|
-
const scrollHeight = root.scrollHeight;
|
|
2598
|
-
const clientHeight = root.clientHeight;
|
|
2599
|
-
if (scrollHeight <= 0 || clientHeight <= 0) return null;
|
|
2600
|
-
if (scrollHeight <= clientHeight + BOTTOM_EPSILON_PX) return null;
|
|
2601
|
-
const maxTop = scrollHeight - clientHeight;
|
|
2602
|
-
const scrollTop = Math.min(Math.max(root.scrollTop, 0), maxTop);
|
|
2603
|
-
if (scrollTop + clientHeight >= scrollHeight - BOTTOM_EPSILON_PX) return 100;
|
|
2604
|
-
return Math.max(1, Math.min(100, Math.round((scrollTop + clientHeight) / scrollHeight * 100)));
|
|
2605
|
-
}
|
|
2606
|
-
function scheduleBaselineSnapshot(onSnapshot) {
|
|
2607
|
-
let rafId = requestAnimationFrame(() => {
|
|
2608
|
-
rafId = requestAnimationFrame(() => {
|
|
2609
|
-
onSnapshot(measureScrollPercent());
|
|
2610
|
-
});
|
|
2611
|
-
});
|
|
2612
|
-
return () => cancelAnimationFrame(rafId);
|
|
2613
|
-
}
|
|
2614
|
-
function createBaselineGate() {
|
|
2615
|
-
let baselinePercent = null;
|
|
2616
|
-
let ready = false;
|
|
2617
|
-
let cancelSnapshot = null;
|
|
2618
|
-
return {
|
|
2619
|
-
rebaseline() {
|
|
2620
|
-
cancelSnapshot?.();
|
|
2621
|
-
ready = false;
|
|
2622
|
-
baselinePercent = null;
|
|
2623
|
-
cancelSnapshot = scheduleBaselineSnapshot((b) => {
|
|
2624
|
-
baselinePercent = b;
|
|
2625
|
-
ready = true;
|
|
2626
|
-
});
|
|
2627
|
-
},
|
|
2628
|
-
cancel() {
|
|
2629
|
-
cancelSnapshot?.();
|
|
2630
|
-
},
|
|
2631
|
-
baseline() {
|
|
2632
|
-
return ready ? baselinePercent : null;
|
|
2633
|
-
},
|
|
2634
|
-
sample() {
|
|
2635
|
-
if (!ready) return null;
|
|
2636
|
-
if (baselinePercent === null) {
|
|
2637
|
-
baselinePercent = measureScrollPercent();
|
|
2638
|
-
return null;
|
|
2639
|
-
}
|
|
2640
|
-
return measureScrollPercent();
|
|
2641
|
-
}
|
|
2642
|
-
};
|
|
2643
|
-
}
|
|
2644
|
-
|
|
2645
|
-
// ../tracking-core/src/triggers/scroll-depth.ts
|
|
2646
|
-
function attachScrollDepth(client, config) {
|
|
2647
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2648
|
-
return () => {
|
|
2649
|
-
};
|
|
2650
|
-
}
|
|
2651
|
-
const thresholds = new Set(config.thresholds);
|
|
2652
|
-
let firedForPath = /* @__PURE__ */ new Set();
|
|
2653
|
-
let currentPath2 = window.location.pathname;
|
|
2654
|
-
let rafId = null;
|
|
2655
|
-
const gate = createBaselineGate();
|
|
2656
|
-
function checkThresholds() {
|
|
2657
|
-
const percent = gate.sample();
|
|
2658
|
-
if (percent === null) return;
|
|
2659
|
-
const baseline = gate.baseline();
|
|
2660
|
-
if (baseline === null) return;
|
|
2661
|
-
for (const threshold of thresholds) {
|
|
2662
|
-
if (threshold <= baseline) continue;
|
|
2663
|
-
if (percent >= threshold && !firedForPath.has(threshold)) {
|
|
2664
|
-
firedForPath.add(threshold);
|
|
2665
|
-
client.trackEvent({
|
|
2666
|
-
eventType: "scroll_depth",
|
|
2667
|
-
metadata: {
|
|
2668
|
-
depth_percent: threshold,
|
|
2669
|
-
page: { path: currentPath2 }
|
|
2670
|
-
},
|
|
2671
|
-
pageUrl: window.location.href,
|
|
2672
|
-
occurredAt: null
|
|
2673
|
-
});
|
|
2674
|
-
}
|
|
2675
|
-
}
|
|
2676
|
-
}
|
|
2677
|
-
function onScroll() {
|
|
2678
|
-
if (rafId !== null) return;
|
|
2679
|
-
rafId = requestAnimationFrame(() => {
|
|
2680
|
-
rafId = null;
|
|
2681
|
-
checkThresholds();
|
|
2682
|
-
});
|
|
2683
|
-
}
|
|
2684
|
-
function resetIfPathChanged() {
|
|
2685
|
-
const newPath = window.location.pathname;
|
|
2686
|
-
if (newPath === currentPath2) return;
|
|
2687
|
-
currentPath2 = newPath;
|
|
2688
|
-
firedForPath = /* @__PURE__ */ new Set();
|
|
2689
|
-
gate.rebaseline();
|
|
2690
|
-
}
|
|
2691
|
-
const unsubscribeNav = onHistoryChange(resetIfPathChanged);
|
|
2692
|
-
window.addEventListener("scroll", onScroll, { passive: true });
|
|
2693
|
-
gate.rebaseline();
|
|
2694
|
-
return () => {
|
|
2695
|
-
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
2696
|
-
gate.cancel();
|
|
2697
|
-
unsubscribeNav();
|
|
2698
|
-
window.removeEventListener("scroll", onScroll);
|
|
2699
|
-
};
|
|
2700
|
-
}
|
|
2701
|
-
|
|
2702
|
-
// ../tracking-core/src/triggers/multi-page-session.ts
|
|
2703
|
-
var STORAGE_KEY2 = "aranova_tracking_mps_paths";
|
|
2704
|
-
var SESSION_KEY = "aranova_tracking_mps_session";
|
|
2705
|
-
var FIRED_KEY = "aranova_tracking_mps_fired";
|
|
2706
|
-
function getSessionStorage() {
|
|
2707
|
-
try {
|
|
2708
|
-
return typeof window !== "undefined" ? window.sessionStorage : null;
|
|
2709
|
-
} catch {
|
|
2710
|
-
return null;
|
|
2711
|
-
}
|
|
2712
|
-
}
|
|
2713
|
-
function attachMultiPageSession(client, config) {
|
|
2714
|
-
if (typeof window === "undefined" || typeof history === "undefined") {
|
|
2715
|
-
return () => {
|
|
2716
|
-
};
|
|
2717
|
-
}
|
|
2718
|
-
const storage = getSessionStorage();
|
|
2719
|
-
if (!storage) return () => {
|
|
2720
|
-
};
|
|
2721
|
-
const { pageThreshold } = config;
|
|
2722
|
-
let lastCheckedPath = "";
|
|
2723
|
-
function getDistinctPaths() {
|
|
2724
|
-
try {
|
|
2725
|
-
const raw = storage.getItem(STORAGE_KEY2);
|
|
2726
|
-
return raw ? new Set(JSON.parse(raw)) : /* @__PURE__ */ new Set();
|
|
2727
|
-
} catch {
|
|
2728
|
-
return /* @__PURE__ */ new Set();
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
function saveDistinctPaths(paths) {
|
|
2732
|
-
try {
|
|
2733
|
-
storage.setItem(STORAGE_KEY2, JSON.stringify([...paths]));
|
|
2734
|
-
} catch {
|
|
2735
|
-
}
|
|
2736
|
-
}
|
|
2737
|
-
function resetIfSessionChanged() {
|
|
2738
|
-
const currentSession = getOrRotateSessionId().id;
|
|
2739
|
-
const storedSession = storage.getItem(SESSION_KEY);
|
|
2740
|
-
if (storedSession !== currentSession) {
|
|
2741
|
-
storage.setItem(SESSION_KEY, currentSession);
|
|
2742
|
-
storage.removeItem(STORAGE_KEY2);
|
|
2743
|
-
storage.removeItem(FIRED_KEY);
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
function hasFired() {
|
|
2747
|
-
return storage.getItem(FIRED_KEY) === "1";
|
|
2748
|
-
}
|
|
2749
|
-
function check() {
|
|
2750
|
-
const currentPath2 = window.location.pathname;
|
|
2751
|
-
if (currentPath2 === lastCheckedPath) return;
|
|
2752
|
-
lastCheckedPath = currentPath2;
|
|
2753
|
-
resetIfSessionChanged();
|
|
2754
|
-
if (hasFired()) return;
|
|
2755
|
-
const paths = getDistinctPaths();
|
|
2756
|
-
paths.add(currentPath2);
|
|
2757
|
-
saveDistinctPaths(paths);
|
|
2758
|
-
if (paths.size >= pageThreshold) {
|
|
2759
|
-
storage.setItem(FIRED_KEY, "1");
|
|
2760
|
-
client.trackEvent({
|
|
2761
|
-
eventType: "multi_page_session",
|
|
2762
|
-
metadata: {
|
|
2763
|
-
page_count: paths.size,
|
|
2764
|
-
page: { path: window.location.pathname }
|
|
2765
|
-
},
|
|
2766
|
-
pageUrl: window.location.href,
|
|
2767
|
-
occurredAt: null
|
|
2768
|
-
});
|
|
2769
|
-
}
|
|
2770
|
-
}
|
|
2771
|
-
const originalPushState = history.pushState.bind(history);
|
|
2772
|
-
const originalReplaceState = history.replaceState.bind(history);
|
|
2773
|
-
function patchedPushState(...args) {
|
|
2774
|
-
originalPushState(...args);
|
|
2775
|
-
setTimeout(check, 0);
|
|
2776
|
-
}
|
|
2777
|
-
function patchedReplaceState(...args) {
|
|
2778
|
-
originalReplaceState(...args);
|
|
2779
|
-
setTimeout(check, 0);
|
|
2780
|
-
}
|
|
2781
|
-
history.pushState = patchedPushState;
|
|
2782
|
-
history.replaceState = patchedReplaceState;
|
|
2783
|
-
window.addEventListener("popstate", check);
|
|
2784
|
-
check();
|
|
2785
|
-
return () => {
|
|
2786
|
-
history.pushState = originalPushState;
|
|
2787
|
-
history.replaceState = originalReplaceState;
|
|
2788
|
-
window.removeEventListener("popstate", check);
|
|
2789
|
-
};
|
|
2790
|
-
}
|
|
2791
|
-
|
|
2792
|
-
// ../tracking-core/src/triggers/form-start.ts
|
|
2793
|
-
function attachFormStart(client, config) {
|
|
2794
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2795
|
-
return () => {
|
|
2796
|
-
};
|
|
2797
|
-
}
|
|
2798
|
-
const selector = config.selector ?? "form";
|
|
2799
|
-
let firedForms = /* @__PURE__ */ new Set();
|
|
2800
|
-
let currentPath2 = window.location.pathname;
|
|
2801
|
-
function getFormKey(form) {
|
|
2802
|
-
if (form.id) return `id:${form.id}`;
|
|
2803
|
-
const explicitAction = form.getAttribute("action");
|
|
2804
|
-
if (explicitAction) return `action:${explicitAction}`;
|
|
2805
|
-
const forms = Array.from(document.querySelectorAll(selector));
|
|
2806
|
-
return `index:${forms.indexOf(form)}`;
|
|
2807
|
-
}
|
|
2808
|
-
function onFocusIn(event) {
|
|
2809
|
-
const target = event.target;
|
|
2810
|
-
if (!(target instanceof HTMLElement)) return;
|
|
2811
|
-
const form = target.closest(selector);
|
|
2812
|
-
if (!form || form.tagName !== "FORM") return;
|
|
2813
|
-
const key = getFormKey(form);
|
|
2814
|
-
if (firedForms.has(key)) return;
|
|
2815
|
-
firedForms.add(key);
|
|
2816
|
-
client.trackEvent({
|
|
2817
|
-
eventType: "form_start",
|
|
2818
|
-
metadata: {
|
|
2819
|
-
form: {
|
|
2820
|
-
id: form.id || "",
|
|
2821
|
-
action: form.getAttribute("action") ?? null
|
|
2822
|
-
},
|
|
2823
|
-
page: { path: window.location.pathname }
|
|
2824
|
-
},
|
|
2825
|
-
pageUrl: window.location.href,
|
|
2826
|
-
occurredAt: null
|
|
2827
|
-
});
|
|
2828
|
-
}
|
|
2829
|
-
function resetIfPathChanged() {
|
|
2830
|
-
const newPath = window.location.pathname;
|
|
2831
|
-
if (newPath === currentPath2) return;
|
|
2832
|
-
currentPath2 = newPath;
|
|
2833
|
-
firedForms = /* @__PURE__ */ new Set();
|
|
2834
|
-
}
|
|
2835
|
-
const originalPushState = history.pushState.bind(history);
|
|
2836
|
-
const originalReplaceState = history.replaceState.bind(history);
|
|
2837
|
-
function patchedPushState(...args) {
|
|
2838
|
-
originalPushState(...args);
|
|
2839
|
-
setTimeout(resetIfPathChanged, 0);
|
|
2840
|
-
}
|
|
2841
|
-
function patchedReplaceState(...args) {
|
|
2842
|
-
originalReplaceState(...args);
|
|
2843
|
-
setTimeout(resetIfPathChanged, 0);
|
|
2844
|
-
}
|
|
2845
|
-
history.pushState = patchedPushState;
|
|
2846
|
-
history.replaceState = patchedReplaceState;
|
|
2847
|
-
window.addEventListener("popstate", resetIfPathChanged);
|
|
2848
|
-
document.addEventListener("focusin", onFocusIn);
|
|
2849
|
-
return () => {
|
|
2850
|
-
history.pushState = originalPushState;
|
|
2851
|
-
history.replaceState = originalReplaceState;
|
|
2852
|
-
window.removeEventListener("popstate", resetIfPathChanged);
|
|
2853
|
-
document.removeEventListener("focusin", onFocusIn);
|
|
2854
|
-
};
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2857
|
-
// ../tracking-core/src/triggers/page-exit.ts
|
|
2858
|
-
var MIN_SEGMENT_MS = 50;
|
|
2859
|
-
function attachPageExit(client) {
|
|
2860
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2861
|
-
return () => {
|
|
2862
|
-
};
|
|
2863
|
-
}
|
|
2864
|
-
let currentPath2 = window.location.pathname;
|
|
2865
|
-
let activeSince = document.visibilityState === "visible" ? Date.now() : null;
|
|
2866
|
-
let accumulatedMs = 0;
|
|
2867
|
-
let maxScrollPercent = null;
|
|
2868
|
-
let rafId = null;
|
|
2869
|
-
const gate = createBaselineGate();
|
|
2870
|
-
function onScroll() {
|
|
2871
|
-
if (rafId !== null) return;
|
|
2872
|
-
rafId = requestAnimationFrame(() => {
|
|
2873
|
-
rafId = null;
|
|
2874
|
-
const percent = gate.sample();
|
|
2875
|
-
if (percent !== null && (maxScrollPercent === null || percent > maxScrollPercent)) {
|
|
2876
|
-
maxScrollPercent = percent;
|
|
2877
|
-
}
|
|
2878
|
-
});
|
|
2879
|
-
}
|
|
2880
|
-
function settledDwellMs() {
|
|
2881
|
-
let total = accumulatedMs;
|
|
2882
|
-
if (activeSince !== null) {
|
|
2883
|
-
total += Date.now() - activeSince;
|
|
2884
|
-
}
|
|
2885
|
-
return Math.max(0, Math.round(total));
|
|
2886
|
-
}
|
|
2887
|
-
function emitSegment(path, flush) {
|
|
2888
|
-
const dwell = settledDwellMs();
|
|
2889
|
-
if (dwell < MIN_SEGMENT_MS) return;
|
|
2890
|
-
client.trackEvent({
|
|
2891
|
-
eventType: "page_exit",
|
|
2892
|
-
metadata: {
|
|
2893
|
-
dwell_ms: dwell,
|
|
2894
|
-
max_scroll_percent: maxScrollPercent,
|
|
2895
|
-
// Lets the backend tell "scrolled to the bottom" apart from "the page
|
|
2896
|
-
// was barely scrollable". null = unscrollable page or the segment
|
|
2897
|
-
// ended before the post-paint snapshot landed. For pages that grew
|
|
2898
|
-
// after the snapshot this is the first-scroll position, not the
|
|
2899
|
-
// at-load fraction (see BaselineGate.baseline).
|
|
2900
|
-
scroll_baseline_percent: gate.baseline(),
|
|
2901
|
-
page: { path }
|
|
2902
|
-
},
|
|
2903
|
-
pageUrl: window.location.href,
|
|
2904
|
-
occurredAt: null
|
|
2905
|
-
});
|
|
2906
|
-
if (flush) {
|
|
2907
|
-
client.flushBeacon();
|
|
2908
|
-
}
|
|
2909
|
-
accumulatedMs = 0;
|
|
2910
|
-
activeSince = null;
|
|
2911
|
-
}
|
|
2912
|
-
function onNavigate() {
|
|
2913
|
-
const newPath = window.location.pathname;
|
|
2914
|
-
if (newPath === currentPath2) return;
|
|
2915
|
-
emitSegment(currentPath2, false);
|
|
2916
|
-
currentPath2 = newPath;
|
|
2917
|
-
maxScrollPercent = null;
|
|
2918
|
-
gate.rebaseline();
|
|
2919
|
-
accumulatedMs = 0;
|
|
2920
|
-
activeSince = document.visibilityState === "visible" ? Date.now() : null;
|
|
2921
|
-
}
|
|
2922
|
-
function onVisibilityChange() {
|
|
2923
|
-
if (document.visibilityState === "hidden") {
|
|
2924
|
-
emitSegment(currentPath2, true);
|
|
2925
|
-
} else {
|
|
2926
|
-
activeSince = Date.now();
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
function onPageHide() {
|
|
2930
|
-
emitSegment(currentPath2, true);
|
|
2931
|
-
}
|
|
2932
|
-
const unsubscribeNav = onHistoryChange(onNavigate);
|
|
2933
|
-
window.addEventListener("scroll", onScroll, { passive: true });
|
|
2934
|
-
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
2935
|
-
window.addEventListener("pagehide", onPageHide);
|
|
2936
|
-
gate.rebaseline();
|
|
2937
|
-
return () => {
|
|
2938
|
-
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
2939
|
-
gate.cancel();
|
|
2940
|
-
unsubscribeNav();
|
|
2941
|
-
window.removeEventListener("scroll", onScroll);
|
|
2942
|
-
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2943
|
-
window.removeEventListener("pagehide", onPageHide);
|
|
2944
|
-
};
|
|
2945
|
-
}
|
|
2946
|
-
|
|
2947
|
-
// ../tracking-core/src/triggers/cta-click-capture.ts
|
|
2948
|
-
var DEFAULT_CTA_SELECTOR = "[data-aranova-cta]";
|
|
2949
|
-
var CTA_NAME_MAX_LENGTH = 120;
|
|
2950
|
-
function describeElement(el) {
|
|
2951
|
-
const tag = el.tagName.toLowerCase();
|
|
2952
|
-
return el.id ? `${tag}#${el.id}` : tag;
|
|
2953
|
-
}
|
|
2954
|
-
function resolveCtaName(el) {
|
|
2955
|
-
const explicit = el.getAttribute("data-aranova-cta");
|
|
2956
|
-
if (explicit && explicit.trim().length > 0) return explicit.trim();
|
|
2957
|
-
const text = (el.textContent ?? "").trim().replaceAll(/\s+/g, " ");
|
|
2958
|
-
if (text.length > 0) return text.slice(0, CTA_NAME_MAX_LENGTH);
|
|
2959
|
-
return describeElement(el);
|
|
2960
|
-
}
|
|
2961
|
-
function attachCtaClickCapture(client, config) {
|
|
2962
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2963
|
-
return () => {
|
|
2964
|
-
};
|
|
2965
|
-
}
|
|
2966
|
-
const autoCapture = config.autoCapture;
|
|
2967
|
-
if (!autoCapture) {
|
|
2968
|
-
return () => {
|
|
2969
|
-
};
|
|
2970
|
-
}
|
|
2971
|
-
registerCapability("cta_click_capture");
|
|
2972
|
-
const selector = autoCapture.selector ?? DEFAULT_CTA_SELECTOR;
|
|
2973
|
-
function onClick(event) {
|
|
2974
|
-
const target = event.target;
|
|
2975
|
-
if (!(target instanceof Element)) return;
|
|
2976
|
-
let matched = null;
|
|
2977
|
-
try {
|
|
2978
|
-
matched = target.closest(selector);
|
|
2979
|
-
} catch {
|
|
2980
|
-
return;
|
|
2981
|
-
}
|
|
2982
|
-
if (matched === null) return;
|
|
2983
|
-
const href = matched instanceof HTMLAnchorElement ? matched.href || null : matched.getAttribute("href");
|
|
2984
|
-
client.trackEvent({
|
|
2985
|
-
eventType: "cta_click",
|
|
2986
|
-
metadata: {
|
|
2987
|
-
cta_name: resolveCtaName(matched),
|
|
2988
|
-
page: { path: window.location.pathname },
|
|
2989
|
-
section: matched.getAttribute("data-aranova-section"),
|
|
2990
|
-
destination_url: href,
|
|
2991
|
-
href,
|
|
2992
|
-
element: describeElement(matched)
|
|
2993
|
-
},
|
|
2994
|
-
pageUrl: window.location.href,
|
|
2995
|
-
occurredAt: null
|
|
2996
|
-
});
|
|
2997
|
-
}
|
|
2998
|
-
document.addEventListener("click", onClick, true);
|
|
2999
|
-
return () => {
|
|
3000
|
-
document.removeEventListener("click", onClick, true);
|
|
3001
|
-
};
|
|
3002
|
-
}
|
|
3003
|
-
|
|
3004
|
-
// ../tracking-core/src/triggers/phone-click-capture.ts
|
|
3005
|
-
var DEFAULT_TEL_SELECTOR = 'a[href^="tel:"]';
|
|
3006
|
-
function safeDecodeURIComponent(value) {
|
|
3007
|
-
try {
|
|
3008
|
-
return decodeURIComponent(value);
|
|
3009
|
-
} catch {
|
|
3010
|
-
return value;
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
function resolvePhoneNumber(el) {
|
|
3014
|
-
const href = el instanceof HTMLAnchorElement ? el.href : el.getAttribute("href") ?? "";
|
|
3015
|
-
const raw = safeDecodeURIComponent(href.replace(/^tel:/i, "").split(";")[0]).trim();
|
|
3016
|
-
return toE164(raw) ?? raw;
|
|
3017
|
-
}
|
|
3018
|
-
function attachPhoneClickCapture(client, config) {
|
|
3019
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
3020
|
-
return () => {
|
|
3021
|
-
};
|
|
3022
|
-
}
|
|
3023
|
-
const autoCapture = config.autoCapture;
|
|
3024
|
-
if (!autoCapture) {
|
|
3025
|
-
return () => {
|
|
3026
|
-
};
|
|
3027
|
-
}
|
|
3028
|
-
registerCapability("phone_click_capture");
|
|
3029
|
-
const selector = autoCapture.selector ?? DEFAULT_TEL_SELECTOR;
|
|
3030
|
-
function onClick(event) {
|
|
3031
|
-
const target = event.target;
|
|
3032
|
-
if (!(target instanceof Element)) return;
|
|
3033
|
-
let matched = null;
|
|
3034
|
-
try {
|
|
3035
|
-
matched = target.closest(selector);
|
|
3036
|
-
} catch {
|
|
3037
|
-
return;
|
|
3038
|
-
}
|
|
3039
|
-
if (matched === null) return;
|
|
3040
|
-
const metadata = {
|
|
3041
|
-
phone_number: resolvePhoneNumber(matched),
|
|
3042
|
-
page: { path: window.location.pathname },
|
|
3043
|
-
section: matched.getAttribute("data-aranova-section")
|
|
3044
|
-
};
|
|
3045
|
-
client.trackEvent({
|
|
3046
|
-
eventType: "phone_click",
|
|
3047
|
-
metadata,
|
|
3048
|
-
pageUrl: window.location.href,
|
|
3049
|
-
occurredAt: null
|
|
3050
|
-
});
|
|
3051
|
-
}
|
|
3052
|
-
document.addEventListener("click", onClick, true);
|
|
3053
|
-
return () => {
|
|
3054
|
-
document.removeEventListener("click", onClick, true);
|
|
3055
|
-
};
|
|
3056
|
-
}
|
|
3057
1627
|
|
|
3058
1628
|
// ../tracking-core/src/resources/http/errors.ts
|
|
3059
1629
|
var AranovaApiError = class extends Error {
|
|
@@ -3424,597 +1994,12 @@ function phoneField(name, raw, country) {
|
|
|
3424
1994
|
return { name, type: "phone", value: toE164(raw, country) };
|
|
3425
1995
|
}
|
|
3426
1996
|
|
|
3427
|
-
// src/
|
|
3428
|
-
function useGclid() {
|
|
3429
|
-
const [gclid, setGclid] = useState(null);
|
|
3430
|
-
useEffect(() => {
|
|
3431
|
-
setGclid(getCookieValueFromDocument("gclid"));
|
|
3432
|
-
}, []);
|
|
3433
|
-
return gclid;
|
|
3434
|
-
}
|
|
3435
|
-
function useTrackingParams() {
|
|
3436
|
-
const [trackingParams, setTrackingParams] = useState(createEmptyTrackingParams());
|
|
3437
|
-
useEffect(() => {
|
|
3438
|
-
setTrackingParams(getTrackingParamsFromCookieReader(getCookieValueFromDocument));
|
|
3439
|
-
}, []);
|
|
3440
|
-
return trackingParams;
|
|
3441
|
-
}
|
|
3442
|
-
var DEFAULT_CHOICE2 = {
|
|
3443
|
-
state: "granted",
|
|
3444
|
-
source: "default",
|
|
3445
|
-
updatedAt: null,
|
|
3446
|
-
expiresAt: null
|
|
3447
|
-
};
|
|
3448
|
-
function useCookiePreferences(options) {
|
|
3449
|
-
registerCapability("consent_controls");
|
|
3450
|
-
const [choice, setChoice] = useState(DEFAULT_CHOICE2);
|
|
3451
|
-
const ttlDays = options?.declineTtlDays;
|
|
3452
|
-
useEffect(() => {
|
|
3453
|
-
const sync = () => setChoice(getConsentChoice());
|
|
3454
|
-
sync();
|
|
3455
|
-
const handleStorage = (event) => {
|
|
3456
|
-
if (event.key === null || event.key === CONSENT_STATE_KEY || event.key === CONSENT_EXPIRES_AT_KEY || event.key === CONSENT_TIMESTAMP_KEY)
|
|
3457
|
-
sync();
|
|
3458
|
-
};
|
|
3459
|
-
window.addEventListener("storage", handleStorage);
|
|
3460
|
-
const unsubscribe = onConsentChange(sync);
|
|
3461
|
-
return () => {
|
|
3462
|
-
window.removeEventListener("storage", handleStorage);
|
|
3463
|
-
unsubscribe();
|
|
3464
|
-
};
|
|
3465
|
-
}, []);
|
|
3466
|
-
const optOutAction = useCallback(() => {
|
|
3467
|
-
optOut(ttlDays != null ? { declineTtlDays: ttlDays } : void 0);
|
|
3468
|
-
}, [ttlDays]);
|
|
3469
|
-
const optInAction = useCallback(() => {
|
|
3470
|
-
optIn();
|
|
3471
|
-
}, []);
|
|
3472
|
-
const reset = useCallback(() => {
|
|
3473
|
-
resetConsent();
|
|
3474
|
-
}, []);
|
|
3475
|
-
return {
|
|
3476
|
-
state: choice.state,
|
|
3477
|
-
source: choice.source,
|
|
3478
|
-
isDefault: choice.source === "default",
|
|
3479
|
-
isGranted: choice.state === "granted",
|
|
3480
|
-
isDenied: choice.state === "denied",
|
|
3481
|
-
updatedAt: choice.updatedAt,
|
|
3482
|
-
expiresAt: choice.expiresAt,
|
|
3483
|
-
optOut: optOutAction,
|
|
3484
|
-
optIn: optInAction,
|
|
3485
|
-
reset
|
|
3486
|
-
};
|
|
3487
|
-
}
|
|
3488
|
-
function useConsentState() {
|
|
3489
|
-
return useConsent().state;
|
|
3490
|
-
}
|
|
3491
|
-
function useConsent() {
|
|
3492
|
-
const {
|
|
3493
|
-
state,
|
|
3494
|
-
isGranted,
|
|
3495
|
-
isDenied,
|
|
3496
|
-
optIn: accept,
|
|
3497
|
-
optOut: decline,
|
|
3498
|
-
reset
|
|
3499
|
-
} = useCookiePreferences();
|
|
3500
|
-
return {
|
|
3501
|
-
state,
|
|
3502
|
-
isPending: false,
|
|
3503
|
-
isGranted,
|
|
3504
|
-
isDenied,
|
|
3505
|
-
accept,
|
|
3506
|
-
decline,
|
|
3507
|
-
reset
|
|
3508
|
-
};
|
|
3509
|
-
}
|
|
3510
|
-
|
|
3511
|
-
// src/ConsentBanner.tsx
|
|
3512
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3513
|
-
var LIGHT_THEME = {
|
|
3514
|
-
background: "#ffffff",
|
|
3515
|
-
border: "#e5e7eb",
|
|
3516
|
-
text: "#111827",
|
|
3517
|
-
mutedText: "#4b5563",
|
|
3518
|
-
acceptBg: "#111827",
|
|
3519
|
-
acceptText: "#ffffff",
|
|
3520
|
-
declineBg: "transparent",
|
|
3521
|
-
declineText: "#111827",
|
|
3522
|
-
declineBorder: "#d1d5db",
|
|
3523
|
-
shadow: "0 -4px 16px -2px rgba(15, 23, 42, 0.08), 0 -2px 6px -1px rgba(15, 23, 42, 0.04)",
|
|
3524
|
-
linkColor: "#1f2937"
|
|
3525
|
-
};
|
|
3526
|
-
var DARK_THEME = {
|
|
3527
|
-
background: "#0f172a",
|
|
3528
|
-
border: "#1e293b",
|
|
3529
|
-
text: "#f1f5f9",
|
|
3530
|
-
mutedText: "#cbd5e1",
|
|
3531
|
-
acceptBg: "#f1f5f9",
|
|
3532
|
-
acceptText: "#0f172a",
|
|
3533
|
-
declineBg: "transparent",
|
|
3534
|
-
declineText: "#f1f5f9",
|
|
3535
|
-
declineBorder: "#334155",
|
|
3536
|
-
shadow: "0 -4px 16px -2px rgba(0, 0, 0, 0.5), 0 -2px 6px -1px rgba(0, 0, 0, 0.3)",
|
|
3537
|
-
linkColor: "#e2e8f0"
|
|
3538
|
-
};
|
|
3539
|
-
function useResolvedTheme(theme) {
|
|
3540
|
-
const [prefersDark, setPrefersDark] = useState2(false);
|
|
3541
|
-
useEffect2(() => {
|
|
3542
|
-
if (theme !== "auto" || typeof window === "undefined" || !window.matchMedia) return;
|
|
3543
|
-
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
3544
|
-
setPrefersDark(mql.matches);
|
|
3545
|
-
const onChange = (e) => setPrefersDark(e.matches);
|
|
3546
|
-
mql.addEventListener("change", onChange);
|
|
3547
|
-
return () => mql.removeEventListener("change", onChange);
|
|
3548
|
-
}, [theme]);
|
|
3549
|
-
if (theme === "dark") return DARK_THEME;
|
|
3550
|
-
if (theme === "auto" && prefersDark) return DARK_THEME;
|
|
3551
|
-
return LIGHT_THEME;
|
|
3552
|
-
}
|
|
3553
|
-
var DEFAULT_MESSAGE = "We use cookies to understand ad performance and improve how our marketing works across visits. You can accept or decline this tracking.";
|
|
3554
|
-
function ConsentBanner({
|
|
3555
|
-
message,
|
|
3556
|
-
title,
|
|
3557
|
-
acceptLabel = "Accept",
|
|
3558
|
-
declineLabel = "Decline",
|
|
3559
|
-
policyHref,
|
|
3560
|
-
policyLabel = "Learn more",
|
|
3561
|
-
onAccept,
|
|
3562
|
-
onDecline,
|
|
3563
|
-
position = "bottom",
|
|
3564
|
-
theme = "light",
|
|
3565
|
-
className,
|
|
3566
|
-
style
|
|
3567
|
-
} = {}) {
|
|
3568
|
-
const { isPending, accept, decline } = useConsent();
|
|
3569
|
-
const tokens = useResolvedTheme(theme);
|
|
3570
|
-
const [hasMounted, setHasMounted] = useState2(false);
|
|
3571
|
-
useEffect2(() => {
|
|
3572
|
-
setHasMounted(true);
|
|
3573
|
-
}, []);
|
|
3574
|
-
if (!hasMounted || !isPending) return null;
|
|
3575
|
-
const wrapperStyle = {
|
|
3576
|
-
position: "fixed",
|
|
3577
|
-
left: 0,
|
|
3578
|
-
right: 0,
|
|
3579
|
-
[position]: 0,
|
|
3580
|
-
zIndex: 2147483640,
|
|
3581
|
-
background: tokens.background,
|
|
3582
|
-
color: tokens.text,
|
|
3583
|
-
borderTop: position === "bottom" ? `1px solid ${tokens.border}` : "none",
|
|
3584
|
-
borderBottom: position === "top" ? `1px solid ${tokens.border}` : "none",
|
|
3585
|
-
boxShadow: tokens.shadow,
|
|
3586
|
-
padding: "16px 20px",
|
|
3587
|
-
boxSizing: "border-box",
|
|
3588
|
-
animation: `${ANIMATION_NAME}-${position} 200ms ease-out`,
|
|
3589
|
-
fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
3590
|
-
...style
|
|
3591
|
-
};
|
|
3592
|
-
const innerStyle = {
|
|
3593
|
-
maxWidth: 1100,
|
|
3594
|
-
margin: "0 auto",
|
|
3595
|
-
display: "flex",
|
|
3596
|
-
flexWrap: "wrap",
|
|
3597
|
-
gap: 16,
|
|
3598
|
-
alignItems: "center",
|
|
3599
|
-
justifyContent: "space-between"
|
|
3600
|
-
};
|
|
3601
|
-
const messageStyle = {
|
|
3602
|
-
flex: "1 1 320px",
|
|
3603
|
-
margin: 0,
|
|
3604
|
-
fontSize: 14,
|
|
3605
|
-
lineHeight: 1.5,
|
|
3606
|
-
color: tokens.mutedText
|
|
3607
|
-
};
|
|
3608
|
-
const titleStyle = {
|
|
3609
|
-
margin: "0 0 4px 0",
|
|
3610
|
-
fontSize: 14,
|
|
3611
|
-
fontWeight: 600,
|
|
3612
|
-
color: tokens.text
|
|
3613
|
-
};
|
|
3614
|
-
const actionsStyle = {
|
|
3615
|
-
display: "flex",
|
|
3616
|
-
gap: 8,
|
|
3617
|
-
flexShrink: 0
|
|
3618
|
-
};
|
|
3619
|
-
const buttonBase = {
|
|
3620
|
-
appearance: "none",
|
|
3621
|
-
fontFamily: "inherit",
|
|
3622
|
-
fontSize: 14,
|
|
3623
|
-
fontWeight: 500,
|
|
3624
|
-
padding: "8px 16px",
|
|
3625
|
-
borderRadius: 6,
|
|
3626
|
-
cursor: "pointer",
|
|
3627
|
-
border: "1px solid transparent",
|
|
3628
|
-
transition: "opacity 120ms ease"
|
|
3629
|
-
};
|
|
3630
|
-
const declineStyle = {
|
|
3631
|
-
...buttonBase,
|
|
3632
|
-
background: tokens.declineBg,
|
|
3633
|
-
color: tokens.declineText,
|
|
3634
|
-
borderColor: tokens.declineBorder
|
|
3635
|
-
};
|
|
3636
|
-
const acceptStyle = {
|
|
3637
|
-
...buttonBase,
|
|
3638
|
-
background: tokens.acceptBg,
|
|
3639
|
-
color: tokens.acceptText
|
|
3640
|
-
};
|
|
3641
|
-
const linkStyle = {
|
|
3642
|
-
color: tokens.linkColor,
|
|
3643
|
-
textDecoration: "underline",
|
|
3644
|
-
textUnderlineOffset: 2
|
|
3645
|
-
};
|
|
3646
|
-
const handleAccept = () => {
|
|
3647
|
-
accept();
|
|
3648
|
-
onAccept?.();
|
|
3649
|
-
};
|
|
3650
|
-
const handleDecline = () => {
|
|
3651
|
-
decline();
|
|
3652
|
-
onDecline?.();
|
|
3653
|
-
};
|
|
3654
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3655
|
-
/* @__PURE__ */ jsx("style", { children: ANIMATION_KEYFRAMES }),
|
|
3656
|
-
/* @__PURE__ */ jsx(
|
|
3657
|
-
"div",
|
|
3658
|
-
{
|
|
3659
|
-
role: "dialog",
|
|
3660
|
-
"aria-live": "polite",
|
|
3661
|
-
"aria-label": "Cookie consent",
|
|
3662
|
-
className,
|
|
3663
|
-
style: wrapperStyle,
|
|
3664
|
-
children: /* @__PURE__ */ jsxs("div", { style: innerStyle, children: [
|
|
3665
|
-
/* @__PURE__ */ jsxs("div", { style: { flex: "1 1 320px" }, children: [
|
|
3666
|
-
title ? /* @__PURE__ */ jsx("p", { style: titleStyle, children: title }) : null,
|
|
3667
|
-
/* @__PURE__ */ jsxs("p", { style: messageStyle, children: [
|
|
3668
|
-
message ?? DEFAULT_MESSAGE,
|
|
3669
|
-
policyHref ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3670
|
-
" ",
|
|
3671
|
-
/* @__PURE__ */ jsx("a", { href: policyHref, style: linkStyle, children: policyLabel })
|
|
3672
|
-
] }) : null
|
|
3673
|
-
] })
|
|
3674
|
-
] }),
|
|
3675
|
-
/* @__PURE__ */ jsxs("div", { style: actionsStyle, children: [
|
|
3676
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: handleDecline, style: declineStyle, children: declineLabel }),
|
|
3677
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: handleAccept, style: acceptStyle, children: acceptLabel })
|
|
3678
|
-
] })
|
|
3679
|
-
] })
|
|
3680
|
-
}
|
|
3681
|
-
)
|
|
3682
|
-
] });
|
|
3683
|
-
}
|
|
3684
|
-
var ANIMATION_NAME = "aranova-consent-banner";
|
|
3685
|
-
var ANIMATION_KEYFRAMES = `
|
|
3686
|
-
@keyframes ${ANIMATION_NAME}-bottom {
|
|
3687
|
-
from { transform: translateY(100%); opacity: 0; }
|
|
3688
|
-
to { transform: translateY(0); opacity: 1; }
|
|
3689
|
-
}
|
|
3690
|
-
@keyframes ${ANIMATION_NAME}-top {
|
|
3691
|
-
from { transform: translateY(-100%); opacity: 0; }
|
|
3692
|
-
to { transform: translateY(0); opacity: 1; }
|
|
3693
|
-
}
|
|
3694
|
-
`;
|
|
3695
|
-
|
|
3696
|
-
// src/AdPlatformTracking.tsx
|
|
3697
|
-
import { useEffect as useEffect3, useMemo } from "react";
|
|
3698
|
-
function AdPlatformTracking({
|
|
3699
|
-
gtagId,
|
|
3700
|
-
gtagIds,
|
|
3701
|
-
trackingConfig,
|
|
3702
|
-
standalonePageView = false,
|
|
3703
|
-
metaPixelId,
|
|
3704
|
-
metaPixelIds
|
|
3705
|
-
}) {
|
|
3706
|
-
const trackingConfigKey2 = trackingConfig ? `${resolveTrackingConfigUrl(trackingConfig)}:${trackingConfig.businessId}:${trackingConfig.environment}` : "";
|
|
3707
|
-
const gtagIdsKey = useMemo(() => gtagIds ? JSON.stringify(gtagIds) : "", [gtagIds]);
|
|
3708
|
-
const metaPixelIdsKey = useMemo(
|
|
3709
|
-
() => metaPixelIds ? JSON.stringify(metaPixelIds) : "",
|
|
3710
|
-
[metaPixelIds]
|
|
3711
|
-
);
|
|
3712
|
-
if (trackingConfig || gtagId || gtagIds && Object.keys(gtagIds).length > 0) {
|
|
3713
|
-
registerCapability("ad_tags_google");
|
|
3714
|
-
}
|
|
3715
|
-
if (metaPixelId || metaPixelIds && Object.keys(metaPixelIds).length > 0) {
|
|
3716
|
-
registerCapability("ad_tags_meta");
|
|
3717
|
-
}
|
|
3718
|
-
useEffect3(() => {
|
|
3719
|
-
if (trackingConfig) {
|
|
3720
|
-
const runtime = getTrackingConfigRuntime(trackingConfig);
|
|
3721
|
-
if (standalonePageView) runtime.queuePageView();
|
|
3722
|
-
else void runtime.revalidate();
|
|
3723
|
-
} else if (gtagIds && Object.keys(gtagIds).length > 0) {
|
|
3724
|
-
bootstrapMultipleGtags(gtagIds);
|
|
3725
|
-
} else if (gtagId) {
|
|
3726
|
-
bootstrapGoogleAdsTracking(gtagId);
|
|
3727
|
-
}
|
|
3728
|
-
}, [gtagId, gtagIdsKey, trackingConfigKey2, standalonePageView]);
|
|
3729
|
-
useEffect3(() => {
|
|
3730
|
-
if (metaPixelIds && Object.keys(metaPixelIds).length > 0) {
|
|
3731
|
-
bootstrapMultiplePixels(metaPixelIds);
|
|
3732
|
-
} else if (metaPixelId) {
|
|
3733
|
-
bootstrapMetaPixel(metaPixelId);
|
|
3734
|
-
}
|
|
3735
|
-
}, [metaPixelId, metaPixelIdsKey]);
|
|
3736
|
-
return null;
|
|
3737
|
-
}
|
|
3738
|
-
|
|
3739
|
-
// src/GoogleAdsTracking.tsx
|
|
3740
|
-
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
3741
|
-
function GoogleAdsTracking(props) {
|
|
3742
|
-
const { gtagId, gtagIds } = props;
|
|
3743
|
-
const gtagIdsKey = useMemo2(() => gtagIds ? JSON.stringify(gtagIds) : "", [gtagIds]);
|
|
3744
|
-
useEffect4(() => {
|
|
3745
|
-
if (gtagIds && Object.keys(gtagIds).length > 0) {
|
|
3746
|
-
bootstrapMultipleGtags(gtagIds);
|
|
3747
|
-
} else if (gtagId) {
|
|
3748
|
-
bootstrapGoogleAdsTracking(gtagId);
|
|
3749
|
-
}
|
|
3750
|
-
}, [gtagId, gtagIdsKey]);
|
|
3751
|
-
return null;
|
|
3752
|
-
}
|
|
3753
|
-
|
|
3754
|
-
// src/factory.tsx
|
|
3755
|
-
import { createContext as createContext2, useContext as useContext2, useEffect as useEffect5, useMemo as useMemo4 } from "react";
|
|
3756
|
-
|
|
3757
|
-
// package.json
|
|
3758
|
-
var version = "0.24.0";
|
|
3759
|
-
|
|
3760
|
-
// ../tracking-core/src/phone-react.tsx
|
|
1997
|
+
// src/index.ts
|
|
3761
1998
|
import {
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
useMemo as useMemo3,
|
|
3767
|
-
useState as useState3
|
|
3768
|
-
} from "react";
|
|
3769
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
3770
|
-
var _phoneConfigContext;
|
|
3771
|
-
function phoneConfigContext() {
|
|
3772
|
-
return _phoneConfigContext ?? (_phoneConfigContext = createContext(null));
|
|
3773
|
-
}
|
|
3774
|
-
function PhoneConfigProvider({
|
|
3775
|
-
value,
|
|
3776
|
-
children
|
|
3777
|
-
}) {
|
|
3778
|
-
const Ctx = phoneConfigContext();
|
|
3779
|
-
return /* @__PURE__ */ jsx2(Ctx.Provider, { value, children });
|
|
3780
|
-
}
|
|
3781
|
-
function usePhoneConfig() {
|
|
3782
|
-
const ctx = useContext(phoneConfigContext());
|
|
3783
|
-
return {
|
|
3784
|
-
defaultCountry: ctx?.defaultCountry ?? DEFAULT_PHONE_COUNTRY,
|
|
3785
|
-
display: ctx?.display ?? "national"
|
|
3786
|
-
};
|
|
3787
|
-
}
|
|
3788
|
-
function usePhoneField(opts = {}) {
|
|
3789
|
-
registerCapability("phone_fields");
|
|
3790
|
-
const cfg = usePhoneConfig();
|
|
3791
|
-
const country = opts.country ?? cfg.defaultCountry;
|
|
3792
|
-
const display = opts.display ?? cfg.display;
|
|
3793
|
-
const { onValueChange } = opts;
|
|
3794
|
-
const [value, setValue] = useState3(() => formatPhoneAsTyped(opts.defaultValue ?? "", country));
|
|
3795
|
-
const [touched, setTouched] = useState3(false);
|
|
3796
|
-
const parsed = useMemo3(() => parsePhone(value, country), [value, country]);
|
|
3797
|
-
const onChange = useCallback2(
|
|
3798
|
-
(event) => {
|
|
3799
|
-
const next = formatPhoneAsTyped(event.target.value, country);
|
|
3800
|
-
setValue(next);
|
|
3801
|
-
onValueChange?.(parsePhone(next, country).e164);
|
|
3802
|
-
},
|
|
3803
|
-
[country, onValueChange]
|
|
3804
|
-
);
|
|
3805
|
-
const onBlur = useCallback2(
|
|
3806
|
-
(_event) => {
|
|
3807
|
-
setTouched(true);
|
|
3808
|
-
setValue((current) => {
|
|
3809
|
-
const p = parsePhone(current, country);
|
|
3810
|
-
return p.isValid ? formatPhone(current, display, country) : current;
|
|
3811
|
-
});
|
|
3812
|
-
},
|
|
3813
|
-
[country, display]
|
|
3814
|
-
);
|
|
3815
|
-
const error = touched && value.length > 0 && !parsed.isValid ? "Enter a valid phone number" : null;
|
|
3816
|
-
return {
|
|
3817
|
-
value,
|
|
3818
|
-
e164: parsed.e164,
|
|
3819
|
-
isValid: parsed.isValid,
|
|
3820
|
-
error,
|
|
3821
|
-
parsed,
|
|
3822
|
-
inputProps: { value, onChange, onBlur, type: "tel", inputMode: "tel", autoComplete: "tel" }
|
|
3823
|
-
};
|
|
3824
|
-
}
|
|
3825
|
-
var PhoneField = forwardRef(function PhoneField2({ country, value, defaultValue, onChange, onE164Change, ...rest }, ref) {
|
|
3826
|
-
const cfg = usePhoneConfig();
|
|
3827
|
-
const resolvedCountry = country ?? cfg.defaultCountry;
|
|
3828
|
-
const isControlled = value !== void 0;
|
|
3829
|
-
const [internal, setInternal] = useState3(
|
|
3830
|
-
() => formatPhoneAsTyped(defaultValue ?? "", resolvedCountry)
|
|
3831
|
-
);
|
|
3832
|
-
const handleChange = (event) => {
|
|
3833
|
-
const formatted = formatPhoneAsTyped(event.target.value, resolvedCountry);
|
|
3834
|
-
event.target.value = formatted;
|
|
3835
|
-
onE164Change?.(parsePhone(formatted, resolvedCountry).e164);
|
|
3836
|
-
if (!isControlled) setInternal(formatted);
|
|
3837
|
-
onChange?.(event);
|
|
3838
|
-
};
|
|
3839
|
-
const shown = isControlled ? formatPhoneAsTyped(value, resolvedCountry) : internal;
|
|
3840
|
-
return /* @__PURE__ */ jsx2(
|
|
3841
|
-
"input",
|
|
3842
|
-
{
|
|
3843
|
-
...rest,
|
|
3844
|
-
ref,
|
|
3845
|
-
type: "tel",
|
|
3846
|
-
inputMode: "tel",
|
|
3847
|
-
autoComplete: "tel",
|
|
3848
|
-
value: shown,
|
|
3849
|
-
onChange: handleChange
|
|
3850
|
-
}
|
|
3851
|
-
);
|
|
3852
|
-
});
|
|
3853
|
-
|
|
3854
|
-
// src/factory.tsx
|
|
3855
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
3856
|
-
var NOOP_CLIENT = {
|
|
3857
|
-
trackEvent: () => {
|
|
3858
|
-
},
|
|
3859
|
-
flush: async () => {
|
|
3860
|
-
},
|
|
3861
|
-
getSessionId: () => "",
|
|
3862
|
-
getVisitorId: () => ""
|
|
3863
|
-
};
|
|
3864
|
-
function createTracking(options) {
|
|
3865
|
-
const {
|
|
3866
|
-
apiKey,
|
|
3867
|
-
endpoint,
|
|
3868
|
-
triggers,
|
|
3869
|
-
environment,
|
|
3870
|
-
debug,
|
|
3871
|
-
phone,
|
|
3872
|
-
conversionConfig,
|
|
3873
|
-
trackingConfig
|
|
3874
|
-
} = options;
|
|
3875
|
-
registerCapability("base_tracking");
|
|
3876
|
-
if (trackingConfig) registerCapability("conversion_goals_auto");
|
|
3877
|
-
if (!apiKey || !endpoint) {
|
|
3878
|
-
if (apiKey || endpoint) {
|
|
3879
|
-
console.warn(
|
|
3880
|
-
"[AranovaTracking] createTracking() requires both `apiKey` and `endpoint`. Tracking is disabled for this session."
|
|
3881
|
-
);
|
|
3882
|
-
}
|
|
3883
|
-
const noopTyped = NOOP_CLIENT;
|
|
3884
|
-
return {
|
|
3885
|
-
// Still publish phone config so usePhoneField/<PhoneField> work even when
|
|
3886
|
-
// tracking is disabled (missing apiKey/endpoint).
|
|
3887
|
-
TrackingProvider: ({ children }) => /* @__PURE__ */ jsx3(PhoneConfigProvider, { value: phone ?? null, children }),
|
|
3888
|
-
useTracking: () => noopTyped
|
|
3889
|
-
};
|
|
3890
|
-
}
|
|
3891
|
-
const TrackingContext = createContext2(null);
|
|
3892
|
-
function TrackingProvider({
|
|
3893
|
-
gtagId,
|
|
3894
|
-
gtagIds,
|
|
3895
|
-
metaPixelId,
|
|
3896
|
-
metaPixelIds,
|
|
3897
|
-
children
|
|
3898
|
-
}) {
|
|
3899
|
-
const gtagIdsKey = useMemo4(() => gtagIds ? JSON.stringify(gtagIds) : "", [gtagIds]);
|
|
3900
|
-
const resolvedGtagIds = useMemo4(
|
|
3901
|
-
() => gtagIds ? Object.fromEntries(
|
|
3902
|
-
Object.entries(gtagIds).filter((e) => e[1] != null)
|
|
3903
|
-
) : gtagId ? { default: gtagId } : void 0,
|
|
3904
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- gtagIdsKey is stable proxy
|
|
3905
|
-
[gtagId, gtagIdsKey]
|
|
3906
|
-
);
|
|
3907
|
-
const rawClient = useMemo4(
|
|
3908
|
-
() => getOrCreateTrackingClient({
|
|
3909
|
-
apiKey,
|
|
3910
|
-
endpoint,
|
|
3911
|
-
surface: "react",
|
|
3912
|
-
packageName: "@aranova/tracking-react",
|
|
3913
|
-
sdkVersion: version,
|
|
3914
|
-
triggers,
|
|
3915
|
-
environment,
|
|
3916
|
-
activeGtagIds: resolvedGtagIds,
|
|
3917
|
-
debug
|
|
3918
|
-
}),
|
|
3919
|
-
[resolvedGtagIds]
|
|
3920
|
-
);
|
|
3921
|
-
const conversionStore = useMemo4(
|
|
3922
|
-
() => trackingConfig ? getTrackingConfigRuntime(trackingConfig) : conversionConfig ? resolveConversionConfig({
|
|
3923
|
-
cdnUrl: conversionConfig.cdnUrl,
|
|
3924
|
-
baked: conversionConfig.baked
|
|
3925
|
-
}) : null,
|
|
3926
|
-
[]
|
|
3927
|
-
);
|
|
3928
|
-
const conversionClient = useMemo4(
|
|
3929
|
-
() => conversionStore ? withConversionAutoFire(rawClient, createConversionAutoFire(conversionStore)) : rawClient,
|
|
3930
|
-
[rawClient, conversionStore]
|
|
3931
|
-
);
|
|
3932
|
-
const client = useMemo4(
|
|
3933
|
-
() => createTypedClient(conversionClient, triggers, { debug }),
|
|
3934
|
-
[conversionClient]
|
|
3935
|
-
);
|
|
3936
|
-
useEffect5(() => {
|
|
3937
|
-
if (trackingConfig) {
|
|
3938
|
-
getTrackingConfigRuntime(trackingConfig).start();
|
|
3939
|
-
} else if (gtagIds && Object.keys(gtagIds).length > 0) {
|
|
3940
|
-
bootstrapMultipleGtags(gtagIds);
|
|
3941
|
-
} else if (gtagId) {
|
|
3942
|
-
bootstrapGoogleAdsTracking(gtagId);
|
|
3943
|
-
}
|
|
3944
|
-
}, [gtagId, gtagIdsKey]);
|
|
3945
|
-
const metaPixelIdsKey = useMemo4(
|
|
3946
|
-
() => metaPixelIds ? JSON.stringify(metaPixelIds) : "",
|
|
3947
|
-
[metaPixelIds]
|
|
3948
|
-
);
|
|
3949
|
-
useEffect5(() => {
|
|
3950
|
-
if (metaPixelIds && Object.keys(metaPixelIds).length > 0) {
|
|
3951
|
-
bootstrapMultiplePixels(metaPixelIds);
|
|
3952
|
-
} else if (metaPixelId) {
|
|
3953
|
-
bootstrapMetaPixel(metaPixelId);
|
|
3954
|
-
}
|
|
3955
|
-
}, [metaPixelId, metaPixelIdsKey]);
|
|
3956
|
-
useEffect5(() => {
|
|
3957
|
-
return attachClientCapturesOnce(rawClient, () => {
|
|
3958
|
-
const detachers = [];
|
|
3959
|
-
const detectorClient = conversionStore ? conversionClient : rawClient;
|
|
3960
|
-
const pageClient = trackingConfig && conversionStore && "queuePageView" in conversionStore ? {
|
|
3961
|
-
...detectorClient,
|
|
3962
|
-
trackEvent: (input) => {
|
|
3963
|
-
detectorClient.trackEvent(input);
|
|
3964
|
-
if (input.eventType === "page_view") conversionStore.queuePageView();
|
|
3965
|
-
}
|
|
3966
|
-
} : detectorClient;
|
|
3967
|
-
detachers.push(attachAutoPageView(pageClient));
|
|
3968
|
-
detachers.push(attachBfcacheRestore(pageClient));
|
|
3969
|
-
detachers.push(attachPageExit(detectorClient));
|
|
3970
|
-
const timeOnSite = triggers.automatic.time_on_site;
|
|
3971
|
-
if (timeOnSite) {
|
|
3972
|
-
detachers.push(attachTimeOnSite(detectorClient, timeOnSite));
|
|
3973
|
-
}
|
|
3974
|
-
const specificPageVisit = triggers.automatic.specific_page_visit;
|
|
3975
|
-
if (specificPageVisit) {
|
|
3976
|
-
detachers.push(attachSpecificPageVisit(detectorClient, specificPageVisit));
|
|
3977
|
-
}
|
|
3978
|
-
const scrollDepth = triggers.automatic.scroll_depth;
|
|
3979
|
-
if (scrollDepth) {
|
|
3980
|
-
detachers.push(attachScrollDepth(detectorClient, scrollDepth));
|
|
3981
|
-
}
|
|
3982
|
-
const multiPageSession = triggers.automatic.multi_page_session;
|
|
3983
|
-
if (multiPageSession) {
|
|
3984
|
-
detachers.push(attachMultiPageSession(detectorClient, multiPageSession));
|
|
3985
|
-
}
|
|
3986
|
-
const formStart = triggers.automatic.form_start;
|
|
3987
|
-
if (formStart) {
|
|
3988
|
-
detachers.push(attachFormStart(detectorClient, formStart));
|
|
3989
|
-
}
|
|
3990
|
-
const ctaClick = triggers.manual?.cta_click;
|
|
3991
|
-
if (ctaClick) {
|
|
3992
|
-
detachers.push(attachCtaClickCapture(detectorClient, ctaClick));
|
|
3993
|
-
}
|
|
3994
|
-
const phoneClick = triggers.manual?.phone_click;
|
|
3995
|
-
if (phoneClick) {
|
|
3996
|
-
detachers.push(attachPhoneClickCapture(detectorClient, phoneClick));
|
|
3997
|
-
}
|
|
3998
|
-
return () => {
|
|
3999
|
-
for (let i = detachers.length - 1; i >= 0; i--) {
|
|
4000
|
-
detachers[i]();
|
|
4001
|
-
}
|
|
4002
|
-
};
|
|
4003
|
-
});
|
|
4004
|
-
}, [conversionClient, conversionStore, rawClient]);
|
|
4005
|
-
return /* @__PURE__ */ jsx3(TrackingContext.Provider, { value: client, children: /* @__PURE__ */ jsx3(PhoneConfigProvider, { value: phone ?? null, children }) });
|
|
4006
|
-
}
|
|
4007
|
-
function useTracking() {
|
|
4008
|
-
const client = useContext2(TrackingContext);
|
|
4009
|
-
if (client === null) {
|
|
4010
|
-
throw new Error(
|
|
4011
|
-
"useTracking must be called inside a <TrackingProvider> returned by createTracking()"
|
|
4012
|
-
);
|
|
4013
|
-
}
|
|
4014
|
-
return client;
|
|
4015
|
-
}
|
|
4016
|
-
return { TrackingProvider, useTracking };
|
|
4017
|
-
}
|
|
1999
|
+
PhoneField,
|
|
2000
|
+
usePhoneConfig,
|
|
2001
|
+
usePhoneField
|
|
2002
|
+
} from "@aranova/tracking-react/client";
|
|
4018
2003
|
export {
|
|
4019
2004
|
AdPlatformTracking,
|
|
4020
2005
|
AranovaApiError,
|