@active-reach/web-sdk 1.14.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/core/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAGX,YAAY,EACb,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAUzC,OAAO,EAAkB,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAgB,mBAAmB,EAAiB,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAoC;IAClD,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,YAAY,CAAoC;IAKxD,OAAO,CAAC,aAAa,CAAsC;IAC3D,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,kBAAkB,CAAyC;IACnE,OAAO,CAAC,qBAAqB,CAA4C;IAQzE,OAAO,CAAC,aAAa,CAAkC;IAMvD,OAAO,CAAC,eAAe,CAA0B;IAKjD,OAAO,CAAC,iBAAiB,C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,CAAC,EAAE,eAAe,GAAG,IAAI;IAa7C,UAAU,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO;IAQ9C,qBAAqB,IAAI,kBAAkB,GAAG,IAAI;IAQlD,eAAe,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,kBAAkB,KAAK,IAAI,GAAG,MAAM,IAAI;IAShF,OAAO,CAAC,iBAAiB;IAQzB,IAAI,SAAS,IAAI,gBAAgB,CAKhC;IAED,IAAI,IAAI,IAAI,aAAa,CAKxB;IAED,OAAO,IAAI,IAAI;CAwBhB"}
@@ -38,14 +38,30 @@ export interface BootstrapResult {
38
38
  */
39
39
  eventGovernance: EventGovernanceHint | null;
40
40
  /**
41
- * Plugin-handshake P1 workspace_code allowlist for SDK path-segment
42
- * detection. Empty array = no workspace codes registered for this org
43
- * (single-outlet tenant). SDK uses this set to decide whether
44
- * `location.pathname.split('/')[1]` is a valid workspace slug vs a
45
- * generic route (e.g. `/products`, `/collections`). Pass to
46
- * `aegis.ingestWorkspaceCodes()` after bootstrap completes.
41
+ * @deprecated since P15.1 (2026-05-26) use `locationCodes` instead.
42
+ * Pre-2026-05-26 the path segment after the brand subdomain was a
43
+ * workspace_code; the canonical hierarchy reversal made it a
44
+ * location_code (outlet under a brand). Field name retained for
45
+ * backward compat with SDK consumers that haven't migrated; new
46
+ * consumers MUST read `locationCodes`. Server still populates BOTH
47
+ * with the same array during the deprecation window so a stale
48
+ * SDK keeps working.
47
49
  */
48
50
  workspaceCodes: string[];
51
+ /**
52
+ * P15.1 — outlet-code allowlist for SDK path-segment detection.
53
+ * Empty array = no outlet codes registered for this org (single-
54
+ * outlet tenant). SDK uses this set to decide whether
55
+ * `location.pathname.split('/')[1]` is a valid outlet code vs a
56
+ * generic route (`/products`, `/collections`). Pass to
57
+ * `aegis.ingestLocationCodes()` after bootstrap completes.
58
+ *
59
+ * Same array contents as `workspaceCodes` during the deprecation
60
+ * window — renaming the field gives semantic clarity (these ARE
61
+ * location codes under the new hierarchy) without breaking
62
+ * existing consumers.
63
+ */
64
+ locationCodes: string[];
49
65
  }
50
66
  export declare class BootstrapError extends Error {
51
67
  readonly status: number;
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/core/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,eAAe,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,YAAY,CAAC;IACpF,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,eAAe,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC5C;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,qBAAa,cAAe,SAAQ,KAAK;aACX,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI5D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAIpD;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAA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IACxC,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,WAAW,CAAC,CAAS;gBAEjB,OAAO,EAAE,OAAO,EAAE,qBAAqB,GAAE,MAAW;IAuBhE,OAAO,CAAC,WAAW;IAyBnB,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,UAAU;IAoBlB,OAAO,CAAC,kBAAkB;IAS1B,YAAY,IAAI,MAAM;IAItB,mBAAmB,IAAI,IAAI;IAM3B,kBAAkB,IAAI,MAAM;IAI5B,aAAa,IAAI,MAAM;IAIvB,QAAQ,IAAI,YAAY;IAWxB,aAAa,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAWjE,aAAa,IAAI,UAAU;IAI3B,cAAc,IAAI,MAAM,GAAG,SAAS;IAIpC,OAAO,IAAI,IAAI;CAMhB"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * E-Commerce helper methods for the Aegis SDK.
2
+ * E-Commerce helper methods for the Active Reach SDK.
3
3
  *
4
4
  * Provides standardized e-commerce event tracking that maps to the
5
5
  * Active Reach Intelligence data governance pipeline.
@@ -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,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MA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MAAM,EAAE,OAAO,CAAM,GAAG,IAAI;IAa/E,OAAO,CAAC,oBAAoB;IAkC5B,OAAO,CAAC,eAAe;IAoFvB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAwCzB,OAAO,CAAC,eAAe;IAsBvB,OAAO,CAAC,oBAAoB;IAkF5B,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,eAAe;IA+CvB,OAAO,CAAC,UAAU;IAiFlB,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,cAAc;IAWtB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,wBAAwB;IAqDhC,OAAO,CAAC,YAAY;IAiHpB,OAAO,CAAC,WAAW;IAkHnB,OAAO,CAAC,gBAAgB;IA6GxB,OAAO,CAAC,sBAAsB;IAyH9B,OAAO,CAAC,WAAW;IAwGnB,OAAO,CAAC,SAAS;IAiHjB,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
@@ -1,5 +1,5 @@
1
- import { S as Storage, l as logger, A as Aegis } from "./analytics-DGt-CSgi.mjs";
2
- import { B, E, N, R, U, m } from "./analytics-DGt-CSgi.mjs";
1
+ import { S as Storage, l as logger, A as Aegis } from "./analytics-CjLItVo2.mjs";
2
+ import { B, E, N, R, U, m } from "./analytics-CjLItVo2.mjs";
3
3
  import { AegisWebPush } from "./push/AegisWebPush.js";
4
4
  function debounce(func, wait) {
5
5
  let timeoutId = null;
@@ -784,7 +784,7 @@ const _AegisInAppManager = class _AegisInAppManager {
784
784
  emitError(err, context) {
785
785
  const handlers = this.hooks.get("error");
786
786
  if (!handlers || handlers.size === 0) {
787
- this.log(`Aegis SDK error: ${err instanceof Error ? err.message : String(err)}`, "error");
787
+ this.log(`Active Reach SDK error: ${err instanceof Error ? err.message : String(err)}`, "error");
788
788
  return;
789
789
  }
790
790
  for (const handler of handlers) {
@@ -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).