@active-reach/web-sdk 1.15.0 → 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.
Files changed (60) hide show
  1. package/README.md +35 -54
  2. package/dist/aegis-sw.js +1 -1
  3. package/dist/aegis.min.js +1 -1
  4. package/dist/aegis.min.js.map +1 -1
  5. package/dist/{analytics-CjLItVo2.mjs → analytics-DblhjFhs.mjs} +66 -3
  6. package/dist/analytics-DblhjFhs.mjs.map +1 -0
  7. package/dist/cdn.d.ts +5 -2
  8. package/dist/cdn.d.ts.map +1 -1
  9. package/dist/chat/AegisChat.d.ts +138 -0
  10. package/dist/chat/AegisChat.d.ts.map +1 -0
  11. package/dist/chat/index.d.ts +3 -0
  12. package/dist/chat/index.d.ts.map +1 -0
  13. package/dist/core/analytics.d.ts +37 -2
  14. package/dist/core/analytics.d.ts.map +1 -1
  15. package/dist/ecommerce/index.d.ts +32 -14
  16. package/dist/ecommerce/index.d.ts.map +1 -1
  17. package/dist/inapp/AegisInAppManager.d.ts +323 -7
  18. package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
  19. package/dist/inapp/devicePairing.d.ts +70 -0
  20. package/dist/inapp/devicePairing.d.ts.map +1 -0
  21. package/dist/inapp/index.d.ts +2 -0
  22. package/dist/inapp/index.d.ts.map +1 -1
  23. package/dist/inapp/renderPreview.d.ts.map +1 -1
  24. package/dist/inapp/renderers/active-web-chat.d.ts +38 -0
  25. package/dist/inapp/renderers/active-web-chat.d.ts.map +1 -0
  26. package/dist/inapp/renderers/carousel-cards.d.ts.map +1 -1
  27. package/dist/inapp/renderers/coachmark-tour.d.ts.map +1 -1
  28. package/dist/inapp/renderers/games.d.ts +27 -0
  29. package/dist/inapp/renderers/games.d.ts.map +1 -0
  30. package/dist/inapp/renderers/index.d.ts +8 -3
  31. package/dist/inapp/renderers/index.d.ts.map +1 -1
  32. package/dist/inapp/renderers/product-recommendation.d.ts +4 -4
  33. package/dist/inapp/renderers/product-recommendation.d.ts.map +1 -1
  34. package/dist/inapp/renderers/progress-bar.d.ts +14 -0
  35. package/dist/inapp/renderers/progress-bar.d.ts.map +1 -1
  36. package/dist/inapp/renderers/sticky-bar.d.ts.map +1 -1
  37. package/dist/inapp/renderers/stories.d.ts +31 -0
  38. package/dist/inapp/renderers/stories.d.ts.map +1 -0
  39. package/dist/inapp/renderers/types.d.ts +73 -2
  40. package/dist/inapp/renderers/types.d.ts.map +1 -1
  41. package/dist/inapp/renderers/video.d.ts +20 -0
  42. package/dist/inapp/renderers/video.d.ts.map +1 -0
  43. package/dist/index.d.ts +5 -3
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +8411 -3154
  46. package/dist/index.js.map +1 -1
  47. package/dist/loyalty/AegisLoyaltyManager.d.ts +120 -0
  48. package/dist/loyalty/AegisLoyaltyManager.d.ts.map +1 -0
  49. package/dist/loyalty/index.d.ts +3 -0
  50. package/dist/loyalty/index.d.ts.map +1 -0
  51. package/dist/push/AegisWebPush.d.ts.map +1 -1
  52. package/dist/push/AegisWebPush.js +13 -2
  53. package/dist/push/AegisWebPush.js.map +1 -1
  54. package/dist/react.js +1 -1
  55. package/dist/runtime/AegisMessageRuntime.d.ts +61 -1
  56. package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
  57. package/package.json +5 -5
  58. package/dist/analytics-CjLItVo2.mjs.map +0 -1
  59. package/dist/placements/AegisPlacementManager.d.ts +0 -97
  60. package/dist/placements/AegisPlacementManager.d.ts.map +0 -1
@@ -1723,6 +1723,9 @@ class EcommerceTracker {
1723
1723
  ...options
1724
1724
  });
1725
1725
  }
1726
+ checkoutOption(option) {
1727
+ this.aegis.track("checkout_option", { ...option });
1728
+ }
1726
1729
  // -- Order --
