@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
@@ -1,8 +1,8 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { ReactNode, ElementType, ComponentType } from 'react';
4
- import { t as XeniaClientOptions, s as XeniaClient, r as ResolveResult, p as ResolveBatchResult, J as JsonValue, W as WebhookResponse, R as ResolveBatchItem, e as AnalyticsEventName, T as TrackOptions, d as XeniaAction, I as InteractionType, m as MessageMountContext, c as MessageComponentRenderer } from '../../actions-DFLoSXO_.cjs';
5
- export { A as AnalyticsContext, f as AnalyticsIdentity, g as AnalyticsIngestResponse, C as ClientEvent, h as ConsentState, i as ContentSwap, j as IdentifyRequest, k as IdentifyResponse, M as MessageCta, n as MessagePlacement, o as MessageRenderContext, b as MessageTemplateFn, P as PersonalizationSwap, q as ResolveOptions, X as XeniaConfig, a as XeniaEvent, u as createXeniaClient, v as extractContentSwaps, w as parseActions, x as spliceSlots } from '../../actions-DFLoSXO_.cjs';
4
+ import { t as XeniaClientOptions, s as XeniaClient, r as ResolveResult, p as ResolveBatchResult, J as JsonValue, W as WebhookResponse, R as ResolveBatchItem, e as AnalyticsEventName, T as TrackOptions, d as XeniaAction, I as InteractionType, m as MessageMountContext, c as MessageComponentRenderer } from '../../actions-CkiSdvSa.cjs';
5
+ export { A as AnalyticsContext, f as AnalyticsIdentity, g as AnalyticsIngestResponse, C as ClientEvent, h as ConsentState, i as ContentSwap, j as IdentifyRequest, k as IdentifyResponse, M as MessageCta, n as MessagePlacement, o as MessageRenderContext, b as MessageTemplateFn, P as PersonalizationSwap, q as ResolveOptions, X as XeniaConfig, a as XeniaEvent, u as createXeniaClient, v as extractContentSwaps, w as parseActions, x as spliceSlots } from '../../actions-CkiSdvSa.cjs';
6
6
 
