@active-reach/web-sdk 1.41.0 → 1.43.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/package.json +1 -1
- package/dist/aegis-push.min.js +0 -2
- package/dist/aegis-push.min.js.map +0 -1
- package/dist/aegis-sw.js +0 -1
- package/dist/aegis.min.js +0 -2
- package/dist/aegis.min.js.map +0 -1
- package/dist/analytics-C-Go3Pm5.mjs +0 -3509
- package/dist/analytics-C-Go3Pm5.mjs.map +0 -1
- package/dist/cdn.d.ts +0 -26
- package/dist/cdn.d.ts.map +0 -1
- package/dist/chat/AegisChat.d.ts +0 -169
- package/dist/chat/AegisChat.d.ts.map +0 -1
- package/dist/chat/index.d.ts +0 -3
- package/dist/chat/index.d.ts.map +0 -1
- package/dist/core/analytics.d.ts +0 -320
- package/dist/core/analytics.d.ts.map +0 -1
- package/dist/core/bootstrap.d.ts +0 -96
- package/dist/core/bootstrap.d.ts.map +0 -1
- package/dist/core/prefetch-bundle-client.d.ts +0 -175
- package/dist/core/prefetch-bundle-client.d.ts.map +0 -1
- package/dist/core/queue.d.ts +0 -35
- package/dist/core/queue.d.ts.map +0 -1
- package/dist/core/rate-limiter.d.ts +0 -45
- package/dist/core/rate-limiter.d.ts.map +0 -1
- package/dist/core/sdk-config-poller.d.ts +0 -59
- package/dist/core/sdk-config-poller.d.ts.map +0 -1
- package/dist/core/session.d.ts +0 -52
- package/dist/core/session.d.ts.map +0 -1
- package/dist/core/transport.d.ts +0 -50
- package/dist/core/transport.d.ts.map +0 -1
- package/dist/core/user-namespace.d.ts +0 -48
- package/dist/core/user-namespace.d.ts.map +0 -1
- package/dist/ecommerce/index.d.ts +0 -94
- package/dist/ecommerce/index.d.ts.map +0 -1
- package/dist/ecommerce/types.d.ts +0 -81
- package/dist/ecommerce/types.d.ts.map +0 -1
- package/dist/governance/bloom-filter.d.ts +0 -47
- package/dist/governance/bloom-filter.d.ts.map +0 -1
- package/dist/governance/index.d.ts +0 -8
- package/dist/governance/index.d.ts.map +0 -1
- package/dist/governance/murmur3.d.ts +0 -43
- package/dist/governance/murmur3.d.ts.map +0 -1
- package/dist/governance/name-governor.d.ts +0 -98
- package/dist/governance/name-governor.d.ts.map +0 -1
- package/dist/governance/trait-governor.d.ts +0 -63
- package/dist/governance/trait-governor.d.ts.map +0 -1
- package/dist/inapp/AegisInAppManager.d.ts +0 -877
- package/dist/inapp/AegisInAppManager.d.ts.map +0 -1
- package/dist/inapp/actions.d.ts +0 -91
- package/dist/inapp/actions.d.ts.map +0 -1
- package/dist/inapp/devicePairing.d.ts +0 -70
- package/dist/inapp/devicePairing.d.ts.map +0 -1
- package/dist/inapp/eval-throttle.d.ts +0 -33
- package/dist/inapp/eval-throttle.d.ts.map +0 -1
- package/dist/inapp/font.d.ts +0 -16
- package/dist/inapp/font.d.ts.map +0 -1
- package/dist/inapp/index.d.ts +0 -8
- package/dist/inapp/index.d.ts.map +0 -1
- package/dist/inapp/lucide-svg.d.ts +0 -46
- package/dist/inapp/lucide-svg.d.ts.map +0 -1
- package/dist/inapp/renderPreview.d.ts +0 -40
- package/dist/inapp/renderPreview.d.ts.map +0 -1
- package/dist/inapp/renderers/active-web-chat.d.ts +0 -45
- package/dist/inapp/renderers/active-web-chat.d.ts.map +0 -1
- package/dist/inapp/renderers/card-style.d.ts +0 -31
- package/dist/inapp/renderers/card-style.d.ts.map +0 -1
- package/dist/inapp/renderers/card-template.d.ts +0 -233
- package/dist/inapp/renderers/card-template.d.ts.map +0 -1
- package/dist/inapp/renderers/carousel-cards.d.ts +0 -15
- package/dist/inapp/renderers/carousel-cards.d.ts.map +0 -1
- package/dist/inapp/renderers/coachmark-tour.d.ts +0 -24
- package/dist/inapp/renderers/coachmark-tour.d.ts.map +0 -1
- package/dist/inapp/renderers/games.d.ts +0 -27
- package/dist/inapp/renderers/games.d.ts.map +0 -1
- package/dist/inapp/renderers/hero.d.ts +0 -23
- package/dist/inapp/renderers/hero.d.ts.map +0 -1
- package/dist/inapp/renderers/index.d.ts +0 -22
- package/dist/inapp/renderers/index.d.ts.map +0 -1
- package/dist/inapp/renderers/interactive-contract.d.ts +0 -48
- package/dist/inapp/renderers/interactive-contract.d.ts.map +0 -1
- package/dist/inapp/renderers/product-recommendation.d.ts +0 -37
- package/dist/inapp/renderers/product-recommendation.d.ts.map +0 -1
- package/dist/inapp/renderers/progress-bar.d.ts +0 -38
- package/dist/inapp/renderers/progress-bar.d.ts.map +0 -1
- package/dist/inapp/renderers/progress-core.d.ts +0 -80
- package/dist/inapp/renderers/progress-core.d.ts.map +0 -1
- package/dist/inapp/renderers/reviews.d.ts +0 -38
- package/dist/inapp/renderers/reviews.d.ts.map +0 -1
- package/dist/inapp/renderers/sticky-bar.d.ts +0 -14
- package/dist/inapp/renderers/sticky-bar.d.ts.map +0 -1
- package/dist/inapp/renderers/stories.d.ts +0 -31
- package/dist/inapp/renderers/stories.d.ts.map +0 -1
- package/dist/inapp/renderers/types.d.ts +0 -147
- package/dist/inapp/renderers/types.d.ts.map +0 -1
- package/dist/inapp/renderers/video.d.ts +0 -20
- package/dist/inapp/renderers/video.d.ts.map +0 -1
- package/dist/inbox/AegisInbox.d.ts +0 -106
- package/dist/inbox/AegisInbox.d.ts.map +0 -1
- package/dist/inbox/index.d.ts +0 -3
- package/dist/inbox/index.d.ts.map +0 -1
- package/dist/index.d.ts +0 -40
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -15127
- package/dist/index.js.map +0 -1
- package/dist/integrations/react.d.ts +0 -19
- package/dist/integrations/react.d.ts.map +0 -1
- package/dist/loyalty/AegisLoyaltyManager.d.ts +0 -120
- package/dist/loyalty/AegisLoyaltyManager.d.ts.map +0 -1
- package/dist/loyalty/index.d.ts +0 -3
- package/dist/loyalty/index.d.ts.map +0 -1
- package/dist/plugins/registry.d.ts +0 -13
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/push/AegisWebPush.d.ts +0 -199
- package/dist/push/AegisWebPush.d.ts.map +0 -1
- package/dist/push/AegisWebPush.js +0 -542
- package/dist/push/AegisWebPush.js.map +0 -1
- package/dist/push/cdn-push.d.ts +0 -21
- package/dist/push/cdn-push.d.ts.map +0 -1
- package/dist/react.js +0 -70
- package/dist/react.js.map +0 -1
- package/dist/runtime/AegisMessageRuntime.d.ts +0 -274
- package/dist/runtime/AegisMessageRuntime.d.ts.map +0 -1
- package/dist/runtime/index.d.ts +0 -3
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/snippet.min.js +0 -1
- package/dist/state/intent_ledger.d.ts +0 -136
- package/dist/state/intent_ledger.d.ts.map +0 -1
- package/dist/triggers/ContactScoresFetcher.d.ts +0 -113
- package/dist/triggers/ContactScoresFetcher.d.ts.map +0 -1
- package/dist/triggers/IntentRuleEvaluator.d.ts +0 -213
- package/dist/triggers/IntentRuleEvaluator.d.ts.map +0 -1
- package/dist/triggers/IntentSnapshotCollector.d.ts +0 -83
- package/dist/triggers/IntentSnapshotCollector.d.ts.map +0 -1
- package/dist/triggers/SelectorBinder.d.ts +0 -118
- package/dist/triggers/SelectorBinder.d.ts.map +0 -1
- package/dist/triggers/TriggerEngine.d.ts +0 -296
- package/dist/triggers/TriggerEngine.d.ts.map +0 -1
- package/dist/triggers/behaviouralTriggers.d.ts +0 -41
- package/dist/triggers/behaviouralTriggers.d.ts.map +0 -1
- package/dist/triggers/index.d.ts +0 -11
- package/dist/triggers/index.d.ts.map +0 -1
- package/dist/types/config.d.ts +0 -77
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/events.d.ts +0 -147
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/plugin.d.ts +0 -21
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/type-safe-events.d.ts +0 -14
- package/dist/types/type-safe-events.d.ts.map +0 -1
- package/dist/utils/canonical-identity.d.ts +0 -29
- package/dist/utils/canonical-identity.d.ts.map +0 -1
- package/dist/utils/consent.d.ts +0 -40
- package/dist/utils/consent.d.ts.map +0 -1
- package/dist/utils/debounce.d.ts +0 -3
- package/dist/utils/debounce.d.ts.map +0 -1
- package/dist/utils/device.d.ts +0 -6
- package/dist/utils/device.d.ts.map +0 -1
- package/dist/utils/identity.d.ts +0 -27
- package/dist/utils/identity.d.ts.map +0 -1
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/logger.d.ts +0 -15
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/meta-cookies.d.ts +0 -65
- package/dist/utils/meta-cookies.d.ts.map +0 -1
- package/dist/utils/redact-url.d.ts +0 -56
- package/dist/utils/redact-url.d.ts.map +0 -1
- package/dist/utils/storage.d.ts +0 -20
- package/dist/utils/storage.d.ts.map +0 -1
- package/dist/utils/url-parser.d.ts +0 -61
- package/dist/utils/url-parser.d.ts.map +0 -1
- package/dist/utils/uuid.d.ts +0 -4
- package/dist/utils/uuid.d.ts.map +0 -1
- package/dist/utils/visitor.d.ts +0 -43
- package/dist/utils/visitor.d.ts.map +0 -1
- package/dist/widgets/AegisWidgetManager.d.ts +0 -209
- package/dist/widgets/AegisWidgetManager.d.ts.map +0 -1
- package/dist/widgets/index.d.ts +0 -3
- package/dist/widgets/index.d.ts.map +0 -1
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Micro-Intent Engine — compound rule evaluator (P1 Task 4).
|
|
3
|
-
*
|
|
4
|
-
* Pure, side-effect-free evaluation of an IntentRule predicate tree against
|
|
5
|
-
* a current snapshot of Layer-1 (identity) + Layer-2 (session) signal values.
|
|
6
|
-
*
|
|
7
|
-
* Why a separate class from TriggerEngine
|
|
8
|
-
* ----------------------------------------
|
|
9
|
-
* TriggerEngine.ts owns signal CAPTURE (scroll, time-on-page, exit-intent,
|
|
10
|
-
* etc.) and emits named events like `scroll_depth_50`. IntentRuleEvaluator
|
|
11
|
-
* owns rule EVALUATION — given a compound predicate and the current state
|
|
12
|
-
* of all known signals, return whether the rule fires now. The two
|
|
13
|
-
* concerns separate cleanly: capture is global per-page (one engine
|
|
14
|
-
* instance), evaluation is per-rule (the manager re-runs every armed
|
|
15
|
-
* rule when a `fire_on` signal fires).
|
|
16
|
-
*
|
|
17
|
-
* Type strategy
|
|
18
|
-
* -------------
|
|
19
|
-
* Types are declared LOCALLY in this file rather than imported from
|
|
20
|
-
* `@aegis/shared-types`. The SDK is published standalone on npm and
|
|
21
|
-
* cannot pull in workspace packages at runtime. A drift-check test
|
|
22
|
-
* (`libs/web-sdk/tests/intent-evaluator-shared-types-drift.test.ts`)
|
|
23
|
-
* parses both files and asserts the local types and the canonical
|
|
24
|
-
* `libs/shared-types/src/intent.ts` declare the same set of signal /
|
|
25
|
-
* comparator values.
|
|
26
|
-
*
|
|
27
|
-
* Plan reference: docs/architecture/MICRO_INTENT_ENGINE.md §"Schemas"
|
|
28
|
-
*/
|
|
29
|
-
export type IntentSignal = 'scroll_depth' | 'time_on_page' | 'exit_intent' | 'back_button' | 'scroll_velocity' | 'inactivity' | 'visibility_change' | 'rage_click' | 'price_hover_ms' | 'cta_hover_ms' | 'cum_dwell_sku' | 'session_count_sku' | 'cart_value' | 'converted_in_session' | 'rfm_segment' | 'rfm_score' | 'lifecycle_stage' | 'churn_risk_tier' | 'predicted_ltv' | 'predicted_ltv_tier' | 'uninstall_risk_tier' | 'engagement_level' | 'price_tier' | 'price_sensitivity_score' | 'top_category' | 'avg_cart_value' | 'scoring_tier';
|
|
30
|
-
export type Comparator = 'gte' | 'lte' | 'gt' | 'lt' | 'eq' | 'neq' | 'in' | 'nin';
|
|
31
|
-
export type IntentLeafValue = number | string | boolean | ReadonlyArray<number | string | boolean>;
|
|
32
|
-
export interface IntentLeaf {
|
|
33
|
-
/** Canonical enum signal (Layer-1/2). Mutually exclusive with `path`. */
|
|
34
|
-
signal?: IntentSignal;
|
|
35
|
-
/** Dot-path into the updateContext namespaces (cart.total / user.tier /
|
|
36
|
-
* session.idle_s). Mutually exclusive with `signal`. */
|
|
37
|
-
path?: string;
|
|
38
|
-
op: Comparator;
|
|
39
|
-
value: IntentLeafValue;
|
|
40
|
-
}
|
|
41
|
-
/** A value/node in the generic reactive context (fed via updateContext). */
|
|
42
|
-
export type ContextValue = string | number | boolean | null | ContextNode | ReadonlyArray<ContextValue>;
|
|
43
|
-
export interface ContextNode {
|
|
44
|
-
[key: string]: ContextValue;
|
|
45
|
-
}
|
|
46
|
-
/** Named namespaces: { cart: {...}, user: {...}, session: {...}, custom: {...} }. */
|
|
47
|
-
export type ContextNamespaces = Record<string, ContextNode>;
|
|
48
|
-
export interface IntentNode {
|
|
49
|
-
op: 'AND' | 'OR' | 'NOT';
|
|
50
|
-
operands: ReadonlyArray<IntentExpr>;
|
|
51
|
-
}
|
|
52
|
-
export type IntentExpr = IntentNode | IntentLeaf;
|
|
53
|
-
export interface IntentRule {
|
|
54
|
-
fire_on: ReadonlyArray<IntentSignal>;
|
|
55
|
-
when: IntentExpr;
|
|
56
|
-
priority: number;
|
|
57
|
-
suppress_competing: boolean;
|
|
58
|
-
}
|
|
59
|
-
/** A scalar a signal can hold in the snapshot. null = signal not (yet)
|
|
60
|
-
* populated — happens for Layer-1 scores on anonymous sessions and for
|
|
61
|
-
* Layer-2 signals before the user triggers them. */
|
|
62
|
-
export type SignalValue = number | string | boolean | null;
|
|
63
|
-
/** Current state of every known signal. Missing keys are treated the
|
|
64
|
-
* same as `null`. */
|
|
65
|
-
export type IntentSnapshot = Partial<Record<IntentSignal, SignalValue>>;
|
|
66
|
-
export declare function isIntentLeaf(expr: IntentExpr): expr is IntentLeaf;
|
|
67
|
-
/** Resolve a dot-path (`cart.total`) against the context namespaces.
|
|
68
|
-
* Returns undefined on any miss → tri-state null in evaluateLeaf (same as a
|
|
69
|
-
* missing signal). Never throws. */
|
|
70
|
-
export declare function getValueByPath(namespaces: ContextNamespaces | undefined, path: string): ContextValue | undefined;
|
|
71
|
-
export declare function isIntentNode(expr: IntentExpr): expr is IntentNode;
|
|
72
|
-
/**
|
|
73
|
-
* Evaluate a single leaf comparison against a snapshot.
|
|
74
|
-
*
|
|
75
|
-
* Missing-signal semantics (per the plan's "Graceful degradation rules"):
|
|
76
|
-
* - The CALLER (evaluateExpr) decides AND/OR semantics on missing
|
|
77
|
-
* operands; this function answers strictly for THIS leaf.
|
|
78
|
-
* - When the signal is missing from the snapshot, the leaf is
|
|
79
|
-
* "unknown" → return null so the parent node can interpret it.
|
|
80
|
-
*
|
|
81
|
-
* Comparator semantics:
|
|
82
|
-
* - gte/lte/gt/lt: numeric only; comparing strings/bools returns false.
|
|
83
|
-
* - eq/neq: any type; strict equality.
|
|
84
|
-
* - in/nin: leaf value must be a list; membership test on the snapshot
|
|
85
|
-
* value. `nin` returns true for missing snapshot values (the
|
|
86
|
-
* contact's RFM segment is "not in" the forbidden list if we don't
|
|
87
|
-
* know it yet — conservative).
|
|
88
|
-
*/
|
|
89
|
-
export declare function evaluateLeaf(leaf: IntentLeaf, snapshot: IntentSnapshot, namespaces?: ContextNamespaces): boolean | null;
|
|
90
|
-
/**
|
|
91
|
-
* Evaluate the full predicate tree.
|
|
92
|
-
*
|
|
93
|
-
* AND/OR/NOT semantics with missing-value handling (per plan §"Graceful
|
|
94
|
-
* degradation rules"):
|
|
95
|
-
*
|
|
96
|
-
* AND(a, b, c) where any operand is null → false (conservative; the
|
|
97
|
-
* rule doesn't fire when we can't prove all conditions).
|
|
98
|
-
* OR(a, b, c) where some operands are null → if any non-null operand
|
|
99
|
-
* is true, returns true. If all operands are null OR all are
|
|
100
|
-
* false, returns false.
|
|
101
|
-
* NOT(a) where a is null → null (parent decides). When this propagates
|
|
102
|
-
* to the top-level evaluateExpr, the rule does NOT fire.
|
|
103
|
-
*
|
|
104
|
-
* The "AND treats missing as unmet" + "OR treats missing as inert" rule
|
|
105
|
-
* from the plan maps exactly onto this implementation: AND short-circuits
|
|
106
|
-
* to false on any null operand; OR ignores nulls and looks at the rest.
|
|
107
|
-
*
|
|
108
|
-
* Top-level: a null result from the root expression means the rule
|
|
109
|
-
* cannot be evaluated yet — do NOT fire.
|
|
110
|
-
*/
|
|
111
|
-
export declare function evaluateExpr(expr: IntentExpr, snapshot: IntentSnapshot, namespaces?: ContextNamespaces): boolean | null;
|
|
112
|
-
/** Top-level "does the rule fire right now?" check. Treats a null
|
|
113
|
-
* evaluation result as "do not fire" (we can't prove the rule's
|
|
114
|
-
* conditions are met). */
|
|
115
|
-
export declare function evaluateRule(rule: IntentRule, snapshot: IntentSnapshot, namespaces?: ContextNamespaces): boolean;
|
|
116
|
-
/** A campaign carrying a compound rule, in the SDK's runtime shape.
|
|
117
|
-
* Mirrors the cell-plane payload at /v1/in-app/active when
|
|
118
|
-
* client_trigger.type === 'micro_intent'. */
|
|
119
|
-
export interface ArmedCampaign {
|
|
120
|
-
id: string;
|
|
121
|
-
rule: IntentRule;
|
|
122
|
-
}
|
|
123
|
-
/** The decision the evaluator returns when a signal fires.
|
|
124
|
-
*
|
|
125
|
-
* fire : caller should display this campaign now.
|
|
126
|
-
* suppress : caller should silence the listed competing campaign IDs
|
|
127
|
-
* for the rest of the session (the bouncing-researcher
|
|
128
|
-
* pattern — a rule whose only job is to silence others).
|
|
129
|
-
* none : no rule matched, do nothing.
|
|
130
|
-
*/
|
|
131
|
-
export interface EvaluationDecision {
|
|
132
|
-
kind: 'fire' | 'suppress' | 'none';
|
|
133
|
-
campaignId?: string;
|
|
134
|
-
suppressIds?: ReadonlyArray<string>;
|
|
135
|
-
}
|
|
136
|
-
export declare class IntentRuleEvaluator {
|
|
137
|
-
/** All campaigns currently armed on this page. Caller (the
|
|
138
|
-
* AegisInAppManager) replaces this on every refresh. */
|
|
139
|
-
private armed;
|
|
140
|
-
/** Latest signal values. Caller pushes updates via updateSignal /
|
|
141
|
-
* updateSnapshot whenever TriggerEngine emits a state change or
|
|
142
|
-
* contact-scores fetch completes. */
|
|
143
|
-
private snapshot;
|
|
144
|
-
/** Generic reactive context namespaces fed via updateContext() — the SINGLE
|
|
145
|
-
* store path-leaves resolve against (no parallel state elsewhere). */
|
|
146
|
-
private namespaces;
|
|
147
|
-
/** Campaigns that have already fired this session — never re-fire. */
|
|
148
|
-
private firedThisSession;
|
|
149
|
-
/** Campaigns silenced by a prior `suppress_competing` win. The set
|
|
150
|
-
* resets on session boundary (new tab / new pageview after timeout).
|
|
151
|
-
* The AegisInAppManager owns durability semantics; this set is
|
|
152
|
-
* in-memory only. */
|
|
153
|
-
private silencedThisSession;
|
|
154
|
-
/** ONE interruptive overlay per session. Once an interruption actually fires
|
|
155
|
-
* (signalled via markFired), further fires are blocked until reset().
|
|
156
|
-
* OPT-IN (default off) so the evaluator's base contract is unchanged for
|
|
157
|
-
* existing consumers (mobile, etc.); the storefront runtime turns it ON via
|
|
158
|
-
* setGovernance() for the ACS "rich, not overwhelming" posture. */
|
|
159
|
-
private oneInterruptionPerSession;
|
|
160
|
-
private interruptiveBudgetSpent;
|
|
161
|
-
/** TTFI floor — never fire an overlay in the first `ttfiMs` of the session
|
|
162
|
-
* ("no overlay at second 0"). Exit/leave signals are exempt. OPT-IN (default
|
|
163
|
-
* 0 = off); the storefront enables a ~4s floor via setGovernance(). */
|
|
164
|
-
private ttfiMs;
|
|
165
|
-
private sessionStartMs;
|
|
166
|
-
/** Injectable clock for deterministic tests. */
|
|
167
|
-
private nowFn;
|
|
168
|
-
private static readonly EXIT_SIGNALS;
|
|
169
|
-
/** Tune governance. `now` also (re)bases the TTFI session clock. */
|
|
170
|
-
setGovernance(opts: {
|
|
171
|
-
oneInterruptionPerSession?: boolean;
|
|
172
|
-
ttfiMs?: number;
|
|
173
|
-
now?: () => number;
|
|
174
|
-
}): void;
|
|
175
|
-
updateSignal(signal: IntentSignal, value: SignalValue): void;
|
|
176
|
-
updateSnapshot(partial: IntentSnapshot): void;
|
|
177
|
-
getSnapshot(): Readonly<IntentSnapshot>;
|
|
178
|
-
/** Merge a namespace's data (shallow). Path-leaves (`cart.total`) resolve
|
|
179
|
-
* against this. The runtime's updateContext() delegates here so there is ONE
|
|
180
|
-
* context store, then bridges well-known paths to enum signals. */
|
|
181
|
-
updateContext(namespace: string, data: ContextNode): void;
|
|
182
|
-
getNamespaces(): Readonly<ContextNamespaces>;
|
|
183
|
-
/** Resolve a dot-path against the live context (for previews / debugging). */
|
|
184
|
-
getValueByPath(path: string): ContextValue | undefined;
|
|
185
|
-
setArmed(campaigns: ArmedCampaign[]): void;
|
|
186
|
-
getArmed(): ReadonlyArray<ArmedCampaign>;
|
|
187
|
-
markFired(campaignId: string): void;
|
|
188
|
-
/** Clear all per-session state. Caller invokes on logout or explicit
|
|
189
|
-
* session reset. */
|
|
190
|
-
reset(): void;
|
|
191
|
-
/**
|
|
192
|
-
* Called every time a signal value changes meaningfully (e.g. a
|
|
193
|
-
* TriggerEngine `exit_intent` event, or a `scroll_depth_50` crossing
|
|
194
|
-
* threshold, or the Layer-1 fetch finishing). Returns the decision the
|
|
195
|
-
* caller should act on.
|
|
196
|
-
*
|
|
197
|
-
* Algorithm:
|
|
198
|
-
* 1. Filter armed campaigns to those whose `fire_on` includes the
|
|
199
|
-
* signal that just changed.
|
|
200
|
-
* 2. Drop already-fired and silenced campaigns.
|
|
201
|
-
* 3. Sort the remainder by priority DESC, tie-broken by campaign id
|
|
202
|
-
* lexicographic (per plan §"Pattern ordering rules").
|
|
203
|
-
* 4. Walk the sorted list:
|
|
204
|
-
* - If a suppress_competing rule matches, emit a 'suppress'
|
|
205
|
-
* decision listing every lower-priority armed campaign id.
|
|
206
|
-
* Mark those as silenced internally too.
|
|
207
|
-
* - Otherwise the first matching rule emits 'fire'.
|
|
208
|
-
* 5. If nothing matches, return 'none'.
|
|
209
|
-
*/
|
|
210
|
-
onSignalChanged(signal: IntentSignal): EvaluationDecision;
|
|
211
|
-
}
|
|
212
|
-
export declare const MAX_RULE_DEPTH: 3;
|
|
213
|
-
//# sourceMappingURL=IntentRuleEvaluator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntentRuleEv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AQ,CAAC,cAAc,CAAC;IAMvC;;wEAEoE;IACpE,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI;IAKzD,aAAa,IAAI,QAAQ,CAAC,iBAAiB,CAAC;IAI5C,8EAA8E;IAC9E,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAMtD,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI;IAI1C,QAAQ,IAAI,aAAa,CAAC,aAAa,CAAC;IAIxC,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAOnC;yBACqB;IACrB,KAAK,IAAI,IAAI;IASb;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,kBAAkB;CAuD1D;AAID,eAAO,MAAM,cAAc,GAAa,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Micro-Intent Engine — pipeline integration (P2 Task 5).
|
|
3
|
-
*
|
|
4
|
-
* Wires the three signal-capture surfaces (SelectorBinder, TriggerEngine,
|
|
5
|
-
* IntentLedger) together and projects their current state onto the
|
|
6
|
-
* IntentRuleEvaluator's `IntentSnapshot`. The collector is the single
|
|
7
|
-
* place every Layer-2 signal flows through on its way into rule
|
|
8
|
-
* evaluation — adding a new signal means touching exactly one file.
|
|
9
|
-
*
|
|
10
|
-
* Wiring summary
|
|
11
|
-
* --------------
|
|
12
|
-
* SelectorBinder.hover_start → TriggerEngine.noteHoverStart
|
|
13
|
-
* → evaluator.updateSignal(price/cta_hover_ms, 0)
|
|
14
|
-
* SelectorBinder.hover_end → TriggerEngine.noteHoverEnd
|
|
15
|
-
* → evaluator.updateSignal(price/cta_hover_ms, getHoverMs)
|
|
16
|
-
* SelectorBinder.click → TriggerEngine.noteClick
|
|
17
|
-
* → evaluator.updateSignal(rage_click, getRageClickCount)
|
|
18
|
-
* SelectorBinder.sku_change → IntentLedger.noteSession
|
|
19
|
-
* → evaluator.updateSignal(cum_dwell_sku, session_count_sku)
|
|
20
|
-
*
|
|
21
|
-
* window.mousemove (≤100ms) → TriggerEngine.noteMousePosition
|
|
22
|
-
* → evaluator.updateSignal(mouse_velocity_to_top)
|
|
23
|
-
*
|
|
24
|
-
* pagehide / beforeunload → ledger.flush()
|
|
25
|
-
*
|
|
26
|
-
* Why a separate class instead of putting this in AegisInAppManager:
|
|
27
|
-
* the manager already owns delivery + display rules + suppression.
|
|
28
|
-
* Adding "snapshot wrangling" on top would make it the SDK's
|
|
29
|
-
* everything-shaped object. The collector keeps signal flow isolated
|
|
30
|
-
* and unit-testable without spinning up the full manager.
|
|
31
|
-
*
|
|
32
|
-
* The collector is signal-name-agnostic in its core flow — the only
|
|
33
|
-
* place IntentSignal names appear is the `signalForIntent()` helper
|
|
34
|
-
* that maps the `price` intent to the `price_hover_ms` signal etc.
|
|
35
|
-
* If we add a new intent (e.g. `coupon_hover_ms`) the helper grows;
|
|
36
|
-
* everything else is reused.
|
|
37
|
-
*/
|
|
38
|
-
import type { SelectorBinder } from './SelectorBinder';
|
|
39
|
-
import type { IntentRuleEvaluator, IntentSignal, EvaluationDecision } from './IntentRuleEvaluator';
|
|
40
|
-
import type { IntentLedger } from '../state/intent_ledger';
|
|
41
|
-
import { TriggerEngine } from './TriggerEngine';
|
|
42
|
-
export interface IntentSnapshotCollectorConfig {
|
|
43
|
-
triggerEngine: TriggerEngine;
|
|
44
|
-
selectorBinder: SelectorBinder;
|
|
45
|
-
intentRuleEvaluator: IntentRuleEvaluator;
|
|
46
|
-
intentLedger?: IntentLedger;
|
|
47
|
-
/** Throttle floor for mousemove sampling, in ms. Plan default = 100. */
|
|
48
|
-
mouseSampleMs?: number;
|
|
49
|
-
/** Forwarded decisions from `evaluator.onSignalChanged` — the
|
|
50
|
-
* AegisInAppManager subscribes here to drive the actual campaign
|
|
51
|
-
* display / suppress side-effects. */
|
|
52
|
-
onDecision?: (decision: EvaluationDecision) => void;
|
|
53
|
-
}
|
|
54
|
-
export declare class IntentSnapshotCollector {
|
|
55
|
-
private readonly triggerEngine;
|
|
56
|
-
private readonly selectorBinder;
|
|
57
|
-
private readonly evaluator;
|
|
58
|
-
private readonly ledger;
|
|
59
|
-
private readonly mouseSampleMs;
|
|
60
|
-
private onDecision?;
|
|
61
|
-
private started;
|
|
62
|
-
private unsubscribeBinder?;
|
|
63
|
-
private lastMouseSampleAt;
|
|
64
|
-
private mouseMoveHandler?;
|
|
65
|
-
private flushHandler?;
|
|
66
|
-
constructor(cfg: IntentSnapshotCollectorConfig);
|
|
67
|
-
start(): void;
|
|
68
|
-
stop(): void;
|
|
69
|
-
/** Override the decision callback after construction — used by the
|
|
70
|
-
* AegisInAppManager when it lazily wires up. */
|
|
71
|
-
setDecisionHandler(handler: (d: EvaluationDecision) => void): void;
|
|
72
|
-
/**
|
|
73
|
-
* Caller signals that a known trigger event happened (exit_intent,
|
|
74
|
-
* back_button, scroll_depth_50, etc.). The collector forwards to the
|
|
75
|
-
* evaluator and pushes any resulting decision through `onDecision`.
|
|
76
|
-
*
|
|
77
|
-
* The signal-name here must be a real IntentSignal — anything else is
|
|
78
|
-
* silently ignored (no-throw, the SDK can't crash a host page).
|
|
79
|
-
*/
|
|
80
|
-
notifyTrigger(signal: IntentSignal): void;
|
|
81
|
-
private handleBinderEvent;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=IntentSnapshotCollector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntentSnapshotCollector.d.ts","sourceRoot":"","sources":["../../src/triggers/IntentSnapshotCollector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,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 Task 5, robustness #1).
|
|
3
|
-
*
|
|
4
|
-
* The problem
|
|
5
|
-
* -----------
|
|
6
|
-
* Static `document.querySelector('.price').addEventListener(...)` on SDK
|
|
7
|
-
* init detaches the moment Shopify themes, React/Next.js storefronts, or
|
|
8
|
-
* any SPA re-renders the price node. Element-scoped signals
|
|
9
|
-
* (price_hover_ms, cta_hover_ms, rage-click-on-coupon) then fail
|
|
10
|
-
* silently — the worst possible failure mode because nothing logs.
|
|
11
|
-
*
|
|
12
|
-
* The fix
|
|
13
|
-
* -------
|
|
14
|
-
* Bind ONCE to `document.body` (capture phase) and dispatch via
|
|
15
|
-
* `event.target.closest(selector)`. The handler runs globally; the
|
|
16
|
-
* configured intent selectors are evaluated per-event. Survives any
|
|
17
|
-
* framework re-render — there's never a stale reference because we
|
|
18
|
-
* never held one.
|
|
19
|
-
*
|
|
20
|
-
* document.body.addEventListener('mouseenter', this.handleHover, true);
|
|
21
|
-
* document.body.addEventListener('mouseleave', this.handleHover, true);
|
|
22
|
-
* document.body.addEventListener('pointerdown', this.handleClick, true);
|
|
23
|
-
*
|
|
24
|
-
* Plus a `MutationObserver` that watches for changes to the configured
|
|
25
|
-
* SKU selector so a SPA navigating between PDPs without a full page
|
|
26
|
-
* load still updates the engine's `cum_dwell_sku` / `session_count_sku`
|
|
27
|
-
* context. The observer is NOT used to re-attach event listeners
|
|
28
|
-
* (delegation makes that unnecessary).
|
|
29
|
-
*
|
|
30
|
-
* What this file does NOT do
|
|
31
|
-
* --------------------------
|
|
32
|
-
* Compute `price_hover_ms` / `cta_hover_ms` dwell totals, or count
|
|
33
|
-
* rage-clicks. That arithmetic lives in TriggerEngine.ts (P2 Tasks
|
|
34
|
-
* 1-3) which subscribes to this binder via `onIntent(handler)` and
|
|
35
|
-
* accumulates into snapshot values. SelectorBinder is the I/O layer;
|
|
36
|
-
* the timing logic is downstream.
|
|
37
|
-
*
|
|
38
|
-
* Plan reference: docs/architecture/MICRO_INTENT_ENGINE.md §"Robustness
|
|
39
|
-
* 1 — DOM brittleness".
|
|
40
|
-
*/
|
|
41
|
-
/** Named element role the storefront marks. The selector config maps
|
|
42
|
-
* each name to one or more CSS selectors; on every match, the binder
|
|
43
|
-
* emits an IntentDomEvent with this name as `intent`. */
|
|
44
|
-
export type IntentElementName = 'price' | 'cta' | 'coupon' | 'checkout' | 'sku';
|
|
45
|
-
/** Event types the binder forwards. Keep narrow on purpose — every
|
|
46
|
-
* type carried downstream is a real signal someone derives from. */
|
|
47
|
-
export type IntentDomEventType = 'hover_start' | 'hover_end' | 'click' | 'sku_change';
|
|
48
|
-
export interface IntentDomEvent {
|
|
49
|
-
type: IntentDomEventType;
|
|
50
|
-
intent: IntentElementName;
|
|
51
|
-
/** Best-effort: the matched element. Consumers shouldn't hold strong
|
|
52
|
-
* references — the SPA may unmount it before the next event fires. */
|
|
53
|
-
target: Element | null;
|
|
54
|
-
/** For `sku_change`: the new SKU id (read from `data-aegis-sku` or the
|
|
55
|
-
* matched element's `data-product-id` / `data-sku` attribute). For
|
|
56
|
-
* other events: undefined. */
|
|
57
|
-
sku?: string;
|
|
58
|
-
timestamp: number;
|
|
59
|
-
}
|
|
60
|
-
export type IntentDomHandler = (evt: IntentDomEvent) => void;
|
|
61
|
-
/** Map from intent name to a list of CSS selectors that mark elements
|
|
62
|
-
* playing that role on the storefront. Multiple selectors per intent
|
|
63
|
-
* so a single plugin config can cover all the themes / DOM variants
|
|
64
|
-
* it knows about. */
|
|
65
|
-
export type IntentSelectors = Partial<Record<IntentElementName, ReadonlyArray<string>>>;
|
|
66
|
-
export interface SelectorBinderConfig {
|
|
67
|
-
/** Caller-supplied selectors, highest priority. */
|
|
68
|
-
intentSelectors?: IntentSelectors;
|
|
69
|
-
/** Server-pushed selectors from /v1/sdk/config (dashboard-managed).
|
|
70
|
-
* Falls behind explicit init but ahead of platform defaults. */
|
|
71
|
-
serverSelectors?: IntentSelectors;
|
|
72
|
-
/** Platform-default map bundled with the plugin (Shopify / Woo /
|
|
73
|
-
* Magento). Lowest non-fallback priority. */
|
|
74
|
-
platformDefaults?: IntentSelectors;
|
|
75
|
-
}
|
|
76
|
-
export declare class SelectorBinder {
|
|
77
|
-
private readonly selectors;
|
|
78
|
-
private readonly listeners;
|
|
79
|
-
private observer;
|
|
80
|
-
private boundRoot;
|
|
81
|
-
private currentSku;
|
|
82
|
-
/** Element-keyed memory of which intent is currently hovered, so we
|
|
83
|
-
* can fire `hover_end` even if the matched DOM node unmounts in
|
|
84
|
-
* between (the unmount path is `hover_start` → unmount → no
|
|
85
|
-
* `hover_end`; we rely on `mouseleave` capture which fires on the
|
|
86
|
-
* original target before unmount in most browsers). */
|
|
87
|
-
private hoverActive;
|
|
88
|
-
constructor(config?: SelectorBinderConfig);
|
|
89
|
-
/** Subscribe to delegated DOM events. Returns an unsubscribe fn. */
|
|
90
|
-
onIntent(handler: IntentDomHandler): () => void;
|
|
91
|
-
/** Attach listeners + MutationObserver. Idempotent — calling twice
|
|
92
|
-
* is a no-op so a manager that re-initializes doesn't double-bind. */
|
|
93
|
-
start(doc?: Document): void;
|
|
94
|
-
/** Detach listeners and observer. Idempotent. The manager calls this
|
|
95
|
-
* on `destroy()`. */
|
|
96
|
-
stop(): void;
|
|
97
|
-
/** Snapshot of the currently-active SKU on the page. Used by
|
|
98
|
-
* TriggerEngine to attribute hover/click events to a product context.
|
|
99
|
-
* Undefined when the page has no SKU element or it's been unmounted. */
|
|
100
|
-
getCurrentSku(): string | undefined;
|
|
101
|
-
/** Current selector resolution — useful for tests + editor "preview"
|
|
102
|
-
* to show which selectors would match. */
|
|
103
|
-
getResolvedSelectors(): Readonly<Required<IntentSelectors>>;
|
|
104
|
-
/** Find the intent name a given event target belongs to (if any).
|
|
105
|
-
* Walks the configured selectors in order; first match wins. Returns
|
|
106
|
-
* null if none match (the event is for unrelated DOM and should be
|
|
107
|
-
* ignored). */
|
|
108
|
-
private matchIntent;
|
|
109
|
-
private emit;
|
|
110
|
-
private handleHoverStart;
|
|
111
|
-
private handleHoverEnd;
|
|
112
|
-
private handleClick;
|
|
113
|
-
private handleMutation;
|
|
114
|
-
/** Re-resolve the current SKU from the page. Emits `sku_change` if
|
|
115
|
-
* the value differs from the prior snapshot. */
|
|
116
|
-
private refreshCurrentSku;
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=SelectorBinder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectorBinder.d.ts","sourceRoot":"","sources":["../../src/triggers/SelectorBinder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH;;0DAE0D;AAC1D,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAC;AAEhF;qEACqE;AACrE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,WAAW,GACX,OAAO,GACP,YAAY,CAAC;AAEjB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B;2EACuE;IACvE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB;;mCAE+B;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;AAE7D;;;sBAGsB;AACtB,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAmDxF,MAAM,WAAW,oBAAoB;IACnC,mDAAmD;IACnD,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;qEACiE;IACjE,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;kDAC8C;IAC9C,gBAAgB,CAAC,EAAE,eAAe,CAAC;CACpC;AAED,qBAAa,cAAc;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