@xenia-martech/sdk-js 1.0.0-dev.25 → 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 +31 -45
- package/dist/{actions-DfuHrjUL.d.cts → actions-CkiSdvSa.d.cts} +73 -11
- package/dist/{actions-DfuHrjUL.d.ts → actions-CkiSdvSa.d.ts} +73 -11
- package/dist/{chunk-PTYUK4P3.js → chunk-7D2HJMW6.js} +33 -4
- package/dist/chunk-7D2HJMW6.js.map +1 -0
- package/dist/{chunk-JEFNAD5J.cjs → chunk-UOW3GK4I.cjs} +34 -3
- package/dist/chunk-UOW3GK4I.cjs.map +1 -0
- package/dist/client/index.cjs +75 -9
- 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 +75 -9
- package/dist/client/index.js.map +1 -1
- package/dist/client/react/index.cjs +75 -9
- package/dist/client/react/index.cjs.map +1 -1
- package/dist/client/react/index.d.cts +3 -3
- package/dist/client/react/index.d.ts +3 -3
- package/dist/client/react/index.js +75 -9
- package/dist/client/react/index.js.map +1 -1
- package/dist/{cookie-names-BQ-L04A8.d.cts → cookie-names-C3LKDhsg.d.cts} +42 -6
- package/dist/{cookie-names-BQ-L04A8.d.ts → cookie-names-C3LKDhsg.d.ts} +42 -6
- package/dist/index.cjs +23 -19
- package/dist/index.d.cts +25 -4
- package/dist/index.d.ts +25 -4
- 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 +37 -14
- package/dist/server/index.d.ts +37 -14
- 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-JEFNAD5J.cjs.map +0 -1
- package/dist/chunk-PTYUK4P3.js.map +0 -1
package/dist/client/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InteractionType, X as XeniaConfig, a as XeniaEvent, M as MessageCta, b as MessageTemplateFn, c as MessageComponentRenderer, d as XeniaAction } from '../actions-
|
|
2
|
-
export { A as AnalyticsContext, e as AnalyticsEventName, f as AnalyticsIdentity, g as AnalyticsIngestResponse, C as ClientEvent, h as ConsentState, i as ContentSwap, j as IdentifyRequest, k as IdentifyResponse, l as Identity, J as JsonValue, m as MessageMountContext, n as MessagePlacement, o as MessageRenderContext, P as PersonalizationSwap, R as ResolveBatchItem, p as ResolveBatchResult, q as ResolveOptions, r as ResolveResult, T as TrackOptions, W as WebhookResponse, s as XeniaClient, t as XeniaClientOptions, u as createXeniaClient, v as extractContentSwaps, w as parseActions, x as spliceSlots } from '../actions-
|
|
1
|
+
import { I as InteractionType, X as XeniaConfig, a as XeniaEvent, M as MessageCta, b as MessageTemplateFn, c as MessageComponentRenderer, d as XeniaAction } from '../actions-CkiSdvSa.cjs';
|
|
2
|
+
export { A as AnalyticsContext, e as AnalyticsEventName, f as AnalyticsIdentity, g as AnalyticsIngestResponse, C as ClientEvent, h as ConsentState, i as ContentSwap, j as IdentifyRequest, k as IdentifyResponse, l as Identity, J as JsonValue, m as MessageMountContext, n as MessagePlacement, o as MessageRenderContext, P as PersonalizationSwap, R as ResolveBatchItem, p as ResolveBatchResult, q as ResolveOptions, r as ResolveResult, T as TrackOptions, W as WebhookResponse, s as XeniaClient, t as XeniaClientOptions, u as createXeniaClient, v as extractContentSwaps, w as parseActions, x as spliceSlots } from '../actions-CkiSdvSa.cjs';
|
|
3
3
|
|
|
4
4
|
interface Parsed {
|
|
5
5
|
eventId: string;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InteractionType, X as XeniaConfig, a as XeniaEvent, M as MessageCta, b as MessageTemplateFn, c as MessageComponentRenderer, d as XeniaAction } from '../actions-
|
|
2
|
-
export { A as AnalyticsContext, e as AnalyticsEventName, f as AnalyticsIdentity, g as AnalyticsIngestResponse, C as ClientEvent, h as ConsentState, i as ContentSwap, j as IdentifyRequest, k as IdentifyResponse, l as Identity, J as JsonValue, m as MessageMountContext, n as MessagePlacement, o as MessageRenderContext, P as PersonalizationSwap, R as ResolveBatchItem, p as ResolveBatchResult, q as ResolveOptions, r as ResolveResult, T as TrackOptions, W as WebhookResponse, s as XeniaClient, t as XeniaClientOptions, u as createXeniaClient, v as extractContentSwaps, w as parseActions, x as spliceSlots } from '../actions-
|
|
1
|
+
import { I as InteractionType, X as XeniaConfig, a as XeniaEvent, M as MessageCta, b as MessageTemplateFn, c as MessageComponentRenderer, d as XeniaAction } from '../actions-CkiSdvSa.js';
|
|
2
|
+
export { A as AnalyticsContext, e as AnalyticsEventName, f as AnalyticsIdentity, g as AnalyticsIngestResponse, C as ClientEvent, h as ConsentState, i as ContentSwap, j as IdentifyRequest, k as IdentifyResponse, l as Identity, J as JsonValue, m as MessageMountContext, n as MessagePlacement, o as MessageRenderContext, P as PersonalizationSwap, R as ResolveBatchItem, p as ResolveBatchResult, q as ResolveOptions, r as ResolveResult, T as TrackOptions, W as WebhookResponse, s as XeniaClient, t as XeniaClientOptions, u as createXeniaClient, v as extractContentSwaps, w as parseActions, x as spliceSlots } from '../actions-CkiSdvSa.js';
|
|
3
3
|
|
|
4
4
|
interface Parsed {
|
|
5
5
|
eventId: string;
|
package/dist/client/index.js
CHANGED
|
@@ -85,6 +85,7 @@ function parseActions(body) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// src/core/http-client.ts
|
|
88
|
+
var DEFAULT_BASE_URL = "https://engine.xeniamartech.com/xenia";
|
|
88
89
|
function isBrowser() {
|
|
89
90
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
90
91
|
}
|
|
@@ -114,7 +115,7 @@ var HttpClient = class {
|
|
|
114
115
|
retry;
|
|
115
116
|
debug;
|
|
116
117
|
constructor(opts) {
|
|
117
|
-
this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
|
|
118
|
+
this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
118
119
|
this.defaultHeaders = opts.defaultHeaders ?? {};
|
|
119
120
|
this.timeout = opts.timeout ?? 8e3;
|
|
120
121
|
this.retry = {
|
|
@@ -963,6 +964,40 @@ var Identity = class {
|
|
|
963
964
|
return null;
|
|
964
965
|
}
|
|
965
966
|
}
|
|
967
|
+
// ── Customer id / email ──────────────────────────────────────────────────
|
|
968
|
+
//
|
|
969
|
+
// Ambient, persisted the same way as the visitor id, so a value set once
|
|
970
|
+
// (typically alongside `identify()`) rides on every later `resolve()` call
|
|
971
|
+
// without the caller having to pass it again — the SDK-provided-fields
|
|
972
|
+
// parity list on the Personalization Resolve trigger includes both.
|
|
973
|
+
setCustomerId(customerId) {
|
|
974
|
+
try {
|
|
975
|
+
if (customerId) localStorage.setItem(this.key("customer_id"), customerId);
|
|
976
|
+
else localStorage.removeItem(this.key("customer_id"));
|
|
977
|
+
} catch {
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
getCustomerId() {
|
|
981
|
+
try {
|
|
982
|
+
return localStorage.getItem(this.key("customer_id"));
|
|
983
|
+
} catch {
|
|
984
|
+
return null;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
setEmail(email) {
|
|
988
|
+
try {
|
|
989
|
+
if (email) localStorage.setItem(this.key("email"), email);
|
|
990
|
+
else localStorage.removeItem(this.key("email"));
|
|
991
|
+
} catch {
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
getEmail() {
|
|
995
|
+
try {
|
|
996
|
+
return localStorage.getItem(this.key("email"));
|
|
997
|
+
} catch {
|
|
998
|
+
return null;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
966
1001
|
// ── Session id ───────────────────────────────────────────────────────────────
|
|
967
1002
|
/**
|
|
968
1003
|
* Resolve the current session id: reused while activity continues within
|
|
@@ -1426,10 +1461,16 @@ var XeniaClient = class {
|
|
|
1426
1461
|
* Persist a visitor id, attached to every subsequent event, and bind it to
|
|
1427
1462
|
* a known user server-side (`POST /api/events/v1/identify`, fire-and-
|
|
1428
1463
|
* forget — resolves to an `"identify"` client event carrying `personId`).
|
|
1464
|
+
*
|
|
1465
|
+
* `extra.customerId`/`extra.email`, when supplied, are also persisted
|
|
1466
|
+
* ambiently (like the visitor id) so they ride on every later `resolve()`
|
|
1467
|
+
* call automatically — part of the SDK-provided-fields parity list.
|
|
1429
1468
|
*/
|
|
1430
|
-
identify(visitorId) {
|
|
1469
|
+
identify(visitorId, extra) {
|
|
1431
1470
|
this.identity.identify(visitorId);
|
|
1432
|
-
|
|
1471
|
+
if (extra?.customerId !== void 0) this.identity.setCustomerId(extra.customerId);
|
|
1472
|
+
if (extra?.email !== void 0) this.identity.setEmail(extra.email);
|
|
1473
|
+
void this.api.identify({ xeniaVisitorId: visitorId, userId: extra?.customerId, email: extra?.email }).then((res) => this.emit("identify", res)).catch((err) => this.emitError(err));
|
|
1433
1474
|
}
|
|
1434
1475
|
/** Override the customer-journey UUID (else derived from utm_id). */
|
|
1435
1476
|
setJourneyId(id) {
|
|
@@ -1547,15 +1588,40 @@ var XeniaClient = class {
|
|
|
1547
1588
|
return this.identity.getVisitorId() ?? this.identity.getDeviceId() ?? void 0;
|
|
1548
1589
|
}
|
|
1549
1590
|
/**
|
|
1550
|
-
* Stamp the SDK-
|
|
1551
|
-
* `
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1591
|
+
* Stamp the full set of SDK-provided fields into the resolve `data` —
|
|
1592
|
+
* `path`, `query`, `deviceId`, `visitorId`, `customerId`, `email`, `url`,
|
|
1593
|
+
* `referrer`, and the five `utm*` fields — the same field-name/type parity
|
|
1594
|
+
* the webhook trigger's "SDK-provided fields" already promises, now native
|
|
1595
|
+
* (always attached, no marketer toggle) for the Personalization Resolve
|
|
1596
|
+
* trigger too. Plus the reserved `_xenia_vid` key the backend reads for
|
|
1597
|
+
* holdout/exposure bucketing. All of these are spread LAST (after the
|
|
1598
|
+
* caller's own `data`) so none can be overridden per call — the same
|
|
1599
|
+
* override-protection guarantee `_xenia_vid` alone used to have, now
|
|
1600
|
+
* widened to the full set. A no-op (returns `opts` unchanged) when nothing
|
|
1601
|
+
* is resolvable yet (e.g. called before `init()` on a fresh visit with no
|
|
1602
|
+
* page context available).
|
|
1554
1603
|
*/
|
|
1555
1604
|
withVisitor(opts) {
|
|
1605
|
+
const ctx = this.identity.collectContext();
|
|
1556
1606
|
const vid = this.resolveVisitorId();
|
|
1557
|
-
|
|
1558
|
-
|
|
1607
|
+
const sdkFields = compact({
|
|
1608
|
+
path: ctx.path,
|
|
1609
|
+
query: ctx.query,
|
|
1610
|
+
deviceId: this.identity.getDeviceId() ?? void 0,
|
|
1611
|
+
visitorId: vid,
|
|
1612
|
+
customerId: this.identity.getCustomerId() ?? void 0,
|
|
1613
|
+
email: this.identity.getEmail() ?? void 0,
|
|
1614
|
+
url: ctx.url,
|
|
1615
|
+
referrer: ctx.referrer,
|
|
1616
|
+
utmSource: ctx.utmSource,
|
|
1617
|
+
utmMedium: ctx.utmMedium,
|
|
1618
|
+
utmCampaign: ctx.utmCampaign,
|
|
1619
|
+
utmContent: ctx.utmContent,
|
|
1620
|
+
utmId: ctx.utmId
|
|
1621
|
+
});
|
|
1622
|
+
if (vid) sdkFields._xenia_vid = vid;
|
|
1623
|
+
if (Object.keys(sdkFields).length === 0) return opts;
|
|
1624
|
+
return { ...opts, data: { ...opts?.data ?? {}, ...sdkFields } };
|
|
1559
1625
|
}
|
|
1560
1626
|
dntBlocked() {
|
|
1561
1627
|
if (this.options.respectDnt === false) return false;
|