@braze/web-sdk 5.6.1 → 5.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 (137) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +15 -5
  3. package/package.json +1 -1
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +23 -23
  6. package/shared-lib/indexed-db-adapter.js +20 -20
  7. package/shared-lib/logger.js +2 -2
  8. package/shared-lib/supported-options.js +17 -17
  9. package/src/Banner/banner-provider.js +53 -50
  10. package/src/Banner/banner.js +1 -1
  11. package/src/Banner/get-all-banners.js +3 -4
  12. package/src/Banner/get-banner.js +11 -11
  13. package/src/Banner/log-banner-click.js +1 -1
  14. package/src/Banner/log-banner-impressions.js +4 -4
  15. package/src/Banner/request-banners-refresh.js +21 -13
  16. package/src/Banner/subscribe-to-banners-updates.js +14 -13
  17. package/src/Banner/ui/insert-banner.js +11 -9
  18. package/src/Card/card-manager.js +10 -10
  19. package/src/Card/log-card-impressions.js +2 -2
  20. package/src/Card/models/captioned-image.js +1 -1
  21. package/src/Card/models/card.js +3 -3
  22. package/src/Card/models/classic-card.js +1 -1
  23. package/src/Card/models/control-card.js +1 -1
  24. package/src/Card/models/image-only.js +1 -1
  25. package/src/ContentCards/content-cards-provider-factory.js +1 -1
  26. package/src/ContentCards/content-cards-provider.js +139 -180
  27. package/src/ContentCards/content-cards.js +3 -3
  28. package/src/ContentCards/get-cached-content-cards.js +1 -1
  29. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  30. package/src/ContentCards/subscribe-to-content-cards-updates.js +10 -10
  31. package/src/ContentCards/ui/show-content-cards.js +8 -8
  32. package/src/Core/add-sdk-metadata.js +2 -2
  33. package/src/Core/change-user.js +3 -3
  34. package/src/Core/disable-sdk.js +7 -7
  35. package/src/Core/enable-sdk.js +5 -5
  36. package/src/Core/get-device-id.js +2 -2
  37. package/src/Core/get-user.js +1 -1
  38. package/src/Core/is-disabled.js +1 -1
  39. package/src/Core/log-custom-event.js +3 -3
  40. package/src/Core/log-purchase.js +1 -1
  41. package/src/Core/open-session.js +9 -9
  42. package/src/Core/wipe-data.js +5 -5
  43. package/src/FeatureFlags/feature-flag-factory.js +4 -4
  44. package/src/FeatureFlags/feature-flag.js +18 -18
  45. package/src/FeatureFlags/feature-flags-provider.js +81 -78
  46. package/src/FeatureFlags/get-all-feature-flags.js +6 -7
  47. package/src/FeatureFlags/get-feature-flag.js +5 -6
  48. package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
  49. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  50. package/src/Feed/feed-provider.js +34 -34
  51. package/src/Feed/feed.js +2 -2
  52. package/src/Feed/get-cached-feed.js +1 -1
  53. package/src/Feed/request-feed-refresh.js +1 -1
  54. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  55. package/src/Feed/ui/show-feed.js +5 -5
  56. package/src/InAppMessage/defer-in-app-message.js +1 -1
  57. package/src/InAppMessage/display/html-message-to-html.js +10 -10
  58. package/src/InAppMessage/display/in-app-message-to-html.js +21 -21
  59. package/src/InAppMessage/display/modal-utils.js +6 -6
  60. package/src/InAppMessage/in-app-message-factory.js +4 -4
  61. package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
  62. package/src/InAppMessage/in-app-message-manager.js +115 -91
  63. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  64. package/src/InAppMessage/log-in-app-message-click.js +3 -3
  65. package/src/InAppMessage/log-in-app-message-html-click.js +4 -4
  66. package/src/InAppMessage/log-in-app-message-impression.js +2 -2
  67. package/src/InAppMessage/models/control-message.js +1 -1
  68. package/src/InAppMessage/models/full-screen-message.js +5 -5
  69. package/src/InAppMessage/models/html-message.js +10 -10
  70. package/src/InAppMessage/models/in-app-message-button.js +5 -5
  71. package/src/InAppMessage/models/in-app-message.js +42 -42
  72. package/src/InAppMessage/models/modal-message.js +5 -5
  73. package/src/InAppMessage/models/slide-up-message.js +8 -8
  74. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  75. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  76. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  77. package/src/InAppMessage/ui/show-in-app-message.js +24 -24
  78. package/src/Push/is-push-blocked.js +2 -2
  79. package/src/Push/is-push-permission-granted.js +2 -2
  80. package/src/Push/is-push-supported.js +2 -2
  81. package/src/Push/push-manager-factory.js +8 -8
  82. package/src/Push/push-manager.js +90 -90
  83. package/src/Push/utils/push-utils.js +12 -12
  84. package/src/User/user-manager.js +12 -12
  85. package/src/User/user.js +48 -36
  86. package/src/common/base-feed.js +3 -3
  87. package/src/common/constants.js +1 -1
  88. package/src/common/event-logger.js +4 -4
  89. package/src/common/feed-display.js +14 -14
  90. package/src/l10n/l10n-manager-factory.js +2 -2
  91. package/src/l10n/l10n-manager.js +1 -1
  92. package/src/managers/auth-manager.js +10 -10
  93. package/src/managers/braze-instance.js +128 -128
  94. package/src/managers/device-manager.js +18 -18
  95. package/src/managers/network-manager.js +184 -147
  96. package/src/managers/server-config-manager.js +63 -63
  97. package/src/managers/session-manager.js +27 -27
  98. package/src/managers/storage-manager-factory.js +10 -10
  99. package/src/managers/storage-manager.js +146 -146
  100. package/src/managers/subscription-manager.js +8 -8
  101. package/src/managers/utils.js +1 -1
  102. package/src/models/backend-errors.js +4 -4
  103. package/src/models/braze-event.js +8 -8
  104. package/src/models/device.js +2 -2
  105. package/src/models/identifier.js +12 -12
  106. package/src/models/push-token.js +8 -8
  107. package/src/models/server-config.js +31 -31
  108. package/src/request-controller.js +163 -151
  109. package/src/triggers/models/custom-event-data.js +5 -5
  110. package/src/triggers/models/custom-event-property-data.js +6 -6
  111. package/src/triggers/models/filter-set.js +8 -8
  112. package/src/triggers/models/filter.js +16 -16
  113. package/src/triggers/models/in-app-message-click-data.js +2 -2
  114. package/src/triggers/models/purchase-data.js +2 -2
  115. package/src/triggers/models/purchase-property-data.js +4 -4
  116. package/src/triggers/models/push-click-data.js +2 -2
  117. package/src/triggers/models/trigger-condition.js +37 -37
  118. package/src/triggers/models/trigger-events.js +2 -2
  119. package/src/triggers/models/trigger.js +11 -11
  120. package/src/triggers/triggers-provider-factory.js +3 -3
  121. package/src/triggers/triggers-provider.js +39 -39
  122. package/src/ui/js/attach-css.js +3 -3
  123. package/src/ui/js/iam-css.js +1 -1
  124. package/src/ui/js/load-font-awesome.js +2 -2
  125. package/src/util/base-device-parser.js +3 -3
  126. package/src/util/braze-actions.js +4 -4
  127. package/src/util/browser-detector.js +6 -6
  128. package/src/util/client-hints-parser.js +1 -1
  129. package/src/util/component-utils.js +2 -2
  130. package/src/util/dom-utils.js +6 -6
  131. package/src/util/html-display-utils.js +1 -0
  132. package/src/util/key-codes.js +1 -1
  133. package/src/util/net.js +22 -23
  134. package/src/util/request-header-utils.js +25 -22
  135. package/src/util/user-agent-parser.js +1 -1
  136. package/src/util/validation-utils.js +17 -17
  137. package/src/util/window-utils.js +2 -2
