@braze/web-sdk 6.7.0 → 6.8.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 (97) hide show
  1. package/index.d.ts +74 -27
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +2 -2
  4. package/shared-lib/event-types.js +13 -13
  5. package/shared-lib/indexed-db-adapter.js +3 -3
  6. package/shared-lib/logger.js +2 -2
  7. package/shared-lib/supported-options.js +8 -8
  8. package/src/Banner/log-banner-impressions.js +20 -11
  9. package/src/ContentCards/content-cards-provider-factory.js +13 -11
  10. package/src/ContentCards/content-cards-provider.js +4 -4
  11. package/src/ContentCards/get-cached-content-cards.js +2 -2
  12. package/src/ContentCards/request-content-cards-refresh.js +2 -2
  13. package/src/ContentCards/subscribe-to-content-cards-updates.js +10 -10
  14. package/src/ContentCards/ui/show-content-cards.js +3 -3
  15. package/src/Core/change-user.js +2 -2
  16. package/src/Core/index.js +1 -0
  17. package/src/Core/log-ecommerce-event.js +29 -0
  18. package/src/Core/log-purchase.js +17 -192
  19. package/src/Core/open-session.js +6 -6
  20. package/src/Core/set-sdk-authentication-signature.js +1 -1
  21. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
  22. package/src/DUST/dust-connection-core.js +1 -0
  23. package/src/DUST/dust-provider-factory.js +10 -10
  24. package/src/DUST/dust-provider.js +181 -158
  25. package/src/DUST/dust-shared-worker-code.js +1 -1
  26. package/src/DUST/dust-shared-worker-impl.js +93 -100
  27. package/src/DUST/dust-worker-bridge.js +27 -27
  28. package/src/DUST/subscribe-to-dust.js +7 -7
  29. package/src/InAppMessage/defer-in-app-message.js +1 -1
  30. package/src/InAppMessage/display/in-app-message-to-html.js +16 -16
  31. package/src/InAppMessage/display/modal-utils.js +2 -2
  32. package/src/InAppMessage/in-app-message-manager.js +64 -64
  33. package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
  34. package/src/InAppMessage/log-in-app-message-click.js +1 -1
  35. package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
  36. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  37. package/src/InAppMessage/models/full-screen-message.js +7 -7
  38. package/src/InAppMessage/models/html-message.js +1 -1
  39. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  40. package/src/InAppMessage/models/in-app-message.js +22 -22
  41. package/src/InAppMessage/models/modal-message.js +5 -5
  42. package/src/InAppMessage/models/slide-up-message.js +6 -6
  43. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  44. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  45. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  46. package/src/InAppMessage/ui/show-in-app-message.js +20 -20
  47. package/src/Push/push-manager-factory.js +2 -2
  48. package/src/Push/push-manager.js +8 -8
  49. package/src/Push/utils/push-utils.js +6 -6
  50. package/src/User/user-manager.js +5 -5
  51. package/src/User/user.js +8 -8
  52. package/src/common/constants.js +1 -0
  53. package/src/common/content-cards-display.js +2 -2
  54. package/src/l10n/l10n-manager-factory.js +1 -1
  55. package/src/l10n/l10n-manager.js +1 -1
  56. package/src/managers/braze-instance.js +21 -21
  57. package/src/managers/device-manager.js +6 -6
  58. package/src/managers/network-manager.js +93 -92
  59. package/src/managers/server-config-manager.js +68 -68
  60. package/src/managers/session-manager.js +2 -2
  61. package/src/managers/storage-manager-factory.js +4 -4
  62. package/src/managers/storage-manager.js +120 -120
  63. package/src/managers/subscription-manager.js +1 -1
  64. package/src/managers/utils.js +1 -1
  65. package/src/models/backend-errors.js +5 -5
  66. package/src/models/braze-event.js +3 -3
  67. package/src/models/device.js +1 -1
  68. package/src/models/identifier.js +3 -3
  69. package/src/models/push-token.js +5 -5
  70. package/src/models/server-config.js +27 -27
  71. package/src/request-controller.js +99 -99
  72. package/src/triggers/models/custom-event-data.js +4 -4
  73. package/src/triggers/models/custom-event-property-data.js +5 -5
  74. package/src/triggers/models/filter-set.js +2 -2
  75. package/src/triggers/models/filter.js +1 -1
  76. package/src/triggers/models/in-app-message-click-data.js +5 -5
  77. package/src/triggers/models/purchase-data.js +1 -1
  78. package/src/triggers/models/purchase-property-data.js +2 -2
  79. package/src/triggers/models/push-click-data.js +5 -5
  80. package/src/triggers/models/trigger-condition.js +42 -42
  81. package/src/triggers/models/trigger-events.js +2 -2
  82. package/src/triggers/models/trigger.js +10 -10
  83. package/src/triggers/triggers-provider-factory.js +1 -1
  84. package/src/triggers/triggers-provider.js +30 -30
  85. package/src/types.js +5 -1
  86. package/src/ui/js/attach-css.js +1 -1
  87. package/src/util/braze-actions.js +5 -5
  88. package/src/util/browser-detector.js +13 -13
  89. package/src/util/client-hints-parser.js +2 -2
  90. package/src/util/dom-utils.js +2 -2
  91. package/src/util/ecommerce-event-validation.js +326 -0
  92. package/src/util/iso-4217-currency-codes.js +176 -0
  93. package/src/util/net.js +3 -3
  94. package/src/util/request-header-utils.js +18 -18
  95. package/src/util/user-agent-parser.js +14 -14
  96. package/src/util/validation-utils.js +2 -2
  97. package/src/util/window-utils.js +2 -2
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Type definitions for @braze/web-sdk v6.7.0
2
+ * Type definitions for @braze/web-sdk v6.8.0
3
3
  * Project: https://github.com/braze-inc/braze-web-sdk
