@active-reach/web-sdk 1.14.1 → 1.15.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.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/inapp/AegisInAppManager.d.ts +32 -0
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/index.js +346 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/AegisMessageRuntime.d.ts +35 -0
- package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
- package/dist/triggers/ContactScoresFetcher.d.ts +105 -0
- package/dist/triggers/ContactScoresFetcher.d.ts.map +1 -0
- package/dist/triggers/IntentRuleEvaluator.d.ts +1 -1
- package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -1
- package/dist/triggers/index.d.ts +2 -0
- package/dist/triggers/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -187,6 +187,38 @@ export declare class AegisInAppManager {
|
|
|
187
187
|
initialize(): Promise<void>;
|
|
188
188
|
updateUserId(userId: string): void;
|
|
189
189
|
updateContactId(contactId: string): void;
|
|
190
|
+
private refreshDebounceTimer?;
|
|
191
|
+
private static readonly REFRESH_DEBOUNCE_MS;
|
|
192
|
+
/**
|
|
193
|
+
* Qualifying-event refresh — schedule a debounced `refreshCampaigns()`
|
|
194
|
+
* call in response to a host-app SDK event (`aegis.page()`,
|
|
195
|
+
* `aegis.screen()`, `aegis.track(name)`). Matches CleverTap / MoEngage /
|
|
196
|
+
* WebEngage's "refresh on qualifying event" shape, translated to the
|
|
197
|
+
* browser session.
|
|
198
|
+
*
|
|
199
|
+
* Why: new server-side eligibility opens on these events (a `page` view
|
|
200
|
+
* arms route-targeted campaigns; a `track('product_viewed')` arms
|
|
201
|
+
* trigger-gated campaigns whose `client_trigger.config.event` matches).
|
|
202
|
+
* Pre-P1, the SDK only refreshed on `initialize()` + `updateContactId()`
|
|
203
|
+
* + the SSE update channel (which storefront has disabled by design),
|
|
204
|
+
* so newly armed campaigns were invisible until the next identity flip.
|
|
205
|
+
*
|
|
206
|
+
* Debounce: 300ms. Five `page()` calls inside the window coalesce to
|
|
207
|
+
* one fetch; a sixth call ≥300ms after the prior burst starts a new
|
|
208
|
+
* fetch. The trailing-edge schedule (re-arm on every call) is correct
|
|
209
|
+
* for storefront rage-clicks + SPA route bursts — we want the LATEST
|
|
210
|
+
* URL's eligibility, not the first.
|
|
211
|
+
*
|
|
212
|
+
* Safe to call on the server (no-op when `setTimeout` is unavailable
|
|
213
|
+
* — though that's vanishingly rare in any modern environment we ship to).
|
|
214
|
+
*
|
|
215
|
+
* `eventName` is currently used only for the debug log line; it's
|
|
216
|
+
* preserved on the signature so a future P-phase can pass it through
|
|
217
|
+
* to `/v1/in-app/active?trigger_event=<name>` for the optional
|
|
218
|
+
* server-side eligibility-on-this-event optimization noted in the
|
|
219
|
+
* P1 plan.
|
|
220
|
+
*/
|
|
221
|
+
refreshOnEvent(eventName: string): void;
|
|
190
222
|
/**
|
|
191
223
|
* Conversion-aware suppression. Call this when the host app observes a
|
|
192
224
|
* goal event (purchase, order_placed, checkout_completed, or any custom
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AegisInAppManager.d.ts","sourceRoot":"","sources":["../../src/inapp/AegisInAppManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAyBH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EACA,OAAO,GACP,QAAQ,GACR,SAAS,GACT,aAAa,GACb,mBAAmB,GACnB,OAAO,GACP,KAAK,GAEL,gBAAgB,GAChB,YAAY,GACZ,cAAc,GACd,gBAAgB,GAChB,wBAAwB,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,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iHjB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,aAAa;IA8IrB,OAAO,CAAC,kBAAkB;IA6C1B,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,aAAa;IAqBrB;;;;;;;;;;;OAWG;YACW,UAAU;IAuExB,OAAO,CAAC,GAAG;IAMX,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CAsCpD"}
|
package/dist/index.js
CHANGED
|
@@ -880,6 +880,49 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
880
880
|
}
|
|
881
881
|
this.refreshCampaigns();
|
|
882
882
|
}
|
|
883
|
+
/**
|
|
884
|
+
* Qualifying-event refresh — schedule a debounced `refreshCampaigns()`
|
|
885
|
+
* call in response to a host-app SDK event (`aegis.page()`,
|
|
886
|
+
* `aegis.screen()`, `aegis.track(name)`). Matches CleverTap / MoEngage /
|
|
887
|
+
* WebEngage's "refresh on qualifying event" shape, translated to the
|
|
888
|
+
* browser session.
|
|
889
|
+
*
|
|
890
|
+
* Why: new server-side eligibility opens on these events (a `page` view
|
|
891
|
+
* arms route-targeted campaigns; a `track('product_viewed')` arms
|
|
892
|
+
* trigger-gated campaigns whose `client_trigger.config.event` matches).
|
|
893
|
+
* Pre-P1, the SDK only refreshed on `initialize()` + `updateContactId()`
|
|
894
|
+
* + the SSE update channel (which storefront has disabled by design),
|
|
895
|
+
* so newly armed campaigns were invisible until the next identity flip.
|
|
896
|
+
*
|
|
897
|
+
* Debounce: 300ms. Five `page()` calls inside the window coalesce to
|
|
898
|
+
* one fetch; a sixth call ≥300ms after the prior burst starts a new
|
|
899
|
+
* fetch. The trailing-edge schedule (re-arm on every call) is correct
|
|
900
|
+
* for storefront rage-clicks + SPA route bursts — we want the LATEST
|
|
901
|
+
* URL's eligibility, not the first.
|
|
902
|
+
*
|
|
903
|
+
* Safe to call on the server (no-op when `setTimeout` is unavailable
|
|
904
|
+
* — though that's vanishingly rare in any modern environment we ship to).
|
|
905
|
+
*
|
|
906
|
+
* `eventName` is currently used only for the debug log line; it's
|
|
907
|
+
* preserved on the signature so a future P-phase can pass it through
|
|
908
|
+
* to `/v1/in-app/active?trigger_event=<name>` for the optional
|
|
909
|
+
* server-side eligibility-on-this-event optimization noted in the
|
|
910
|
+
* P1 plan.
|
|
911
|
+
*/
|
|
912
|
+
refreshOnEvent(eventName) {
|
|
913
|
+
if (!this.isInitialized) {
|
|
914
|
+
this.log(`refreshOnEvent(${eventName}) before initialize — ignored`);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
if (this.refreshDebounceTimer) {
|
|
918
|
+
clearTimeout(this.refreshDebounceTimer);
|
|
919
|
+
}
|
|
920
|
+
this.refreshDebounceTimer = setTimeout(() => {
|
|
921
|
+
this.refreshDebounceTimer = void 0;
|
|
922
|
+
this.log(`refreshOnEvent(${eventName}) — firing refreshCampaigns()`);
|
|
923
|
+
void this.refreshCampaigns();
|
|
924
|
+
}, _AegisInAppManager.REFRESH_DEBOUNCE_MS);
|
|
925
|
+
}
|
|
883
926
|
/**
|
|
884
927
|
* Conversion-aware suppression. Call this when the host app observes a
|
|
885
928
|
* goal event (purchase, order_placed, checkout_completed, or any custom
|
|
@@ -2814,6 +2857,10 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
2814
2857
|
}
|
|
2815
2858
|
destroy(options) {
|
|
2816
2859
|
this.disconnectSSE();
|
|
2860
|
+
if (this.refreshDebounceTimer) {
|
|
2861
|
+
clearTimeout(this.refreshDebounceTimer);
|
|
2862
|
+
this.refreshDebounceTimer = void 0;
|
|
2863
|
+
}
|
|
2817
2864
|
if (typeof document !== "undefined") {
|
|
2818
2865
|
document.querySelectorAll(
|
|
2819
2866
|
".aegis-in-app-banner, .aegis-in-app-modal-overlay, .aegis-in-app-fullscreen-overlay, .aegis-in-app-half-interstitial-overlay, .aegis-in-app-alert-overlay, .aegis-in-app-pip, .aegis-in-app-nps-overlay, .aegis-in-app-countdown-overlay, .aegis-in-app-rating-overlay, .aegis-in-app-poll-overlay, .aegis-in-app-quiz-overlay, .aegis-in-app-rating-card, .aegis-in-app-nps-card"
|
|
@@ -2835,6 +2882,7 @@ const _AegisInAppManager = class _AegisInAppManager {
|
|
|
2835
2882
|
}
|
|
2836
2883
|
};
|
|
2837
2884
|
_AegisInAppManager.CONVERSION_STORAGE_PREFIX = "aegis_conv_";
|
|
2885
|
+
_AegisInAppManager.REFRESH_DEBOUNCE_MS = 300;
|
|
2838
2886
|
let AegisInAppManager = _AegisInAppManager;
|
|
2839
2887
|
function renderPreview(config) {
|
|
2840
2888
|
document.querySelectorAll(
|
|
@@ -4048,6 +4096,244 @@ class TriggerEngine {
|
|
|
4048
4096
|
}
|
|
4049
4097
|
}
|
|
4050
4098
|
}
|
|
4099
|
+
function isIntentLeaf(expr) {
|
|
4100
|
+
return "signal" in expr;
|
|
4101
|
+
}
|
|
4102
|
+
function evaluateLeaf(leaf, snapshot) {
|
|
4103
|
+
const actual = snapshot[leaf.signal];
|
|
4104
|
+
if (actual === void 0 || actual === null) {
|
|
4105
|
+
return null;
|
|
4106
|
+
}
|
|
4107
|
+
const want = leaf.value;
|
|
4108
|
+
switch (leaf.op) {
|
|
4109
|
+
case "gte":
|
|
4110
|
+
case "lte":
|
|
4111
|
+
case "gt":
|
|
4112
|
+
case "lt": {
|
|
4113
|
+
if (typeof actual !== "number" || typeof want !== "number") return false;
|
|
4114
|
+
if (leaf.op === "gte") return actual >= want;
|
|
4115
|
+
if (leaf.op === "lte") return actual <= want;
|
|
4116
|
+
if (leaf.op === "gt") return actual > want;
|
|
4117
|
+
return actual < want;
|
|
4118
|
+
}
|
|
4119
|
+
case "eq":
|
|
4120
|
+
return actual === want;
|
|
4121
|
+
case "neq":
|
|
4122
|
+
return actual !== want;
|
|
4123
|
+
case "in":
|
|
4124
|
+
case "nin": {
|
|
4125
|
+
if (!Array.isArray(want)) return false;
|
|
4126
|
+
const isMember = want.some((v) => v === actual);
|
|
4127
|
+
return leaf.op === "in" ? isMember : !isMember;
|
|
4128
|
+
}
|
|
4129
|
+
default: {
|
|
4130
|
+
leaf.op;
|
|
4131
|
+
return false;
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
function evaluateExpr(expr, snapshot) {
|
|
4136
|
+
if (isIntentLeaf(expr)) {
|
|
4137
|
+
return evaluateLeaf(expr, snapshot);
|
|
4138
|
+
}
|
|
4139
|
+
switch (expr.op) {
|
|
4140
|
+
case "AND": {
|
|
4141
|
+
for (const operand of expr.operands) {
|
|
4142
|
+
const v = evaluateExpr(operand, snapshot);
|
|
4143
|
+
if (v === null) return false;
|
|
4144
|
+
if (!v) return false;
|
|
4145
|
+
}
|
|
4146
|
+
return true;
|
|
4147
|
+
}
|
|
4148
|
+
case "OR": {
|
|
4149
|
+
let allNull = true;
|
|
4150
|
+
for (const operand of expr.operands) {
|
|
4151
|
+
const v = evaluateExpr(operand, snapshot);
|
|
4152
|
+
if (v === true) return true;
|
|
4153
|
+
if (v !== null) allNull = false;
|
|
4154
|
+
}
|
|
4155
|
+
return allNull ? null : false;
|
|
4156
|
+
}
|
|
4157
|
+
case "NOT": {
|
|
4158
|
+
const v = evaluateExpr(expr.operands[0], snapshot);
|
|
4159
|
+
if (v === null) return null;
|
|
4160
|
+
return !v;
|
|
4161
|
+
}
|
|
4162
|
+
default: {
|
|
4163
|
+
return false;
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
function evaluateRule(rule, snapshot) {
|
|
4168
|
+
const result = evaluateExpr(rule.when, snapshot);
|
|
4169
|
+
return result === true;
|
|
4170
|
+
}
|
|
4171
|
+
class IntentRuleEvaluator {
|
|
4172
|
+
constructor() {
|
|
4173
|
+
this.armed = [];
|
|
4174
|
+
this.snapshot = {};
|
|
4175
|
+
this.firedThisSession = /* @__PURE__ */ new Set();
|
|
4176
|
+
this.silencedThisSession = /* @__PURE__ */ new Set();
|
|
4177
|
+
}
|
|
4178
|
+
// ─── snapshot management ───
|
|
4179
|
+
updateSignal(signal, value) {
|
|
4180
|
+
this.snapshot[signal] = value;
|
|
4181
|
+
}
|
|
4182
|
+
updateSnapshot(partial) {
|
|
4183
|
+
Object.assign(this.snapshot, partial);
|
|
4184
|
+
}
|
|
4185
|
+
getSnapshot() {
|
|
4186
|
+
return this.snapshot;
|
|
4187
|
+
}
|
|
4188
|
+
// ─── armed-campaign management ───
|
|
4189
|
+
setArmed(campaigns) {
|
|
4190
|
+
this.armed = [...campaigns];
|
|
4191
|
+
}
|
|
4192
|
+
getArmed() {
|
|
4193
|
+
return this.armed;
|
|
4194
|
+
}
|
|
4195
|
+
markFired(campaignId) {
|
|
4196
|
+
this.firedThisSession.add(campaignId);
|
|
4197
|
+
}
|
|
4198
|
+
/** Clear all per-session state. Caller invokes on logout or explicit
|
|
4199
|
+
* session reset. */
|
|
4200
|
+
reset() {
|
|
4201
|
+
this.firedThisSession.clear();
|
|
4202
|
+
this.silencedThisSession.clear();
|
|
4203
|
+
}
|
|
4204
|
+
// ─── the main dispatch ───
|
|
4205
|
+
/**
|
|
4206
|
+
* Called every time a signal value changes meaningfully (e.g. a
|
|
4207
|
+
* TriggerEngine `exit_intent` event, or a `scroll_depth_50` crossing
|
|
4208
|
+
* threshold, or the Layer-1 fetch finishing). Returns the decision the
|
|
4209
|
+
* caller should act on.
|
|
4210
|
+
*
|
|
4211
|
+
* Algorithm:
|
|
4212
|
+
* 1. Filter armed campaigns to those whose `fire_on` includes the
|
|
4213
|
+
* signal that just changed.
|
|
4214
|
+
* 2. Drop already-fired and silenced campaigns.
|
|
4215
|
+
* 3. Sort the remainder by priority DESC, tie-broken by campaign id
|
|
4216
|
+
* lexicographic (per plan §"Pattern ordering rules").
|
|
4217
|
+
* 4. Walk the sorted list:
|
|
4218
|
+
* - If a suppress_competing rule matches, emit a 'suppress'
|
|
4219
|
+
* decision listing every lower-priority armed campaign id.
|
|
4220
|
+
* Mark those as silenced internally too.
|
|
4221
|
+
* - Otherwise the first matching rule emits 'fire'.
|
|
4222
|
+
* 5. If nothing matches, return 'none'.
|
|
4223
|
+
*/
|
|
4224
|
+
onSignalChanged(signal) {
|
|
4225
|
+
const candidates = this.armed.filter((c) => c.rule.fire_on.includes(signal)).filter((c) => !this.firedThisSession.has(c.id)).filter((c) => !this.silencedThisSession.has(c.id)).sort((a, b) => {
|
|
4226
|
+
if (b.rule.priority !== a.rule.priority) {
|
|
4227
|
+
return b.rule.priority - a.rule.priority;
|
|
4228
|
+
}
|
|
4229
|
+
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
4230
|
+
});
|
|
4231
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
4232
|
+
const c = candidates[i];
|
|
4233
|
+
if (!evaluateRule(c.rule, this.snapshot)) continue;
|
|
4234
|
+
if (c.rule.suppress_competing) {
|
|
4235
|
+
const suppressIds = this.armed.filter((other) => other.id !== c.id).map((other) => other.id);
|
|
4236
|
+
suppressIds.forEach((id) => this.silencedThisSession.add(id));
|
|
4237
|
+
return {
|
|
4238
|
+
kind: "suppress",
|
|
4239
|
+
campaignId: c.id,
|
|
4240
|
+
suppressIds
|
|
4241
|
+
};
|
|
4242
|
+
}
|
|
4243
|
+
return { kind: "fire", campaignId: c.id };
|
|
4244
|
+
}
|
|
4245
|
+
return { kind: "none" };
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
class ContactScoresFetcher {
|
|
4249
|
+
constructor(cfg) {
|
|
4250
|
+
this.lastFetchedAt = 0;
|
|
4251
|
+
this.latestSnapshot = null;
|
|
4252
|
+
this.apiHost = cfg.apiHost.replace(/\/$/, "");
|
|
4253
|
+
this.writeKey = cfg.writeKey;
|
|
4254
|
+
this.organizationId = cfg.organizationId;
|
|
4255
|
+
this.evaluator = cfg.evaluator;
|
|
4256
|
+
this.dedupWindowMs = cfg.dedupWindowMs ?? 6e4;
|
|
4257
|
+
this.fetchImpl = cfg.fetchImpl ?? (typeof fetch !== "undefined" ? fetch.bind(globalThis) : (() => Promise.reject(new Error("fetch unavailable"))));
|
|
4258
|
+
this.onError = cfg.onError;
|
|
4259
|
+
}
|
|
4260
|
+
/** Update the org so subsequent fetches scope correctly (e.g. when
|
|
4261
|
+
* the SDK resolves an org id after init). */
|
|
4262
|
+
updateOrganizationId(organizationId) {
|
|
4263
|
+
this.organizationId = organizationId;
|
|
4264
|
+
}
|
|
4265
|
+
/** Most recent successful response. `null` when no fetch has succeeded
|
|
4266
|
+
* yet, OR when the endpoint returned 204 (unscored). Consumers can
|
|
4267
|
+
* poll this for diagnostic UIs; campaign evaluation does not need to
|
|
4268
|
+
* read it directly because the evaluator (if configured) already has
|
|
4269
|
+
* the snapshot applied. */
|
|
4270
|
+
getSnapshot() {
|
|
4271
|
+
return this.latestSnapshot;
|
|
4272
|
+
}
|
|
4273
|
+
/** Fetch scores for `contactId` and apply to the configured evaluator
|
|
4274
|
+
* (if any). Returns the response on success, null on 204 / error.
|
|
4275
|
+
*
|
|
4276
|
+
* Session-dedup: repeat calls for the same contactId within
|
|
4277
|
+
* `dedupWindowMs` are no-ops. Pass `force: true` to override. */
|
|
4278
|
+
async fetchForContact(contactId, opts = {}) {
|
|
4279
|
+
var _a;
|
|
4280
|
+
if (!contactId) return null;
|
|
4281
|
+
const now = Date.now();
|
|
4282
|
+
if (!opts.force && this.lastFetchedContactId === contactId && now - this.lastFetchedAt < this.dedupWindowMs) {
|
|
4283
|
+
return this.latestSnapshot;
|
|
4284
|
+
}
|
|
4285
|
+
this.lastFetchedContactId = contactId;
|
|
4286
|
+
this.lastFetchedAt = now;
|
|
4287
|
+
const headers = {
|
|
4288
|
+
"X-Aegis-Write-Key": this.writeKey,
|
|
4289
|
+
"X-Contact-ID": contactId,
|
|
4290
|
+
"X-User-ID": contactId
|
|
4291
|
+
};
|
|
4292
|
+
if (this.organizationId) {
|
|
4293
|
+
headers["X-Organization-ID"] = this.organizationId;
|
|
4294
|
+
}
|
|
4295
|
+
try {
|
|
4296
|
+
const resp = await this.fetchImpl(
|
|
4297
|
+
`${this.apiHost}/v1/sdk/contact-scores`,
|
|
4298
|
+
{
|
|
4299
|
+
method: "GET",
|
|
4300
|
+
headers,
|
|
4301
|
+
credentials: "include"
|
|
4302
|
+
}
|
|
4303
|
+
);
|
|
4304
|
+
if (resp.status === 204) {
|
|
4305
|
+
this.latestSnapshot = null;
|
|
4306
|
+
return null;
|
|
4307
|
+
}
|
|
4308
|
+
if (!resp.ok) {
|
|
4309
|
+
this.latestSnapshot = null;
|
|
4310
|
+
return null;
|
|
4311
|
+
}
|
|
4312
|
+
const payload = await resp.json();
|
|
4313
|
+
this.latestSnapshot = payload;
|
|
4314
|
+
if (this.evaluator) {
|
|
4315
|
+
this.evaluator.updateSnapshot(toIntentSnapshot(payload));
|
|
4316
|
+
}
|
|
4317
|
+
return payload;
|
|
4318
|
+
} catch (err) {
|
|
4319
|
+
(_a = this.onError) == null ? void 0 : _a.call(this, err, contactId);
|
|
4320
|
+
return null;
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4323
|
+
}
|
|
4324
|
+
function toIntentSnapshot(r) {
|
|
4325
|
+
const snap = {};
|
|
4326
|
+
if (r.rfm_segment) snap.rfm_segment = r.rfm_segment;
|
|
4327
|
+
if (r.lifecycle_stage) snap.lifecycle_stage = r.lifecycle_stage;
|
|
4328
|
+
if (r.churn_risk_tier) snap.churn_risk_tier = r.churn_risk_tier;
|
|
4329
|
+
if (r.predicted_ltv_tier) snap.predicted_ltv_tier = r.predicted_ltv_tier;
|
|
4330
|
+
if (typeof r.predicted_ltv === "number") snap.predicted_ltv = r.predicted_ltv;
|
|
4331
|
+
if (typeof r.price_sensitivity_score === "number") {
|
|
4332
|
+
snap.price_sensitivity_score = r.price_sensitivity_score;
|
|
4333
|
+
}
|
|
4334
|
+
if (r.scoring_tier) snap.scoring_tier = r.scoring_tier;
|
|
4335
|
+
return snap;
|
|
4336
|
+
}
|
|
4051
4337
|
class SdkConfigPoller {
|
|
4052
4338
|
constructor(options) {
|
|
4053
4339
|
this.currentETag = null;
|
|
@@ -6639,6 +6925,7 @@ class AegisMessageRuntime {
|
|
|
6639
6925
|
this.initialized = false;
|
|
6640
6926
|
const triggerEngine = config.triggerEngine ?? new TriggerEngine();
|
|
6641
6927
|
const ownsTriggerEngine = !config.triggerEngine;
|
|
6928
|
+
this.contactId = config.contactId;
|
|
6642
6929
|
this.widgets = new AegisWidgetManager({
|
|
6643
6930
|
writeKey: config.writeKey,
|
|
6644
6931
|
apiHost: config.apiHost,
|
|
@@ -6669,6 +6956,16 @@ class AegisMessageRuntime {
|
|
|
6669
6956
|
},
|
|
6670
6957
|
getWorkspaceId: config.getWorkspaceId
|
|
6671
6958
|
});
|
|
6959
|
+
this.intentRuleEvaluator = new IntentRuleEvaluator();
|
|
6960
|
+
this.contactScores = new ContactScoresFetcher({
|
|
6961
|
+
// Falls back to same-origin when no apiHost configured (storefront
|
|
6962
|
+
// typical case) — matches WidgetManager/InAppManager handling
|
|
6963
|
+
// where `config.apiHost` is also `string | undefined`.
|
|
6964
|
+
apiHost: config.apiHost ?? "",
|
|
6965
|
+
writeKey: config.writeKey,
|
|
6966
|
+
organizationId: config.organizationId,
|
|
6967
|
+
evaluator: this.intentRuleEvaluator
|
|
6968
|
+
});
|
|
6672
6969
|
}
|
|
6673
6970
|
/**
|
|
6674
6971
|
* Boots both managers in parallel. Safe to call multiple times — the
|
|
@@ -6681,6 +6978,9 @@ class AegisMessageRuntime {
|
|
|
6681
6978
|
this.inApp.initialize(),
|
|
6682
6979
|
this.widgets.initialize()
|
|
6683
6980
|
]);
|
|
6981
|
+
if (this.contactId) {
|
|
6982
|
+
void this.contactScores.fetchForContact(this.contactId);
|
|
6983
|
+
}
|
|
6684
6984
|
}
|
|
6685
6985
|
/**
|
|
6686
6986
|
* Both managers carry contactId. Updates both so the server-side
|
|
@@ -6692,8 +6992,10 @@ class AegisMessageRuntime {
|
|
|
6692
6992
|
*/
|
|
6693
6993
|
async updateContactId(contactId) {
|
|
6694
6994
|
var _a, _b;
|
|
6995
|
+
this.contactId = contactId;
|
|
6695
6996
|
(_b = (_a = this.inApp).updateContactId) == null ? void 0 : _b.call(_a, contactId);
|
|
6696
6997
|
await this.widgets.updateContactId(contactId);
|
|
6998
|
+
void this.contactScores.fetchForContact(contactId);
|
|
6697
6999
|
}
|
|
6698
7000
|
/**
|
|
6699
7001
|
* Forward a client-side event (product_viewed, cart_idle_90s, etc.)
|
|
@@ -6706,6 +7008,50 @@ class AegisMessageRuntime {
|
|
|
6706
7008
|
var _a, _b;
|
|
6707
7009
|
(_b = (_a = this.inApp).onClientEvent) == null ? void 0 : _b.call(_a, eventName, eventData);
|
|
6708
7010
|
}
|
|
7011
|
+
// --- Qualifying-event refresh facade (DLR Tracker 1 / P1, 2026-05-28) ---
|
|
7012
|
+
//
|
|
7013
|
+
// `track`, `page`, and `screen` here are thin trigger taps for the
|
|
7014
|
+
// in-app subsystem — they tell `AegisInAppManager.refreshOnEvent` that
|
|
7015
|
+
// a host-app event happened, and the debounced refresh re-fetches
|
|
7016
|
+
// `/v1/in-app/active` so newly armed campaigns become visible without
|
|
7017
|
+
// waiting for the next identity flip. They are NOT a substitute for
|
|
7018
|
+
// the main analytics SDK (`Aegis` in `core/analytics.ts`) — those
|
|
7019
|
+
// methods own the canonical capture path (batch uplink, governance,
|
|
7020
|
+
// workspace resolution, etc.). Integrations that already call
|
|
7021
|
+
// `aegis.track(...)` should also call `runtime.track(...)` to drive
|
|
7022
|
+
// the in-app refresh. A future P-phase will bridge the two so a single
|
|
7023
|
+
// call on the public analytics surface drives both behaviors.
|
|
7024
|
+
/**
|
|
7025
|
+
* Notify the in-app subsystem that a tracked event occurred. Schedules
|
|
7026
|
+
* a debounced refresh of armed campaigns so newly eligible in-app
|
|
7027
|
+
* messages (e.g., trigger-gated on `cart_item_added`) become visible
|
|
7028
|
+
* within ~300ms — bursts coalesce. See
|
|
7029
|
+
* `AegisInAppManager.refreshOnEvent` for debounce semantics and why
|
|
7030
|
+
* this matters under storefront polling.
|
|
7031
|
+
*/
|
|
7032
|
+
track(eventName) {
|
|
7033
|
+
if (!eventName) return;
|
|
7034
|
+
this.inApp.refreshOnEvent(eventName);
|
|
7035
|
+
}
|
|
7036
|
+
/**
|
|
7037
|
+
* Notify the in-app subsystem that a URL-bound page view occurred.
|
|
7038
|
+
* Mirrors `aegis.page()` semantics — fires `'page_view'` as the
|
|
7039
|
+
* qualifying event so the trailing debounce covers SPA route bursts
|
|
7040
|
+
* (history.pushState rapid-fire) without spamming the endpoint.
|
|
7041
|
+
*/
|
|
7042
|
+
page(name) {
|
|
7043
|
+
this.inApp.refreshOnEvent(name ?? "page_view");
|
|
7044
|
+
}
|
|
7045
|
+
/**
|
|
7046
|
+
* Notify the in-app subsystem that a SPA-logical screen view occurred
|
|
7047
|
+
* (cart drawer open, checkout step transition — anywhere `aegis.screen()`
|
|
7048
|
+
* is called). Refresh-on-screen lets per-screen-targeted campaigns
|
|
7049
|
+
* arm without a URL change.
|
|
7050
|
+
*/
|
|
7051
|
+
screen(name) {
|
|
7052
|
+
if (!name) return;
|
|
7053
|
+
this.inApp.refreshOnEvent(name);
|
|
7054
|
+
}
|
|
6709
7055
|
/**
|
|
6710
7056
|
* Conversion-aware suppression — call when the host app observes a
|
|
6711
7057
|
* goal event (purchase / order_completed / checkout_completed / custom).
|