@xenia-martech/sdk-js 1.0.0-dev.26 → 1.0.0-dev.27
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 +21 -1
- package/dist/{actions-DFLoSXO_.d.cts → actions-CkiSdvSa.d.cts} +65 -5
- package/dist/{actions-DFLoSXO_.d.ts → actions-CkiSdvSa.d.ts} +65 -5
- package/dist/{chunk-D37RD3UC.js → chunk-7D2HJMW6.js} +31 -3
- package/dist/chunk-7D2HJMW6.js.map +1 -0
- package/dist/{chunk-3KYKKIIG.cjs → chunk-UOW3GK4I.cjs} +32 -2
- package/dist/chunk-UOW3GK4I.cjs.map +1 -0
- package/dist/client/index.cjs +73 -8
- 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 +73 -8
- package/dist/client/index.js.map +1 -1
- package/dist/client/react/index.cjs +73 -8
- 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 +73 -8
- package/dist/client/react/index.js.map +1 -1
- package/dist/{cookie-names-LgNDAreS.d.cts → cookie-names-C3LKDhsg.d.cts} +34 -0
- package/dist/{cookie-names-LgNDAreS.d.ts → cookie-names-C3LKDhsg.d.ts} +34 -0
- package/dist/index.cjs +23 -19
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +1 -1
- package/dist/server/index.cjs +53 -22
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +31 -11
- package/dist/server/index.d.ts +31 -11
- package/dist/server/index.js +43 -12
- package/dist/server/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
- package/dist/chunk-3KYKKIIG.cjs.map +0 -1
- package/dist/chunk-D37RD3UC.js.map +0 -1
|
@@ -973,6 +973,40 @@ var Identity = class {
|
|
|
973
973
|
return null;
|
|
974
974
|
}
|
|
975
975
|
}
|
|
976
|
+
// ── Customer id / email ──────────────────────────────────────────────────
|
|
977
|
+
//
|
|
978
|
+
// Ambient, persisted the same way as the visitor id, so a value set once
|
|
979
|
+
// (typically alongside `identify()`) rides on every later `resolve()` call
|
|
980
|
+
// without the caller having to pass it again — the SDK-provided-fields
|
|
981
|
+
// parity list on the Personalization Resolve trigger includes both.
|
|
982
|
+
setCustomerId(customerId) {
|
|
983
|
+
try {
|
|
984
|
+
if (customerId) localStorage.setItem(this.key("customer_id"), customerId);
|
|
985
|
+
else localStorage.removeItem(this.key("customer_id"));
|
|
986
|
+
} catch {
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
getCustomerId() {
|
|
990
|
+
try {
|
|
991
|
+
return localStorage.getItem(this.key("customer_id"));
|
|
992
|
+
} catch {
|
|
993
|
+
return null;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
setEmail(email) {
|
|
997
|
+
try {
|
|
998
|
+
if (email) localStorage.setItem(this.key("email"), email);
|
|
999
|
+
else localStorage.removeItem(this.key("email"));
|
|
1000
|
+
} catch {
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
getEmail() {
|
|
1004
|
+
try {
|
|
1005
|
+
return localStorage.getItem(this.key("email"));
|
|
1006
|
+
} catch {
|
|
1007
|
+
return null;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
976
1010
|
// ── Session id ───────────────────────────────────────────────────────────────
|
|
977
1011
|
/**
|
|
978
1012
|
* Resolve the current session id: reused while activity continues within
|
|
@@ -1436,10 +1470,16 @@ var XeniaClient = class {
|
|
|
1436
1470
|
* Persist a visitor id, attached to every subsequent event, and bind it to
|
|
1437
1471
|
* a known user server-side (`POST /api/events/v1/identify`, fire-and-
|
|
1438
1472
|
* forget — resolves to an `"identify"` client event carrying `personId`).
|
|
1473
|
+
*
|
|
1474
|
+
* `extra.customerId`/`extra.email`, when supplied, are also persisted
|
|
1475
|
+
* ambiently (like the visitor id) so they ride on every later `resolve()`
|
|
1476
|
+
* call automatically — part of the SDK-provided-fields parity list.
|
|
1439
1477
|
*/
|
|
1440
|
-
identify(visitorId) {
|
|
1478
|
+
identify(visitorId, extra) {
|
|
1441
1479
|
this.identity.identify(visitorId);
|
|
1442
|
-
|
|
1480
|
+
if (extra?.customerId !== void 0) this.identity.setCustomerId(extra.customerId);
|
|
1481
|
+
if (extra?.email !== void 0) this.identity.setEmail(extra.email);
|
|
1482
|
+
void this.api.identify({ xeniaVisitorId: visitorId, userId: extra?.customerId, email: extra?.email }).then((res) => this.emit("identify", res)).catch((err) => this.emitError(err));
|
|
1443
1483
|
}
|
|
1444
1484
|
/** Override the customer-journey UUID (else derived from utm_id). */
|
|
1445
1485
|
setJourneyId(id) {
|
|
@@ -1557,15 +1597,40 @@ var XeniaClient = class {
|
|
|
1557
1597
|
return this.identity.getVisitorId() ?? this.identity.getDeviceId() ?? void 0;
|
|
1558
1598
|
}
|
|
1559
1599
|
/**
|
|
1560
|
-
* Stamp the SDK-
|
|
1561
|
-
* `
|
|
1562
|
-
*
|
|
1563
|
-
*
|
|
1600
|
+
* Stamp the full set of SDK-provided fields into the resolve `data` —
|
|
1601
|
+
* `path`, `query`, `deviceId`, `visitorId`, `customerId`, `email`, `url`,
|
|
1602
|
+
* `referrer`, and the five `utm*` fields — the same field-name/type parity
|
|
1603
|
+
* the webhook trigger's "SDK-provided fields" already promises, now native
|
|
1604
|
+
* (always attached, no marketer toggle) for the Personalization Resolve
|
|
1605
|
+
* trigger too. Plus the reserved `_xenia_vid` key the backend reads for
|
|
1606
|
+
* holdout/exposure bucketing. All of these are spread LAST (after the
|
|
1607
|
+
* caller's own `data`) so none can be overridden per call — the same
|
|
1608
|
+
* override-protection guarantee `_xenia_vid` alone used to have, now
|
|
1609
|
+
* widened to the full set. A no-op (returns `opts` unchanged) when nothing
|
|
1610
|
+
* is resolvable yet (e.g. called before `init()` on a fresh visit with no
|
|
1611
|
+
* page context available).
|
|
1564
1612
|
*/
|
|
1565
1613
|
withVisitor(opts) {
|
|
1614
|
+
const ctx = this.identity.collectContext();
|
|
1566
1615
|
const vid = this.resolveVisitorId();
|
|
1567
|
-
|
|
1568
|
-
|
|
1616
|
+
const sdkFields = compact({
|
|
1617
|
+
path: ctx.path,
|
|
1618
|
+
query: ctx.query,
|
|
1619
|
+
deviceId: this.identity.getDeviceId() ?? void 0,
|
|
1620
|
+
visitorId: vid,
|
|
1621
|
+
customerId: this.identity.getCustomerId() ?? void 0,
|
|
1622
|
+
email: this.identity.getEmail() ?? void 0,
|
|
1623
|
+
url: ctx.url,
|
|
1624
|
+
referrer: ctx.referrer,
|
|
1625
|
+
utmSource: ctx.utmSource,
|
|
1626
|
+
utmMedium: ctx.utmMedium,
|
|
1627
|
+
utmCampaign: ctx.utmCampaign,
|
|
1628
|
+
utmContent: ctx.utmContent,
|
|
1629
|
+
utmId: ctx.utmId
|
|
1630
|
+
});
|
|
1631
|
+
if (vid) sdkFields._xenia_vid = vid;
|
|
1632
|
+
if (Object.keys(sdkFields).length === 0) return opts;
|
|
1633
|
+
return { ...opts, data: { ...opts?.data ?? {}, ...sdkFields } };
|
|
1569
1634
|
}
|
|
1570
1635
|
dntBlocked() {
|
|
1571
1636
|
if (this.options.respectDnt === false) return false;
|