4
4
  * (c) Braze, Inc. 2026 - http://braze.com
5
5
  * License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
@@ -1585,7 +1585,7 @@ export type PropertiesJson = Partial<
1585
1585
  >
1586
1586
  >;
1587
1587
 
1588
- export interface eCommerceProductProperties {
1588
+ export interface EcommerceProductProperties {
1589
1589
  /**
1590
1590
  * A unique identifier for the product, such as product ID or SKU. Cannot exceed 255 characters in length.
1591
1591
  */
@@ -1622,7 +1622,7 @@ export interface eCommerceProductProperties {
1622
1622
  price: number;
1623
1623
 
1624
1624
  /**
1625
- * Additional metadata about the product. Keys are limited to 255 characters in length, cannot begin with a $ character,
1625
+ * Additional metadata about the product. Keys are limited to 255 characters in length, cannot begin with a $ character,
1626
1626
  * and can only contain alphanumeric characters and punctuation. Total size of metadata cannot exceed 50KB.
1627
1627
  */
1628
1628
  metadata?: {
@@ -1634,7 +1634,7 @@ export interface eCommerceProductProperties {
1634
1634
  };
1635
1635
  }
1636
1636
 
1637
- export interface eCommerceEventProperties {
1637
+ export interface EcommerceEventProperties {
1638
1638
  /**
1639
1639
  * Default USD. Currencies should be represented as an ISO 4217 currency code. Supported
1640
1640
  * currency symbols include: AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF,
@@ -1657,14 +1657,14 @@ export interface eCommerceEventProperties {
1657
1657
  }
1658
1658
 
1659
1659
  export interface CheckoutStartedEventProperties
1660
- extends eCommerceEventProperties {
1660
+ extends EcommerceEventProperties {
1661
1661
  /**
1662
1662
  * A unique identifier for the checkout. Cannot exceed 255 characters in length.
1663
1663
  */
1664
1664
  checkout_id: string;
1665
1665
 
1666
1666
  /**
1667
- * A unique identifier for the cart. If no value is passed, a default value is assumed
1667
+ * A unique identifier for the cart. If no value is passed, a default value is assumed
1668
1668
  * (shared across cart/checkout/order events) for user cart mapping.
1669
1669
  * Cannot exceed 255 characters in length.
1670
1670
  */
@@ -1678,10 +1678,10 @@ export interface CheckoutStartedEventProperties
1678
1678
  /**
1679
1679
  * The products associated with the checkout.
1680
1680
  */
1681
- products: eCommerceProductProperties[];
1681
+ products: EcommerceProductProperties[];
1682
1682
 
1683
1683
  /**
1684
- * Additional metadata about the checkout. Keys are limited to 255 characters in length, cannot begin with a $ character,
1684
+ * Additional metadata about the checkout. Keys are limited to 255 characters in length, cannot begin with a $ character,
1685
1685
  * and can only contain alphanumeric characters and punctuation. Total size of metadata cannot exceed 50KB.
1686
1686
  */
1687
1687
  metadata?: {
@@ -1690,34 +1690,60 @@ export interface CheckoutStartedEventProperties
1690
1690
  };
1691
1691
  }
1692
1692
 
1693
- export interface CartUpdatedEventProperties extends eCommerceEventProperties {
1693
+ type CartUpdatedBaseProperties = EcommerceEventProperties & {
1694
1694
  /**
1695
- * A unique identifier for the cart. If no value is passed, a default value is assumed
1695
+ * A unique identifier for the cart. If no value is passed, a default value is assumed
1696
1696
  * (shared across cart/checkout/order events) for user cart mapping.
1697
1697
  * Cannot exceed 255 characters in length.
1698
1698
  */
1699
1699
  cart_id: string;
1700
1700
 
1701
- /**
1702
- * The total monetary value of the cart (ex: 12.99).
1703
- */
1704
- total_value: number;
1705
-
1706
1701
  /**
1707
1702
  * The products in the updated cart.
1708
1703
  */
1709
- products: eCommerceProductProperties[];
1704
+ products: EcommerceProductProperties[];
1710
1705
 
1711
1706
  /**
1712
- * Additional metadata about the cart update. Keys are limited to 255 characters in length, cannot begin with a $ character,
1707
+ * Additional metadata about the cart update. Keys are limited to 255 characters in length, cannot begin with a $ character,
1713
1708
  * and can only contain alphanumeric characters and punctuation. Total size of metadata cannot exceed 50KB.
1714
1709
  */
1715
1710
  metadata?: {
1716
1711
  [key: string]: any;
1717
1712
  };
1718
- }
1713
+ };
1719
1714
 
1720
- export interface ProductViewedEventProperties extends eCommerceEventProperties {
1715
+ /**
1716
+ * Properties for the `ecommerce.cart_updated` event.
1717
+ *
1718
+ * `total_value` is required when `action` is `"replace"` or omitted (defaults to `"replace"`).
1719
+ * `total_value` is optional when `action` is `"add"` or `"remove"`.
1720
+ */
1721
+ export type CartUpdatedEventProperties =
1722
+ | (CartUpdatedBaseProperties & {
1723
+ /**
1724
+ * The action that triggered the cart update. Defaults to "replace" if not provided.
1725
+ * - "replace": the cart contents were fully replaced (default)
1726
+ */
1727
+ action?: "replace";
1728
+ /**
1729
+ * The total monetary value of the cart (ex: 12.99). Required when action is "replace" or omitted.
1730
+ */
1731
+ total_value: number;
1732
+ })
1733
+ | (CartUpdatedBaseProperties & {
1734
+ /**
1735
+ * The action that triggered the cart update.
1736
+ * - "add": one or more products were added to the cart
1737
+ * - "remove": one or more products were removed from the cart
1738
+ */
1739
+ action: "add" | "remove";
1740
+ /**
1741
+ * The total monetary value of the cart (ex: 12.99). Optional when action is "add" or "remove".
1742
+ */
1743
+ total_value?: number;
1744
+ });
1745
+
1746
+ export interface ProductViewedEventProperties extends EcommerceEventProperties {
1721
1747
  /**
1722
1748
  * A unique identifier for the product that was viewed. Cannot exceed 255 characters in length.
1723
1749
  */
@@ -1749,7 +1775,7 @@ export interface ProductViewedEventProperties extends eCommerceEventProperties {
1749
1775
  price: number;
1750
1776
 
1751
1777
  /**
1752
- * Additional metadata about the product viewed. Keys are limited to 255 characters in length, cannot begin with a $ character,
1778
+ * Additional metadata about the product viewed. Keys are limited to 255 characters in length, cannot begin with a $ character,
1753
1779
  * and can only contain alphanumeric characters and punctuation. Total size of metadata cannot exceed 50KB.
1754
1780
  */
1755
1781
  metadata?: {
@@ -1767,14 +1793,14 @@ export interface ProductViewedEventProperties extends eCommerceEventProperties {
1767
1793
  };
1768
1794
  }
1769
1795
 
1770
- export interface OrderPlacedEventProperties extends eCommerceEventProperties {
1796
+ export interface OrderPlacedEventProperties extends EcommerceEventProperties {
1771
1797
  /**
1772
1798
  * A unique identifier for the order that was placed. Cannot exceed 255 characters in length.
1773
1799
  */
1774
1800
  order_id: string;
1775
1801
 
1776
1802
  /**
1777
- * A unique identifier for the cart. If no value is passed, a default value is assumed
1803
+ * A unique identifier for the cart. If no value is passed, a default value is assumed
1778
1804
  * (shared across cart/checkout/order events) for user cart mapping.
1779
1805
  * Cannot exceed 255 characters in length.
1780
1806
  */
@@ -1798,10 +1824,10 @@ export interface OrderPlacedEventProperties extends eCommerceEventProperties {
1798
1824
  /**
1799
1825
  * The products in the order.
1800
1826
  */
1801
- products: eCommerceProductProperties[];
1827
+ products: EcommerceProductProperties[];
1802
1828
 
1803
1829
  /**
1804
- * Additional metadata about the product viewed. Keys are limited to 255 characters in length, cannot begin with a $ character,
1830
+ * Additional metadata about the product viewed. Keys are limited to 255 characters in length, cannot begin with a $ character,
1805
1831
  * and can only contain alphanumeric characters and punctuation. Total size of metadata cannot exceed 50KB.
1806
1832
  */
1807
1833
  metadata?: {
@@ -1826,7 +1852,7 @@ export interface OrderPlacedEventProperties extends eCommerceEventProperties {
1826
1852
  referring_site?: string;
1827
1853
 
1828
1854
  /**
1829
- * A list of payment system sources (ex: POS, mobile, etc.), only applicable to Shopify integrations.
1855
+ * A list of payment system sources (ex: POS, mobile, etc.), only applicable to Shopify integrations.
1830
1856
  * Each payment gateway name cannot exceed 255 characters in length.
1831
1857
  */
1832
1858
  payment_gateway_names?: string[];
@@ -1834,6 +1860,16 @@ export interface OrderPlacedEventProperties extends eCommerceEventProperties {
1834
1860
  };
1835
1861
  }
1836
1862
 
1863
+ /**
1864
+ * The `name` field selects which eCommerce event is logged,
1865
+ * `properties` must match the corresponding properties interface.
1866
+ */
1867
+ export type EcommerceEvent =
1868
+ | { name: "ecommerce.product_viewed"; properties: ProductViewedEventProperties }
1869
+ | { name: "ecommerce.cart_updated"; properties: CartUpdatedEventProperties }
1870
+ | { name: "ecommerce.checkout_started"; properties: CheckoutStartedEventProperties }
1871
+ | { name: "ecommerce.order_placed"; properties: OrderPlacedEventProperties };
1872
+
1837
1873
  export class FeatureFlag {
1838
1874
  /** Indicates whether or not this feature flag is enabled. */
1839
1875
  enabled: boolean;
@@ -2305,6 +2341,17 @@ export function logCustomEvent(
2305
2341
  eventProperties?: object,
2306
2342
  ): boolean;
2307
2343
 
2344
+ /**
2345
+ * Logs a typed eCommerce event through the custom event pipeline (`EventTypes.CustomEvent`): `n` is the event
2346
+ * name (e.g. `ecommerce.product_viewed`) and `p` is the validated properties payload. On success, fires the same
2347
+ * custom event trigger as `logCustomEvent` for backwards compatibility.
2348
+ *
2349
+ * @param event - Which eCommerce event to log and its validated properties object.
2350
+ *
2351
+ * @returns Whether the event was successfully queued for later flush.
2352
+ */
2353
+ export function logEcommerceEvent(event: EcommerceEvent): boolean;
2354
+
2308
2355
  /**
2309
2356
  * Logs that the user clicked the given in-app message button. This is done automatically when the user clicks on
2310
2357
  * a button in a message generated by `showInAppMessage`,
@@ -2420,7 +2467,7 @@ export function openSession(): void;
2420
2467
  * - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
2421
2468
  *
2422
2469
  * ```
2423
- * self.importScripts('https://js.appboycdn.com/web-sdk/6.7/service-worker.js');
2470
+ * self.importScripts('https://js.appboycdn.com/web-sdk/6.8/service-worker.js');
2424
2471
  * ```
2425
2472
  *
2426
2473
  * For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
@@ -2842,7 +2889,7 @@ export type InitializationOptions = {
2842
2889
  * lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
2843
2890
  * option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
2844
2891
  * `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
2845
- * `self.importScripts('https://js.appboycdn.com/web-sdk/6.7/service-worker.js');` or by including the content
2892
+ * `self.importScripts('https://js.appboycdn.com/web-sdk/6.8/service-worker.js');` or by including the content
2846
2893
  * of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
2847
2894
  */
2848
2895
  manageServiceWorkerExternally?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braze/web-sdk",
3
- "version": "6.7.0",
3
+ "version": "6.8.0",
4
4
  "description": "Braze SDK for web sites and other JS platforms.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,4 +1,4 @@
1
- const ui = {
1
+ const ai = {
2
2
  Nu: function (t) {
3
3
  const r = (t + "=".repeat((4 - (t.length % 4)) % 4))
4
4
  .replace(/\-/g, "+")
@@ -9,4 +9,4 @@ const ui = {
9
9
  return o;
10
10
  },
11
11
  };
12
- export default ui;
12
+ export default ai;
@@ -1,35 +1,35 @@
1
1
  const p = {
2
2
  CustomEvent: "ce",
3
3
  Pr: "p",
4
- Uc: "pc",
4
+ Jc: "pc",
5
5
  ev: "ca",
6
- gl: "i",
7
- Ya: "ie",
6
+ ql: "i",
7
+ Va: "ie",
8
8
  ds: "cci",
9
9
  js: "ccic",
10
10
  os: "ccc",
11
11
  cs: "ccd",
12
12
  wm: "ss",
13
13
  hm: "se",
14
- Fn: "si",
15
- On: "sc",
16
- Xn: "sbc",
14
+ Xn: "si",
15
+ Hn: "sc",
16
+ Jn: "sbc",
17
17
  tv: "sfe",
18
18
  om: "iec",
19
- Oc: "lr",
20
- Nc: "uae",
21
- Kc: "lcaa",
22
- Jc: "lcar",
19
+ Bc: "lr",
20
+ Uc: "uae",
21
+ Gc: "lcaa",
22
+ Wc: "lcar",
23
23
  Zu: "inc",
24
24
  Qu: "add",
25
25
  Xu: "rem",
26
26
  Yu: "set",
27
27
  Vu: "ncam",
28
- Wc: "sgu",
28
+ Xc: "sgu",
29
29
  xo: "ffi",
30
30
  ro: "bi",
31
31
  Dt: "bc",
32
32
  Ft: "bd",
33
33
  },
34
- Qe = { nv: "content_cards_displayed" };
35
- export { p as EventTypes, Qe as InternalEventTypes };
34
+ We = { nv: "content_cards_displayed" };
35
+ export { p as EventTypes, We as InternalEventTypes };
@@ -338,13 +338,13 @@ et.Ps = {
338
338
  xd: "AppboyServiceWorkerAsyncStorage",
339
339
  VERSION: 6,
340
340
  Os: {
341
- pn: "data",
342
- $r: "pushClicks",
341
+ wn: "data",
342
+ yr: "pushClicks",
343
343
  Fu: "pushSubscribed",
344
344
  yd: "fallbackDevice",
345
345
  _s: "cardUpdates",
346
346
  pe: "optOut",
347
- qr: "pendingData",
347
+ Br: "pendingData",
348
348
  wh: "sdkAuthenticationSignature",
349
349
  },
350
350
  be: 1,
@@ -24,13 +24,13 @@ const E = {
24
24
  },
25
25
  warn: function (n) {
26
26
  if (E.zg) {
27
- const o = "Braze SDK Warning: " + n + " (v6.7.0)";
27
+ const o = "Braze SDK Warning: " + n + " (v6.8.0)";
28
28
  null != E.vd ? E.vd(o) : console.warn(o);
29
29
  }
30
30
  },
31
31
  error: function (n) {
32
32
  if (E.zg) {
33
- const o = "Braze SDK Error: " + n + " (v6.7.0)";
33
+ const o = "Braze SDK Error: " + n + " (v6.8.0)";
34
34
  null != E.vd ? E.vd(o) : console.error(o);
35
35
  }
36
36
  },
@@ -4,26 +4,26 @@ export default {
4
4
  se: "cookieExpiryInDays",
5
5
  Oh: "noCookies",
6
6
  Th: "devicePropertyAllowlist",
7
- ka: "disablePushTokenMaintenance",
7
+ qa: "disablePushTokenMaintenance",
8
8
  Rh: "enableLogging",
9
9
  Ph: "enableSdkAuthentication",
10
- _a: "manageServiceWorkerExternally",
10
+ ka: "manageServiceWorkerExternally",
11
11
  Dh: "minimumIntervalBetweenTriggerActionsInSeconds",
12
12
  Lh: "sessionTimeoutInSeconds",
13
13
  yh: "appVersion",
14
14
  Mh: "appVersionNumber",
15
15
  xa: "serviceWorkerLocation",
16
- Ma: "safariWebsitePushId",
17
- qa: "localization",
16
+ _a: "safariWebsitePushId",
17
+ Ba: "localization",
18
18
  sr: "contentSecurityNonce",
19
19
  nr: "allowUserSuppliedJavascript",
20
- ja: "inAppMessageZIndex",
21
- ba: "openInAppMessagesInNewTab",
20
+ wa: "inAppMessageZIndex",
21
+ va: "openInAppMessagesInNewTab",
22
22
  oh: "requireExplicitInAppMessageDismissal",
23
23
  Uh: "doNotLoadFontAwesome",
24
24
  Wh: "deviceId",
25
- ya: "serviceWorkerScope",
26
- Qe: "dustHost",
25
+ Ma: "serviceWorkerScope",
26
+ Xe: "dustHost",
27
27
  Bh: "sdkFlavor",
28
28
  tn: "openCardsInNewTab",
29
29
  };
@@ -10,22 +10,31 @@ export function logBannerImpressions(o) {
10
10
  s = n.k();
11
11
  if (0 === D(s).length)
12
12
  return E.info("Not logging banners impression. No banners exist."), !1;
13
- const e = n.Ut(),
14
- t = [];
15
- for (const r of o) {
16
- const o = s[r];
13
+ let e = n.Ut(),
14
+ t = !1;
15
+ if (Object.keys(e).some((o) => void 0 !== s[o])) {
16
+ const o = {};
17
+ for (const n of Object.keys(e)) {
18
+ const r = s[n];
19
+ r && e[n] && (o[r.id] = !0);
20
+ }
21
+ (e = o), (t = !0);
22
+ }
23
+ const a = [];
24
+ for (const n of o) {
25
+ const o = s[n];
17
26
  o
18
- ? e[o.placementId]
27
+ ? e[o.id]
19
28
  ? E.info(
20
- `Not logging banners impression for ID ${r}. This ID was already logged this session.`,
29
+ `Not logging banners impression for ID ${n}. This ID was already logged this session.`,
21
30
  )
22
- : ((e[o.placementId] = !0), t.push(o.id))
31
+ : ((e[o.id] = !0), a.push(o.id))
23
32
  : E.info(
24
- `Not logging banners impression for ID ${r}. The placement ID did not correspond to any banner.`,
33
+ `Not logging banners impression for ID ${n}. The placement ID did not correspond to any banner.`,
25
34
  );
26
35
  }
27
- if (0 === t.length) return !1;
36
+ if (0 === a.length) return t && n.At(e), !1;
28
37
  n.At(e);
29
- const a = { ids: t };
30
- return v.wt(p.ro, a).lt;
38
+ const f = { ids: a };
39
+ return v.wt(p.ro, f).lt;
31
40
  }
@@ -1,24 +1,26 @@
1
1
  import r from "../managers/braze-instance.js";
2
2
  import rr from "./content-cards-provider.js";
3
- const er = {
3
+ const ir = {
4
4
  i: !1,
5
5
  provider: null,
6
6
  o: () => (
7
- er.t(),
8
- er.provider ||
9
- ((er.provider = new rr(r.ir(), r.p(), r.l(), r.ar(), r.m())),
10
- r.v(er.provider),
11
- r.dr("ccr", () => {
7
+ ir.t(),
8
+ ir.provider ||
9
+ ((ir.provider = new rr(r.ir(), r.p(), r.l(), r.dr(), r.m())),
10
+ r.v(ir.provider),
11
+ r.ar("ccr", () => {
12
12
  var r;
13
- null === (r = er.provider) || void 0 === r || r.lr();
13
+ null === (r = ir.provider) ||
14
+ void 0 === r ||
15
+ r.lr(void 0, void 0, "dust");
14
16
  })),
15
- er.provider
17
+ ir.provider
16
18
  ),
17
19
  t: () => {
18
- er.i || (r.g(er), (er.i = !0));
20
+ ir.i || (r.g(ir), (ir.i = !0));
19
21
  },
20
22
  destroy: () => {
21
- (er.provider = null), (er.i = !1);
23
+ (ir.provider = null), (ir.i = !1);
22
24
  },
23
25
  };
24
- export default er;
26
+ export default ir;
@@ -207,17 +207,17 @@ export default class rr extends t {
207
207
  Fi() {
208
208
  this.Ws && (clearTimeout(this.Ws), (this.Ws = null));
209
209
  }
210
- lr(t, i, e = !1) {
210
+ lr(t, i, e = "sdk") {
211
211
  var n;
212
212
  const o = this.B,
213
213
  u = this.C;
214
214
  if (!o || !u) return void ("function" == typeof i && i());
215
- if ((e && (h.Li(u, h.it.Ji), this.Fi()), !this.Ui()))
215
+ if (("client" === e && (h.Li(u, h.it.Ji), this.Fi()), !this.Ui()))
216
216
  return void (
217
217
  null === (n = this.h) ||
218
218
  void 0 === n ||
219
219
  n.Mi(() => {
220
- this.lr(t, i, !0);
220
+ this.lr(t, i, "client");
221
221
  })
222
222
  );
223
223
  const f = o.Z({}, !0);
@@ -267,7 +267,7 @@ export default class rr extends t {
267
267
  o.yt(
268
268
  e,
269
269
  () => {
270
- this.lr(t, i, !1);
270
+ this.lr(t, i);
271
271
  },
272
272
  h.it.Ji,
273
273
  (t) => this.xi(t),
@@ -1,5 +1,5 @@
1
- import er from "./content-cards-provider-factory.js";
1
+ import ir from "./content-cards-provider-factory.js";
2
2
  import r from "../managers/braze-instance.js";
3
3
  export function getCachedContentCards() {
4
- if (r.rr()) return er.o().qi(!1);
4
+ if (r.rr()) return ir.o().qi(!1);
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import er from "./content-cards-provider-factory.js";
2
+ import ir from "./content-cards-provider-factory.js";
3
3
  export function requestContentCardsRefresh(e, t) {
4
- if (r.rr()) return er.o().lr(e, t, !0);
4
+ if (r.rr()) return ir.o().lr(e, t, "client");
5
5
  }
@@ -1,16 +1,16 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import er from "./content-cards-provider-factory.js";
3
- export function subscribeToContentCardsUpdates(o) {
2
+ import ir from "./content-cards-provider-factory.js";
3
+ export function subscribeToContentCardsUpdates(t) {
4
4
  if (!r.rr()) return;
5
- const t = er.o(),
6
- n = t.zt(o);
7
- if (!t.Lt()) {
8
- const o = r.nn();
9
- if (o) {
10
- const r = o.rn(() => {
11
- t.lr(void 0, void 0, !0);
5
+ const o = ir.o(),
6
+ n = o.zt(t);
7
+ if (!o.Lt()) {
8
+ const t = r.nn();
9
+ if (t) {
10
+ const r = t.rn(() => {
11
+ o.lr(void 0, void 0, "client");
12
12
  });
13
- r && t.$t(r);
13
+ r && o.$t(r);
14
14
  }
15
15
  }
16
16
  return n;
@@ -1,6 +1,6 @@
1
1
  import r, { OPTIONS as U } from "../../managers/braze-instance.js";
2
2
  import { ContentCards, subscribeToContentCardsUpdates } from "../index.js";
3
- import er from "../content-cards-provider-factory.js";
3
+ import ir from "../content-cards-provider-factory.js";
4
4
  import { setCardHeight as tn } from "../../Card/display/card-display.js";
5
5
  import { logger as E } from "../../../shared-lib/index.js";
6
6
  import {
@@ -19,10 +19,10 @@ export function showContentCards(n, t) {
19
19
  let e = !1;
20
20
  null == n && ((n = document.body), (e = !0));
21
21
  const o = r.er(U.tn) || !1,
22
- s = er.o().qi(!1);
22
+ s = ir.o().qi(!1);
23
23
  "function" == typeof t && cn(s, t(s.cards.slice()), s.lastUpdated, null, o);
24
24
  const a = on(s, o, e),
25
- i = er.o(),
25
+ i = ir.o(),
26
26
  c = i.fi();
27
27
  (null == s.lastUpdated ||
28
28
  new Date().valueOf() - s.lastUpdated.valueOf() > ContentCards.mr) &&
@@ -1,5 +1,5 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import { getByteLength as ir } from "../util/string-utils.js";
2
+ import { getByteLength as er } from "../util/string-utils.js";
3
3
  import { logger as E } from "../../shared-lib/index.js";
4
4
  import { User } from "../User/index.js";
5
5
  import { validateStandardString as tr } from "../util/validation-utils.js";
@@ -7,7 +7,7 @@ export function changeUser(e, i) {
7
7
  if (!r.rr()) return;
8
8
  if (null == e || 0 === e.length || e != e)
9
9
  return void E.error("changeUser requires a non-empty userId.");
10
- if (ir(e) > User.br)
10
+ if (er(e) > User.br)
11
11
  return void E.error(
12
12
  `Rejected user id "${e}" because it is longer than ${User.br} bytes.`,
13
13
  );
package/src/Core/index.js CHANGED
@@ -11,6 +11,7 @@ export { initialize } from "./initialize.js";
11
11
  export { isDisabled } from "./is-disabled.js";
12
12
  export { isInitialized } from "./is-initialized.js";
13
13
  export { logCustomEvent } from "./log-custom-event.js";
14
+ export { logEcommerceEvent } from "./log-ecommerce-event.js";
14
15
  export { logPurchase } from "./log-purchase.js";
15
16
  export { openSession } from "./open-session.js";
16
17
  export { removeAllSubscriptions } from "./remove-all-subscriptions.js";
@@ -0,0 +1,29 @@
1
+ import { EventTypes as p, logger as E } from "../../shared-lib/index.js";
2
+ import v from "../common/event-logger.js";
3
+ import r from "../managers/braze-instance.js";
4
+ import ot from "../triggers/models/trigger-events.js";
5
+ import { TriggersProviderFactory as rt } from "../triggers/triggers-provider-factory.js";
6
+ import { sanitizeEcommerceEvent as re } from "../util/ecommerce-event-validation.js";
7
+ export function logEcommerceEvent(e) {
8
+ if (!r.rr()) return !1;
9
+ if (null == e || "object" != typeof e || null == e.name)
10
+ return (
11
+ E.error(
12
+ 'logEcommerceEvent requires an event object with a "name" field.',
13
+ ),
14
+ !1
15
+ );
16
+ const o = re(e);
17
+ if (null == o) return !1;
18
+ const t = r.l();
19
+ if (t && t.$e(e.name))
20
+ return (
21
+ E.info(`The eCommerce event "${e.name}" is blocklisted, ignoring.`), !1
22
+ );
23
+ const n = v.wt(p.CustomEvent, { n: e.name, p: o });
24
+ if (n.lt) {
25
+ E.info(`Logged eCommerce event "${e.name}".`);
26
+ for (const r of n.Ce) rt.o().Ee(ot.he, [e.name, e.properties], r);
27
+ }
28
+ return n.lt;
29
+ }