7
7
  interface XeniaProviderProps extends XeniaClientOptions {
8
8
  children: ReactNode;
@@ -1,8 +1,8 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { ReactNode, ElementType, ComponentType } from 'react';
4
- import { t as XeniaClientOptions, s as XeniaClient, r as ResolveResult, p as ResolveBatchResult, J as JsonValue, W as WebhookResponse, R as ResolveBatchItem, e as AnalyticsEventName, T as TrackOptions, d as XeniaAction, I as InteractionType, m as MessageMountContext, c as MessageComponentRenderer } from '../../actions-DFLoSXO_.js';
5
- export { A as AnalyticsContext, f as AnalyticsIdentity, g as AnalyticsIngestResponse, C as ClientEvent, h as ConsentState, i as ContentSwap, j as IdentifyRequest, k as IdentifyResponse, M as MessageCta, n as MessagePlacement, o as MessageRenderContext, b as MessageTemplateFn, P as PersonalizationSwap, q as ResolveOptions, X as XeniaConfig, a as XeniaEvent, u as createXeniaClient, v as extractContentSwaps, w as parseActions, x as spliceSlots } from '../../actions-DFLoSXO_.js';
4
+ import { t as XeniaClientOptions, s as XeniaClient, r as ResolveResult, p as ResolveBatchResult, J as JsonValue, W as WebhookResponse, R as ResolveBatchItem, e as AnalyticsEventName, T as TrackOptions, d as XeniaAction, I as InteractionType, m as MessageMountContext, c as MessageComponentRenderer } from '../../actions-CkiSdvSa.js';
5
+ export { A as AnalyticsContext, f as AnalyticsIdentity, g as AnalyticsIngestResponse, C as ClientEvent, h as ConsentState, i as ContentSwap, j as IdentifyRequest, k as IdentifyResponse, M as MessageCta, n as MessagePlacement, o as MessageRenderContext, b as MessageTemplateFn, P as PersonalizationSwap, q as ResolveOptions, X as XeniaConfig, a as XeniaEvent, u as createXeniaClient, v as extractContentSwaps, w as parseActions, x as spliceSlots } from '../../actions-CkiSdvSa.js';
6
6
 
7
7
  interface XeniaProviderProps extends XeniaClientOptions {
8
8
  children: ReactNode;
@@ -971,6 +971,40 @@ var Identity = class {
971
971
  return null;
972
972
  }
973
973
  }
974
+ // ── Customer id / email ──────────────────────────────────────────────────
975
+ //
976
+ // Ambient, persisted the same way as the visitor id, so a value set once
977
+ // (typically alongside `identify()`) rides on every later `resolve()` call
978
+ // without the caller having to pass it again — the SDK-provided-fields
979
+ // parity list on the Personalization Resolve trigger includes both.
980
+ setCustomerId(customerId) {
981
+ try {
982
+ if (customerId) localStorage.setItem(this.key("customer_id"), customerId);
983
+ else localStorage.removeItem(this.key("customer_id"));
984
+ } catch {
985
+ }
986
+ }
987
+ getCustomerId() {
988
+ try {
989
+ return localStorage.getItem(this.key("customer_id"));
990
+ } catch {
991
+ return null;
992
+ }
993
+ }
994
+ setEmail(email) {
995
+ try {
996
+ if (email) localStorage.setItem(this.key("email"), email);
997
+ else localStorage.removeItem(this.key("email"));
998
+ } catch {
999
+ }
1000
+ }
1001
+ getEmail() {
1002
+ try {
1003
+ return localStorage.getItem(this.key("email"));
1004
+ } catch {
1005
+ return null;
1006
+ }
1007
+ }
974
1008
  // ── Session id ───────────────────────────────────────────────────────────────
975
1009
  /**
976
1010
  * Resolve the current session id: reused while activity continues within
@@ -1434,10 +1468,16 @@ var XeniaClient = class {
1434
1468
  * Persist a visitor id, attached to every subsequent event, and bind it to
1435
1469
  * a known user server-side (`POST /api/events/v1/identify`, fire-and-
1436
1470
  * forget — resolves to an `"identify"` client event carrying `personId`).
1471
+ *
1472
+ * `extra.customerId`/`extra.email`, when supplied, are also persisted
1473
+ * ambiently (like the visitor id) so they ride on every later `resolve()`
1474
+ * call automatically — part of the SDK-provided-fields parity list.
1437
1475
  */
1438
- identify(visitorId) {
1476
+ identify(visitorId, extra) {
1439
1477
  this.identity.identify(visitorId);
1440
- void this.api.identify({ xeniaVisitorId: visitorId }).then((res) => this.emit("identify", res)).catch((err) => this.emitError(err));
1478
+ if (extra?.customerId !== void 0) this.identity.setCustomerId(extra.customerId);
1479
+ if (extra?.email !== void 0) this.identity.setEmail(extra.email);
1480
+ void this.api.identify({ xeniaVisitorId: visitorId, userId: extra?.customerId, email: extra?.email }).then((res) => this.emit("identify", res)).catch((err) => this.emitError(err));
1441
1481
  }
1442
1482
  /** Override the customer-journey UUID (else derived from utm_id). */
1443
1483
  setJourneyId(id) {
@@ -1555,15 +1595,40 @@ var XeniaClient = class {
1555
1595
  return this.identity.getVisitorId() ?? this.identity.getDeviceId() ?? void 0;
1556
1596
  }
1557
1597
  /**
1558
- * Stamp the SDK-owned visitor id into the resolve `data` under the reserved
1559
- * `_xenia_vid` key so the backend can bucket holdout experiments and record
1560
- * exposure per visitor (it reads visitor identity from `data`). Set last so a
1561
- * caller can't override it; a no-op when no visitor id is resolvable yet.
1598
+ * Stamp the full set of SDK-provided fields into the resolve `data` —
1599
+ * `path`, `query`, `deviceId`, `visitorId`, `customerId`, `email`, `url`,
1600
+ * `referrer`, and the five `utm*` fields — the same field-name/type parity
1601
+ * the webhook trigger's "SDK-provided fields" already promises, now native
1602
+ * (always attached, no marketer toggle) for the Personalization Resolve
1603
+ * trigger too. Plus the reserved `_xenia_vid` key the backend reads for
1604
+ * holdout/exposure bucketing. All of these are spread LAST (after the
1605
+ * caller's own `data`) so none can be overridden per call — the same
1606
+ * override-protection guarantee `_xenia_vid` alone used to have, now
1607
+ * widened to the full set. A no-op (returns `opts` unchanged) when nothing
1608
+ * is resolvable yet (e.g. called before `init()` on a fresh visit with no
1609
+ * page context available).
1562
1610
  */
1563
1611
  withVisitor(opts) {
1612
+ const ctx = this.identity.collectContext();
1564
1613
  const vid = this.resolveVisitorId();
1565
- if (!vid) return opts;
1566
- return { ...opts, data: { ...opts?.data ?? {}, _xenia_vid: vid } };
1614
+ const sdkFields = compact({
1615
+ path: ctx.path,
1616
+ query: ctx.query,
1617
+ deviceId: this.identity.getDeviceId() ?? void 0,
1618
+ visitorId: vid,
1619
+ customerId: this.identity.getCustomerId() ?? void 0,
1620
+ email: this.identity.getEmail() ?? void 0,
1621
+ url: ctx.url,
1622
+ referrer: ctx.referrer,
1623
+ utmSource: ctx.utmSource,
1624
+ utmMedium: ctx.utmMedium,
1625
+ utmCampaign: ctx.utmCampaign,
1626
+ utmContent: ctx.utmContent,
1627
+ utmId: ctx.utmId
1628
+ });
1629
+ if (vid) sdkFields._xenia_vid = vid;
1630
+ if (Object.keys(sdkFields).length === 0) return opts;
1631
+ return { ...opts, data: { ...opts?.data ?? {}, ...sdkFields } };
1567
1632
  }
1568
1633
  dntBlocked() {
1569
1634
  if (this.options.respectDnt === false) return false;