@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.
Files changed (36) hide show
  1. package/README.md +21 -1
  2. package/dist/{actions-DFLoSXO_.d.cts → actions-CkiSdvSa.d.cts} +65 -5
  3. package/dist/{actions-DFLoSXO_.d.ts → actions-CkiSdvSa.d.ts} +65 -5
  4. package/dist/{chunk-D37RD3UC.js → chunk-7D2HJMW6.js} +31 -3
  5. package/dist/chunk-7D2HJMW6.js.map +1 -0
  6. package/dist/{chunk-3KYKKIIG.cjs → chunk-UOW3GK4I.cjs} +32 -2
  7. package/dist/chunk-UOW3GK4I.cjs.map +1 -0
  8. package/dist/client/index.cjs +73 -8
  9. package/dist/client/index.cjs.map +1 -1
  10. package/dist/client/index.d.cts +2 -2
  11. package/dist/client/index.d.ts +2 -2
  12. package/dist/client/index.js +73 -8
  13. package/dist/client/index.js.map +1 -1
  14. package/dist/client/react/index.cjs +73 -8
  15. package/dist/client/react/index.cjs.map +1 -1
  16. package/dist/client/react/index.d.cts +2 -2
  17. package/dist/client/react/index.d.ts +2 -2
  18. package/dist/client/react/index.js +73 -8
  19. package/dist/client/react/index.js.map +1 -1
  20. package/dist/{cookie-names-LgNDAreS.d.cts → cookie-names-C3LKDhsg.d.cts} +34 -0
  21. package/dist/{cookie-names-LgNDAreS.d.ts → cookie-names-C3LKDhsg.d.ts} +34 -0
  22. package/dist/index.cjs +23 -19
  23. package/dist/index.d.cts +23 -3
  24. package/dist/index.d.ts +23 -3
  25. package/dist/index.js +1 -1
  26. package/dist/server/index.cjs +53 -22
  27. package/dist/server/index.cjs.map +1 -1
  28. package/dist/server/index.d.cts +31 -11
  29. package/dist/server/index.d.ts +31 -11
  30. package/dist/server/index.js +43 -12
  31. package/dist/server/index.js.map +1 -1
  32. package/dist/xenia-sdk.iife.js +3 -3
  33. package/dist/xenia-sdk.iife.js.map +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunk-3KYKKIIG.cjs.map +0 -1
  36. package/dist/chunk-D37RD3UC.js.map +0 -1
@@ -966,6 +966,40 @@ var Identity = class {
966
966
  return null;
967
967
  }
968
968
  }
969
+ // ── Customer id / email ──────────────────────────────────────────────────
970
+ //
971
+ // Ambient, persisted the same way as the visitor id, so a value set once
972
+ // (typically alongside `identify()`) rides on every later `resolve()` call
973
+ // without the caller having to pass it again — the SDK-provided-fields
974
+ // parity list on the Personalization Resolve trigger includes both.
975
+ setCustomerId(customerId) {
976
+ try {
977
+ if (customerId) localStorage.setItem(this.key("customer_id"), customerId);
978
+ else localStorage.removeItem(this.key("customer_id"));
979
+ } catch {
980
+ }
981
+ }
982
+ getCustomerId() {
983
+ try {
984
+ return localStorage.getItem(this.key("customer_id"));
985
+ } catch {
986
+ return null;
987
+ }
988
+ }
989
+ setEmail(email) {
990
+ try {
991
+ if (email) localStorage.setItem(this.key("email"), email);
992
+ else localStorage.removeItem(this.key("email"));
993
+ } catch {
994
+ }
995
+ }
996
+ getEmail() {
997
+ try {
998
+ return localStorage.getItem(this.key("email"));
999
+ } catch {
1000
+ return null;
1001
+ }
1002
+ }
969
1003
  // ── Session id ───────────────────────────────────────────────────────────────
