@active-reach/web-sdk 1.44.0 → 1.45.1
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 +39 -0
- package/dist/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/{analytics-C-Go3Pm5.mjs → analytics-CfEHNTzy.mjs} +1 -1
- package/dist/{analytics-C-Go3Pm5.mjs.map → analytics-CfEHNTzy.mjs.map} +1 -1
- package/dist/inapp/AegisInAppManager.d.ts +28 -0
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/renderers/card-template.d.ts +4 -0
- package/dist/inapp/renderers/card-template.d.ts.map +1 -1
- package/dist/inapp/renderers/hero.d.ts.map +1 -1
- package/dist/inapp/renderers/product-recommendation.d.ts +1 -1
- package/dist/inapp/slot-shells.d.ts +99 -0
- package/dist/inapp/slot-shells.d.ts.map +1 -0
- package/dist/inapp/slot-winners.d.ts +43 -0
- package/dist/inapp/slot-winners.d.ts.map +1 -0
- package/dist/index.js +369 -45
- package/dist/index.js.map +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -477,6 +477,45 @@ Drop an empty element wherever you want the card to appear. Its `data-aegis-slot
|
|
|
477
477
|
|
|
478
478
|
No per-slot script and no manual registration — `runtime.initialize()` scans for every `[data-aegis-slot]` element and fills it. It re-scans on each SSE/poll refresh and skips slots it has already filled.
|
|
479
479
|
|
|
480
|
+
#### Slot shells — reserve the box before the campaign arrives
|
|
481
|
+
|
|
482
|
+
An empty slot grows when its campaign lands, which pushes the page down (layout shift), and the hero image request waits for the campaign fetch. The SDK fixes both with a **shell**: a placeholder of the right size, drawn into each empty slot *before* it fetches, which the campaign then fills in place. A slot that nothing fills collapses as soon as the fetch answers, so a box never shows and then disappears later.
|
|
483
|
+
|
|
484
|
+
The SDK takes each slot's shell from the first of these that has one:
|
|
485
|
+
|
|
486
|
+
1. **Inline shapes your page prints** (server-rendered pages): the `shapes` from `GET /v1/in-app/slot-shapes` (below), in a script tag. When this tag is present, a slot missing from it is treated as "will not fill".
|
|
487
|
+
```html
|
|
488
|
+
<script type="application/json" data-aegis-slot-shapes>{"shapes":[ … ]}</script>
|
|
489
|
+
```
|
|
490
|
+
2. **The slot's own attributes** (any site, by hand):
|
|
491
|
+
```html
|
|
492
|
+
<div data-aegis-slot="hero" data-aegis-slot-aspect="8/3"></div>
|
|
493
|
+
<div data-aegis-slot="commerce" data-aegis-slot-min-height="272"></div>
|
|
494
|
+
```
|
|
495
|
+
`data-aegis-slot-aspect` takes `w/h` (or `w:h`). `data-aegis-slot-min-height` takes pixels or a CSS length (`300`, `20rem`, `45vh`).
|
|
496
|
+
3. **The last visit's shapes**: after every fetch, the SDK saves the winning campaigns' shapes in `localStorage`. The key is the property plus the declared surface, screen and outlet (`locationId`), and saved shapes expire after 6 hours. If storage is blocked, this step is skipped.
|
|
497
|
+
|
|
498
|
+
Content you render yourself is left alone. If the slot already has children (a `data-aegis-slot-default` fallback, or your own `<div data-aegis-slot-shell>` child), the SDK draws nothing there. It replaces your shell with the campaign, or removes it when the slot will not fill, exactly as it does its own. The SDK never draws a shape marked `may_be_empty` from data (for example a buy-again rail for a first-time visitor). Only the slot's own attributes can reserve a box for one.
|
|
499
|
+
|
|
500
|
+
**`GET /v1/in-app/slot-shapes`**: for server renderers. It takes the same write-key headers as `/v1/in-app/active` (`X-Aegis-Write-Key`, optional `X-User-ID` / `X-Contact-ID` / `X-Property-Id`). The query parameters are `property_id` (used when the header is absent), `surface`, `screen`, `page_url` (path + search), `location_id`, `device_type`, `geo` and `is_new_user`. The response carries `Cache-Control: private, max-age=60` and the body is `{"shapes": [SlotShape, …]}`, one shape per slot that **will** fill. A slot that is absent will not fill. Each campaign in `/v1/in-app/active` also carries its own `slot_shape`.
|
|
501
|
+
|
|
502
|
+
`SlotShape`:
|
|
503
|
+
|
|
504
|
+
| Field | Meaning |
|
|
505
|
+
|---|---|
|
|
506
|
+
| `slot` | The slot key (`data-aegis-slot` value = the campaign's `widget_category`) |
|
|
507
|
+
| `campaign_id` | The winning campaign |
|
|
508
|
+
| `layout` | `hero`, `rail`, `grid` (`columns` 2, or 1 for a list), `bar` (announcement bar / value bar) or `card` |
|
|
509
|
+
| `aspect` | Box aspect `w/h`. For a hero this is the desktop aspect (`8/3`, ≥768px) |
|
|
510
|
+
| `aspect_phone` | Hero only: the phone (<768px) aspect (`chrome.aspect_ratio`, or `1/1` when a slide has a phone image). Null means use `min_height` |
|
|
511
|
+
| `min_height` / `max_height` | Pixels / a CSS length (a hero is capped at `70vh`) |
|
|
512
|
+
| `card_aspect`, `card_count`, `title` | Rails and grids: each card's image aspect, the number of cards, and the heading (null when absent) |
|
|
513
|
+
| `may_be_empty` | The slot may stay empty for this viewer (a rail with nothing to show, or a winner that depends on who is looking: an A/B test or holdout in shapes computed for all anonymous visitors). Draw no box from data alone. Such a shape carries no `image` or sizes |
|
|
514
|
+
| `rotate_count` | The slot rotates through this many campaigns. The shape is the first one's |
|
|
515
|
+
| `image` | Hero only: the first slide's image `{src, src_phone, alt, aspect, aspect_phone, width, height}`. Render it as `<img fetchpriority="high">` so it is the page's LCP request |
|
|
516
|
+
|
|
517
|
+
The hero draws slide 0 as `<img fetchpriority="high" decoding="async" width height>` and lazy-loads the other slides. Rail card images carry `decoding="async"` plus explicit `width`/`height`, and fade in once decoded.
|
|
518
|
+
|
|
480
519
|
### Cart state — one store, fed the CEP-standard way
|
|
481
520
|
|
|
482
521
|
Every cart-reactive surface — the **free-delivery progress card**, the standalone
|