@xenia-martech/sdk-js 1.2.0-dev.1 → 1.2.0-dev.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/dist/{actions-D9_aAvCv.d.cts → actions-BcdlokGO.d.cts} +4 -2
- package/dist/{actions-D9_aAvCv.d.ts → actions-BcdlokGO.d.ts} +4 -2
- package/dist/client/index.cjs +27 -3
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +27 -3
- package/dist/client/index.js.map +1 -1
- package/dist/client/react/index.cjs +27 -3
- package/dist/client/react/index.cjs.map +1 -1
- package/dist/client/react/index.d.cts +2 -2
- package/dist/client/react/index.d.ts +2 -2
- package/dist/client/react/index.js +27 -3
- package/dist/client/react/index.js.map +1 -1
- package/dist/xenia-sdk.iife.js +3 -3
- package/dist/xenia-sdk.iife.js.map +1 -1
- package/package.json +1 -1
|
@@ -1238,6 +1238,20 @@ var AutoTracker = class {
|
|
|
1238
1238
|
}
|
|
1239
1239
|
};
|
|
1240
1240
|
|
|
1241
|
+
// src/server/cookies.ts
|
|
1242
|
+
function parseCookies(header) {
|
|
1243
|
+
const out = {};
|
|
1244
|
+
if (!header) return out;
|
|
1245
|
+
for (const part of header.split(";")) {
|
|
1246
|
+
const idx = part.indexOf("=");
|
|
1247
|
+
if (idx === -1) continue;
|
|
1248
|
+
const key = part.slice(0, idx).trim();
|
|
1249
|
+
const value = part.slice(idx + 1).trim();
|
|
1250
|
+
if (key) out[key] = decodeURIComponent(value);
|
|
1251
|
+
}
|
|
1252
|
+
return out;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1241
1255
|
// src/client/identity.ts
|
|
1242
1256
|
var SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
1243
1257
|
var Identity = class {
|
|
@@ -1285,10 +1299,19 @@ var Identity = class {
|
|
|
1285
1299
|
} catch {
|
|
1286
1300
|
}
|
|
1287
1301
|
}
|
|
1302
|
+
/** The visitor id already in the cookie — e.g. minted by `xeniaProxy()` on the first request. */
|
|
1303
|
+
readVisitorCookie() {
|
|
1304
|
+
if (!this.cookie || typeof document === "undefined") return null;
|
|
1305
|
+
try {
|
|
1306
|
+
return parseCookies(document.cookie)[this.cookieName()] || null;
|
|
1307
|
+
} catch {
|
|
1308
|
+
return null;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1288
1311
|
// ── Device id ────────────────────────────────────────────────────────────
|
|
1289
1312
|
/**
|
|
1290
|
-
* Resolve a stable device id: localStorage cache →
|
|
1291
|
-
* browser fingerprint. Cached for the session and across reloads.
|
|
1313
|
+
* Resolve a stable device id: localStorage cache → the visitor cookie a server already set →
|
|
1314
|
+
* MediaDevices → SHA-256 browser fingerprint. Cached for the session and across reloads.
|
|
1292
1315
|
*/
|
|
1293
1316
|
async resolveDeviceId() {
|
|
1294
1317
|
if (this.deviceId) {
|
|
@@ -1305,7 +1328,8 @@ var Identity = class {
|
|
|
1305
1328
|
}
|
|
1306
1329
|
} catch {
|
|
1307
1330
|
}
|
|
1308
|
-
let id =
|
|
1331
|
+
let id = this.readVisitorCookie();
|
|
1332
|
+
if (!id) id = await this.mediaDeviceId();
|
|
1309
1333
|
if (!id) id = await this.fingerprint();
|
|
1310
1334
|
this.deviceId = id;
|
|
1311
1335
|
try {
|