970
1004
  /**
971
1005
  * Resolve the current session id: reused while activity continues within
@@ -1429,10 +1463,16 @@ var XeniaClient = class {
1429
1463
  * Persist a visitor id, attached to every subsequent event, and bind it to
1430
1464
  * a known user server-side (`POST /api/events/v1/identify`, fire-and-
1431
1465
  * forget — resolves to an `"identify"` client event carrying `personId`).
1466
+ *
1467
+ * `extra.customerId`/`extra.email`, when supplied, are also persisted
1468
+ * ambiently (like the visitor id) so they ride on every later `resolve()`
1469
+ * call automatically — part of the SDK-provided-fields parity list.
1432
1470
  */
1433
- identify(visitorId) {
1471
+ identify(visitorId, extra) {
1434
1472
  this.identity.identify(visitorId);
1435
- void this.api.identify({ xeniaVisitorId: visitorId }).then((res) => this.emit("identify", res)).catch((err) => this.emitError(err));
1473
+ if (extra?.customerId !== void 0) this.identity.setCustomerId(extra.customerId);
1474
+ if (extra?.email !== void 0) this.identity.setEmail(extra.email);
1475
+ void this.api.identify({ xeniaVisitorId: visitorId, userId: extra?.customerId, email: extra?.email }).then((res) => this.emit("identify", res)).catch((err) => this.emitError(err));
1436
1476
  }
1437
1477
  /** Override the customer-journey UUID (else derived from utm_id). */
1438
1478
  setJourneyId(id) {
@@ -1550,15 +1590,40 @@ var XeniaClient = class {
1550
1590
  return this.identity.getVisitorId() ?? this.identity.getDeviceId() ?? void 0;
1551
1591
  }
1552
1592
  /**
1553
- * Stamp the SDK-owned visitor id into the resolve `data` under the reserved
1554
- * `_xenia_vid` key so the backend can bucket holdout experiments and record
1555
- * exposure per visitor (it reads visitor identity from `data`). Set last so a
1556
- * caller can't override it; a no-op when no visitor id is resolvable yet.
1593
+ * Stamp the full set of SDK-provided fields into the resolve `data` —
1594
+ * `path`, `query`, `deviceId`, `visitorId`, `customerId`, `email`, `url`,
1595
+ * `referrer`, and the five `utm*` fields — the same field-name/type parity
1596
+ * the webhook trigger's "SDK-provided fields" already promises, now native
1597
+ * (always attached, no marketer toggle) for the Personalization Resolve
1598
+ * trigger too. Plus the reserved `_xenia_vid` key the backend reads for
1599
+ * holdout/exposure bucketing. All of these are spread LAST (after the
1600
+ * caller's own `data`) so none can be overridden per call — the same
1601
+ * override-protection guarantee `_xenia_vid` alone used to have, now
1602
+ * widened to the full set. A no-op (returns `opts` unchanged) when nothing
1603
+ * is resolvable yet (e.g. called before `init()` on a fresh visit with no
1604
+ * page context available).
1557
1605
  */
1558
1606
  withVisitor(opts) {
1607
+ const ctx = this.identity.collectContext();
1559
1608
  const vid = this.resolveVisitorId();
1560
- if (!vid) return opts;
1561
- return { ...opts, data: { ...opts?.data ?? {}, _xenia_vid: vid } };
1609
+ const sdkFields = compact({
1610
+ path: ctx.path,
1611
+ query: ctx.query,
1612
+ deviceId: this.identity.getDeviceId() ?? void 0,
1613
+ visitorId: vid,
1614
+ customerId: this.identity.getCustomerId() ?? void 0,
1615
+ email: this.identity.getEmail() ?? void 0,
1616
+ url: ctx.url,
1617
+ referrer: ctx.referrer,
1618
+ utmSource: ctx.utmSource,
1619
+ utmMedium: ctx.utmMedium,
1620
+ utmCampaign: ctx.utmCampaign,
1621
+ utmContent: ctx.utmContent,
1622
+ utmId: ctx.utmId
1623
+ });
1624
+ if (vid) sdkFields._xenia_vid = vid;
1625
+ if (Object.keys(sdkFields).length === 0) return opts;
1626
+ return { ...opts, data: { ...opts?.data ?? {}, ...sdkFields } };
1562
1627
  }
1563
1628
  dntBlocked() {
1564
1629
  if (this.options.respectDnt === false) return false;