@active-reach/web-sdk 1.27.3 → 1.28.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 +26 -15
- package/dist/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/{analytics-0p0p56H0.mjs → analytics-CCDZCnut.mjs} +37 -3
- package/dist/analytics-CCDZCnut.mjs.map +1 -0
- package/dist/ecommerce/index.d.ts +11 -0
- package/dist/ecommerce/index.d.ts.map +1 -1
- package/dist/inapp/renderers/carousel-cards.d.ts.map +1 -1
- package/dist/inapp/renderers/product-recommendation.d.ts.map +1 -1
- package/dist/index.js +52 -27
- package/dist/index.js.map +1 -1
- package/dist/react.js +1 -1
- package/dist/runtime/AegisMessageRuntime.d.ts +28 -0
- package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
- package/dist/widgets/AegisWidgetManager.d.ts +9 -0
- package/dist/widgets/AegisWidgetManager.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/analytics-0p0p56H0.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Storage, l as logger, A as Aegis } from "./analytics-
|
|
2
|
-
import { B, E, N, R, U, m } from "./analytics-
|
|
1
|
+
import { S as Storage, l as logger, A as Aegis } from "./analytics-CCDZCnut.mjs";
|
|
2
|
+
import { B, E, N, R, U, m } from "./analytics-CCDZCnut.mjs";
|
|
3
3
|
import { AegisWebPush } from "./push/AegisWebPush.js";
|
|
4
4
|
function debounce(func, wait) {
|
|
5
5
|
let timeoutId = null;
|
|
@@ -957,7 +957,7 @@ function renderCardFromTemplate(card, opts) {
|
|
|
957
957
|
background:${frame.bg ? sanitizeColor(frame.bg) : "#ffffff"};
|
|
958
958
|
border:1px solid ${frame.border ? sanitizeColor(frame.border) : "transparent"};
|
|
959
959
|
border-radius:${radius}; padding:8px;
|
|
960
|
-
${fLayout === "row" ? "" : "box-shadow:0
|
|
960
|
+
${fLayout === "row" ? "" : "box-shadow:0 4px 16px rgba(0,0,0,0.18);"}
|
|
961
961
|
${frame.max_width ? `max-width:${frame.max_width}px;` : ""}${frame.min_width ? `min-width:${frame.min_width}px;` : ""}
|
|
962
962
|
${frame.height ? `height:${frame.height}px;` : ""}${frame.min_height ? `min-height:${frame.min_height}px;` : ""}
|
|
963
963
|
${sizing}
|
|
@@ -1256,7 +1256,8 @@ function renderCarouselCards(ctx) {
|
|
|
1256
1256
|
track.style.cssText = `
|
|
1257
1257
|
display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity;
|
|
1258
1258
|
scroll-padding-left: 0; scrollbar-width: none; -ms-overflow-style: none;
|
|
1259
|
-
|
|
1259
|
+
/* room so overflow-x: auto doesn't clip the card drop-shadow */
|
|
1260
|
+
padding: 8px 6px 16px; margin: -8px -6px -6px; -webkit-overflow-scrolling: touch;
|
|
1260
1261
|
`;
|
|
1261
1262
|
track.style.msOverflowStyle = "none";
|
|
1262
1263
|
const template = resolveGlobalTemplate(ic);
|
|
@@ -1921,12 +1922,12 @@ function renderProductRecommendation(ctx) {
|
|
|
1921
1922
|
if (layout === "row") {
|
|
1922
1923
|
grid.style.cssText = `
|
|
1923
1924
|
display: flex; gap: 10px; overflow-x: auto;
|
|
1924
|
-
scroll-snap-type: x mandatory; padding: 14px
|
|
1925
|
+
scroll-snap-type: x mandatory; padding: 14px 2px 18px;
|
|
1925
1926
|
`;
|
|
1926
1927
|
} else {
|
|
1927
1928
|
grid.style.cssText = `
|
|
1928
1929
|
display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
|
|
1929
|
-
padding
|
|
1930
|
+
padding: 14px 2px 6px;
|
|
1930
1931
|
`;
|
|
1931
1932
|
}
|
|
1932
1933
|
cards.forEach((c) => {
|
|
@@ -1985,7 +1986,7 @@ function renderProductRecommendationInline(ctx, target) {
|
|
|
1985
1986
|
} else {
|
|
1986
1987
|
grid.style.cssText = `
|
|
1987
1988
|
display: flex; gap: 10px; overflow-x: auto;
|
|
1988
|
-
scroll-snap-type: x proximity; padding:
|
|
1989
|
+
scroll-snap-type: x proximity; padding: 10px 8px 18px; margin: -8px -8px -6px;
|
|
1989
1990
|
-webkit-overflow-scrolling: touch; scrollbar-width: none;
|
|
1990
1991
|
`;
|
|
1991
1992
|
grid.style.msOverflowStyle = "none";
|
|
@@ -11498,6 +11499,7 @@ class AegisWidgetManager {
|
|
|
11498
11499
|
this.onEvent = config.onEvent;
|
|
11499
11500
|
this.sourcePlatform = config.sourcePlatform;
|
|
11500
11501
|
this.getWorkspaceId = config.getWorkspaceId;
|
|
11502
|
+
this.onCartDetected = config.onCartDetected;
|
|
11501
11503
|
}
|
|
11502
11504
|
updateCSSCustomization(customization) {
|
|
11503
11505
|
this.cssCustomization = { ...this.cssCustomization, ...customization };
|
|
@@ -11609,24 +11611,18 @@ class AegisWidgetManager {
|
|
|
11609
11611
|
this.log("AegisWidgets initialized successfully");
|
|
11610
11612
|
}
|
|
11611
11613
|
setCartData(cartData) {
|
|
11614
|
+
var _a;
|
|
11612
11615
|
this.cartData = cartData;
|
|
11613
11616
|
this.log(`Cart data updated: ${cartData.cart_items.length} items, total: ${cartData.cart_currency} ${cartData.cart_total}`);
|
|
11617
|
+
(_a = this.onCartDetected) == null ? void 0 : _a.call(this, cartData);
|
|
11614
11618
|
}
|
|
11615
11619
|
detectPlatformCart() {
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
if (wooCart) {
|
|
11623
|
-
this.log("Detected WooCommerce cart via injected data");
|
|
11624
|
-
return wooCart;
|
|
11625
|
-
}
|
|
11626
|
-
const magentoCart = this.normalizeMagentoCart();
|
|
11627
|
-
if (magentoCart) {
|
|
11628
|
-
this.log("Detected Magento cart via localStorage");
|
|
11629
|
-
return magentoCart;
|
|
11620
|
+
var _a;
|
|
11621
|
+
const detected = this.normalizeShopifyCart() ?? this.normalizeWooCart() ?? this.normalizeMagentoCart();
|
|
11622
|
+
if (detected) {
|
|
11623
|
+
this.log("Detected platform cart (Shopify/Woo/Magento)");
|
|
11624
|
+
(_a = this.onCartDetected) == null ? void 0 : _a.call(this, detected);
|
|
11625
|
+
return detected;
|
|
11630
11626
|
}
|
|
11631
11627
|
if (this.cartData) {
|
|
11632
11628
|
this.log("Using manually set cart data");
|
|
@@ -13611,7 +13607,16 @@ class AegisMessageRuntime {
|
|
|
13611
13607
|
ownsTriggerEngine,
|
|
13612
13608
|
enablePrefetch: config.enableWidgetPrefetch !== false,
|
|
13613
13609
|
sourcePlatform: config.sourcePlatform,
|
|
13614
|
-
getWorkspaceId: config.getWorkspaceId
|
|
13610
|
+
getWorkspaceId: config.getWorkspaceId,
|
|
13611
|
+
// Cart-store unification: when the widget subsystem detects a platform
|
|
13612
|
+
// cart (Shopify/Woo/Magento) or the host calls `widgets.setCartData`, flow
|
|
13613
|
+
// it UP into the ONE cart store so the Free-Delivery card / progress bar /
|
|
13614
|
+
// rule eval see the same cart. See CART_STORE_UNIFICATION_TRACKER.md.
|
|
13615
|
+
onCartDetected: (cart) => this.applyCart({
|
|
13616
|
+
total: cart.cart_total,
|
|
13617
|
+
itemCount: Array.isArray(cart.cart_items) ? cart.cart_items.reduce((s, it) => s + (Number(it.quantity) || 1), 0) : 0,
|
|
13618
|
+
currency: cart.cart_currency
|
|
13619
|
+
})
|
|
13615
13620
|
});
|
|
13616
13621
|
this.inApp = new AegisInAppManager({
|
|
13617
13622
|
writeKey: config.writeKey,
|
|
@@ -13781,11 +13786,31 @@ class AegisMessageRuntime {
|
|
|
13781
13786
|
* feed for headless storefronts; prefer `updateContext` for new code.
|
|
13782
13787
|
*/
|
|
13783
13788
|
setCartState(state) {
|
|
13784
|
-
this.
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
|
|
13789
|
+
this.applyCart(state);
|
|
13790
|
+
}
|
|
13791
|
+
/**
|
|
13792
|
+
* The ONE cart writer. Normalizes any cart-ish shape and funnels it into the
|
|
13793
|
+
* single `cart` context namespace (read by the Free-Delivery progress card,
|
|
13794
|
+
* the progress-bar widget, and rule eval via the `cart_value` signal). EVERY
|
|
13795
|
+
* cart feed routes through here: ecommerce events (`bindEcommerce`), platform
|
|
13796
|
+
* auto-detect + `widgets.setCartData` (`onCartDetected`), and the explicit
|
|
13797
|
+
* `setCartState` escape hatch. See CART_STORE_UNIFICATION_TRACKER.md.
|
|
13798
|
+
*/
|
|
13799
|
+
applyCart(cart) {
|
|
13800
|
+
const total = Number(cart.total) || 0;
|
|
13801
|
+
const itemCount = Number(cart.itemCount ?? cart.items) || 0;
|
|
13802
|
+
const currency = typeof cart.currency === "string" && cart.currency ? cart.currency : "INR";
|
|
13803
|
+
this.updateContext("cart", { total, items: itemCount, currency });
|
|
13804
|
+
}
|
|
13805
|
+
/**
|
|
13806
|
+
* Wire the analytics ecommerce tracker into the cart store — the CEP-standard
|
|
13807
|
+
* path. After this, a host firing `aegis.ecommerce.addToCart(...)` /
|
|
13808
|
+
* `cartViewed(...)` automatically drives every cart-reactive surface; no
|
|
13809
|
+
* separate `setCartState` call is needed. Call once after constructing both
|
|
13810
|
+
* the analytics SDK and the runtime. Idempotent.
|
|
13811
|
+
*/
|
|
13812
|
+
bindEcommerce(tracker) {
|
|
13813
|
+
tracker.onCartChange((c) => this.applyCart(c));
|
|
13789
13814
|
}
|
|
13790
13815
|
// --- Qualifying-event refresh facade (DLR Tracker 1 / P1, 2026-05-28) ---
|
|
13791
13816
|
//
|