@active-reach/web-sdk 1.27.3 → 1.29.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/AegisInAppManager.d.ts +39 -2
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/actions.d.ts +76 -0
- package/dist/inapp/actions.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/renderers/card-template.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/inapp/renderers/types.d.ts +8 -0
- package/dist/inapp/renderers/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -49
- package/dist/index.js.map +1 -1
- package/dist/react.js +1 -1
- package/dist/runtime/AegisMessageRuntime.d.ts +38 -1
- 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
|
@@ -1607,6 +1607,25 @@ function mapProducts(products) {
|
|
|
1607
1607
|
class EcommerceTracker {
|
|
1608
1608
|
constructor(aegis) {
|
|
1609
1609
|
this.aegis = aegis;
|
|
1610
|
+
this._cart = {
|
|
1611
|
+
total: 0,
|
|
1612
|
+
itemCount: 0,
|
|
1613
|
+
currency: "INR"
|
|
1614
|
+
};
|
|
1615
|
+
this._cartSink = null;
|
|
1616
|
+
}
|
|
1617
|
+
/** Register a sink that receives the derived cart on every cart event.
|
|
1618
|
+
* Wired once by `AegisMessageRuntime.bindEcommerce(...)`. Emits the current
|
|
1619
|
+
* snapshot immediately so a late binding still gets the latest cart. */
|
|
1620
|
+
onCartChange(sink) {
|
|
1621
|
+
this._cartSink = sink;
|
|
1622
|
+
sink({ ...this._cart });
|
|
1623
|
+
}
|
|
1624
|
+
_emitCart() {
|
|
1625
|
+
var _a;
|
|
1626
|
+
if (this._cart.total < 0) this._cart.total = 0;
|
|
1627
|
+
if (this._cart.itemCount < 0) this._cart.itemCount = 0;
|
|
1628
|
+
(_a = this._cartSink) == null ? void 0 : _a.call(this, { ...this._cart });
|
|
1610
1629
|
}
|
|
1611
1630
|
// -- Product Discovery --
|
|
1612
1631
|
productViewed(product) {
|
|
@@ -1676,29 +1695,38 @@ class EcommerceTracker {
|
|
|
1676
1695
|
}
|
|
1677
1696
|
// -- Cart --
|
|
1678
1697
|
addToCart(product) {
|
|
1698
|
+
const qty = product.quantity ?? 1;
|
|
1679
1699
|
this.aegis.track("cart_item_added", {
|
|
1680
1700
|
product_id: product.product_id,
|
|
1681
1701
|
sku: product.sku ?? product.product_id,
|
|
1682
1702
|
name: product.name,
|
|
1683
1703
|
price: product.price,
|
|
1684
|
-
quantity:
|
|
1704
|
+
quantity: qty,
|
|
1685
1705
|
currency: product.currency ?? "INR",
|
|
1686
1706
|
category: product.category,
|
|
1687
1707
|
brand: product.brand,
|
|
1688
1708
|
variant_id: product.variant_id,
|
|
1689
1709
|
variant_label: product.variant_label
|
|
1690
1710
|
});
|
|
1711
|
+
this._cart.total += (product.price || 0) * qty;
|
|
1712
|
+
this._cart.itemCount += qty;
|
|
1713
|
+
if (product.currency) this._cart.currency = product.currency;
|
|
1714
|
+
this._emitCart();
|
|
1691
1715
|
}
|
|
1692
1716
|
removeFromCart(product) {
|
|
1717
|
+
const qty = product.quantity ?? 1;
|
|
1693
1718
|
this.aegis.track("cart_item_removed", {
|
|
1694
1719
|
product_id: product.product_id,
|
|
1695
1720
|
sku: product.sku ?? product.product_id,
|
|
1696
1721
|
name: product.name,
|
|
1697
1722
|
price: product.price,
|
|
1698
|
-
quantity:
|
|
1723
|
+
quantity: qty,
|
|
1699
1724
|
currency: product.currency ?? "INR",
|
|
1700
1725
|
variant_id: product.variant_id
|
|
1701
1726
|
});
|
|
1727
|
+
this._cart.total -= (product.price || 0) * qty;
|
|
1728
|
+
this._cart.itemCount -= qty;
|
|
1729
|
+
this._emitCart();
|
|
1702
1730
|
}
|
|
1703
1731
|
cartViewed(cart) {
|
|
1704
1732
|
this.aegis.track("cart_viewed", {
|
|
@@ -1708,6 +1736,12 @@ class EcommerceTracker {
|
|
|
1708
1736
|
num_items: sumItems(cart.products),
|
|
1709
1737
|
products: mapProducts(cart.products)
|
|
1710
1738
|
});
|
|
1739
|
+
this._cart = {
|
|
1740
|
+
total: cart.value || 0,
|
|
1741
|
+
itemCount: sumItems(cart.products),
|
|
1742
|
+
currency: cart.currency ?? this._cart.currency ?? "INR"
|
|
1743
|
+
};
|
|
1744
|
+
this._emitCart();
|
|
1711
1745
|
}
|
|
1712
1746
|
// -- Checkout --
|
|
1713
1747
|
checkoutStarted(checkout) {
|
|
@@ -3291,4 +3325,4 @@ export {
|
|
|
3291
3325
|
logger as l,
|
|
3292
3326
|
murmurhash3_x86_32 as m
|
|
3293
3327
|
};
|
|
3294
|
-
//# sourceMappingURL=analytics-
|
|
3328
|
+
//# sourceMappingURL=analytics-CCDZCnut.mjs.map
|