@active-reach/web-sdk 1.43.1 → 1.43.2
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 +2 -0
- package/dist/aegis-push.min.js.map +1 -0
- package/dist/aegis-sw.js +1 -0
- package/dist/aegis.min.js +2 -0
- package/dist/aegis.min.js.map +1 -0
- package/dist/analytics-C-Go3Pm5.mjs +3509 -0
- package/dist/analytics-C-Go3Pm5.mjs.map +1 -0
- package/dist/cdn.d.ts +26 -0
- package/dist/cdn.d.ts.map +1 -0
- package/dist/chat/AegisChat.d.ts +169 -0
- package/dist/chat/AegisChat.d.ts.map +1 -0
- package/dist/chat/index.d.ts +3 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/core/analytics.d.ts +320 -0
- package/dist/core/analytics.d.ts.map +1 -0
- package/dist/core/bootstrap.d.ts +96 -0
- package/dist/core/bootstrap.d.ts.map +1 -0
- package/dist/core/prefetch-bundle-client.d.ts +175 -0
- package/dist/core/prefetch-bundle-client.d.ts.map +1 -0
- package/dist/core/queue.d.ts +35 -0
- package/dist/core/queue.d.ts.map +1 -0
- package/dist/core/rate-limiter.d.ts +45 -0
- package/dist/core/rate-limiter.d.ts.map +1 -0
- package/dist/core/sdk-config-poller.d.ts +59 -0
- package/dist/core/sdk-config-poller.d.ts.map +1 -0
- package/dist/core/session.d.ts +52 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/transport.d.ts +50 -0
- package/dist/core/transport.d.ts.map +1 -0
- package/dist/core/user-namespace.d.ts +48 -0
- package/dist/core/user-namespace.d.ts.map +1 -0
- package/dist/ecommerce/index.d.ts +94 -0
- package/dist/ecommerce/index.d.ts.map +1 -0
- package/dist/ecommerce/types.d.ts +81 -0
- package/dist/ecommerce/types.d.ts.map +1 -0
- package/dist/governance/bloom-filter.d.ts +47 -0
- package/dist/governance/bloom-filter.d.ts.map +1 -0
- package/dist/governance/index.d.ts +8 -0
- package/dist/governance/index.d.ts.map +1 -0
- package/dist/governance/murmur3.d.ts +43 -0
- package/dist/governance/murmur3.d.ts.map +1 -0
- package/dist/governance/name-governor.d.ts +98 -0
- package/dist/governance/name-governor.d.ts.map +1 -0
- package/dist/governance/trait-governor.d.ts +63 -0
- package/dist/governance/trait-governor.d.ts.map +1 -0
- package/dist/inapp/AegisInAppManager.d.ts +894 -0
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -0
- package/dist/inapp/actions.d.ts +91 -0
- package/dist/inapp/actions.d.ts.map +1 -0
- package/dist/inapp/devicePairing.d.ts +70 -0
- package/dist/inapp/devicePairing.d.ts.map +1 -0
- package/dist/inapp/eval-throttle.d.ts +33 -0
- package/dist/inapp/eval-throttle.d.ts.map +1 -0
- package/dist/inapp/font.d.ts +16 -0
- package/dist/inapp/font.d.ts.map +1 -0
- package/dist/inapp/index.d.ts +8 -0
- package/dist/inapp/index.d.ts.map +1 -0
- package/dist/inapp/lucide-svg.d.ts +46 -0
- package/dist/inapp/lucide-svg.d.ts.map +1 -0
- package/dist/inapp/renderPreview.d.ts +40 -0
- package/dist/inapp/renderPreview.d.ts.map +1 -0
- package/dist/inapp/renderers/active-web-chat.d.ts +45 -0
- package/dist/inapp/renderers/active-web-chat.d.ts.map +1 -0
- package/dist/inapp/renderers/card-style.d.ts +31 -0
- package/dist/inapp/renderers/card-style.d.ts.map +1 -0
- package/dist/inapp/renderers/card-template.d.ts +233 -0
- package/dist/inapp/renderers/card-template.d.ts.map +1 -0
- package/dist/inapp/renderers/carousel-cards.d.ts +15 -0
- package/dist/inapp/renderers/carousel-cards.d.ts.map +1 -0
- package/dist/inapp/renderers/coachmark-tour.d.ts +24 -0
- package/dist/inapp/renderers/coachmark-tour.d.ts.map +1 -0
- package/dist/inapp/renderers/games.d.ts +27 -0
- package/dist/inapp/renderers/games.d.ts.map +1 -0
- package/dist/inapp/renderers/hero.d.ts +23 -0
- package/dist/inapp/renderers/hero.d.ts.map +1 -0
- package/dist/inapp/renderers/index.d.ts +22 -0
- package/dist/inapp/renderers/index.d.ts.map +1 -0
- package/dist/inapp/renderers/interactive-contract.d.ts +48 -0
- package/dist/inapp/renderers/interactive-contract.d.ts.map +1 -0
- package/dist/inapp/renderers/product-recommendation.d.ts +37 -0
- package/dist/inapp/renderers/product-recommendation.d.ts.map +1 -0
- package/dist/inapp/renderers/progress-bar.d.ts +38 -0
- package/dist/inapp/renderers/progress-bar.d.ts.map +1 -0
- package/dist/inapp/renderers/progress-core.d.ts +80 -0
- package/dist/inapp/renderers/progress-core.d.ts.map +1 -0
- package/dist/inapp/renderers/reviews.d.ts +38 -0
- package/dist/inapp/renderers/reviews.d.ts.map +1 -0
- package/dist/inapp/renderers/scratch-engine.d.ts +66 -0
- package/dist/inapp/renderers/scratch-engine.d.ts.map +1 -0
- package/dist/inapp/renderers/sticky-bar.d.ts +14 -0
- package/dist/inapp/renderers/sticky-bar.d.ts.map +1 -0
- package/dist/inapp/renderers/stories.d.ts +31 -0
- package/dist/inapp/renderers/stories.d.ts.map +1 -0
- package/dist/inapp/renderers/types.d.ts +152 -0
- package/dist/inapp/renderers/types.d.ts.map +1 -0
- package/dist/inapp/renderers/video.d.ts +20 -0
- package/dist/inapp/renderers/video.d.ts.map +1 -0
- package/dist/inbox/AegisInbox.d.ts +106 -0
- package/dist/inbox/AegisInbox.d.ts.map +1 -0
- package/dist/inbox/index.d.ts +3 -0
- package/dist/inbox/index.d.ts.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15478 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/react.d.ts +19 -0
- package/dist/integrations/react.d.ts.map +1 -0
- package/dist/loyalty/AegisLoyaltyManager.d.ts +120 -0
- package/dist/loyalty/AegisLoyaltyManager.d.ts.map +1 -0
- package/dist/loyalty/index.d.ts +3 -0
- package/dist/loyalty/index.d.ts.map +1 -0
- package/dist/plugins/registry.d.ts +13 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/push/AegisWebPush.d.ts +199 -0
- package/dist/push/AegisWebPush.d.ts.map +1 -0
- package/dist/push/AegisWebPush.js +542 -0
- package/dist/push/AegisWebPush.js.map +1 -0
- package/dist/push/cdn-push.d.ts +21 -0
- package/dist/push/cdn-push.d.ts.map +1 -0
- package/dist/react.js +70 -0
- package/dist/react.js.map +1 -0
- package/dist/runtime/AegisMessageRuntime.d.ts +276 -0
- package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/snippet.min.js +1 -0
- package/dist/state/intent_ledger.d.ts +136 -0
- package/dist/state/intent_ledger.d.ts.map +1 -0
- package/dist/triggers/ContactScoresFetcher.d.ts +113 -0
- package/dist/triggers/ContactScoresFetcher.d.ts.map +1 -0
- package/dist/triggers/IntentRuleEvaluator.d.ts +213 -0
- package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -0
- package/dist/triggers/IntentSnapshotCollector.d.ts +83 -0
- package/dist/triggers/IntentSnapshotCollector.d.ts.map +1 -0
- package/dist/triggers/SelectorBinder.d.ts +118 -0
- package/dist/triggers/SelectorBinder.d.ts.map +1 -0
- package/dist/triggers/TriggerEngine.d.ts +296 -0
- package/dist/triggers/TriggerEngine.d.ts.map +1 -0
- package/dist/triggers/behaviouralTriggers.d.ts +44 -0
- package/dist/triggers/behaviouralTriggers.d.ts.map +1 -0
- package/dist/triggers/index.d.ts +11 -0
- package/dist/triggers/index.d.ts.map +1 -0
- package/dist/triggers/microIntentTriggers.d.ts +80 -0
- package/dist/triggers/microIntentTriggers.d.ts.map +1 -0
- package/dist/types/config.d.ts +77 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/events.d.ts +147 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +21 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/type-safe-events.d.ts +14 -0
- package/dist/types/type-safe-events.d.ts.map +1 -0
- package/dist/utils/canonical-identity.d.ts +29 -0
- package/dist/utils/canonical-identity.d.ts.map +1 -0
- package/dist/utils/consent.d.ts +40 -0
- package/dist/utils/consent.d.ts.map +1 -0
- package/dist/utils/debounce.d.ts +3 -0
- package/dist/utils/debounce.d.ts.map +1 -0
- package/dist/utils/device.d.ts +6 -0
- package/dist/utils/device.d.ts.map +1 -0
- package/dist/utils/identity.d.ts +27 -0
- package/dist/utils/identity.d.ts.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +15 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/meta-cookies.d.ts +65 -0
- package/dist/utils/meta-cookies.d.ts.map +1 -0
- package/dist/utils/redact-url.d.ts +56 -0
- package/dist/utils/redact-url.d.ts.map +1 -0
- package/dist/utils/storage.d.ts +20 -0
- package/dist/utils/storage.d.ts.map +1 -0
- package/dist/utils/url-parser.d.ts +61 -0
- package/dist/utils/url-parser.d.ts.map +1 -0
- package/dist/utils/uuid.d.ts +4 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/visitor.d.ts +43 -0
- package/dist/utils/visitor.d.ts.map +1 -0
- package/dist/widgets/AegisWidgetManager.d.ts +209 -0
- package/dist/widgets/AegisWidgetManager.d.ts.map +1 -0
- package/dist/widgets/index.d.ts +3 -0
- package/dist/widgets/index.d.ts.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TriggerEngine - Client-Side Trigger Evaluation
|
|
3
|
+
*
|
|
4
|
+
* Evaluates behavioral triggers that require real-time client state:
|
|
5
|
+
* - Scroll depth (e.g., user scrolled >= 50%)
|
|
6
|
+
* - Time on page (e.g., >= 30 seconds on current page)
|
|
7
|
+
* - Exit intent (mouse leaving viewport toward browser controls)
|
|
8
|
+
* - Inactivity (no user interaction for X seconds)
|
|
9
|
+
* - Scroll velocity (mobile exit intent - fast upward scroll)
|
|
10
|
+
* - Visibility change (tab/app switching)
|
|
11
|
+
* - Back button (history navigation)
|
|
12
|
+
*
|
|
13
|
+
* Architecture:
|
|
14
|
+
* - Server evaluates historical triggers (event counts, segments)
|
|
15
|
+
* - Client evaluates behavioral triggers (scroll, time, exit intent)
|
|
16
|
+
* - Zero latency - no server round trip needed
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
* const trigger = new TriggerEngine();
|
|
20
|
+
* trigger.on('scroll_depth_50', (data) => {
|
|
21
|
+
* console.log('User scrolled to 50%', data);
|
|
22
|
+
* });
|
|
23
|
+
* trigger.start();
|
|
24
|
+
*
|
|
25
|
+
* Every `page_url` a trigger emits is credential-redacted (`redactUrl`): the
|
|
26
|
+
* payload is handed to listeners that track it. The two `history.pushState`
|
|
27
|
+
* calls read the raw URL on purpose — they re-push the page the visitor is
|
|
28
|
+
* on, and a redacted URL there would rewrite the address bar.
|
|
29
|
+
*/
|
|
30
|
+
export interface TriggerRule {
|
|
31
|
+
type: 'scroll_depth' | 'time_on_page' | 'exit_intent' | 'inactivity' | 'scroll_velocity' | 'visibility_change' | 'back_button';
|
|
32
|
+
config: ScrollDepthConfig | TimeOnPageConfig | ExitIntentConfig | InactivityConfig | ScrollVelocityConfig | VisibilityChangeConfig | BackButtonConfig;
|
|
33
|
+
}
|
|
34
|
+
export interface ScrollDepthConfig {
|
|
35
|
+
depth_percent: number;
|
|
36
|
+
}
|
|
37
|
+
export interface TimeOnPageConfig {
|
|
38
|
+
seconds: number;
|
|
39
|
+
}
|
|
40
|
+
export interface ExitIntentConfig {
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface InactivityConfig {
|
|
44
|
+
idle_seconds: number;
|
|
45
|
+
}
|
|
46
|
+
export interface ScrollVelocityConfig {
|
|
47
|
+
threshold: number;
|
|
48
|
+
minScrollPosition: number;
|
|
49
|
+
cooldown: number;
|
|
50
|
+
}
|
|
51
|
+
export interface VisibilityChangeConfig {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface BackButtonConfig {
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Rage-click detection (Micro-Intent Engine P2 Task 1).
|
|
59
|
+
*
|
|
60
|
+
* Per-intent ring buffer: when ≥ `threshold` clicks land on the same
|
|
61
|
+
* intent inside `windowMs`, the engine emits `rage_click` with the
|
|
62
|
+
* intent name + current count + window. Frustration signal used by the
|
|
63
|
+
* Stuck-at-Checkout pattern (e.g., rage-clicking the coupon input four
|
|
64
|
+
* times in 800ms).
|
|
65
|
+
*
|
|
66
|
+
* Defaults match the plan:
|
|
67
|
+
* threshold = 3 clicks
|
|
68
|
+
* windowMs = 1000 ms
|
|
69
|
+
*
|
|
70
|
+
* TriggerEngine does NOT attach its own pointerdown listener — the
|
|
71
|
+
* SelectorBinder (P1 Task 5) owns the global, delegated listener and
|
|
72
|
+
* dispatches per-intent click events. The IntentSnapshotCollector
|
|
73
|
+
* (P2 Task 5) wires `SelectorBinder.onIntent` to
|
|
74
|
+
* `TriggerEngine.noteClick(intent)` so TriggerEngine sees a clean
|
|
75
|
+
* intent-stamped stream instead of raw DOM events.
|
|
76
|
+
*/
|
|
77
|
+
export interface RageClickConfig {
|
|
78
|
+
threshold: number;
|
|
79
|
+
windowMs: number;
|
|
80
|
+
}
|
|
81
|
+
/** Payload emitted on the `rage_click` event. */
|
|
82
|
+
export interface RageClickData {
|
|
83
|
+
intent: string;
|
|
84
|
+
count: number;
|
|
85
|
+
window_ms: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Hover-dwell tracking (Micro-Intent Engine P2 Task 2).
|
|
89
|
+
*
|
|
90
|
+
* Tracks per-intent hover duration in milliseconds. `getHoverMs(intent)`
|
|
91
|
+
* returns:
|
|
92
|
+
* - if currently hovering the intent: ms since hover_start (live)
|
|
93
|
+
* - else: ms duration of the most recent hover on that intent (sticky)
|
|
94
|
+
* - if never hovered: 0
|
|
95
|
+
*
|
|
96
|
+
* The sticky behaviour is deliberate. The canonical use case
|
|
97
|
+
* (MICRO_INTENT_ENGINE.md Story 1):
|
|
98
|
+
* "Priya hovers price for 1.8s, considers, moves cursor away.
|
|
99
|
+
* Exit_intent fires. Rule checks price_hover_ms >= 1500 → true."
|
|
100
|
+
* The rule evaluator queries `price_hover_ms` AFTER the hover ends. If
|
|
101
|
+
* we reset to 0 on hover_end, the rule never matches the very pattern
|
|
102
|
+
* the engine exists to detect.
|
|
103
|
+
*
|
|
104
|
+
* Threshold-based emission: when a hover crosses one of the registered
|
|
105
|
+
* dwell targets (e.g. 1500ms), a `<intent>_hover_dwell_<ms>` event
|
|
106
|
+
* fires. Useful for journeys that want event-style hooks; the
|
|
107
|
+
* snapshot-style `getHoverMs` is the primary surface for the
|
|
108
|
+
* compound-rule evaluator.
|
|
109
|
+
*/
|
|
110
|
+
export interface HoverDwellConfig {
|
|
111
|
+
/** Dwell thresholds (ms) per intent. The engine fires
|
|
112
|
+
* `<intent>_hover_dwell_<ms>` when an active hover crosses each
|
|
113
|
+
* threshold. Defaults: price→[1500], cta→[1500]. */
|
|
114
|
+
thresholdsByIntent?: Partial<Record<string, ReadonlyArray<number>>>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Mouse velocity toward the viewport top (Micro-Intent Engine P2 Task 3).
|
|
118
|
+
*
|
|
119
|
+
* Detects the early phase of exit-intent: the mouse moving rapidly
|
|
120
|
+
* upward before it actually crosses out of the viewport. The signal is
|
|
121
|
+
* a continuous px/ms value (positive = moving up), updated as samples
|
|
122
|
+
* arrive. When velocity crosses `threshold`, a `mouse_velocity_to_top`
|
|
123
|
+
* event fires (once per session-window cooldown to avoid spamming on a
|
|
124
|
+
* single gesture).
|
|
125
|
+
*
|
|
126
|
+
* Sampling: callers feed positions via `noteMousePosition(x, y, ts)`.
|
|
127
|
+
* The engine keeps a sliding `windowMs` ring buffer of samples and
|
|
128
|
+
* computes velocity as the average dy / dt over samples in the window.
|
|
129
|
+
* Per the plan: sampled at 100ms, 400ms window. That bound is
|
|
130
|
+
* configurable.
|
|
131
|
+
*
|
|
132
|
+
* Why "to top" specifically: exit-intent fires only when y crosses 0;
|
|
133
|
+
* we want the warning BEFORE that. A typical exit-intent gesture has
|
|
134
|
+
* upward velocity well above any normal browsing motion.
|
|
135
|
+
*/
|
|
136
|
+
export interface MouseVelocityConfig {
|
|
137
|
+
/** Threshold in px/ms (positive = moving up). Default 1.5 px/ms,
|
|
138
|
+
* ≈ moving 600px in 400ms, which only happens during a deliberate
|
|
139
|
+
* upward sweep. */
|
|
140
|
+
threshold: number;
|
|
141
|
+
/** Rolling-window length over which to compute velocity. */
|
|
142
|
+
windowMs: number;
|
|
143
|
+
/** Cooldown after a fire before the signal can fire again. */
|
|
144
|
+
cooldownMs: number;
|
|
145
|
+
}
|
|
146
|
+
export interface TriggerEvent {
|
|
147
|
+
type: string;
|
|
148
|
+
data: Record<string, any>;
|
|
149
|
+
timestamp: number;
|
|
150
|
+
}
|
|
151
|
+
type TriggerCallback = (event: TriggerEvent) => void;
|
|
152
|
+
export declare class TriggerEngine {
|
|
153
|
+
private listeners;
|
|
154
|
+
private isStarted;
|
|
155
|
+
private scrollDepthTargets;
|
|
156
|
+
private scrollDepthReached;
|
|
157
|
+
private timeOnPageTargets;
|
|
158
|
+
private pageLoadTime?;
|
|
159
|
+
private exitIntentEnabled;
|
|
160
|
+
private exitIntentFired;
|
|
161
|
+
private inactivityTargets;
|
|
162
|
+
private lastActivityTime;
|
|
163
|
+
private inactivityCheckInterval?;
|
|
164
|
+
private scrollVelocityEnabled;
|
|
165
|
+
private scrollVelocityFired;
|
|
166
|
+
private scrollVelocityConfig;
|
|
167
|
+
private lastScrollY;
|
|
168
|
+
private lastScrollTime;
|
|
169
|
+
private scrollVelocityCooldownTimer?;
|
|
170
|
+
private visibilityChangeEnabled;
|
|
171
|
+
private backButtonEnabled;
|
|
172
|
+
private backButtonFired;
|
|
173
|
+
private rageClickEnabled;
|
|
174
|
+
private rageClickConfig;
|
|
175
|
+
private rageClickBuffer;
|
|
176
|
+
/** Tracks whether a rage_click event has already fired for an intent
|
|
177
|
+
* in the current burst. Reset when the buffer empties below threshold.
|
|
178
|
+
* Prevents the same burst from firing the event N-2 times as each
|
|
179
|
+
* click after threshold pushes the count higher. */
|
|
180
|
+
private rageClickFiredInBurst;
|
|
181
|
+
private hoverEnabled;
|
|
182
|
+
private hoverStartAt;
|
|
183
|
+
private hoverLastMs;
|
|
184
|
+
private hoverThresholds;
|
|
185
|
+
/** Track which (intent, threshold) pairs have already fired in the
|
|
186
|
+
* current hover so a single long hover doesn't double-fire as time
|
|
187
|
+
* marches on. Reset on hover_start. */
|
|
188
|
+
private hoverThresholdsFired;
|
|
189
|
+
/** Pending threshold timers, keyed by intent. Cleared on hover_end. */
|
|
190
|
+
private hoverThresholdTimers;
|
|
191
|
+
private mouseVelEnabled;
|
|
192
|
+
private mouseVelConfig;
|
|
193
|
+
/** Ring buffer of (x, y, ts) samples within the rolling window. */
|
|
194
|
+
private mouseSamples;
|
|
195
|
+
/** Last computed velocity-to-top in px/ms (positive = moving up). */
|
|
196
|
+
private mouseVelLast;
|
|
197
|
+
/** Epoch ms when the velocity event last fired — gates cooldown. */
|
|
198
|
+
private mouseVelLastFiredAt;
|
|
199
|
+
constructor();
|
|
200
|
+
on(eventType: string, callback: TriggerCallback): void;
|
|
201
|
+
off(eventType: string, callback: TriggerCallback): void;
|
|
202
|
+
registerScrollDepth(depthPercent: number): void;
|
|
203
|
+
registerTimeOnPage(seconds: number): void;
|
|
204
|
+
registerExitIntent(): void;
|
|
205
|
+
registerInactivity(idleSeconds: number): void;
|
|
206
|
+
registerScrollVelocity(config?: Partial<ScrollVelocityConfig>): void;
|
|
207
|
+
registerVisibilityChange(): void;
|
|
208
|
+
registerBackButton(): void;
|
|
209
|
+
/**
|
|
210
|
+
* Enable rage-click detection (P2 Task 1).
|
|
211
|
+
*
|
|
212
|
+
* After calling this, feed click events via `noteClick(intent)`.
|
|
213
|
+
* SelectorBinder (P1 Task 5) is the upstream source; the wiring lives
|
|
214
|
+
* in IntentSnapshotCollector (P2 Task 5). Calling `noteClick` without
|
|
215
|
+
* a prior `registerRageClick()` is a no-op so legacy callers don't
|
|
216
|
+
* accidentally enable the feature.
|
|
217
|
+
*/
|
|
218
|
+
registerRageClick(config?: Partial<RageClickConfig>): void;
|
|
219
|
+
/**
|
|
220
|
+
* Feed a click event for rage-click detection. Returns the current
|
|
221
|
+
* count within-window for the intent — useful for the snapshot
|
|
222
|
+
* collector (P2 Task 5) which updates IntentRuleEvaluator with
|
|
223
|
+
* `rage_click_count` continuously, not just at the burst threshold.
|
|
224
|
+
*
|
|
225
|
+
* Idempotent w.r.t. `registerRageClick` — when not enabled, this
|
|
226
|
+
* returns 0 without buffering.
|
|
227
|
+
*/
|
|
228
|
+
noteClick(intent: string, timestamp?: number): number;
|
|
229
|
+
/** Snapshot the current rage_click count for an intent. The
|
|
230
|
+
* IntentSnapshotCollector (P2 Task 5) calls this when building the
|
|
231
|
+
* `rage_click_count` signal value for the IntentRuleEvaluator. */
|
|
232
|
+
getRageClickCount(intent: string): number;
|
|
233
|
+
/**
|
|
234
|
+
* Enable hover-dwell tracking (P2 Task 2). After registration, feed
|
|
235
|
+
* hover events via `noteHoverStart(intent, ts)` / `noteHoverEnd`.
|
|
236
|
+
* SelectorBinder (P1 Task 5) is the upstream source; wiring lands in
|
|
237
|
+
* P2 Task 5.
|
|
238
|
+
*/
|
|
239
|
+
registerHoverDwell(config?: HoverDwellConfig): void;
|
|
240
|
+
/** Record the start of a hover on the named intent. Schedules
|
|
241
|
+
* per-threshold timers that emit `<intent>_hover_dwell_<ms>` when
|
|
242
|
+
* the active hover passes each registered threshold. */
|
|
243
|
+
noteHoverStart(intent: string, timestamp?: number): void;
|
|
244
|
+
/** Record the end of a hover on the named intent. Updates the sticky
|
|
245
|
+
* `lastHoverMs` so `getHoverMs` keeps returning the last-known
|
|
246
|
+
* duration until the next hover_start. */
|
|
247
|
+
noteHoverEnd(intent: string, timestamp?: number): void;
|
|
248
|
+
/**
|
|
249
|
+
* Enable mouse-velocity-to-top tracking (P2 Task 3). After
|
|
250
|
+
* registration, feed positions via `noteMousePosition(x, y, ts?)`.
|
|
251
|
+
* IntentSnapshotCollector (P2 Task 5) wires window 'mousemove' to
|
|
252
|
+
* this method, with throttling to ~100ms per the plan.
|
|
253
|
+
*/
|
|
254
|
+
registerMouseVelocityToTop(config?: Partial<MouseVelocityConfig>): void;
|
|
255
|
+
/** Feed a mouse-position sample. Recomputes the rolling-window
|
|
256
|
+
* velocity-to-top and fires `mouse_velocity_to_top` when the value
|
|
257
|
+
* crosses the configured threshold (subject to cooldown). */
|
|
258
|
+
noteMousePosition(x: number, y: number, timestamp?: number): number;
|
|
259
|
+
/** Snapshot the current velocity-to-top in px/ms (positive = up).
|
|
260
|
+
* Returns 0 when not enabled or insufficient samples. */
|
|
261
|
+
getMouseVelocityToTop(): number;
|
|
262
|
+
/**
|
|
263
|
+
* Snapshot the hover dwell for an intent.
|
|
264
|
+
* - Currently hovering: returns `Date.now() - hover_start_at`.
|
|
265
|
+
* - Hovered before, not currently: returns the most recent hover's
|
|
266
|
+
* duration (sticky — the rule evaluator queries this AFTER
|
|
267
|
+
* mouseleave to see "did Priya hover the price ≥ 1.5s?").
|
|
268
|
+
* - Never hovered: returns 0.
|
|
269
|
+
*/
|
|
270
|
+
getHoverMs(intent: string): number;
|
|
271
|
+
start(): void;
|
|
272
|
+
stop(): void;
|
|
273
|
+
reset(): void;
|
|
274
|
+
private attachScrollListener;
|
|
275
|
+
private removeScrollListener;
|
|
276
|
+
private handleScroll;
|
|
277
|
+
private attachExitIntentListener;
|
|
278
|
+
private removeExitIntentListener;
|
|
279
|
+
private handleExitIntent;
|
|
280
|
+
private attachScrollVelocityListener;
|
|
281
|
+
private removeScrollVelocityListener;
|
|
282
|
+
private handleScrollVelocity;
|
|
283
|
+
private attachVisibilityChangeListener;
|
|
284
|
+
private removeVisibilityChangeListener;
|
|
285
|
+
private handleVisibilityChange;
|
|
286
|
+
private attachBackButtonListener;
|
|
287
|
+
private removeBackButtonListener;
|
|
288
|
+
private handleBackButton;
|
|
289
|
+
private attachActivityListeners;
|
|
290
|
+
private removeActivityListeners;
|
|
291
|
+
private handleActivity;
|
|
292
|
+
private startInactivityCheck;
|
|
293
|
+
private emit;
|
|
294
|
+
}
|
|
295
|
+
export {};
|
|
296
|
+
//# sourceMappingURL=TriggerEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TriggerEngine.d.ts","sourceRoot":"","sources":["../../src/triggers/TriggerEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,aAAa,GAAG,YAAY,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,aAAa,CAAC;IAC/H,MAAM,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,oBAAoB,GAAG,sBAAsB,GAAG,gBAAgB,CAAC;CACvJ;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,M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AAwB;IAIhC,OAAO,CAAC,gBAAgB,CActB;IAEF,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,oBAAoB,CAoC1B;IAEF,OAAO,CAAC,8BAA8B;IAItC,OAAO,CAAC,8BAA8B;IAItC,OAAO,CAAC,sBAAsB,CAW5B;IAEF,OAAO,CAAC,wBAAwB;IAOhC,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,gBAAgB,CAatB;IAEF,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,cAAc,CAEpB;IAEF,OAAO,CAAC,oBAAoB;IAqB5B,OAAO,CAAC,IAAI;CA6Bb"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behavioural in-app triggers — the builder's "When" options
|
|
3
|
+
* (`display_rules.trigger_type`, served as `client_trigger`) that wait on a
|
|
4
|
+
* visitor behaviour the TriggerEngine detects.
|
|
5
|
+
*
|
|
6
|
+
* ONE table maps each trigger to the client event it fires on, so the in-app
|
|
7
|
+
* manager's matcher and the runtime's arming read the same names. Defaults
|
|
8
|
+
* match the builder's (when-panel.tsx): 50 % scroll, 30 s on page, 30 s idle.
|
|
9
|
+
*
|
|
10
|
+
* `micro_intent` is NOT here: it is a compound rule the IntentRuleEvaluator
|
|
11
|
+
* owns, not one engine event.
|
|
12
|
+
*/
|
|
13
|
+
import type { TriggerEngine } from './TriggerEngine';
|
|
14
|
+
export interface ClientTrigger {
|
|
15
|
+
type: string;
|
|
16
|
+
config?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export declare const BEHAVIOURAL_TRIGGER_TYPES: readonly ["exit_intent", "scroll_depth", "time_on_page", "inactivity"];
|
|
19
|
+
export declare const DEFAULT_SCROLL_DEPTH_PERCENT = 50;
|
|
20
|
+
export declare const DEFAULT_TIME_ON_PAGE_SECONDS = 30;
|
|
21
|
+
export declare const DEFAULT_IDLE_SECONDS = 30;
|
|
22
|
+
/**
|
|
23
|
+
* The client event a behavioural trigger fires on — the TriggerEngine's own
|
|
24
|
+
* event name — or null when the trigger is not behavioural.
|
|
25
|
+
*/
|
|
26
|
+
export declare function behaviouralTriggerEvent(trigger: ClientTrigger | null | undefined): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* The inverse of `behaviouralTriggerEvent`: reads an engine event name
|
|
29
|
+
* (`exit_intent`, `inactivity_60`, `time_on_page_30`, `scroll_depth_50`) back
|
|
30
|
+
* into its trigger, for hosts that configure triggers by event name (the chat
|
|
31
|
+
* launcher's `proactiveTriggers`). Null for any other name.
|
|
32
|
+
*/
|
|
33
|
+
export declare function triggerFromEngineEvent(eventName: string): ClientTrigger | null;
|
|
34
|
+
/**
|
|
35
|
+
* Arms the TriggerEngine for the behavioural triggers of `triggers` and calls
|
|
36
|
+
* `fire(eventName)` when one happens. Returns the events it newly armed, so a
|
|
37
|
+
* caller re-arming after each campaign refresh subscribes each event once.
|
|
38
|
+
*
|
|
39
|
+
* Exit intent: mouse leaving the top of the window on desktop; on mobile (no
|
|
40
|
+
* mouse) a fast scroll back up, which the engine reports as
|
|
41
|
+
* `mobile_exit_intent` and this forwards as `exit_intent`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function armBehaviouralTriggers(engine: TriggerEngine, triggers: ReadonlyArray<ClientTrigger | null | undefined>, armed: Set<string>, fire: (eventName: string) => void, isMobile: boolean): string[];
|
|
44
|
+
//# sourceMappingURL=behaviouralTriggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behaviouralTriggers.d.ts","sourceRoot":"","sources":["../../src/triggers/behaviouralTriggers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,eAAO,MAAM,yBAAyB,wEAK5B,CAAC;AAEX,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAOvC;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAehG;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAQ9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,aAAa,CAAC,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC,EACzD,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EAClB,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,EACjC,QAAQ,EAAE,OAAO,GAChB,MAAM,EAAE,CA+BV"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { TriggerEngine } from './TriggerEngine';
|
|
2
|
+
export type { TriggerRule, ScrollDepthConfig, TimeOnPageConfig, ExitIntentConfig, InactivityConfig, TriggerEvent, RageClickConfig, RageClickData, HoverDwellConfig, MouseVelocityConfig, } from './TriggerEngine';
|
|
3
|
+
export { IntentRuleEvaluator, evaluateLeaf, evaluateExpr, evaluateRule, isIntentLeaf, isIntentNode, MAX_RULE_DEPTH, } from './IntentRuleEvaluator';
|
|
4
|
+
export type { IntentSignal, Comparator, IntentLeafValue, IntentLeaf, IntentNode, IntentExpr, IntentRule, IntentSnapshot, SignalValue, ArmedCampaign, EvaluationDecision, } from './IntentRuleEvaluator';
|
|
5
|
+
export { SelectorBinder } from './SelectorBinder';
|
|
6
|
+
export type { IntentElementName, IntentDomEventType, IntentDomEvent, IntentDomHandler, IntentSelectors, SelectorBinderConfig, } from './SelectorBinder';
|
|
7
|
+
export { IntentSnapshotCollector } from './IntentSnapshotCollector';
|
|
8
|
+
export type { IntentSnapshotCollectorConfig } from './IntentSnapshotCollector';
|
|
9
|
+
export { ContactScoresFetcher, toIntentSnapshot } from './ContactScoresFetcher';
|
|
10
|
+
export type { ContactScoresFetcherConfig, ContactScoresResponse } from './ContactScoresFetcher';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/triggers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,YAAY,EACZ,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,aAAa,EACb,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAG/E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,YAAY,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart trigger (`micro_intent`) arming — the production caller the
|
|
3
|
+
* IntentRuleEvaluator never had (Aman 2026-09-28, plan
|
|
4
|
+
* GAMIFICATION_ENGAGEMENT_TARGETING_PLAN §0d).
|
|
5
|
+
*
|
|
6
|
+
* A `micro_intent` campaign is served as `client_trigger: { type:
|
|
7
|
+
* 'micro_intent', config: <IntentRule> }`. Before this module nothing called
|
|
8
|
+
* `setArmed`, nothing turned a TriggerEngine event into an evaluator signal,
|
|
9
|
+
* and `converted_in_session` was never written — so `NOT(converted)` stayed
|
|
10
|
+
* null and every rule carrying it could never fire.
|
|
11
|
+
*
|
|
12
|
+
* This arms the evaluator on every campaign load, registers the engine
|
|
13
|
+
* thresholds the rules read (the `fire_on` signals and every numeric leaf of
|
|
14
|
+
* `time_on_page` / `scroll_depth` / `inactivity`), writes each engine event
|
|
15
|
+
* into the snapshot, and asks the evaluator for a decision.
|
|
16
|
+
*
|
|
17
|
+
* Signals owned elsewhere: Layer-1 scores (ContactScoresFetcher), `cart_value`
|
|
18
|
+
* (runtime updateContext). Hover / rage-click / SKU dwell need the
|
|
19
|
+
* IntentSnapshotCollector + SelectorBinder, which no host wires yet — rules on
|
|
20
|
+
* them stay unmet (null), never fire.
|
|
21
|
+
*/
|
|
22
|
+
import type { TriggerEngine } from './TriggerEngine';
|
|
23
|
+
import type { ArmedCampaign, IntentRule, IntentRuleEvaluator } from './IntentRuleEvaluator';
|
|
24
|
+
import { type ClientTrigger } from './behaviouralTriggers';
|
|
25
|
+
export declare const MICRO_INTENT_TRIGGER_TYPE = "micro_intent";
|
|
26
|
+
/** Signals whose value is a count the engine reports at registered thresholds. */
|
|
27
|
+
declare const THRESHOLD_SIGNALS: {
|
|
28
|
+
readonly time_on_page: 30;
|
|
29
|
+
readonly scroll_depth: 50;
|
|
30
|
+
readonly inactivity: 30;
|
|
31
|
+
};
|
|
32
|
+
type ThresholdSignal = keyof typeof THRESHOLD_SIGNALS;
|
|
33
|
+
/** The rule a `micro_intent` trigger carries, or null when it is not one or is malformed. */
|
|
34
|
+
export declare function microIntentRule(trigger: ClientTrigger | null | undefined): IntentRule | null;
|
|
35
|
+
/** Every loaded campaign whose client trigger is a well-formed smart trigger. */
|
|
36
|
+
export declare function armedMicroIntentCampaigns(campaigns: ReadonlyArray<{
|
|
37
|
+
id: string;
|
|
38
|
+
client_trigger?: ClientTrigger | null;
|
|
39
|
+
}>): ArmedCampaign[];
|
|
40
|
+
/**
|
|
41
|
+
* The engine thresholds at which `signal` must be observed for `rules` to be
|
|
42
|
+
* decided truthfully: each numeric leaf's crossing point (`gte 8` → 8,
|
|
43
|
+
* `gt 8` → 9), plus the builder default when a rule fires on the signal but
|
|
44
|
+
* never names a value.
|
|
45
|
+
*/
|
|
46
|
+
export declare function signalThresholds(rules: ReadonlyArray<IntentRule>, signal: ThresholdSignal): number[];
|
|
47
|
+
export interface MicroIntentArmingConfig {
|
|
48
|
+
engine: TriggerEngine;
|
|
49
|
+
evaluator: IntentRuleEvaluator;
|
|
50
|
+
/** Display the campaign; true only when it actually showed. */
|
|
51
|
+
show: (campaignId: string) => boolean;
|
|
52
|
+
/** Whether this session already converted (the in-app manager's record). */
|
|
53
|
+
hasConverted: () => boolean;
|
|
54
|
+
/** No hovering pointer: exit intent is the engine's fast scroll up. */
|
|
55
|
+
isMobile: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare class MicroIntentArming {
|
|
58
|
+
private readonly cfg;
|
|
59
|
+
private readonly registered;
|
|
60
|
+
private listening;
|
|
61
|
+
private readonly onEngineEvent;
|
|
62
|
+
constructor(cfg: MicroIntentArmingConfig);
|
|
63
|
+
/** Replace the armed rules with the smart triggers among `campaigns`. */
|
|
64
|
+
arm(campaigns: ReadonlyArray<{
|
|
65
|
+
id: string;
|
|
66
|
+
client_trigger?: ClientTrigger | null;
|
|
67
|
+
}>): void;
|
|
68
|
+
/** The host reported a conversion: rules gated on NOT converted stop matching. */
|
|
69
|
+
noteConversion(): void;
|
|
70
|
+
destroy(): void;
|
|
71
|
+
private once;
|
|
72
|
+
/** Subscribe once, and seed the page-start values: nothing scrolled, no
|
|
73
|
+
* time elapsed, no exit yet, conversion as the manager recorded it. A null
|
|
74
|
+
* here would make every AND/NOT over these signals unprovable. */
|
|
75
|
+
private listen;
|
|
76
|
+
private handle;
|
|
77
|
+
private decide;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=microIntentTriggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"microIntentTriggers.d.ts","sourceRoot":"","sources":["../../src/triggers/microIntentTriggers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EACV,aAAa,EAEb,UAAU,EACV,mBAAmB,EAEpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AAExD,kFAAkF;AAClF,QAAA,MAAM,iBAAiB;;;;CAIb,CAAC;AACX,KAAK,eAAe,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAItD,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAe5F;AAED,iFAAiF;AACjF,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,aAAa,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAAC,GAC9E,aAAa,EAAE,CAOjB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,EAAE,CAgBpG;AAOD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,+DAA+D;IAC/D,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,4EAA4E;IAC5E,YAAY,EAAE,MAAM,OAAO,CAAC;IAC5B,uEAAuE;IACvE,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA0B;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0D;gBAE5E,GAAG,EAAE,uBAAuB;IAIxC,yEAAyE;IACzE,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;KAAE,CAAC,GAAG,IAAI;IAwB1F,kFAAkF;IAClF,cAAc,IAAI,IAAI;IAItB,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,IAAI;IAMZ;;uEAEmE;IACnE,OAAO,CAAC,MAAM;IAmBd,OAAO,CAAC,MAAM;IAwBd,OAAO,CAAC,MAAM;CAQf"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export type CellRegion = 'us-east' | 'us-west' | 'eu-central' | 'ap-south' | 'ap-southeast';
|
|
2
|
+
export interface CellEndpoint {
|
|
3
|
+
region: CellRegion;
|
|
4
|
+
url: string;
|
|
5
|
+
priority: number;
|
|
6
|
+
healthy: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface AegisConfig {
|
|
9
|
+
write_key: string;
|
|
10
|
+
workspace_id?: string;
|
|
11
|
+
api_host?: string;
|
|
12
|
+
cell_endpoints?: CellEndpoint[];
|
|
13
|
+
preferred_region?: CellRegion;
|
|
14
|
+
auto_region_detection?: boolean;
|
|
15
|
+
batch_size?: number;
|
|
16
|
+
batch_interval?: number;
|
|
17
|
+
capture_utm?: boolean;
|
|
18
|
+
capture_referrer?: boolean;
|
|
19
|
+
auto_page_view?: boolean;
|
|
20
|
+
session_timeout?: number;
|
|
21
|
+
debug?: boolean;
|
|
22
|
+
respect_dnt?: boolean;
|
|
23
|
+
cross_domain_tracking?: boolean;
|
|
24
|
+
cookie_domain?: string;
|
|
25
|
+
secure_cookie?: boolean;
|
|
26
|
+
enable_offline_mode?: boolean;
|
|
27
|
+
max_offline_events?: number;
|
|
28
|
+
retry_failed_requests?: boolean;
|
|
29
|
+
max_retries?: number;
|
|
30
|
+
retry_backoff_multiplier?: number;
|
|
31
|
+
request_timeout?: number;
|
|
32
|
+
/** Client-side rate limiter — burst (token bucket capacity). Default 100. */
|
|
33
|
+
rate_limit_burst?: number;
|
|
34
|
+
/** Client-side rate limiter — sustained tokens per second. Default 20. */
|
|
35
|
+
rate_limit_per_second?: number;
|
|
36
|
+
plugins?: string[];
|
|
37
|
+
wait_for_consent?: boolean;
|
|
38
|
+
default_consent?: {
|
|
39
|
+
analytics?: boolean;
|
|
40
|
+
marketing?: boolean;
|
|
41
|
+
functional?: boolean;
|
|
42
|
+
};
|
|
43
|
+
enable_consent_mode?: boolean;
|
|
44
|
+
integrate_onetrust?: boolean;
|
|
45
|
+
integrate_cookiebot?: boolean;
|
|
46
|
+
integrate_google_consent_mode?: boolean;
|
|
47
|
+
/** Push notification configuration. When provided, AegisWebPush is initialized. */
|
|
48
|
+
push?: {
|
|
49
|
+
/** VAPID public key for Web Push subscription. */
|
|
50
|
+
vapidPublicKey: string;
|
|
51
|
+
/** Automatically prompt for push permission after SDK init. Default: false. */
|
|
52
|
+
autoPrompt?: boolean;
|
|
53
|
+
/** Delay in ms before showing auto-prompt. Default: 5000. */
|
|
54
|
+
promptDelay?: number;
|
|
55
|
+
/** Path to the service worker file. Default: '/aegis-sw.js'. */
|
|
56
|
+
serviceWorkerPath?: string;
|
|
57
|
+
/** Scope for the service worker registration. Default: '/'. Critical for e-commerce platforms. */
|
|
58
|
+
serviceWorkerScope?: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface AegisConfigInternal extends Required<Omit<AegisConfig, 'api_host' | 'cell_endpoints' | 'preferred_region' | 'cookie_domain' | 'plugins' | 'default_consent' | 'workspace_id'>> {
|
|
62
|
+
initialized: boolean;
|
|
63
|
+
workspace_id: string | null;
|
|
64
|
+
api_host: string | null;
|
|
65
|
+
cell_endpoints: CellEndpoint[];
|
|
66
|
+
preferred_region: CellRegion | null;
|
|
67
|
+
cookie_domain: string | null;
|
|
68
|
+
plugins: string[];
|
|
69
|
+
active_cell: CellEndpoint | null;
|
|
70
|
+
default_consent: {
|
|
71
|
+
analytics: boolean;
|
|
72
|
+
marketing: boolean;
|
|
73
|
+
functional: boolean;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export declare const DEFAULT_CONFIG: Partial<AegisConfigInternal>;
|
|
77
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,CAAC;AAE5F,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAElB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,cA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