@active-reach/web-sdk 1.38.0 → 1.40.0
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/aegis-push.min.js +1 -1
- package/dist/aegis-push.min.js.map +1 -1
- package/dist/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/{analytics-Cz1ZBOxH.mjs → analytics-C-Go3Pm5.mjs} +27 -2
- package/dist/analytics-C-Go3Pm5.mjs.map +1 -0
- package/dist/core/analytics.d.ts +12 -0
- package/dist/core/analytics.d.ts.map +1 -1
- package/dist/core/prefetch-bundle-client.d.ts +3 -0
- package/dist/core/prefetch-bundle-client.d.ts.map +1 -1
- package/dist/inapp/AegisInAppManager.d.ts +5 -1
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/renderers/card-template.d.ts.map +1 -1
- package/dist/inapp/renderers/games.d.ts.map +1 -1
- package/dist/inapp/renderers/types.d.ts +13 -0
- package/dist/inapp/renderers/types.d.ts.map +1 -1
- package/dist/inbox/AegisInbox.d.ts +3 -0
- package/dist/inbox/AegisInbox.d.ts.map +1 -1
- package/dist/index.js +124 -16
- package/dist/index.js.map +1 -1
- package/dist/push/AegisWebPush.d.ts +19 -0
- package/dist/push/AegisWebPush.d.ts.map +1 -1
- package/dist/push/AegisWebPush.js +31 -2
- package/dist/push/AegisWebPush.js.map +1 -1
- package/dist/react.js +1 -1
- package/dist/runtime/AegisMessageRuntime.d.ts +2 -1
- package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
- package/dist/triggers/ContactScoresFetcher.d.ts +3 -1
- package/dist/triggers/ContactScoresFetcher.d.ts.map +1 -1
- package/dist/triggers/IntentRuleEvaluator.d.ts +1 -1
- package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -1
- package/dist/utils/redact-url.d.ts +1 -1
- package/dist/utils/redact-url.d.ts.map +1 -1
- package/dist/widgets/AegisWidgetManager.d.ts +22 -1
- package/dist/widgets/AegisWidgetManager.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/analytics-Cz1ZBOxH.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Storage, r as redactUrl, l as logger, A as Aegis } from "./analytics-
|
|
2
|
-
import { B, E, N, R, U, m } from "./analytics-
|
|
1
|
+
import { S as Storage, r as redactUrl, l as logger, A as Aegis } from "./analytics-C-Go3Pm5.mjs";
|
|
2
|
+
import { B, E, N, R, U, m } from "./analytics-C-Go3Pm5.mjs";
|
|
3
3
|
import { AegisWebPush } from "./push/AegisWebPush.js";
|
|
4
4
|
function debounce(func, wait) {
|
|
5
5
|
let timeoutId = null;
|
|
@@ -1411,8 +1411,11 @@ function buildProgressElement(el2, ctx, accent, muted) {
|
|
|
1411
1411
|
return code && M[code] || "";
|
|
1412
1412
|
};
|
|
1413
1413
|
const threshold = () => {
|
|
1414
|
+
var _a;
|
|
1414
1415
|
if (typeof el2.threshold === "number" && el2.threshold > 0) return el2.threshold;
|
|
1415
1416
|
if (el2.threshold_source === "free_delivery_setting") {
|
|
1417
|
+
const fromCart = ctx.getCartState && ((_a = ctx.getCartState()) == null ? void 0 : _a.freeDeliveryAbove);
|
|
1418
|
+
if (typeof fromCart === "number" && fromCart > 0) return fromCart;
|
|
1416
1419
|
const v = Number(props()["cart.free_delivery_above"]);
|
|
1417
1420
|
if (v > 0) return v;
|
|
1418
1421
|
}
|
|
@@ -1447,6 +1450,11 @@ function buildProgressElement(el2, ctx, accent, muted) {
|
|
|
1447
1450
|
var _a;
|
|
1448
1451
|
const th = threshold();
|
|
1449
1452
|
const cur = readCur();
|
|
1453
|
+
if (th <= 0 && el2.threshold_source === "free_delivery_setting") {
|
|
1454
|
+
wrap.style.display = "none";
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
wrap.style.display = "flex";
|
|
1450
1458
|
const { pct, complete } = computeProgress({ threshold: th, current: cur });
|
|
1451
1459
|
bar.style.width = `${pct}%`;
|
|
1452
1460
|
const labeled = cardProgressSubLabel({
|
|
@@ -3213,10 +3221,11 @@ function fillBar(accent, pct, h = 8) {
|
|
|
3213
3221
|
}
|
|
3214
3222
|
function renderStreak(ctx) {
|
|
3215
3223
|
const ic = ctx.campaign.interactive_config || {};
|
|
3224
|
+
const count = num(ic.streak_count, 0);
|
|
3225
|
+
if (count <= 0) return;
|
|
3216
3226
|
const s = openGameModal(ctx, "aegis-in-app-streak");
|
|
3217
|
-
const count = num(ic.streak_count, 5);
|
|
3218
3227
|
const goal = num(ic.streak_goal, count + 1);
|
|
3219
|
-
const reward = str$1(ic.streak_reward_text, "
|
|
3228
|
+
const reward = str$1(ic.streak_reward_text, "Order today to keep it going.");
|
|
3220
3229
|
const days = ["M", "T", "W", "T", "F", "S", "S"];
|
|
3221
3230
|
s.content.appendChild(gEl("div", "font-size:44px;line-height:1", "🔥"));
|
|
3222
3231
|
s.content.appendChild(gEl("div", "font-size:22px;font-weight:800;margin:4px 0 2px", `${count}-day streak!`));
|
|
@@ -3233,11 +3242,13 @@ function renderStreak(ctx) {
|
|
|
3233
3242
|
note.appendChild(gEl("b", "", `Day ${goal}`));
|
|
3234
3243
|
note.appendChild(document.createTextNode(" unlocks a reward."));
|
|
3235
3244
|
s.content.appendChild(note);
|
|
3236
|
-
|
|
3245
|
+
const hasUrl = Boolean(str$1(ctx.campaign.action_url));
|
|
3246
|
+
s.ctaButton(str$1(ic.streak_cta_text, hasUrl ? "Order today" : "Got it"), () => {
|
|
3237
3247
|
var _a, _b, _c;
|
|
3238
3248
|
(_a = ctx.haptic) == null ? void 0 : _a.call(ctx, 20);
|
|
3239
3249
|
(_b = ctx.playReaction) == null ? void 0 : _b.call(ctx, s.card, "affirm");
|
|
3240
3250
|
void ((_c = ctx.submitResponse) == null ? void 0 : _c.call(ctx, "streak", { streak_count: count }));
|
|
3251
|
+
if (!hasUrl) s.dismiss();
|
|
3241
3252
|
});
|
|
3242
3253
|
}
|
|
3243
3254
|
function renderMilestone(ctx) {
|
|
@@ -6092,6 +6103,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6092
6103
|
this.apiHost = config.apiHost || "https://api.aegis.ai";
|
|
6093
6104
|
this.userId = config.userId ?? readAnonIdFromStorage$1();
|
|
6094
6105
|
this.contactId = config.contactId;
|
|
6106
|
+
this.contactToken = config.contactToken;
|
|
6095
6107
|
this.organizationId = config.organizationId;
|
|
6096
6108
|
this.propertyId = config.propertyId;
|
|
6097
6109
|
this.debugMode = config.debugMode || false;
|
|
@@ -6306,9 +6318,10 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6306
6318
|
this.userId = userId;
|
|
6307
6319
|
this.refreshCampaigns();
|
|
6308
6320
|
}
|
|
6309
|
-
updateContactId(contactId) {
|
|
6321
|
+
updateContactId(contactId, contactToken) {
|
|
6310
6322
|
var _a;
|
|
6311
6323
|
this.contactId = contactId;
|
|
6324
|
+
this.contactToken = contactToken;
|
|
6312
6325
|
(_a = this.activeWebChat) == null ? void 0 : _a.updateContactId(contactId);
|
|
6313
6326
|
this.disconnectSSE();
|
|
6314
6327
|
if (this.enableSSE && this.organizationId) {
|
|
@@ -6523,6 +6536,9 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6523
6536
|
if (this.contactId) {
|
|
6524
6537
|
headers["X-Contact-ID"] = this.contactId;
|
|
6525
6538
|
}
|
|
6539
|
+
if (this.contactId && this.contactToken) {
|
|
6540
|
+
headers["X-Contact-Token"] = this.contactToken;
|
|
6541
|
+
}
|
|
6526
6542
|
Object.entries(headers).forEach(([key, value]) => {
|
|
6527
6543
|
url.searchParams.append(key, value);
|
|
6528
6544
|
});
|
|
@@ -6601,6 +6617,9 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
6601
6617
|
if (this.contactId) {
|
|
6602
6618
|
headers["X-Contact-ID"] = this.contactId;
|
|
6603
6619
|
}
|
|
6620
|
+
if (this.contactId && this.contactToken) {
|
|
6621
|
+
headers["X-Contact-Token"] = this.contactToken;
|
|
6622
|
+
}
|
|
6604
6623
|
if (this.organizationId) {
|
|
6605
6624
|
headers["X-Organization-ID"] = this.organizationId;
|
|
6606
6625
|
}
|
|
@@ -7538,6 +7557,23 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7538
7557
|
b.textContent = campaign.body;
|
|
7539
7558
|
body.appendChild(b);
|
|
7540
7559
|
}
|
|
7560
|
+
const _profileKeys = /* @__PURE__ */ new Set(["first_name", "email", "date_of_birth"]);
|
|
7561
|
+
const _collectsProfile = fields.some(
|
|
7562
|
+
(f) => typeof f.maps_to === "string" && _profileKeys.has(f.maps_to)
|
|
7563
|
+
);
|
|
7564
|
+
if (_collectsProfile && this.organizationId && this.writeKey) {
|
|
7565
|
+
const earn = document.createElement("div");
|
|
7566
|
+
earn.style.cssText = "font-size: 11px; font-weight: 600; opacity: 0.75; margin-top: -4px;";
|
|
7567
|
+
body.appendChild(earn);
|
|
7568
|
+
void fetch(`${this.apiHost}/v1/in-app/earn-hint?rule_type=profile_complete`, {
|
|
7569
|
+
headers: { "X-Aegis-Write-Key": this.writeKey, "X-Organization-ID": this.organizationId }
|
|
7570
|
+
}).then((r) => r.ok ? r.json() : null).then((d) => {
|
|
7571
|
+
if (!d || d.enabled !== true || !(Number(d.points) > 0)) return;
|
|
7572
|
+
const name = typeof d.points_name === "string" ? d.points_name : "points";
|
|
7573
|
+
earn.textContent = `Earn ${Number(d.points)} ${name} for completing your profile`;
|
|
7574
|
+
}).catch(() => {
|
|
7575
|
+
});
|
|
7576
|
+
}
|
|
7541
7577
|
const inputs = /* @__PURE__ */ new Map();
|
|
7542
7578
|
const requiredKeys = /* @__PURE__ */ new Set();
|
|
7543
7579
|
const ctrlCss = `padding: 9px 11px; border-radius: 9px; border: 1px solid ${text}33; background: ${text}0d; color: ${text}; font-size: 13px; width: 100%; box-sizing: border-box; font-family: inherit;`;
|
|
@@ -7644,6 +7680,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7644
7680
|
"X-Organization-ID": this.organizationId
|
|
7645
7681
|
};
|
|
7646
7682
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
7683
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
7647
7684
|
const variantId = campaign.assigned_variant_id;
|
|
7648
7685
|
const res = await fetch(`${this.apiHost}/v1/in-app/responses`, {
|
|
7649
7686
|
method: "POST",
|
|
@@ -7653,6 +7690,9 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7653
7690
|
campaign_id: campaign.id,
|
|
7654
7691
|
response_type: "form",
|
|
7655
7692
|
contact_id: this.contactId,
|
|
7693
|
+
// The device id, so a play before login joins the person once they
|
|
7694
|
+
// log in (RP1, Aman 2026-09-27). `user_id` may be the brand's own id.
|
|
7695
|
+
anonymous_id: readAnonIdFromStorage$1(),
|
|
7656
7696
|
user_id: this.userId,
|
|
7657
7697
|
variant_id: variantId,
|
|
7658
7698
|
platform: "web",
|
|
@@ -7679,6 +7719,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7679
7719
|
"X-Organization-ID": this.organizationId
|
|
7680
7720
|
};
|
|
7681
7721
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
7722
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
7682
7723
|
const variantId = campaign.assigned_variant_id;
|
|
7683
7724
|
const res = await fetch(`${this.apiHost}/v1/in-app/responses`, {
|
|
7684
7725
|
method: "POST",
|
|
@@ -7688,6 +7729,9 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
7688
7729
|
campaign_id: campaign.id,
|
|
7689
7730
|
response_type: responseType,
|
|
7690
7731
|
contact_id: this.contactId,
|
|
7732
|
+
// The device id, so a play before login joins the person once they
|
|
7733
|
+
// log in (RP1, Aman 2026-09-27). `user_id` may be the brand's own id.
|
|
7734
|
+
anonymous_id: readAnonIdFromStorage$1(),
|
|
7691
7735
|
user_id: this.userId,
|
|
7692
7736
|
variant_id: variantId,
|
|
7693
7737
|
platform: "web",
|
|
@@ -11880,13 +11924,16 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11880
11924
|
if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
|
|
11881
11925
|
if (this.userId) headers["X-User-ID"] = this.userId;
|
|
11882
11926
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
11927
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
11883
11928
|
const workspaceId = (_a = this.getWorkspaceId) == null ? void 0 : _a.call(this);
|
|
11929
|
+
const storedAnonId = readAnonIdFromStorage$1();
|
|
11930
|
+
const identifiedUserId = this.userId && this.userId !== storedAnonId ? this.userId : void 0;
|
|
11884
11931
|
const body = {
|
|
11885
11932
|
campaign_id: campaignId,
|
|
11886
11933
|
event_type: eventType,
|
|
11887
|
-
user_id:
|
|
11934
|
+
user_id: identifiedUserId,
|
|
11888
11935
|
contact_id: this.contactId,
|
|
11889
|
-
anonymous_id:
|
|
11936
|
+
anonymous_id: storedAnonId,
|
|
11890
11937
|
platform: "web",
|
|
11891
11938
|
workspace_id: workspaceId,
|
|
11892
11939
|
// Per-surface traffic (PROPERTY_IN_APP_TAB_SURFACE_BREAKDOWN_TRACKER
|
|
@@ -11978,6 +12025,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
11978
12025
|
if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
|
|
11979
12026
|
if (this.userId) headers["X-User-ID"] = this.userId;
|
|
11980
12027
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
12028
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
11981
12029
|
let retryable = true;
|
|
11982
12030
|
try {
|
|
11983
12031
|
const response = await fetch(
|
|
@@ -12490,6 +12538,9 @@ class ContactScoresFetcher {
|
|
|
12490
12538
|
"X-Contact-ID": contactId,
|
|
12491
12539
|
"X-User-ID": contactId
|
|
12492
12540
|
};
|
|
12541
|
+
if (opts.contactToken) {
|
|
12542
|
+
headers["X-Contact-Token"] = opts.contactToken;
|
|
12543
|
+
}
|
|
12493
12544
|
if (this.organizationId) {
|
|
12494
12545
|
headers["X-Organization-ID"] = this.organizationId;
|
|
12495
12546
|
}
|
|
@@ -12652,6 +12703,7 @@ class PrefetchBundleClient {
|
|
|
12652
12703
|
this.writeKey = options.writeKey;
|
|
12653
12704
|
this.organizationId = options.organizationId;
|
|
12654
12705
|
this.contactId = options.contactId;
|
|
12706
|
+
this.contactToken = options.contactToken;
|
|
12655
12707
|
this.userId = options.userId;
|
|
12656
12708
|
this.propertyId = options.propertyId;
|
|
12657
12709
|
this.abAssignments = options.abAssignments ?? {};
|
|
@@ -12716,7 +12768,10 @@ class PrefetchBundleClient {
|
|
|
12716
12768
|
let changed = false;
|
|
12717
12769
|
if (partial.contactId !== void 0 && partial.contactId !== this.contactId) {
|
|
12718
12770
|
this.contactId = partial.contactId;
|
|
12771
|
+
this.contactToken = partial.contactToken;
|
|
12719
12772
|
changed = true;
|
|
12773
|
+
} else if (partial.contactToken !== void 0 && partial.contactToken !== this.contactToken) {
|
|
12774
|
+
this.contactToken = partial.contactToken;
|
|
12720
12775
|
}
|
|
12721
12776
|
if (partial.userId !== void 0 && partial.userId !== this.userId) {
|
|
12722
12777
|
this.userId = partial.userId;
|
|
@@ -12789,6 +12844,7 @@ class PrefetchBundleClient {
|
|
|
12789
12844
|
};
|
|
12790
12845
|
if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
|
|
12791
12846
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
12847
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
12792
12848
|
if (this.userId) headers["X-User-ID"] = this.userId;
|
|
12793
12849
|
if (this.propertyId) headers["X-Property-Id"] = this.propertyId;
|
|
12794
12850
|
if (this.currentETag) headers["If-None-Match"] = this.currentETag;
|
|
@@ -12848,6 +12904,7 @@ class AegisInbox {
|
|
|
12848
12904
|
this.writeKey = config.writeKey;
|
|
12849
12905
|
this.organizationId = config.organizationId;
|
|
12850
12906
|
this.contactId = config.contactId;
|
|
12907
|
+
this.contactToken = config.contactToken;
|
|
12851
12908
|
this.propertyId = config.propertyId;
|
|
12852
12909
|
this.bundleClient = config.bundleClient;
|
|
12853
12910
|
this.unreadPollIntervalMs = config.unreadPollIntervalMs ?? DEFAULT_UNREAD_POLL;
|
|
@@ -12896,7 +12953,10 @@ class AegisInbox {
|
|
|
12896
12953
|
let changed = false;
|
|
12897
12954
|
if (partial.contactId !== void 0 && partial.contactId !== this.contactId) {
|
|
12898
12955
|
this.contactId = partial.contactId;
|
|
12956
|
+
this.contactToken = partial.contactToken;
|
|
12899
12957
|
changed = true;
|
|
12958
|
+
} else if (partial.contactToken !== void 0 && partial.contactToken !== this.contactToken) {
|
|
12959
|
+
this.contactToken = partial.contactToken;
|
|
12900
12960
|
}
|
|
12901
12961
|
if (partial.propertyId !== void 0 && partial.propertyId !== this.propertyId) {
|
|
12902
12962
|
this.propertyId = partial.propertyId;
|
|
@@ -13067,6 +13127,7 @@ class AegisInbox {
|
|
|
13067
13127
|
};
|
|
13068
13128
|
if (this.organizationId) h["X-Organization-ID"] = this.organizationId;
|
|
13069
13129
|
if (this.contactId) h["X-Contact-ID"] = this.contactId;
|
|
13130
|
+
if (this.contactId && this.contactToken) h["X-Contact-Token"] = this.contactToken;
|
|
13070
13131
|
if (this.propertyId) h["X-Property-Id"] = this.propertyId;
|
|
13071
13132
|
return h;
|
|
13072
13133
|
}
|
|
@@ -13181,6 +13242,7 @@ class AegisWidgetManager {
|
|
|
13181
13242
|
this.apiHost = config.apiHost || "https://api.aegis.ai";
|
|
13182
13243
|
this.userId = config.userId ?? readAnonIdFromStorage();
|
|
13183
13244
|
this.contactId = config.contactId;
|
|
13245
|
+
this.contactToken = config.contactToken;
|
|
13184
13246
|
this.organizationId = config.organizationId;
|
|
13185
13247
|
this.debugMode = config.debugMode || false;
|
|
13186
13248
|
this.triggerEngine = config.triggerEngine;
|
|
@@ -13203,9 +13265,10 @@ class AegisWidgetManager {
|
|
|
13203
13265
|
* configs so subsequent renders target the new identity. Does NOT
|
|
13204
13266
|
* re-render already-visible widgets — a full teardown requires destroy().
|
|
13205
13267
|
*/
|
|
13206
|
-
async updateContactId(contactId) {
|
|
13207
|
-
if (this.contactId === contactId) return;
|
|
13268
|
+
async updateContactId(contactId, contactToken) {
|
|
13269
|
+
if (this.contactId === contactId && this.contactToken === contactToken) return;
|
|
13208
13270
|
this.contactId = contactId;
|
|
13271
|
+
this.contactToken = contactToken;
|
|
13209
13272
|
this.log(`Contact ID updated → ${contactId ?? "(cleared)"}`);
|
|
13210
13273
|
if (this.isInitialized && !this.isDestroyed && this.enablePrefetch && contactId) {
|
|
13211
13274
|
await this.fetchPrefetchConfigs();
|
|
@@ -13441,6 +13504,7 @@ class AegisWidgetManager {
|
|
|
13441
13504
|
"X-Aegis-Write-Key": this.writeKey
|
|
13442
13505
|
};
|
|
13443
13506
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
13507
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
13444
13508
|
if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
|
|
13445
13509
|
const response = await fetch(url, { headers, credentials: "include" });
|
|
13446
13510
|
if (!response.ok) {
|
|
@@ -13463,6 +13527,7 @@ class AegisWidgetManager {
|
|
|
13463
13527
|
};
|
|
13464
13528
|
if (this.userId) headers["X-User-ID"] = this.userId;
|
|
13465
13529
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
13530
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
13466
13531
|
if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
|
|
13467
13532
|
if (this.sourcePlatform) headers["X-Source-Platform"] = this.sourcePlatform;
|
|
13468
13533
|
const response = await fetch(url, { headers, credentials: "include" });
|
|
@@ -14063,6 +14128,37 @@ class AegisWidgetManager {
|
|
|
14063
14128
|
box-sizing: border-box;
|
|
14064
14129
|
`;
|
|
14065
14130
|
form.appendChild(nameInput);
|
|
14131
|
+
const collectBirthday = config.collect_birthday === true;
|
|
14132
|
+
let birthdayInput = null;
|
|
14133
|
+
if (collectBirthday) {
|
|
14134
|
+
const birthdayId = `aegis-spin-dob-${widgetId}`;
|
|
14135
|
+
const birthdayLabel = document.createElement("label");
|
|
14136
|
+
birthdayLabel.htmlFor = birthdayId;
|
|
14137
|
+
birthdayLabel.textContent = "Birthday (optional) — for a birthday treat";
|
|
14138
|
+
birthdayLabel.style.cssText = `
|
|
14139
|
+
display: block;
|
|
14140
|
+
font-size: 12px;
|
|
14141
|
+
font-weight: 600;
|
|
14142
|
+
opacity: 0.75;
|
|
14143
|
+
margin-bottom: 4px;
|
|
14144
|
+
color: ${this.sanitizeColor(textColor)};
|
|
14145
|
+
`;
|
|
14146
|
+
form.appendChild(birthdayLabel);
|
|
14147
|
+
birthdayInput = document.createElement("input");
|
|
14148
|
+
birthdayInput.id = birthdayId;
|
|
14149
|
+
birthdayInput.type = "date";
|
|
14150
|
+
birthdayInput.max = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
14151
|
+
birthdayInput.style.cssText = `
|
|
14152
|
+
width: 100%;
|
|
14153
|
+
padding: 14px;
|
|
14154
|
+
border: 2px solid #ddd;
|
|
14155
|
+
border-radius: 8px;
|
|
14156
|
+
font-size: 16px;
|
|
14157
|
+
margin-bottom: 12px;
|
|
14158
|
+
box-sizing: border-box;
|
|
14159
|
+
`;
|
|
14160
|
+
form.appendChild(birthdayInput);
|
|
14161
|
+
}
|
|
14066
14162
|
const submitButton = document.createElement("button");
|
|
14067
14163
|
submitButton.type = "submit";
|
|
14068
14164
|
submitButton.textContent = "Spin the Wheel!";
|
|
@@ -14093,6 +14189,7 @@ class AegisWidgetManager {
|
|
|
14093
14189
|
const phone = phoneInput.value.trim();
|
|
14094
14190
|
const email = emailInput.value.trim();
|
|
14095
14191
|
const name = nameInput.value.trim();
|
|
14192
|
+
const dateOfBirth = birthdayInput ? birthdayInput.value.trim() : "";
|
|
14096
14193
|
if (!this.validatePhone(phone)) {
|
|
14097
14194
|
errorMessage.textContent = "Please enter a valid phone number (e.g., +1234567890)";
|
|
14098
14195
|
errorMessage.style.display = "block";
|
|
@@ -14113,6 +14210,7 @@ class AegisWidgetManager {
|
|
|
14113
14210
|
phone,
|
|
14114
14211
|
email,
|
|
14115
14212
|
name,
|
|
14213
|
+
dateOfBirth,
|
|
14116
14214
|
cart,
|
|
14117
14215
|
widgetId
|
|
14118
14216
|
});
|
|
@@ -14163,6 +14261,9 @@ class AegisWidgetManager {
|
|
|
14163
14261
|
phone: data.phone.replace(/[\s()-]/g, ""),
|
|
14164
14262
|
email: data.email || void 0,
|
|
14165
14263
|
name: data.name || void 0,
|
|
14264
|
+
// Omitted when blank — the server distinguishes "not given" from a value
|
|
14265
|
+
// it could not parse, and neither is an empty string.
|
|
14266
|
+
date_of_birth: data.dateOfBirth || void 0,
|
|
14166
14267
|
cart_id: ((_a = data.cart) == null ? void 0 : _a.cart_id) || `web_${Date.now()}`,
|
|
14167
14268
|
cart_token: (_b = data.cart) == null ? void 0 : _b.cart_id,
|
|
14168
14269
|
cart_total: ((_c = data.cart) == null ? void 0 : _c.cart_total) || 0,
|
|
@@ -14664,6 +14765,7 @@ class AegisWidgetManager {
|
|
|
14664
14765
|
};
|
|
14665
14766
|
if (this.userId) headers["X-User-ID"] = this.userId;
|
|
14666
14767
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
14768
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
14667
14769
|
if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
|
|
14668
14770
|
const response = await fetch(url, {
|
|
14669
14771
|
method: "POST",
|
|
@@ -14741,6 +14843,7 @@ class AegisWidgetManager {
|
|
|
14741
14843
|
};
|
|
14742
14844
|
if (this.userId) headers["X-User-ID"] = this.userId;
|
|
14743
14845
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
14846
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
14744
14847
|
if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
|
|
14745
14848
|
const workspaceId = (_a = this.getWorkspaceId) == null ? void 0 : _a.call(this);
|
|
14746
14849
|
const response = await fetch(url, {
|
|
@@ -14768,6 +14871,7 @@ class AegisWidgetManager {
|
|
|
14768
14871
|
};
|
|
14769
14872
|
if (this.userId) headers["X-User-ID"] = this.userId;
|
|
14770
14873
|
if (this.contactId) headers["X-Contact-ID"] = this.contactId;
|
|
14874
|
+
if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
|
|
14771
14875
|
if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
|
|
14772
14876
|
const workspaceId = (_a = this.getWorkspaceId) == null ? void 0 : _a.call(this);
|
|
14773
14877
|
await fetch(url, {
|
|
@@ -15286,7 +15390,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
15286
15390
|
var _a;
|
|
15287
15391
|
this.initialized = false;
|
|
15288
15392
|
{
|
|
15289
|
-
const v = "1.
|
|
15393
|
+
const v = "1.40.0";
|
|
15290
15394
|
try {
|
|
15291
15395
|
globalThis.__AEGIS_SDK_VERSION__ = v;
|
|
15292
15396
|
} catch {
|
|
@@ -15306,12 +15410,14 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
15306
15410
|
const triggerEngine = config.triggerEngine ?? new TriggerEngine();
|
|
15307
15411
|
const ownsTriggerEngine = !config.triggerEngine;
|
|
15308
15412
|
this.contactId = config.contactId;
|
|
15413
|
+
this.contactToken = config.contactToken;
|
|
15309
15414
|
this.pairingApiHost = config.apiHost ?? "";
|
|
15310
15415
|
this.widgets = new AegisWidgetManager({
|
|
15311
15416
|
writeKey: config.writeKey,
|
|
15312
15417
|
apiHost: config.apiHost,
|
|
15313
15418
|
userId: config.userId,
|
|
15314
15419
|
contactId: config.contactId,
|
|
15420
|
+
contactToken: config.contactToken,
|
|
15315
15421
|
organizationId: config.organizationId,
|
|
15316
15422
|
debugMode: config.debugMode,
|
|
15317
15423
|
triggerEngine,
|
|
@@ -15334,6 +15440,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
15334
15440
|
apiHost: config.apiHost,
|
|
15335
15441
|
userId: config.userId,
|
|
15336
15442
|
contactId: config.contactId,
|
|
15443
|
+
contactToken: config.contactToken,
|
|
15337
15444
|
organizationId: config.organizationId,
|
|
15338
15445
|
propertyId: config.propertyId,
|
|
15339
15446
|
debugMode: config.debugMode,
|
|
@@ -15406,7 +15513,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
15406
15513
|
]);
|
|
15407
15514
|
(_a = this.chat) == null ? void 0 : _a.initialize();
|
|
15408
15515
|
if (this.contactId) {
|
|
15409
|
-
void this.contactScores.fetchForContact(this.contactId);
|
|
15516
|
+
void this.contactScores.fetchForContact(this.contactId, { contactToken: this.contactToken });
|
|
15410
15517
|
}
|
|
15411
15518
|
}
|
|
15412
15519
|
/**
|
|
@@ -15417,13 +15524,14 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
|
|
|
15417
15524
|
* wait — callers that care about the fetched state await on the
|
|
15418
15525
|
* returned promise.
|
|
15419
15526
|
*/
|
|
15420
|
-
async updateContactId(contactId) {
|
|
15527
|
+
async updateContactId(contactId, contactToken) {
|
|
15421
15528
|
var _a, _b, _c;
|
|
15422
15529
|
this.contactId = contactId;
|
|
15423
|
-
|
|
15530
|
+
this.contactToken = contactToken;
|
|
15531
|
+
(_b = (_a = this.inApp).updateContactId) == null ? void 0 : _b.call(_a, contactId, contactToken);
|
|
15424
15532
|
(_c = this.chat) == null ? void 0 : _c.updateContactId(contactId);
|
|
15425
|
-
await this.widgets.updateContactId(contactId);
|
|
15426
|
-
void this.contactScores.fetchForContact(contactId);
|
|
15533
|
+
await this.widgets.updateContactId(contactId, contactToken);
|
|
15534
|
+
void this.contactScores.fetchForContact(contactId, { contactToken });
|
|
15427
15535
|
}
|
|
15428
15536
|
/**
|
|
15429
15537
|
* Forward a client-side event (product_viewed, cart_idle_90s, etc.)
|