@active-reach/web-sdk 1.14.1 → 1.19.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/README.md +35 -54
- package/dist/aegis-sw.js +1 -1
- package/dist/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/{analytics-CjLItVo2.mjs → analytics-DblhjFhs.mjs} +66 -3
- package/dist/analytics-DblhjFhs.mjs.map +1 -0
- package/dist/cdn.d.ts +5 -2
- package/dist/cdn.d.ts.map +1 -1
- package/dist/chat/AegisChat.d.ts +138 -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 +37 -2
- package/dist/core/analytics.d.ts.map +1 -1
- package/dist/ecommerce/index.d.ts +32 -14
- package/dist/ecommerce/index.d.ts.map +1 -1
- package/dist/inapp/AegisInAppManager.d.ts +349 -1
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/devicePairing.d.ts +70 -0
- package/dist/inapp/devicePairing.d.ts.map +1 -0
- package/dist/inapp/index.d.ts +2 -0
- package/dist/inapp/index.d.ts.map +1 -1
- package/dist/inapp/renderPreview.d.ts.map +1 -1
- package/dist/inapp/renderers/active-web-chat.d.ts +38 -0
- package/dist/inapp/renderers/active-web-chat.d.ts.map +1 -0
- package/dist/inapp/renderers/carousel-cards.d.ts.map +1 -1
- package/dist/inapp/renderers/coachmark-tour.d.ts.map +1 -1
- package/dist/inapp/renderers/games.d.ts +27 -0
- package/dist/inapp/renderers/games.d.ts.map +1 -0
- package/dist/inapp/renderers/index.d.ts +8 -3
- package/dist/inapp/renderers/index.d.ts.map +1 -1
- package/dist/inapp/renderers/product-recommendation.d.ts +4 -4
- package/dist/inapp/renderers/product-recommendation.d.ts.map +1 -1
- package/dist/inapp/renderers/progress-bar.d.ts +14 -0
- package/dist/inapp/renderers/progress-bar.d.ts.map +1 -1
- package/dist/inapp/renderers/sticky-bar.d.ts.map +1 -1
- 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 +73 -2
- package/dist/inapp/renderers/types.d.ts.map +1 -1
- package/dist/inapp/renderers/video.d.ts +20 -0
- package/dist/inapp/renderers/video.d.ts.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8696 -3093
- package/dist/index.js.map +1 -1
- 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/push/AegisWebPush.d.ts.map +1 -1
- package/dist/push/AegisWebPush.js +13 -2
- package/dist/push/AegisWebPush.js.map +1 -1
- package/dist/react.js +1 -1
- package/dist/runtime/AegisMessageRuntime.d.ts +96 -1
- package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
- package/dist/triggers/ContactScoresFetcher.d.ts +105 -0
- package/dist/triggers/ContactScoresFetcher.d.ts.map +1 -0
- package/dist/triggers/IntentRuleEvaluator.d.ts +1 -1
- package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -1
- package/dist/triggers/index.d.ts +2 -0
- package/dist/triggers/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/analytics-CjLItVo2.mjs.map +0 -1
- package/dist/placements/AegisPlacementManager.d.ts +0 -97
- package/dist/placements/AegisPlacementManager.d.ts.map +0 -1
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
* live page) open SSE directly via Next.js API routes — not via this SDK.
|
|
20
20
|
* End-user storefronts use polling + Web Push for background delivery.
|
|
21
21
|
*/
|
|
22
|
+
import type { CartState } from './renderers';
|
|
22
23
|
export interface InAppCampaign {
|
|
23
24
|
id: string;
|
|
24
|
-
type: 'modal' | 'banner' | 'tooltip' | 'full_screen' | 'half_interstitial' | 'alert' | 'pip' | 'carousel_cards' | 'sticky_bar' | 'progress_bar' | 'coachmark_tour' | 'product_recommendation';
|
|
25
|
+
type: 'modal' | 'banner' | 'tooltip' | 'full_screen' | 'half_interstitial' | 'alert' | 'pip' | 'video' | 'stories' | 'carousel_cards' | 'sticky_bar' | 'progress_bar' | 'coachmark_tour' | 'product_recommendation' | 'active_web_chat' | 'custom_html';
|
|
25
26
|
sub_type?: string;
|
|
26
27
|
title: string;
|
|
27
28
|
body: string;
|
|
@@ -50,6 +51,8 @@ export interface InAppCampaign {
|
|
|
50
51
|
delivery_modes?: Array<'in_app_overlay' | 'embedded_card' | 'standalone_page'>;
|
|
51
52
|
widget_category?: 'feedback' | 'loyalty' | 'promo' | 'commerce' | 'support' | 'custom';
|
|
52
53
|
page_key?: 'bill' | 'rewards' | 'feedback' | 'reviews' | 'members';
|
|
54
|
+
surface?: string[];
|
|
55
|
+
target_screens?: string[];
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
58
|
* Payload for `campaign-click` lifecycle event. CANCELLABLE — return `false`
|
|
@@ -124,6 +127,13 @@ export interface AegisInAppConfig {
|
|
|
124
127
|
* back to the org's primary workspace.
|
|
125
128
|
*/
|
|
126
129
|
getWorkspaceId?: () => string | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Live cart-state reader, set by the runtime from its imperative
|
|
132
|
+
* `setCartState(...)`. Threaded into the renderer `RenderContext` so the
|
|
133
|
+
* progress-bar renderer can read a first-party cart value instead of
|
|
134
|
+
* `window.*` cart globals. Undefined for embeds that never feed a cart.
|
|
135
|
+
*/
|
|
136
|
+
getCartState?: () => CartState | undefined;
|
|
127
137
|
}
|
|
128
138
|
export declare class AegisInAppManager {
|
|
129
139
|
private writeKey;
|
|
@@ -136,6 +146,7 @@ export declare class AegisInAppManager {
|
|
|
136
146
|
private enableSSE;
|
|
137
147
|
private onInteractiveCampaign?;
|
|
138
148
|
private getWorkspaceId?;
|
|
149
|
+
private getCartState?;
|
|
139
150
|
private campaigns;
|
|
140
151
|
private displayedCampaigns;
|
|
141
152
|
private suppressedUntil;
|
|
@@ -187,6 +198,58 @@ export declare class AegisInAppManager {
|
|
|
187
198
|
initialize(): Promise<void>;
|
|
188
199
|
updateUserId(userId: string): void;
|
|
189
200
|
updateContactId(contactId: string): void;
|
|
201
|
+
private refreshDebounceTimer?;
|
|
202
|
+
private static readonly REFRESH_DEBOUNCE_MS;
|
|
203
|
+
private currentSurface;
|
|
204
|
+
private currentScreen;
|
|
205
|
+
private currentLocationId;
|
|
206
|
+
private static readonly KNOWN_SURFACES;
|
|
207
|
+
/**
|
|
208
|
+
* Qualifying-event refresh — schedule a debounced `refreshCampaigns()`
|
|
209
|
+
* call in response to a host-app SDK event (`aegis.page()`,
|
|
210
|
+
* `aegis.screen()`, `aegis.track(name)`). Matches CleverTap / MoEngage /
|
|
211
|
+
* WebEngage's "refresh on qualifying event" shape, translated to the
|
|
212
|
+
* browser session.
|
|
213
|
+
*
|
|
214
|
+
* Why: new server-side eligibility opens on these events (a `page` view
|
|
215
|
+
* arms route-targeted campaigns; a `track('product_viewed')` arms
|
|
216
|
+
* trigger-gated campaigns whose `client_trigger.config.event` matches).
|
|
217
|
+
* Pre-P1, the SDK only refreshed on `initialize()` + `updateContactId()`
|
|
218
|
+
* + the SSE update channel (which storefront has disabled by design),
|
|
219
|
+
* so newly armed campaigns were invisible until the next identity flip.
|
|
220
|
+
*
|
|
221
|
+
* Debounce: 300ms. Five `page()` calls inside the window coalesce to
|
|
222
|
+
* one fetch; a sixth call ≥300ms after the prior burst starts a new
|
|
223
|
+
* fetch. The trailing-edge schedule (re-arm on every call) is correct
|
|
224
|
+
* for storefront rage-clicks + SPA route bursts — we want the LATEST
|
|
225
|
+
* URL's eligibility, not the first.
|
|
226
|
+
*
|
|
227
|
+
* Safe to call on the server (no-op when `setTimeout` is unavailable
|
|
228
|
+
* — though that's vanishingly rare in any modern environment we ship to).
|
|
229
|
+
*
|
|
230
|
+
* Surface capture (In-App Surface Filter tracker P2): when `eventName`
|
|
231
|
+
* matches one of the 8 canonical surface keys, it is captured into
|
|
232
|
+
* `currentSurface` and threaded to `/v1/in-app/active?current_surface=<name>`
|
|
233
|
+
* on the next refresh — wiring the existing `aegis.page(name)` /
|
|
234
|
+
* `aegis.screen(name)` argument through to campaign targeting. Unknown names
|
|
235
|
+
* (e.g. `aegis.track('product_viewed')`) still trigger a refresh but do NOT
|
|
236
|
+
* change `currentSurface`, so arbitrary events never poison the surface gate.
|
|
237
|
+
*/
|
|
238
|
+
refreshOnEvent(eventName: string, isScreenDeclaration?: boolean): void;
|
|
239
|
+
/**
|
|
240
|
+
* Outlet context — declare the outlet the customer is actively viewing
|
|
241
|
+
* (storefront outlet switcher / location-code). The host calls this when the
|
|
242
|
+
* shopper picks an outlet (or on initial outlet-scoped page load) and again
|
|
243
|
+
* with the new id when they switch. Threaded to
|
|
244
|
+
* `/v1/in-app/active?location_id=<id>` so the server serves outlet-scoped
|
|
245
|
+
* campaigns for THIS outlet (preferred over the property's static outlet) —
|
|
246
|
+
* the fix that makes a SHARED multi-outlet storefront's switcher actually
|
|
247
|
+
* drive in-app targeting. Pass `null` to clear (back to property/brand-wide).
|
|
248
|
+
*
|
|
249
|
+
* No-ops when the value is unchanged; otherwise debounce-refreshes so the
|
|
250
|
+
* armed campaign set follows the switcher within ~300ms.
|
|
251
|
+
*/
|
|
252
|
+
setLocation(locationId: string | null): void;
|
|
190
253
|
/**
|
|
191
254
|
* Conversion-aware suppression. Call this when the host app observes a
|
|
192
255
|
* goal event (purchase, order_placed, checkout_completed, or any custom
|
|
@@ -239,6 +302,8 @@ export declare class AegisInAppManager {
|
|
|
239
302
|
private disconnectSSE;
|
|
240
303
|
private attemptReconnect;
|
|
241
304
|
private refreshCampaigns;
|
|
305
|
+
private static readonly SERVED_DEDUP_PREFIX;
|
|
306
|
+
private emitServedEvents;
|
|
242
307
|
private detectDeviceType;
|
|
243
308
|
private isNewUser;
|
|
244
309
|
private getABAssignments;
|
|
@@ -257,7 +322,50 @@ export declare class AegisInAppManager {
|
|
|
257
322
|
* `<div data-aegis-slot="feedback">` will accept the first active
|
|
258
323
|
* campaign with `widget_category='feedback'` + embedded_card mode.
|
|
259
324
|
*/
|
|
325
|
+
/**
|
|
326
|
+
* Surface predicate (In-App Surface Filter tracker P2). Byte-for-byte the
|
|
327
|
+
* same logic as the server-side `_surface_matches` in
|
|
328
|
+
* apps/cell-plane/app/api/v1/in_app/campaigns.py:
|
|
329
|
+
* - campaign with no `surface` (undefined / []) renders on every surface
|
|
330
|
+
* - no declared `currentSurface` => no filter (back-compat)
|
|
331
|
+
* - otherwise the current surface must be in the campaign's surface array
|
|
332
|
+
*/
|
|
333
|
+
private matchesCurrentSurface;
|
|
334
|
+
/**
|
|
335
|
+
* Dynamic Screens P2 — combined surface + free-form screen predicate.
|
|
336
|
+
* Byte-for-byte the server's `_screen_or_surface_matches`: when the campaign
|
|
337
|
+
* has no `target_screens` this is exactly `matchesCurrentSurface` (every
|
|
338
|
+
* existing campaign → zero behaviour change). A screen-only campaign matches
|
|
339
|
+
* strictly on `currentScreen`; a dual campaign ORs the two tiers.
|
|
340
|
+
*/
|
|
341
|
+
private matchesCurrentScreenOrSurface;
|
|
260
342
|
private renderIntoSlots;
|
|
343
|
+
/**
|
|
344
|
+
* Rotating slot — cycles eligible campaigns one at a time inside a single host
|
|
345
|
+
* slot (the storefront sticky-footer "value bar"). Each campaign is pre-rendered
|
|
346
|
+
* into its own hidden pane so a live `progress_bar` keeps tracking the cart even
|
|
347
|
+
* while off-screen; only the visibility toggles every `rotateMs`. The impression
|
|
348
|
+
* is deferred at render and fired per campaign on FIRST visibility, so hidden
|
|
349
|
+
* panes never over-count. One rendered pane → no rotation (just shows it).
|
|
350
|
+
*/
|
|
351
|
+
private renderRotatingSlot;
|
|
352
|
+
/**
|
|
353
|
+
* Surface-Canvas inline element anchoring (Plotline / WebEngage model).
|
|
354
|
+
*
|
|
355
|
+
* Render inline-format campaigns into a HOST element the operator picked via
|
|
356
|
+
* the element inspector — `interactive_config.anchor.element_selector` — instead
|
|
357
|
+
* of a host-declared `[data-aegis-slot]`. `position` controls placement:
|
|
358
|
+
* inside (default) — append into the element (e.g. the storefront footer card)
|
|
359
|
+
* replace — clear the element's host-default children, then render in
|
|
360
|
+
* before / after — render into a wrapper inserted as a sibling
|
|
361
|
+
*
|
|
362
|
+
* Reuses `renderCampaignIntoSlot` (same sub_type dispatch → `renderProgressBarInline`
|
|
363
|
+
* etc.) so inline render code is single-sourced with the slot path. Embedded-card
|
|
364
|
+
* gated (so an anchored campaign never ALSO renders as an overlay), surface-gated,
|
|
365
|
+
* and idempotent via `filledSlots` keyed on the resolved element. A selector that
|
|
366
|
+
* doesn't resolve emits `anchor_unresolved` (parity with tooltip anchoring).
|
|
367
|
+
*/
|
|
368
|
+
private renderIntoAnchors;
|
|
261
369
|
/**
|
|
262
370
|
* U7 — render server-injected token-bound campaigns.
|
|
263
371
|
*
|
|
@@ -301,6 +409,68 @@ export declare class AegisInAppManager {
|
|
|
301
409
|
*/
|
|
302
410
|
private renderStarRatingSlot;
|
|
303
411
|
private renderNPSSurveySlot;
|
|
412
|
+
/** §7.13.H — generic embedded card: image / title / body / coupon chip / CTA.
|
|
413
|
+
* The catch-all for banner + nudge sub_types (birthday, referral, app-install,
|
|
414
|
+
* win-back, etc.) so EVERY gallery nudge renders on the bill (previously only
|
|
415
|
+
* star_rating / nps_survey / form were handled → nudges never appeared). */
|
|
416
|
+
private renderGenericCardSlot;
|
|
417
|
+
/**
|
|
418
|
+
* §7.13.I — embedded profile FORM. Renders one input per `form_fields` entry
|
|
419
|
+
* and, on submit, POSTs `{response_type:'form', payload:{fields:{key:value}}}`
|
|
420
|
+
* to `/in-app/responses` — the cell-plane enrichment writes the mapped answers
|
|
421
|
+
* back onto the contact. Keyed by each field's `key` so it matches the
|
|
422
|
+
* campaign's field→contact map.
|
|
423
|
+
*/
|
|
424
|
+
private renderFormSlot;
|
|
425
|
+
/** Shared form body — the input fields + submit. Used embedded (slot) today;
|
|
426
|
+
* the overlay form path reuses it too. */
|
|
427
|
+
private _buildFormBody;
|
|
428
|
+
/** POST a form response to /in-app/responses (gateway → cell-plane). The
|
|
429
|
+
* cell-plane enriches the contact from the campaign's field-map. Best-effort. */
|
|
430
|
+
private submitFormResponse;
|
|
431
|
+
/**
|
|
432
|
+
* Generic interactive response submit → POST /v1/in-app/responses. Returns the
|
|
433
|
+
* parsed server response (which for spin/scratch carries the server-picked
|
|
434
|
+
* `prize`) or null. Interactive Widgets Parity tracker — every embedded widget
|
|
435
|
+
* records a response so analytics + prize-from-segments work uniformly.
|
|
436
|
+
*/
|
|
437
|
+
private submitWidgetResponse;
|
|
438
|
+
/**
|
|
439
|
+
* Built-in embedded SPIN WHEEL (no AegisMessageRuntime callback dependency —
|
|
440
|
+
* works on the bill). Slices come from `interactive_config.segments`; on Spin
|
|
441
|
+
* it submits to /in-app/responses, the server picks the prize from the AUTHORED
|
|
442
|
+
* segments, and the wheel animates to that segment + reveals the prize/coupon.
|
|
443
|
+
*/
|
|
444
|
+
private renderSpinWheelSlot;
|
|
445
|
+
/** Built-in embedded QUICK POLL — option buttons submit the chosen index. */
|
|
446
|
+
private renderQuickPollSlot;
|
|
447
|
+
/** Pull a poll vote distribution out of the server response, if present.
|
|
448
|
+
* Accepts `results`/`distribution`/`tallies` as a number[] aligned to the
|
|
449
|
+
* option order. Returns null when the server didn't surface tallies (then
|
|
450
|
+
* we only confirm the chosen option — never fabricate percentages). */
|
|
451
|
+
private _readPollDistribution;
|
|
452
|
+
/** Animate result bars on the poll options. With a real `dist` it renders
|
|
453
|
+
* each option's share; without one it just fills the selected option 100%
|
|
454
|
+
* as a "vote locked in" confirmation. */
|
|
455
|
+
private _paintPollResult;
|
|
456
|
+
/**
|
|
457
|
+
* Built-in embedded IMAGE/VIDEO CAROUSEL — a swipeable horizontal strip of
|
|
458
|
+
* `interactive_config.cards` (image OR video + title + body + CTA), contained
|
|
459
|
+
* to the slot (the parent overflow:hidden + this strip's own scroll). Each card
|
|
460
|
+
* reuses the same shape as the In-App carousel editor authors.
|
|
461
|
+
*/
|
|
462
|
+
private renderCarouselCardsSlot;
|
|
463
|
+
/** Built-in embedded COUNTDOWN — live H:M:S digits that pulse red in the
|
|
464
|
+
* final stretch (<60s) to create urgency, plus the CTA. */
|
|
465
|
+
private renderCountdownSlot;
|
|
466
|
+
/** Built-in embedded SCRATCH CARD — a canvas foil the customer scratches to
|
|
467
|
+
* reveal the server-picked prize, then submits (records + grants). Confetti
|
|
468
|
+
* on reveal. No AegisMessageRuntime callback dependency (works on the bill). */
|
|
469
|
+
private renderScratchCardSlot;
|
|
470
|
+
/** Extract a human prize label from a spin/scratch server response. */
|
|
471
|
+
private _extractPrizeLabel;
|
|
472
|
+
/** Extract a redeemable coupon code from a spin/scratch server response. */
|
|
473
|
+
private _extractCouponCode;
|
|
304
474
|
/**
|
|
305
475
|
* Token-bound submission helper. POSTs the structured response to
|
|
306
476
|
* the per-token submit URL the page handler embedded. Best-effort
|
|
@@ -308,9 +478,43 @@ export declare class AegisInAppManager {
|
|
|
308
478
|
* clicked; we can't undo their interaction).
|
|
309
479
|
*/
|
|
310
480
|
private _submitTokenResponse;
|
|
481
|
+
/**
|
|
482
|
+
* Slot styling — the operator's look-&-feel knobs (Style panel) applied to the
|
|
483
|
+
* EMBEDDED render, CLAMPED to boundary-safe ranges so an authored value can
|
|
484
|
+
* never break out of the dynamic block. Unauthored knobs are `undefined` so
|
|
485
|
+
* each renderer keeps its own compact default (no visual regression). Colors
|
|
486
|
+
* default to the current slot defaults. The slot card keeps `width:100%;
|
|
487
|
+
* overflow:hidden` regardless, so the boundary guarantee is independent of
|
|
488
|
+
* these values.
|
|
489
|
+
*/
|
|
490
|
+
private _slotStyle;
|
|
311
491
|
private _wrapInSlotCard;
|
|
492
|
+
private _appendHeaderImage;
|
|
312
493
|
private _buildStarRatingBody;
|
|
494
|
+
/**
|
|
495
|
+
* Post-rating flow — the Reelo/Plotline "smart rating" gate. A happy rater
|
|
496
|
+
* (>= threshold) is invited to leave a PUBLIC review; an unhappy one is given
|
|
497
|
+
* a PRIVATE "what went wrong?" comment box so the complaint is captured for
|
|
498
|
+
* the operator instead of landing on a public platform. Exactly ONE response
|
|
499
|
+
* row is written per rating (deferred on the low path until Send/Skip) so the
|
|
500
|
+
* star distribution isn't double-counted.
|
|
501
|
+
*/
|
|
502
|
+
private _onStarRatingPicked;
|
|
503
|
+
/** Thank-you takeover; happy raters also get a public-review CTA when authored. */
|
|
504
|
+
private _renderRatingThankYou;
|
|
505
|
+
/** Unhappy-path private comment capture; submits {stars, comment} once. */
|
|
506
|
+
private _renderRatingLowFollowup;
|
|
313
507
|
private _buildNPSSurveyBody;
|
|
508
|
+
/**
|
|
509
|
+
* NPS reason-capture step (overlay). Wires the per-band `nps_follow_up_*`
|
|
510
|
+
* prompt (promoter / passive / detractor) as the heading and captures an
|
|
511
|
+
* open-text reason (+ optional quick-pick chips). Submits {score, comment}
|
|
512
|
+
* exactly ONCE (deferred from the pick), then shows the thank-you (promoters
|
|
513
|
+
* get an optional review/referral CTA).
|
|
514
|
+
*/
|
|
515
|
+
private _renderNpsReasonFollowup;
|
|
516
|
+
/** NPS thank-you takeover; promoters get an optional review/referral CTA. */
|
|
517
|
+
private _renderNpsThankYou;
|
|
314
518
|
/**
|
|
315
519
|
* Evaluate the currently armed campaigns against a client-side event
|
|
316
520
|
* and render any that match their `client_trigger`.
|
|
@@ -330,6 +534,16 @@ export declare class AegisInAppManager {
|
|
|
330
534
|
onClientEvent(eventName: string, eventData?: Record<string, unknown>): void;
|
|
331
535
|
private matchesClientTrigger;
|
|
332
536
|
private displayCampaign;
|
|
537
|
+
/** The single chat launcher on the page (Active Web Chat). Persistent — not
|
|
538
|
+
* re-mounted on SSE/poll refresh; torn down on manager teardown. */
|
|
539
|
+
private activeWebChat?;
|
|
540
|
+
/**
|
|
541
|
+
* Mount the Active Web Chat launcher. Idempotent: a repeat delivery of the
|
|
542
|
+
* same (or another) chat campaign is a no-op once one launcher is live — at
|
|
543
|
+
* most one bubble per page, and an open session is never yanked out from
|
|
544
|
+
* under the customer.
|
|
545
|
+
*/
|
|
546
|
+
private renderActiveWebChatLauncher;
|
|
333
547
|
/**
|
|
334
548
|
* Build the shared context passed into the preload-first renderers.
|
|
335
549
|
* Matches the interface in `./renderers/types.ts`. Kept as a private
|
|
@@ -343,11 +557,64 @@ export declare class AegisInAppManager {
|
|
|
343
557
|
* interactive_config payload for type-specific behavior.
|
|
344
558
|
*/
|
|
345
559
|
private renderInteractive;
|
|
560
|
+
/**
|
|
561
|
+
* Built-in overlay for spin_wheel / scratch_card when no host runtime is
|
|
562
|
+
* wired (dashboard preview, runtime-less hosts). Wraps the same interactive
|
|
563
|
+
* slot renderers (`renderSpinWheelSlot` / `renderScratchCardSlot`) in a modal
|
|
564
|
+
* so the gamified widget is fully playable — not a dead frame.
|
|
565
|
+
*/
|
|
566
|
+
private renderGamificationOverlay;
|
|
567
|
+
/** A circular ✕ close button in the modal's top-right corner. */
|
|
568
|
+
private _addCornerClose;
|
|
569
|
+
/**
|
|
570
|
+
* Custom HTML type — render operator-authored HTML in a SANDBOXED iframe.
|
|
571
|
+
* The frame runs with `sandbox="allow-scripts"` and NO `allow-same-origin`, so
|
|
572
|
+
* it's an opaque/null origin: no access to the host DOM, cookies, localStorage,
|
|
573
|
+
* the SDK write-key, or same-origin creds. The only channel out is a validated
|
|
574
|
+
* `postMessage` bridge (close / track / cta / resize), exposed to authors as a
|
|
575
|
+
* tiny injected `aegis` shim. See IN_APP_CUSTOM_HTML_TRACKER.md (security model).
|
|
576
|
+
*/
|
|
577
|
+
private renderCustomHtml;
|
|
578
|
+
/** Build the sandboxed iframe + the validated message bridge. Reused by the
|
|
579
|
+
* overlay + embedded-slot custom-HTML renderers. */
|
|
580
|
+
private _buildCustomHtmlFrame;
|
|
581
|
+
/** Embedded-slot custom HTML (e.g. on the bill) — the same sandboxed frame in
|
|
582
|
+
* a slot card instead of an overlay. */
|
|
583
|
+
private renderCustomHtmlSlot;
|
|
346
584
|
private renderNPSSurvey;
|
|
347
585
|
private renderCountdownOffer;
|
|
348
586
|
private renderStarRating;
|
|
349
587
|
private renderQuickPoll;
|
|
588
|
+
/**
|
|
589
|
+
* Multi-step form (SDK Demo v4 W1b) — in-app render type matching the
|
|
590
|
+
* Plotline multi-step flow pattern: a progress bar + per-step question with
|
|
591
|
+
* options, Back/Next navigation, Submit on the last step. `ic.steps` is an
|
|
592
|
+
* array of `{ question, options[] }`. DOM-safe (no innerHTML).
|
|
593
|
+
*/
|
|
594
|
+
private renderMultiStepForm;
|
|
595
|
+
/**
|
|
596
|
+
* Push primer (SDK Demo v4 W3) — in-app render type that "soft-asks" before
|
|
597
|
+
* the OS hard-ask. The Enable CTA calls `Notification.requestPermission()`;
|
|
598
|
+
* we report `permission_granted` / `permission_denied` / `permission_default`
|
|
599
|
+
* so journeys can react. Degrades gracefully where Notification is absent.
|
|
600
|
+
*/
|
|
601
|
+
private renderPushPrimer;
|
|
350
602
|
private renderQuiz;
|
|
603
|
+
/**
|
|
604
|
+
* Embedded quiz on a bill/page slot — same question-stepping flow as the
|
|
605
|
+
* overlay, rendered inline with no overlay/close (Open/Closed: both paths
|
|
606
|
+
* share `_runQuizFlow`, so a feature added once lights up both). Returns
|
|
607
|
+
* false when there are no questions so dispatch can fall back to a card.
|
|
608
|
+
*/
|
|
609
|
+
private renderQuizSlot;
|
|
610
|
+
/**
|
|
611
|
+
* Shared quiz engine — drives the question stepper, scoring (knowledge =
|
|
612
|
+
* correct_index/points, personality = outcome tally), result-band selection,
|
|
613
|
+
* CTA, reaction and the `quiz` response submit. Renders into the provided
|
|
614
|
+
* `body`. `overlay` is the dismiss target for the close button on the overlay
|
|
615
|
+
* path; pass null on the slot path (no close affordance inline).
|
|
616
|
+
*/
|
|
617
|
+
private _runQuizFlow;
|
|
351
618
|
private createOverlay;
|
|
352
619
|
private createCTAButton;
|
|
353
620
|
private addCloseButton;
|
|
@@ -370,15 +637,96 @@ export declare class AegisInAppManager {
|
|
|
370
637
|
* (in-place state change) without per-host configuration.
|
|
371
638
|
*/
|
|
372
639
|
private navigateToCampaignAction;
|
|
640
|
+
/**
|
|
641
|
+
* Phase-2 CTA action verbs (`aegis://<verb>?<params>`). Performs an in-app
|
|
642
|
+
* behaviour instead of navigating. Verbs:
|
|
643
|
+
* dismiss — close the message (tracked as dismissed)
|
|
644
|
+
* request-push — prompt for web-push permission, then close
|
|
645
|
+
* cart-add?sku=X — dispatch `aegis:cart-add` for the storefront to handle;
|
|
646
|
+
* if unhandled, fall back to the product page
|
|
647
|
+
*/
|
|
648
|
+
private runCampaignActionVerb;
|
|
649
|
+
/** Remove a rendered campaign's element(s) from the DOM by campaign id. */
|
|
650
|
+
private removeCampaignEl;
|
|
651
|
+
/**
|
|
652
|
+
* Resolve the operator's colour + style choices into concrete CSS values.
|
|
653
|
+
* Mirrors the studio preview's styleFrom() 1:1 (apps/web/src/app/api/preview/
|
|
654
|
+
* in-app/route.tsx) — same keys, same defaults — so what the operator designs
|
|
655
|
+
* in the editor is what the live SDK renders. The container uses the
|
|
656
|
+
* campaign's background_color/text_color and the CTA button is the inverse
|
|
657
|
+
* (so it pops on the coloured surface), exactly like the preview. Earlier the
|
|
658
|
+
* card renderers hardcoded a white card + dark text and ignored the Style
|
|
659
|
+
* panel entirely, so the live message looked nothing like the preview.
|
|
660
|
+
*/
|
|
661
|
+
/** Pick a legible label colour (#fff or near-black) for a solid fill, by
|
|
662
|
+
* relative luminance — so a brand-accent button is always readable. */
|
|
663
|
+
private _contrastText;
|
|
664
|
+
/** Central surface palette — the ONE place the brand colour becomes either a
|
|
665
|
+
* surface fill or an accent, so every widget is consistent.
|
|
666
|
+
*
|
|
667
|
+
* `surface_style` (interactive_config), default `clean`:
|
|
668
|
+
* - `clean` → NEUTRAL surface (white) + dark text + the brand colour as the
|
|
669
|
+
* CTA ACCENT. The 60-30-10 / WCAG-safe default: legible copy and
|
|
670
|
+
* a CTA that actually pops (higher CTR than a flat colour card).
|
|
671
|
+
* - `branded`→ brand-colour SURFACE + contrasting text + inverse CTA. For
|
|
672
|
+
* high-impact, low-text moments (flash sale, celebration).
|
|
673
|
+
* `background_color` is the operator's brand colour in BOTH modes — surface
|
|
674
|
+
* fill when branded, CTA accent when clean. */
|
|
675
|
+
private _surfacePalette;
|
|
676
|
+
private inAppStyle;
|
|
373
677
|
private renderBanner;
|
|
374
678
|
private renderModal;
|
|
679
|
+
private _heroVideo;
|
|
375
680
|
private renderFullScreen;
|
|
376
681
|
private renderHalfInterstitial;
|
|
377
682
|
private renderAlert;
|
|
683
|
+
private _pipCornerCss;
|
|
378
684
|
private renderPIP;
|
|
379
685
|
private removeBanner;
|
|
380
686
|
private removeModal;
|
|
687
|
+
/**
|
|
688
|
+
* Spotlight backdrop colour → a dim of the chosen base at `dim` opacity.
|
|
689
|
+
* `dark` (slate, default) · `brand` (the campaign brand colour) · `black` ·
|
|
690
|
+
* `custom` (a picked hex). Encoded as 8-digit hex alpha; falls back to slate
|
|
691
|
+
* rgba when the base isn't a 6-digit hex (e.g. an rgb() brand colour).
|
|
692
|
+
*/
|
|
693
|
+
private _spotlightDimColor;
|
|
381
694
|
private renderTooltip;
|
|
695
|
+
/** Fire a short confetti burst from the top of an anchor element. Vanilla
|
|
696
|
+
* (no deps) — mirrors the cashier-portal confetti. Respects
|
|
697
|
+
* prefers-reduced-motion. Used on positive moments (high rating, won prize,
|
|
698
|
+
* form complete). */
|
|
699
|
+
private _fireConfetti;
|
|
700
|
+
/**
|
|
701
|
+
* Emotional reaction layer (CEP parity — CleverTap exposes configurable
|
|
702
|
+
* outcome animation; MoEngage sets distinct win/lose icons). Three CONTEXT-
|
|
703
|
+
* AWARE intents drive a premium Lottie animation (with an instant SVG
|
|
704
|
+
* placeholder + graceful fallback):
|
|
705
|
+
*
|
|
706
|
+
* - `celebrate` → a real WIN in a game (spin/scratch prize). Trophy Lottie,
|
|
707
|
+
* gold rings, confetti. The big, earned moment.
|
|
708
|
+
* - `affirm` → positive FEEDBACK (high rating, NPS promoter, quiz/form
|
|
709
|
+
* done). An animated success check — friendly, NOT a trophy
|
|
710
|
+
* (a survey isn't a contest).
|
|
711
|
+
* - `empathize` → a negative outcome (low rating, NPS detractor, no-prize /
|
|
712
|
+
* "Try again"). A soft breathing heart — supportive, NO
|
|
713
|
+
* confetti, NO rings.
|
|
714
|
+
*
|
|
715
|
+
* Honors prefers-reduced-motion (static badge, no motion).
|
|
716
|
+
*/
|
|
717
|
+
private _playReaction;
|
|
718
|
+
/** Hand-built, brand-neutral animated SVG badges for the reaction layer — a
|
|
719
|
+
* premium alternative to system emoji (consistent across browsers, no Lottie
|
|
720
|
+
* dependency). The check strokes itself in; the heart breathes gently. */
|
|
721
|
+
private _reactionSvg;
|
|
722
|
+
/** Resolve the base URL the SDK assets are served from (so Lottie JSON +
|
|
723
|
+
* player load from the same origin/path as the SDK bundle — works in the
|
|
724
|
+
* dashboard preview and same-origin installs; cross-origin CDN installs fall
|
|
725
|
+
* back to the inline SVG when the asset 404s). */
|
|
726
|
+
private _assetBase;
|
|
727
|
+
/** Lazy-load the Lottie player once (cached on window). Resolves to the
|
|
728
|
+
* global `lottie`, or rejects if it can't be fetched (→ SVG fallback). */
|
|
729
|
+
private _loadLottie;
|
|
382
730
|
private addAnimationStyles;
|
|
383
731
|
private sanitizeUrl;
|
|
384
732
|
private sanitizeColor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AegisInAppManager.d.ts","sourceRoot":"","sources":["../../src/inapp/AegisInAppManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"AegisInAppManager.d.ts","sourceRoot":"","sources":["../../src/inapp/AegisInAppManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,aAAa,CAAC;AAiC5D,MAAM,WAAW,aAAa;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xB;;;;;;;;;OASG;IACH;4EACwE;IACxE,OAAO,CAAC,aAAa;IAQrB;;;;;;;;;;oDAUgD;IAChD,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,UAAU;IA4BlB,OAAO,CAAC,YAAY;IAsIpB,OAAO,CAAC,WAAW;IAmKnB,OAAO,CAAC,UAAU;IAqClB,OAAO,CAAC,gBAAgB;IA2IxB,OAAO,CAAC,sBAAsB;IA0K9B,OAAO,CAAC,WAAW;IAgInB,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,SAAS;IA0QjB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,WAAW;IASnB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,aAAa;IA6PrB;;;0BAGsB;IACtB,OAAO,CAAC,aAAa;IAmCrB;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,aAAa;IA4GrB;;+EAE2E;IAC3E,OAAO,CAAC,YAAY;IAyCpB;;;uDAGmD;IACnD,OAAO,CAAC,UAAU;IAWlB;+EAC2E;IAC3E,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,kBAAkB;IAiI1B,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,aAAa;IAqBrB;;;;;;;;;;;OAWG;YACW,UAAU;IA6GxB,OAAO,CAAC,GAAG;IAMX,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CA2CpD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aegis device pairing — WEB client (Surface Canvas P6).
|
|
3
|
+
*
|
|
4
|
+
* Pairs a web property to the dashboard canvas so an operator can anchor in-app
|
|
5
|
+
* overlays to REAL page elements. Flow:
|
|
6
|
+
* 1. operator opens a session in the dashboard → short pairing code
|
|
7
|
+
* 2. `pairWebDevice(apiHost, code)` claims it, then captures the current
|
|
8
|
+
* screen: the page's addressable element tree (stable CSS selectors +
|
|
9
|
+
* bounds + roles) + viewport, and POSTs it to the backend.
|
|
10
|
+
* 3. re-captures on navigation (SPA route changes) so the canvas tracks the
|
|
11
|
+
* live page.
|
|
12
|
+
*
|
|
13
|
+
* This is the web sibling of the native (Flutter/Android/iOS/RN) pairing clients
|
|
14
|
+
* — they stream the native view hierarchy; this walks the DOM. Same backend
|
|
15
|
+
* contract (`/v1/device-pairing/...`).
|
|
16
|
+
*/
|
|
17
|
+
export interface PairingElementNode {
|
|
18
|
+
/** A stable CSS selector the SDK can re-resolve at runtime (id > data-* > path). */
|
|
19
|
+
selector: string;
|
|
20
|
+
role: string;
|
|
21
|
+
text?: string;
|
|
22
|
+
bounds: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
w: number;
|
|
26
|
+
h: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface CapturedWebScreen {
|
|
30
|
+
screen_name: string;
|
|
31
|
+
view_tree: PairingElementNode[];
|
|
32
|
+
viewport: {
|
|
33
|
+
w: number;
|
|
34
|
+
h: number;
|
|
35
|
+
scale: number;
|
|
36
|
+
};
|
|
37
|
+
platform: 'web';
|
|
38
|
+
}
|
|
39
|
+
export interface PairWebOptions {
|
|
40
|
+
/** Override the screen name (defaults to location.pathname). */
|
|
41
|
+
screenName?: string;
|
|
42
|
+
deviceLabel?: string;
|
|
43
|
+
/** Keep re-capturing on SPA navigation + a slow heartbeat. Default true. */
|
|
44
|
+
live?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** Walk the DOM for addressable anchor candidates (interactive + labelled
|
|
47
|
+
* elements that are visible), with bounds + a re-resolvable selector. */
|
|
48
|
+
export declare function captureWebScreen(screenName?: string): CapturedWebScreen;
|
|
49
|
+
/** Claim a pairing code + stream this web page as a captured screen. Returns a
|
|
50
|
+
* stop() to end live re-capture. */
|
|
51
|
+
export declare function pairWebDevice(apiHost: string, code: string, opts?: PairWebOptions): Promise<{
|
|
52
|
+
ok: boolean;
|
|
53
|
+
stop: () => void;
|
|
54
|
+
error?: string;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Read `?aegis_pair=CODE` from the URL and enter pairing — ONCE per page load.
|
|
58
|
+
*
|
|
59
|
+
* Shared entry point so pairing fires the SAME way for BOTH distribution styles:
|
|
60
|
+
* - npm package consumers — the PREFERRED path: the Active Commerce Store AND
|
|
61
|
+
* external websites that `npm i @active-reach/web-sdk` + `new AegisMessageRuntime(...)`
|
|
62
|
+
* → called from `AegisMessageRuntime.initialize()`.
|
|
63
|
+
* - CDN bundle (`aegis.min.js`) — only for platforms that can't consume npm
|
|
64
|
+
* (Shopify / Magento / WooCommerce) → called from `cdn.ts` on bundle boot.
|
|
65
|
+
* The module-level guard dedupes when both paths exist in one bundle. This is
|
|
66
|
+
* what makes the storefront a true testbed: it pairs exactly like any external
|
|
67
|
+
* npm-SDK site — no per-integration divergence.
|
|
68
|
+
*/
|
|
69
|
+
export declare function maybeStartPairing(apiHost?: string): void;
|
|
70
|
+
//# sourceMappingURL=devicePairing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devicePairing.d.ts","sourceRoot":"","sources":["../../src/inapp/devicePairing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,kBAAkB;IACjC,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxD;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,QAAQ,EAAE,KAAK,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA+BD;0EAC0E;AAC1E,wBAAgB,gBAAgB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAkCvE;AAED;qCACqC;AACrC,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA2C5D;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAUxD"}
|
package/dist/inapp/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { AegisInAppManager } from './AegisInAppManager';
|
|
2
2
|
export type { InAppCampaign, AegisInAppConfig, CampaignClickEvent, CampaignDismissEvent, AegisErrorEvent, InAppLifecycleEventMap, } from './AegisInAppManager';
|
|
3
|
+
export type { CartState } from './renderers';
|
|
3
4
|
export { renderPreview } from './renderPreview';
|
|
5
|
+
export { pairWebDevice, captureWebScreen, maybeStartPairing, type PairingElementNode, type CapturedWebScreen, type PairWebOptions, } from './devicePairing';
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/inapp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/inapp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderPreview.d.ts","sourceRoot":"","sources":["../../src/inapp/renderPreview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderPreview.d.ts","sourceRoot":"","sources":["../../src/inapp/renderPreview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG;IAAE,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,IAAI,CAgF5G"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Active Web Chat renderer — the "Shopping Assistant" chat launcher delivered
|
|
3
|
+
* as a first-class in-app campaign widget (type `active_web_chat`).
|
|
4
|
+
*
|
|
5
|
+
* Unlike the preload-first renderers in this directory (pure DOM mutation, no
|
|
6
|
+
* I/O), Active Web Chat is a *persistent launcher* backed by a stateful chat
|
|
7
|
+
* engine. It does NOT reimplement chat transport — it instantiates the existing
|
|
8
|
+
* `AegisChat` engine (chat/AegisChat.ts) and feeds it config from the campaign's
|
|
9
|
+
* `interactive_config`. The chat SSE stays OFF until the customer opens the
|
|
10
|
+
* panel and is torn down on close — that lifecycle lives entirely in AegisChat
|
|
11
|
+
* (connectSSE/disconnectSSE are panel-gated); this renderer only wires the
|
|
12
|
+
* campaign config + analytics bridge.
|
|
13
|
+
*
|
|
14
|
+
* Singleton per page: there is at most one chat launcher on screen. A repeat
|
|
15
|
+
* delivery (SSE/poll refresh re-arming the same campaign) is a no-op.
|
|
16
|
+
*
|
|
17
|
+
* See docs/architecture/CHAT_WIDGET_AS_INAPP_CAMPAIGN_TRACKER.md.
|
|
18
|
+
*/
|
|
19
|
+
import { AegisChat } from '../../chat/AegisChat';
|
|
20
|
+
import type { RenderContext } from './types';
|
|
21
|
+
/** SDK credentials the chat engine needs that the campaign payload doesn't
|
|
22
|
+
* carry. Supplied by `AegisInAppManager` (which owns them). */
|
|
23
|
+
export interface ActiveWebChatCredentials {
|
|
24
|
+
writeKey: string;
|
|
25
|
+
apiHost: string;
|
|
26
|
+
contactId?: string;
|
|
27
|
+
channel?: 'web' | 'in_app';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Mount the Active Web Chat launcher for `ctx.campaign`. Returns the engine
|
|
31
|
+
* instance (or the existing one if already mounted), or null in non-DOM
|
|
32
|
+
* environments. The bubble is mounted immediately; the chat session (and its
|
|
33
|
+
* SSE) is established only when the customer opens the panel.
|
|
34
|
+
*/
|
|
35
|
+
export declare function renderActiveWebChat(ctx: RenderContext, creds: ActiveWebChatCredentials): AegisChat | null;
|
|
36
|
+
/** Tear down the launcher (manager teardown / page unload). */
|
|
37
|
+
export declare function disposeActiveWebChat(): void;
|
|
38
|
+
//# sourceMappingURL=active-web-chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"active-web-chat.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/active-web-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,SAAS,EAAwB,MAAM,sBAAsB,CAAC;AAGvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAM7C;gEACgE;AAChE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC5B;AAWD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,wBAAwB,GAC9B,SAAS,GAAG,IAAI,CAiElB;AAED,+DAA+D;AAC/D,wBAAgB,oBAAoB,IAAI,IAAI,CAK3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel-cards.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/carousel-cards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"carousel-cards.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/carousel-cards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAa7C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAoQ5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coachmark-tour.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/coachmark-tour.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA6C7C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"coachmark-tour.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/coachmark-tour.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA6C7C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAyR5D"}
|