1727
1730
  orderCompleted(order) {
1728
1731
  this.aegis.track("order_completed", {
@@ -1746,6 +1749,14 @@ class EcommerceTracker {
1746
1749
  products: products ? mapProducts(products) : void 0
1747
1750
  });
1748
1751
  }
1752
+ orderShipped(orderId, tracking) {
1753
+ this.aegis.track("order_shipped", {
1754
+ order_id: orderId,
1755
+ carrier: tracking == null ? void 0 : tracking.carrier,
1756
+ tracking_code: tracking == null ? void 0 : tracking.tracking_code,
1757
+ tracking_url: tracking == null ? void 0 : tracking.tracking_url
1758
+ });
1759
+ }
1749
1760
  // -- Coupons --
1750
1761
  couponApplied(coupon) {
1751
1762
  this.aegis.track("coupon_applied", { ...coupon });
@@ -1753,6 +1764,9 @@ class EcommerceTracker {
1753
1764
  couponRemoved(coupon) {
1754
1765
  this.aegis.track("coupon_removed", { ...coupon });
1755
1766
  }
1767
+ couponDenied(coupon, reason) {
1768
+ this.aegis.track("coupon_denied", { ...coupon, reason });
1769
+ }
1756
1770
  // -- Wishlist --
1757
1771
  wishlistItemAdded(wishlist) {
1758
1772
  this.aegis.track("wishlist_item_added", {
@@ -1765,6 +1779,17 @@ class EcommerceTracker {
1765
1779
  variant_id: wishlist.product.variant_id
1766
1780
  });
1767
1781
  }
1782
+ productRemovedFromWishlist(wishlist) {
1783
+ this.aegis.track("wishlist_item_removed", {
1784
+ wishlist_id: wishlist.wishlist_id,
1785
+ wishlist_name: wishlist.wishlist_name,
1786
+ product_id: wishlist.product.product_id,
1787
+ sku: wishlist.product.sku ?? wishlist.product.product_id,
1788
+ name: wishlist.product.name,
1789
+ price: wishlist.product.price,
1790
+ variant_id: wishlist.product.variant_id
1791
+ });
1792
+ }
1768
1793
  // -- Back-in-stock waitlist --
1769
1794
  //
1770
1795
  // Server-side substrate: contact_events row keyed on
@@ -2773,10 +2798,10 @@ class Aegis {
2773
2798
  */
2774
2799
  /**
2775
2800
  * Public so peer SDK surfaces (AegisMessageRuntime / AegisInAppManager /
2776
- * AegisPlacementManager / AegisWidgetManager) can plumb the same
2801
+ * AegisWidgetManager) can plumb the same
2777
2802
  * resolved workspace into their own gateway POSTs. Each manager calls
2778
2803
  * the gateway on its own endpoint (`/v1/in_app/events`,
2779
- * `/v1/placements/track`, `/v1/widgets/track-event`); without this,
2804
+ * `/v1/widgets/track-event`); without this,
2780
2805
  * those events arrive at event-ingress with no workspace_id stamped
2781
2806
  * → impressions/clicks fall back to the org's primary workspace and
2782
2807
  * cross-outlet attribution breaks.
@@ -3068,6 +3093,44 @@ class Aegis {
3068
3093
  if (!this.identity) return null;
3069
3094
  return this.identity.getUserId();
3070
3095
  }
3096
+ /**
3097
+ * Fetch the identified contact's REDEEMABLE rewards — coupon codes the
3098
+ * storefront can auto-apply at checkout + loyalty points balance/tier.
3099
+ * Mirrors `GET /api/v1/sdk/entitlements`. Returns `null` when the SDK is
3100
+ * uninitialised, the contact is anonymous, the endpoint returns 204 (nothing
3101
+ * to show), or on any network/HTTP error — callers degrade gracefully.
3102
+ *
3103
+ * Scoped to the identified contact (own grants only) and, when an outlet is
3104
+ * resolvable (`getEffectiveLocationId()`), to org-wide + that outlet's grants.
3105
+ */
3106
+ async getRewards() {
3107
+ const config = this.config;
3108
+ if (!config || !config.api_host || !this.identity) return null;
3109
+ const contactId = this.identity.getUserId();
3110
+ if (!contactId) return null;
3111
+ const apiHost = config.api_host.replace(/\/$/, "");
3112
+ const headers = {
3113
+ "X-Aegis-Write-Key": config.write_key,
3114
+ "X-Contact-ID": contactId,
3115
+ "X-User-ID": contactId
3116
+ };
3117
+ const orgId = config.organization_id;
3118
+ if (orgId) headers["X-Organization-ID"] = orgId;
3119
+ const location = this.getEffectiveLocationId();
3120
+ if (location) headers["X-Location-Id"] = location;
3121
+ try {
3122
+ const resp = await fetch(`${apiHost}/api/v1/sdk/entitlements`, {
3123
+ method: "GET",
3124
+ headers,
3125
+ credentials: "include"
3126
+ });
3127
+ if (resp.status === 204 || !resp.ok) return null;
3128
+ return await resp.json();
3129
+ } catch (err) {
3130
+ logger.warn("getRewards() failed", err);
3131
+ return null;
3132
+ }
3133
+ }
3071
3134
  getSessionId() {
3072
3135
  if (!this.session) return null;
3073
3136
  return this.session.getSessionId();
@@ -3223,4 +3286,4 @@ export {
3223
3286
  logger as l,
3224
3287
  murmurhash3_x86_32 as m
3225
3288
  };
3226
- //# sourceMappingURL=analytics-CjLItVo2.mjs.map
3289
+ //# sourceMappingURL=analytics-DblhjFhs.mjs.map