@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
|
@@ -911,9 +911,11 @@ declare class Identity {
|
|
|
911
911
|
* a browser-entered journey. No-op when disabled or off-DOM.
|
|
912
912
|
*/
|
|
913
913
|
private writeVisitorCookie;
|
|
914
|
+
/** The visitor id already in the cookie — e.g. minted by `xeniaProxy()` on the first request. */
|
|
915
|
+
private readVisitorCookie;
|
|
914
916
|
/**
|
|
915
|
-
* Resolve a stable device id: localStorage cache →
|
|
916
|
-
* browser fingerprint. Cached for the session and across reloads.
|
|
917
|
+
* Resolve a stable device id: localStorage cache → the visitor cookie a server already set →
|
|
918
|
+
* MediaDevices → SHA-256 browser fingerprint. Cached for the session and across reloads.
|
|
917
919
|
*/
|
|
918
920
|
resolveDeviceId(): Promise<string>;
|
|
919
921
|
getDeviceId(): string | null;
|
|
@@ -911,9 +911,11 @@ declare class Identity {
|
|
|
911
911
|
* a browser-entered journey. No-op when disabled or off-DOM.
|
|
912
912
|
*/
|
|
913
913
|
private writeVisitorCookie;
|
|
914
|
+
/** The visitor id already in the cookie — e.g. minted by `xeniaProxy()` on the first request. */
|
|
915
|
+
private readVisitorCookie;
|
|
914
916
|
/**
|
|
915
|
-
* Resolve a stable device id: localStorage cache →
|
|
916
|
-
* browser fingerprint. Cached for the session and across reloads.
|
|
917
|
+
* Resolve a stable device id: localStorage cache → the visitor cookie a server already set →
|
|
918
|
+
* MediaDevices → SHA-256 browser fingerprint. Cached for the session and across reloads.
|
|
917
919
|
*/
|
|
918
920
|
resolveDeviceId(): Promise<string>;
|
|
919
921
|
getDeviceId(): string | null;
|
package/dist/client/index.cjs
CHANGED
|
@@ -1231,6 +1231,20 @@ var AutoTracker = class {
|
|
|
1231
1231
|
}
|
|
1232
1232
|
};
|
|
1233
1233
|
|
|
1234
|
+
// src/server/cookies.ts
|
|
1235
|
+
function parseCookies(header) {
|
|
1236
|
+
const out = {};
|
|
1237
|
+
if (!header) return out;
|
|
1238
|
+
for (const part of header.split(";")) {
|
|
1239
|
+
const idx = part.indexOf("=");
|
|
1240
|
+
if (idx === -1) continue;
|
|
1241
|
+
const key = part.slice(0, idx).trim();
|
|
1242
|
+
const value = part.slice(idx + 1).trim();
|
|
1243
|
+
if (key) out[key] = decodeURIComponent(value);
|
|
1244
|
+
}
|
|
1245
|
+
return out;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1234
1248
|
// src/client/identity.ts
|
|
1235
1249
|
var SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
1236
1250
|
var Identity = class {
|
|
@@ -1278,10 +1292,19 @@ var Identity = class {
|
|
|
1278
1292
|
} catch {
|
|
1279
1293
|
}
|
|
1280
1294
|
}
|
|
1295
|
+
/** The visitor id already in the cookie — e.g. minted by `xeniaProxy()` on the first request. */
|
|
1296
|
+
readVisitorCookie() {
|
|
1297
|
+
if (!this.cookie || typeof document === "undefined") return null;
|
|
1298
|
+
try {
|
|
1299
|
+
return parseCookies(document.cookie)[this.cookieName()] || null;
|
|
1300
|
+
} catch {
|
|
1301
|
+
return null;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1281
1304
|
// ── Device id ────────────────────────────────────────────────────────────
|
|
1282
1305
|
/**
|
|
1283
|
-
* Resolve a stable device id: localStorage cache →
|
|
1284
|
-
* browser fingerprint. Cached for the session and across reloads.
|
|
1306
|
+
* Resolve a stable device id: localStorage cache → the visitor cookie a server already set →
|
|
1307
|
+
* MediaDevices → SHA-256 browser fingerprint. Cached for the session and across reloads.
|
|
1285
1308
|
*/
|
|
1286
1309
|
async resolveDeviceId() {
|
|
1287
1310
|
if (this.deviceId) {
|
|
@@ -1298,7 +1321,8 @@ var Identity = class {
|
|
|
1298
1321
|
}
|
|
1299
1322
|
} catch {
|
|
1300
1323
|
}
|
|
1301
|
-
let id =
|
|
1324
|
+
let id = this.readVisitorCookie();
|
|
1325
|
+
if (!id) id = await this.mediaDeviceId();
|
|
1302
1326
|
if (!id) id = await this.fingerprint();
|
|
1303
1327
|
this.deviceId = id;
|
|
1304
1328
|
try {
|