package/README.md CHANGED
@@ -8,5 +8,5 @@ Note: The Braze Web SDK is meant to be used client-side in a web application and
8
8
 
9
9
  See the [Public Github Repo](https://github.com/braze-inc/braze-web-sdk#readme) for getting started instructions or [our documentation pages](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/initial_sdk_setup/) for use-case based documentation.
10
10
 
11
- (c) Braze, Inc. 2024 - http://braze.com
11
+ (c) Braze, Inc. 2025 - http://braze.com
12
12
  License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * Type definitions for @braze/web-sdk v5.6.1
2
+ * Type definitions for @braze/web-sdk v5.8.0
3
3
  * Project: https://github.com/braze-inc/braze-web-sdk
4
- * (c) Braze, Inc. 2024 - http://braze.com
4
+ * (c) Braze, Inc. 2025 - http://braze.com
5
5
  * License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
6
6
  */
7
7
 
@@ -1442,6 +1442,16 @@ export class User {
1442
1442
  setPushNotificationSubscriptionType(
1443
1443
  notificationSubscriptionType: NotificationSubscriptionTypes,
1444
1444
  ): boolean;
1445
+
1446
+ /**
1447
+ * Sets the LINE user ID for the user.
1448
+ *
1449
+ * @param lineId - Must be a non-empty string no greater than 33 characters in length.
1450
+ * Accepts an explicit null value to null out attribute.
1451
+ *
1452
+ * @returns Whether the update was successfully enqueued.
1453
+ */
1454
+ setLineId(lineId: string | null): boolean;
1445
1455
  }
1446
1456
 
1447
1457
  export class InAppMessageButton {
@@ -2152,7 +2162,7 @@ export function openSession(): void;
2152
2162
  * - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
2153
2163
  *
2154
2164
  * ```
2155
- * self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.6/service-worker.js');
2165
+ * self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.8/service-worker.js');
2156
2166
  * ```
2157
2167
  *
2158
2168
  * For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
@@ -2465,7 +2475,7 @@ export function getBanner(placementId: string): Banner | null | undefined;
2465
2475
  * @param banner - The `Banner` to insert onto the page.
2466
2476
  * @param parentNode - The HTML element to render the banner into.
2467
2477
  */
2468
- export function insertBanner(banner: Banner, parentNode: HTMLElement): void;
2478
+ export function insertBanner(banner: Banner | null | undefined, parentNode: HTMLElement): void;
2469
2479
 
2470
2480
  /**
2471
2481
  * Logs that the user clicked the given banner. This should generally be called through the Braze JavaScript bridge
@@ -2620,7 +2630,7 @@ export type InitializationOptions = {
2620
2630
  * lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
2621
2631
  * option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
2622
2632
  * `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
2623
- * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.6/service-worker.js');` or by including the content
2633
+ * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.8/service-worker.js');` or by including the content
2624
2634
  * of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
2625
2635
  */
2626
2636
  manageServiceWorkerExternally?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braze/web-sdk",
3
- "version": "5.6.1",
3
+ "version": "5.8.0",
4
4
  "description": "Braze SDK for web sites and other JS platforms.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  const ei = {
2
- Jn: function (t) {
2
+ Cn: function (t) {
3
3
  const r = (t + "=".repeat((4 - (t.length % 4)) % 4))
4
4
  .replace(/\-/g, "+")
5
5
  .replace(/_/g, "/"),
@@ -1,36 +1,36 @@
1
1
  const d = {
2
2
  CustomEvent: "ce",
3
3
  Pr: "p",
4
- mc: "pc",
5
- Cc: "ca",
6
- Mu: "i",
7
- Li: "ie",
4
+ gc: "pc",
5
+ Ac: "ca",
6
+ zu: "i",
7
+ Du: "ie",
8
8
  xt: "cci",
9
9
  $t: "ccic",
10
10
  lt: "ccc",
11
11
  dt: "ccd",
12
- Jl: "ss",
13
- Gl: "se",
14
- Nr: "si",
15
- Cr: "sc",
16
- Or: "sbc",
17
- yc: "sfe",
18
- zo: "iec",
19
- dc: "lr",
20
- cc: "uae",
12
+ Il: "ss",
13
+ Dl: "se",
14
+ Ir: "si",
15
+ Mr: "sc",
16
+ Tr: "sbc",
17
+ Mc: "sfe",
18
+ qo: "iec",
19
+ fc: "lr",
20
+ mc: "uae",
21
21
  yt: "ci",
22
22
  ut: "cc",
23
- vc: "lcaa",
24
- gc: "lcar",
25
- fu: "inc",
26
- pu: "add",
27
- bu: "rem",
28
- au: "set",
29
- du: "ncam",
30
- bc: "sgu",
23
+ wc: "lcaa",
24
+ bc: "lcar",
25
+ Jn: "inc",
26
+ Mn: "add",
27
+ Yn: "rem",
28
+ Hn: "set",
29
+ Kn: "ncam",
30
+ kc: "sgu",
31
31
  yr: "ffi",
32
32
  ro: "bi",
33
- fs: "bc",
33
+ ds: "bc",
34
34
  },
35
- dr = { Fr: "feed_displayed", Mc: "content_cards_displayed" };
35
+ dr = { Fr: "feed_displayed", Sc: "content_cards_displayed" };
36
36
  export { d as EventTypes, dr as InternalEventTypes };
@@ -1,4 +1,4 @@
1
- export default class it {
1
+ export default class tt {
2
2
  constructor(t, e) {
3
3
  (this.database = t),
4
4
  (this.vd = e),
@@ -64,11 +64,11 @@ export default class it {
64
64
  "...",
65
65
  );
66
66
  const n = null === (e = t.target) || void 0 === e ? void 0 : e.result;
67
- for (const t in i.database.Os) {
67
+ for (const t in i.database.Ks) {
68
68
  const e = t;
69
- i.database.Os.hasOwnProperty(t) &&
70
- !n.objectStoreNames.contains(i.database.Os[e]) &&
71
- n.createObjectStore(i.database.Os[e]);
69
+ i.database.Ks.hasOwnProperty(t) &&
70
+ !n.objectStoreNames.contains(i.database.Ks[e]) &&
71
+ n.createObjectStore(i.database.Ks[e]);
72
72
  }
73
73
  }),
74
74
  (o.onsuccess = (n) => {
@@ -180,7 +180,7 @@ export default class it {
180
180
  });
181
181
  });
182
182
  }
183
- jr(t, e, n) {
183
+ cr(t, e, n) {
184
184
  if (!this.isSupported()) return "function" == typeof n && n(), !1;
185
185
  const o = this;
186
186
  return this.Bd((i) => {
@@ -249,7 +249,7 @@ export default class it {
249
249
  };
250
250
  });
251
251
  }
252
- Hs(t, e) {
252
+ Gs(t, e) {
253
253
  if (!this.isSupported()) return !1;
254
254
  const n = this;
255
255
  return this.Bd((o) => {
@@ -304,11 +304,11 @@ export default class it {
304
304
  clearData() {
305
305
  if (!this.isSupported()) return !1;
306
306
  const t = [];
307
- for (const e in this.database.Os) {
307
+ for (const e in this.database.Ks) {
308
308
  const n = e;
309
- this.database.Os.hasOwnProperty(e) &&
310
- this.database.Os[n] !== this.database.Os.ie &&
311
- t.push(this.database.Os[n]);
309
+ this.database.Ks.hasOwnProperty(e) &&
310
+ this.database.Ks[n] !== this.database.Ks.oe &&
311
+ t.push(this.database.Ks[n]);
312
312
  }
313
313
  const e = this;
314
314
  return this.Bd(function (n) {
@@ -333,20 +333,20 @@ export default class it {
333
333
  });
334
334
  }
335
335
  }
336
- it.Gs = {
337
- _s: {
336
+ tt._s = {
337
+ Xs: {
338
338
  Sd: "AppboyServiceWorkerAsyncStorage",
339
339
  VERSION: 6,
340
- Os: {
341
- Xu: "data",
342
- hr: "pushClicks",
340
+ Ks: {
341
+ Su: "data",
342
+ jr: "pushClicks",
343
343
  cu: "pushSubscribed",
344
344
  Cd: "fallbackDevice",
345
- Ks: "cardUpdates",
346
- ie: "optOut",
347
- $r: "pendingData",
345
+ Hs: "cardUpdates",
346
+ oe: "optOut",
347
+ kr: "pendingData",
348
348
  yh: "sdkAuthenticationSignature",
349
349
  },
350
- oe: 1,
350
+ te: 1,
351
351
  },
352
352
  };
@@ -24,13 +24,13 @@ const N = {
24
24
  },
25
25
  warn: function (n) {
26
26
  if (N.zg) {
27
- const o = "Braze SDK Warning: " + n + " (v5.6.1)";
27
+ const o = "Braze SDK Warning: " + n + " (v5.8.0)";
28
28
  null != N.vd ? N.vd(o) : console.warn(o);
29
29
  }
30
30
  },
31
31
  error: function (n) {
32
32
  if (N.zg) {
33
- const o = "Braze SDK Error: " + n + " (v5.6.1)";
33
+ const o = "Braze SDK Error: " + n + " (v5.8.0)";
34
34
  null != N.vd ? N.vd(o) : console.error(o);
35
35
  }
36
36
  },
@@ -1,28 +1,28 @@
1
1
  export default {
2
- Oo: "allowCrawlerActivity",
3
- Ro: "baseUrl",
4
- Lo: "noCookies",
5
- Wo: "devicePropertyAllowlist",
2
+ Wo: "allowCrawlerActivity",
3
+ Vo: "baseUrl",
4
+ Ko: "noCookies",
5
+ Yo: "devicePropertyAllowlist",
6
6
  Da: "disablePushTokenMaintenance",
7
- Vo: "enableLogging",
8
- Ko: "enableSdkAuthentication",
7
+ Xo: "enableLogging",
8
+ Zo: "enableSdkAuthentication",
9
9
  Ca: "manageServiceWorkerExternally",
10
- Go: "minimumIntervalBetweenTriggerActionsInSeconds",
11
- Yo: "sessionTimeoutInSeconds",
12
- Ho: "appVersion",
13
- Xo: "appVersionNumber",
10
+ Qo: "minimumIntervalBetweenTriggerActionsInSeconds",
11
+ Wh: "sessionTimeoutInSeconds",
12
+ Vh: "appVersion",
13
+ $h: "appVersionNumber",
14
14
  _a: "serviceWorkerLocation",
15
15
  Ba: "safariWebsitePushId",
16
16
  Ea: "localization",
17
- ir: "contentSecurityNonce",
18
- er: "allowUserSuppliedJavascript",
19
- Jo: "inAppMessageZIndex",
20
- Do: "openInAppMessagesInNewTab",
17
+ er: "contentSecurityNonce",
18
+ re: "allowUserSuppliedJavascript",
19
+ To: "inAppMessageZIndex",
20
+ Fo: "openInAppMessagesInNewTab",
21
21
  en: "openNewsFeedCardsInNewTab",
22
22
  mh: "requireExplicitInAppMessageDismissal",
23
- Zo: "doNotLoadFontAwesome",
24
- Qo: "deviceId",
23
+ Yh: "doNotLoadFontAwesome",
24
+ Xh: "deviceId",
25
25
  Aa: "serviceWorkerScope",
26
- Wh: "sdkFlavor",
26
+ Zh: "sdkFlavor",
27
27
  tn: "openCardsInNewTab",
28
28
  };
@@ -68,33 +68,40 @@ export default class e extends s {
68
68
  let m = !1;
69
69
  o.V(
70
70
  u,
71
- (n = -1) => {
72
- if (!this.S) return void r();
71
+ (e = -1) => {
72
+ const n = this.S;
73
+ if (!n) return void r();
73
74
  const o = new Date().valueOf();
74
75
  h.W(this.C, h.O.K, o),
75
- -1 !== n && d.push(["X-Braze-Req-Tokens-Remaining", n.toString()]),
76
+ -1 !== e && d.push(["X-Braze-Req-Tokens-Remaining", e.toString()]),
76
77
  l.Y({
77
- url: `${this.S.Z()}/banners/sync`,
78
+ url: `${n.Z()}/banners/sync`,
78
79
  headers: d,
79
80
  data: u,
80
81
  ss: (s) => {
81
- if (!this.S.ts(u, s, d)) return (m = !0), void r();
82
- this.S.es(),
83
- this.U(s),
84
- (m = !1),
85
- h.ns(this.C, h.O.K, 1),
86
- "function" == typeof t && t();
82
+ if (!n.ts(u, s, d)) return (m = !0), void r();
83
+ n.es(), this.U(s), (m = !1), "function" == typeof t && t();
87
84
  },
88
85
  error: (s) => {
89
- this.S.rs(s, "retrieving banners"), (m = !0), r();
86
+ n.ns(s, "retrieving banners"), (m = !0), r();
90
87
  },
91
- os: () => {
92
- if (((this.D = s), e && m && !this.q)) {
93
- h.hs(this.C, h.O.K);
94
- let e = this.I;
95
- (null == e || e < 1e3 * this.R) && (e = 1e3 * this.R),
96
- this.ls(s, t, i, Math.min(3e5, a(1e3 * this.R, 3 * e)));
88
+ rs: (e, r) => {
89
+ let o;
90
+ if (((this.D = s), m)) {
91
+ let s = this.I;
92
+ (null == s || s < 1e3 * this.R) && (s = 1e3 * this.R),
93
+ (o = Math.min(3e5, a(1e3 * this.R, 3 * s)));
97
94
  }
95
+ n.os(
96
+ r,
97
+ () => {
98
+ this.$(s, t, i, !1);
99
+ },
100
+ h.O.K,
101
+ (s) => this.hs(s),
102
+ () => this.G(),
103
+ o,
104
+ );
98
105
  },
99
106
  });
100
107
  },
@@ -102,27 +109,23 @@ export default class e extends s {
102
109
  i,
103
110
  );
104
111
  }
105
- us() {
112
+ ls() {
106
113
  return this.D;
107
114
  }
108
- cs(s, t) {
115
+ us(s, t) {
109
116
  const i = { id: s.id };
110
117
  t && (i.bid = t);
111
- return c.ds(d.fs, i).ss;
118
+ return c.cs(d.ds, i).ss;
112
119
  }
113
120
  G() {
114
121
  null != this.q && (clearTimeout(this.q), (this.q = null));
115
122
  }
116
- ls(s, t, i, e = 1e3 * this.R) {
117
- this.G(),
118
- (this.q = window.setTimeout(() => {
119
- this.$(s, t, i);
120
- }, e)),
121
- (this.I = e);
123
+ hs(s) {
124
+ this.G(), (this.q = s);
122
125
  }
123
- vs() {
126
+ fs() {
124
127
  let s = {};
125
- this.C && (s = this.C.ps(t.bs.gs));
128
+ this.C && (s = this.C.vs(t.gs.ps));
126
129
  const i = {};
127
130
  for (const t in s) {
128
131
  let e = null;
@@ -136,63 +139,63 @@ export default class e extends s {
136
139
  const i = {};
137
140
  for (const t in this.banners) {
138
141
  const e =
139
- (null === (s = this.banners[t]) || void 0 === s ? void 0 : s.Bs()) ||
142
+ (null === (s = this.banners[t]) || void 0 === s ? void 0 : s.bs()) ||
140
143
  null;
141
144
  i[t] = e;
142
145
  }
143
- this.C.js(t.bs.gs, i), this.ws();
146
+ this.C.Bs(t.gs.ps, i), this.js();
144
147
  }
145
- ws() {
148
+ js() {
146
149
  var s, i;
147
150
  null === (s = this.C) ||
148
151
  void 0 === s ||
149
- s.js(t.bs.ys, null === (i = this.T) || void 0 === i ? void 0 : i.Ss());
152
+ s.Bs(t.gs.ys, null === (i = this.T) || void 0 === i ? void 0 : i.Ss());
150
153
  }
151
- Cs() {
154
+ ws() {
152
155
  var s;
153
156
  return (
154
- (null === (s = this.C) || void 0 === s ? void 0 : s.ps(t.bs.ys)) || null
157
+ (null === (s = this.C) || void 0 === s ? void 0 : s.vs(t.gs.ys)) || null
155
158
  );
156
159
  }
157
- Ts() {
160
+ Cs() {
158
161
  return this.k;
159
162
  }
160
- Rs(s) {
163
+ Ts(s) {
161
164
  this.k = s;
162
165
  }
163
- Is() {
166
+ Rs() {
164
167
  var s;
165
168
  const t = null === (s = this.T) || void 0 === s ? void 0 : s.Ss(),
166
- i = this.Cs();
169
+ i = this.ws();
167
170
  return null != i && t === i;
168
171
  }
169
- qs() {
172
+ Is() {
170
173
  var s;
171
174
  const t = null === (s = this.T) || void 0 === s ? void 0 : s.Ss(),
172
- i = this.Cs();
175
+ i = this.ws();
173
176
  return null == i || t === i;
174
177
  }
175
- Fs(s) {
176
- return this.F.Ns(s);
178
+ qs(s) {
179
+ return this.F.Fs(s);
177
180
  }
178
- ks() {
181
+ Ns() {
179
182
  var s;
180
183
  return (
181
- (null === (s = this.C) || void 0 === s ? void 0 : s.ps(t.bs.xs)) || {}
184
+ (null === (s = this.C) || void 0 === s ? void 0 : s.vs(t.gs.ks)) || {}
182
185
  );
183
186
  }
184
- zs(s) {
185
- this.C && this.C.js(t.bs.xs, s);
187
+ xs(s) {
188
+ this.C && this.C.Bs(t.gs.ks, s);
186
189
  }
187
190
  changeUser() {
188
- this.Ds();
191
+ this.zs();
189
192
  }
190
193
  L() {
191
- return !!this.B && (!!this.B.Us() || (0 !== this.B.Es() && this.Ds(), !1));
194
+ return !!this.B && (!!this.B.Ds() || (0 !== this.B.Us() && this.zs(), !1));
192
195
  }
193
- Ds() {
196
+ zs() {
194
197
  (this.banners = {}),
195
- this.C && (this.C.Ls(t.bs.gs), this.C.Ls(t.bs.xs)),
198
+ this.C && (this.C.Es(t.gs.ps), this.C.Es(t.gs.ks)),
196
199
  this.F.X({});
197
200
  }
198
201
  }
@@ -17,7 +17,7 @@ export default class Banner {
17
17
  ht() {
18
18
  return this.isControl;
19
19
  }
20
- Bs() {
20
+ bs() {
21
21
  return {
22
22
  id: this.id,
23
23
  o: this.placementId,
@@ -1,13 +1,12 @@
1
- import { logger as N } from "../../shared-lib/index.js";
2
1
  import r from "../managers/braze-instance.js";
3
2
  import i from "./banner-provider-factory.js";
4
3
  import { getBannerIfNotExpired as v } from "./get-banner.js";
5
4
  export function getAllBanners() {
6
5
  if (!r.rr()) return;
7
6
  const n = {},
8
- e = r.v();
9
- if (e && !e.Us()) return N.info("Banners are not enabled."), n;
10
- const o = i.m().vs();
7
+ t = r.v();
8
+ if (t && !t.Ds()) return n;
9
+ const o = i.m().fs();
11
10
  for (const r in o) n[r] = v(o, r);
12
11
  return n;
13
12
  }
@@ -1,19 +1,19 @@
1
1
  import { logger as N } from "../../shared-lib/index.js";
2
2
  import r from "../managers/braze-instance.js";
3
3
  import i from "./banner-provider-factory.js";
4
- export function getBannerIfNotExpired(n, e) {
5
- const r = n[e];
6
- if (!r) return null;
7
- const t = r.it,
8
- a = new Date().valueOf();
9
- return -1 !== t && 1e3 * t < a
10
- ? (N.info(`Banner with ID: ${r.id} and placement ID: ${e} has expired.`),
4
+ export function getBannerIfNotExpired(n, r) {
5
+ const e = n[r];
6
+ if (!e) return null;
7
+ const t = e.it,
8
+ o = new Date().valueOf();
9
+ return -1 !== t && 1e3 * t < o
10
+ ? (N.info(`Banner with ID: ${e.id} and placement ID: ${r} has expired.`),
11
11
  null)
12
- : r;
12
+ : e;
13
13
  }
14
14
  export function getBanner(n) {
15
15
  if (!r.rr()) return;
16
- const e = r.v();
17
- if (e && !e.Us()) return N.info("Banners are not enabled."), null;
18
- return getBannerIfNotExpired(i.m().vs(), n);
16
+ const e = i.m();
17
+ if (!e.L()) return null;
18
+ return getBannerIfNotExpired(e.fs(), n);
19
19
  }
@@ -10,7 +10,7 @@ export function logBannerClick(n, o) {
10
10
  N.error("Banner argument to logBannerClick must be an Banner object."), !1
11
11
  );
12
12
  const e = i.m(),
13
- t = e.vs();
13
+ t = e.fs();
14
14
  return 0 === y(t).length
15
15
  ? (N.info("Not logging banner click. No banners exist."), !1)
16
16
  : t[n.placementId]
@@ -7,10 +7,10 @@ export function logBannerImpressions(o) {
7
7
  if (!r.rr()) return;
8
8
  if (!o || o.length <= 0) return !1;
9
9
  const n = i.m(),
10
- s = n.vs();
10
+ s = n.fs();
11
11
  if (0 === y(s).length)
12
12
  return N.info("Not logging banners impression. No banners exist."), !1;
13
- const e = n.ks(),
13
+ const e = n.Ns(),
14
14
  t = [];
15
15
  for (const r of o) {
16
16
  const o = s[r];
@@ -25,7 +25,7 @@ export function logBannerImpressions(o) {
25
25
  );
26
26
  }
27
27
  if (0 === t.length) return !1;
28
- n.zs(e);
28
+ n.xs(e);
29
29
  const a = { ids: t };
30
- return c.ds(d.ro, a).ss;
30
+ return c.cs(d.ro, a).ss;
31
31
  }
@@ -1,26 +1,34 @@
1
1
  import { logger as N } from "../../shared-lib/index.js";
2
2
  import { BRAZE_MUST_BE_INITIALIZED_ERROR as p } from "../common/constants.js";
3
- import r from "../managers/braze-instance.js";
4
- import { isArray as w } from "../util/code-utils.js";
3
+ import r, { OPTIONS as w } from "../managers/braze-instance.js";
4
+ import { isArray as z } from "../util/code-utils.js";
5
5
  import { isValidBannerPlacementId as D } from "../util/validation-utils.js";
6
6
  import i from "./banner-provider-factory.js";
7
- export function requestBannersRefresh(e, n, o) {
7
+ export function requestBannersRefresh(e, n, t) {
8
8
  if (!r.rr()) return void N.warn(p);
9
- const t = r.v();
10
- if (!t) return void N.warn(p);
11
- if (!t.Us()) return void N.info("Banners are not enabled.");
12
- if (!w(e) || 0 === e.length)
9
+ const s = r.v();
10
+ if (!s) return;
11
+ if (!z(e) || 0 === e.length)
13
12
  return void N.warn("placementIds should be a non-empty array.");
14
- if (i.m().Is())
13
+ if (!r.ee(w.re))
14
+ return void N.error(
15
+ "Banners are disabled. Use the 'allowUserSuppliedJavascript' option for braze.initialize to enable these messages.",
16
+ );
17
+ const o = i.m();
18
+ if (i.m().Rs())
15
19
  return void N.warn(
16
20
  "Banners can be refreshed only once per session per user.",
17
21
  );
18
- const s = t.ee();
19
- e.length > s &&
22
+ if (!s || !o.L())
23
+ return void s.A(() => {
24
+ requestBannersRefresh(e, n, t);
25
+ });
26
+ const a = s.ne();
27
+ e.length > a &&
20
28
  (N.warn(
21
- `Number of placement IDs requested exceeds the max allowed. Trimming placementIds array from length ${e.length} to ${s} (max allowed).`,
29
+ `Number of placement IDs requested exceeds the max allowed. Trimming placementIds array from length ${e.length} to ${a} (max allowed).`,
22
30
  ),
23
- (e = e.slice(0, s))),
31
+ (e = e.slice(0, a))),
24
32
  0 !==
25
33
  (e = e.filter(
26
34
  (e) =>
@@ -31,5 +39,5 @@ export function requestBannersRefresh(e, n, o) {
31
39
  !1),
32
40
  )).length &&
33
41
  (N.info(`Requesting banners for placement IDs: ${JSON.stringify(e)}`),
34
- i.m().$(e, n, o));
42
+ i.m().$(e, n, t));
35
43
  }
@@ -2,22 +2,23 @@ import r from "../managers/braze-instance.js";
2
2
  import i from "./banner-provider-factory.js";
3
3
  import { getAllBanners } from "./get-all-banners.js";
4
4
  export function subscribeToBannersUpdates(n) {
5
+ var o;
5
6
  if (!r.rr()) return;
6
- const o = i.m();
7
- if (o.qs()) {
7
+ const t = i.m();
8
+ if (t.Is()) {
8
9
  const r = getAllBanners();
9
10
  r && "function" == typeof n && n(r);
10
11
  }
11
- const t = o.Fs(n);
12
- if (!o.Ts()) {
13
- const n = r.nn();
14
- if (n) {
15
- const r = n.rn(() => {
16
- const n = o.us();
17
- n && n.length > 0 && o.$(n);
18
- });
19
- r && o.Rs(r);
20
- }
12
+ const s = t.qs(n);
13
+ if (!t.Cs()) {
14
+ const n =
15
+ null === (o = r.nn()) || void 0 === o
16
+ ? void 0
17
+ : o.rn(() => {
18
+ const n = t.ls();
19
+ n && n.length > 0 && t.$(n);
20
+ });
21
+ n && t.Ts(n);
21
22
  }
22
- return t;
23
+ return s;
23
24
  }