@braze/web-sdk 5.9.1 → 6.0.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 (159) hide show
  1. package/index.d.ts +109 -253
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +1 -1
  4. package/shared-lib/event-types.js +24 -26
  5. package/shared-lib/guid.js +2 -2
  6. package/shared-lib/indexed-db-adapter.js +19 -19
  7. package/shared-lib/logger.js +2 -2
  8. package/shared-lib/supported-options.js +21 -22
  9. package/src/Banner/display/banner-to-html.js +13 -25
  10. package/src/Banner/display/destroy-banner-html.js +2 -2
  11. package/src/Banner/display/detect-banner-impressions.js +11 -11
  12. package/src/Banner/index.js +0 -1
  13. package/src/Banner/request-banners-refresh.js +8 -8
  14. package/src/Banner/subscribe-to-banners-updates.js +2 -2
  15. package/src/Banner/ui/insert-banner.js +7 -7
  16. package/src/Card/card-manager.js +35 -37
  17. package/src/Card/display/card-display.js +76 -74
  18. package/src/Card/index.js +0 -2
  19. package/src/Card/log-card-dismissal.js +2 -2
  20. package/src/Card/log-content-card-click.js +9 -2
  21. package/src/Card/log-content-card-impressions.js +11 -2
  22. package/src/Card/models/captioned-image.js +20 -20
  23. package/src/Card/models/card.js +110 -104
  24. package/src/Card/models/classic-card.js +20 -20
  25. package/src/Card/models/control-card.js +14 -14
  26. package/src/Card/models/image-only.js +19 -20
  27. package/src/Card/util/card-factory.js +57 -78
  28. package/src/ContentCards/content-cards-provider-factory.js +10 -10
  29. package/src/ContentCards/content-cards-provider.js +109 -109
  30. package/src/ContentCards/content-cards.js +21 -13
  31. package/src/ContentCards/get-cached-content-cards.js +2 -2
  32. package/src/ContentCards/request-content-cards-refresh.js +2 -2
  33. package/src/ContentCards/subscribe-to-content-cards-updates.js +5 -5
  34. package/src/ContentCards/ui/hide-content-cards.js +5 -5
  35. package/src/ContentCards/ui/show-content-cards.js +34 -34
  36. package/src/Core/add-sdk-metadata.js +2 -2
  37. package/src/Core/change-user.js +7 -7
  38. package/src/Core/disable-sdk.js +6 -6
  39. package/src/Core/enable-sdk.js +5 -5
  40. package/src/Core/get-user.js +1 -1
  41. package/src/Core/handle-braze-action.js +7 -7
  42. package/src/Core/is-disabled.js +2 -2
  43. package/src/Core/is-initialized.js +1 -1
  44. package/src/Core/log-custom-event.js +9 -9
  45. package/src/Core/log-purchase.js +7 -7
  46. package/src/Core/open-session.js +12 -12
  47. package/src/Core/request-immediate-data-flush.js +1 -1
  48. package/src/Core/set-sdk-authentication-signature.js +2 -2
  49. package/src/Core/wipe-data.js +7 -7
  50. package/src/FeatureFlags/feature-flag-factory.js +7 -7
  51. package/src/FeatureFlags/feature-flag.js +6 -6
  52. package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
  53. package/src/FeatureFlags/feature-flags-provider.js +1 -1
  54. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  55. package/src/FeatureFlags/get-feature-flag.js +2 -2
  56. package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
  57. package/src/FeatureFlags/refresh-feature-flags.js +2 -2
  58. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  59. package/src/InAppMessage/defer-in-app-message.js +1 -1
  60. package/src/InAppMessage/display/html-message-to-html.js +37 -37
  61. package/src/InAppMessage/display/in-app-message-to-html.js +139 -133
  62. package/src/InAppMessage/display/modal-utils.js +39 -41
  63. package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
  64. package/src/InAppMessage/in-app-message-factory.js +22 -14
  65. package/src/InAppMessage/in-app-message-manager.js +90 -88
  66. package/src/InAppMessage/log-in-app-message-button-click.js +5 -5
  67. package/src/InAppMessage/log-in-app-message-click.js +5 -5
  68. package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
  69. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  70. package/src/InAppMessage/models/control-message.js +2 -2
  71. package/src/InAppMessage/models/full-screen-message.js +40 -34
  72. package/src/InAppMessage/models/html-message.js +23 -21
  73. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  74. package/src/InAppMessage/models/in-app-message.js +137 -133
  75. package/src/InAppMessage/models/modal-message.js +39 -33
  76. package/src/InAppMessage/models/slide-up-message.js +36 -30
  77. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  78. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  79. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  80. package/src/InAppMessage/ui/show-in-app-message.js +56 -62
  81. package/src/Push/is-push-blocked.js +2 -2
  82. package/src/Push/is-push-permission-granted.js +2 -2
  83. package/src/Push/is-push-supported.js +2 -2
  84. package/src/Push/push-manager-factory.js +8 -8
  85. package/src/Push/push-manager.js +90 -90
  86. package/src/Push/request-push-permission.js +1 -1
  87. package/src/Push/utils/push-utils.js +25 -15
  88. package/src/User/user-manager.js +14 -14
  89. package/src/User/user.js +55 -55
  90. package/src/common/content-cards-display.js +211 -0
  91. package/src/common/event-logger.js +6 -6
  92. package/src/index.js +0 -1
  93. package/src/l10n/l10n-manager-factory.js +9 -9
  94. package/src/l10n/l10n-manager.js +6 -6
  95. package/src/managers/auth-manager.js +27 -27
  96. package/src/managers/braze-instance.js +136 -137
  97. package/src/managers/device-manager.js +22 -22
  98. package/src/managers/network-manager.js +180 -183
  99. package/src/managers/server-config-manager.js +63 -63
  100. package/src/managers/session-manager.js +34 -34
  101. package/src/managers/storage-manager-factory.js +11 -11
  102. package/src/managers/storage-manager.js +139 -141
  103. package/src/managers/subscription-manager.js +3 -3
  104. package/src/managers/utils.js +1 -1
  105. package/src/models/backend-errors.js +5 -5
  106. package/src/models/braze-event.js +15 -15
  107. package/src/models/device.js +3 -3
  108. package/src/models/identifier.js +13 -13
  109. package/src/models/push-token.js +12 -12
  110. package/src/models/request-result.js +2 -2
  111. package/src/models/server-config.js +29 -29
  112. package/src/request-controller.js +175 -174
  113. package/src/triggers/models/custom-event-data.js +6 -6
  114. package/src/triggers/models/custom-event-property-data.js +7 -7
  115. package/src/triggers/models/filter-set.js +8 -8
  116. package/src/triggers/models/filter.js +45 -45
  117. package/src/triggers/models/in-app-message-click-data.js +3 -3
  118. package/src/triggers/models/purchase-data.js +1 -1
  119. package/src/triggers/models/purchase-property-data.js +4 -4
  120. package/src/triggers/models/push-click-data.js +1 -1
  121. package/src/triggers/models/trigger-condition.js +47 -47
  122. package/src/triggers/models/trigger-events.js +3 -3
  123. package/src/triggers/models/trigger.js +15 -15
  124. package/src/triggers/triggers-provider-factory.js +4 -4
  125. package/src/triggers/triggers-provider.js +44 -44
  126. package/src/ui/js/attach-css.js +3 -3
  127. package/src/ui/js/banner-css.js +1 -1
  128. package/src/ui/js/iam-css.js +1 -1
  129. package/src/ui/js/load-font-awesome.js +2 -2
  130. package/src/util/base-device-parser.js +4 -4
  131. package/src/util/braze-actions.js +8 -14
  132. package/src/util/browser-detector.js +12 -12
  133. package/src/util/client-hints-parser.js +3 -3
  134. package/src/util/component-utils.js +14 -14
  135. package/src/util/device-constants.js +1 -1
  136. package/src/util/dom-utils.js +6 -6
  137. package/src/util/html-display-utils.js +37 -37
  138. package/src/util/key-codes.js +1 -1
  139. package/src/util/net.js +1 -1
  140. package/src/util/request-header-utils.js +17 -17
  141. package/src/util/user-agent-parser.js +4 -4
  142. package/src/util/validation-utils.js +20 -20
  143. package/src/util/window-utils.js +1 -1
  144. package/src/Card/log-card-click.js +0 -11
  145. package/src/Card/log-card-impressions.js +0 -13
  146. package/src/Feed/feed-provider-factory.js +0 -18
  147. package/src/Feed/feed-provider.js +0 -90
  148. package/src/Feed/feed.js +0 -20
  149. package/src/Feed/get-cached-feed.js +0 -5
  150. package/src/Feed/index.js +0 -8
  151. package/src/Feed/log-feed-displayed.js +0 -7
  152. package/src/Feed/request-feed-refresh.js +0 -5
  153. package/src/Feed/subscribe-to-feed-updates.js +0 -5
  154. package/src/Feed/types.js +0 -1
  155. package/src/Feed/ui/hide-feed.js +0 -7
  156. package/src/Feed/ui/show-feed.js +0 -96
  157. package/src/Feed/ui/toggle-feed.js +0 -8
  158. package/src/common/base-feed.js +0 -29
  159. package/src/common/feed-display.js +0 -211
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Type definitions for @braze/web-sdk v5.9.1
2
+ * Type definitions for @braze/web-sdk v6.0.0
3
3
  * Project: https://github.com/braze-inc/braze-web-sdk
4
4
  * (c) Braze, Inc. 2025 - http://braze.com
5
5
  * License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
@@ -57,7 +57,7 @@ export class DeviceProperties {
57
57
  }
58
58
 
59
59
  /**
60
- * Abstract base for news feed and Content Cards cards. Use subclasses `ClassicCard`, `CaptionedImage`,
60
+ * Abstract base for Content Cards. Use subclasses `ClassicCard`, `CaptionedImage`,
61
61
  * `ImageOnly`, and `ControlCard`. For example, you can check `if (card instanceof ClassicCard)` to
62
62
  * determine if the card is of the type `ClassicCard`.
63
63
  */
@@ -132,61 +132,46 @@ export class Card {
132
132
 
133
133
  export class ImageOnly extends Card {
134
134
  /**
135
- * A card with only an image, which can be passed to `showFeed` or handled manually.
136
- * Subscribe to receive new cards via `subscribeToFeedUpdates`
135
+ * A card with only an image, which can be passed to `showContentCards` or handled manually.
136
+ * Subscribe to receive new cards via `subscribeToContentCardsUpdates`
137
137
  *
138
138
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
139
139
  * @param viewed - Whether this card has been shown to the user.
140
140
  * @param imageUrl - The url for this card's image.
141
- * @param created - When this card was created.
142
141
  * @param updated - When this card was last modified.
143
- * @param categories - Purely for organization in your custom implementation, these categories can be set in
144
- * the dashboard composer.
145
142
  * @param expiresAt - When this card expires and should stop being shown to the user.
146
143
  * @param url - A url to open when this card is clicked.
147
- * @param linkText - The display text for the url.
148
144
  * @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before
149
145
  * image loading completes. Note that the field may not be supplied in certain circumstances.
150
146
  * @param extras - Object of string/string key/value pairs.
151
147
  * @param pinned - Whether to pin this card to the top of the view.
152
148
  * @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
153
149
  * @param clicked - Whether this card has ever been clicked on this device.
150
+ * @param language - The language of the card in BCP 47 format. This field is set in the campaign on the Braze dashboard.
151
+ * @param altImageText - The alternate text of the card's image to be announced when in accessibility mode.
154
152
  */
155
153
  constructor(
156
154
  id?: string,
157
155
  viewed?: boolean,
158
156
  imageUrl?: string,
159
- created?: Date,
160
157
  updated?: Date,
161
- categories?: string[],
162
158
  expiresAt?: Date,
163
159
  url?: string,
164
- linkText?: string,
165
160
  aspectRatio?: number,
166
161
  extras?: Record<string, string>,
167
162
  pinned?: boolean,
168
163
  dismissible?: boolean,
169
164
  clicked?: boolean,
165
+ language?: string,
166
+ altImageText?: string,
170
167
  );
171
168
 
172
169
  /** The url for this card's image. */
173
170
  imageUrl?: string;
174
171
 
175
- /** When this card was created. */
176
- created: Date | null;
177
-
178
- /**
179
- * Purely for organization in your custom implementation, these categories can be set in
180
- * the dashboard composer.
181
- */
182
- categories: string[];
183
-
184
172
  /** A url to open when this card is clicked. */
185
173
  url?: string;
186
174
 
187
- /** The display text for the url. */
188
- linkText?: string;
189
-
190
175
  /**
191
176
  * The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes.
192
177
  * Note that the field may not be supplied in certain circumstances.
@@ -201,22 +186,25 @@ export class ImageOnly extends Card {
201
186
 
202
187
  /** Whether this card has ever been clicked on this device. */
203
188
  clicked: boolean;
189
+
190
+ /** The language of the card in BCP 47 format. This field is set in the campaign on the Braze dashboard. */
191
+ language?: string;
192
+
193
+ /** The alternate text of the card's image to be announced when in accessibility mode. */
194
+ altImageText?: string;
204
195
  }
205
196
 
206
197
  export class CaptionedImage extends Card {
207
198
  /**
208
- * A card with a large image and descriptive text, which can be passed to `showFeed` or handled manually.
209
- * Subscribe to receive new cards via `subscribeToFeedUpdates`.
199
+ * A card with a large image and descriptive text, which can be passed to `showContentCards` or handled manually.
200
+ * Subscribe to receive new cards via `subscribeToContentCardsUpdates`.
210
201
  *
211
202
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
212
203
  * @param viewed - Whether this card has been shown to the user.
213
204
  * @param title - The title text for this card.
214
205
  * @param imageUrl - The url for this card's image.
215
206
  * @param description - The body text for this card.
216
- * @param created - When this card was created.
217
207
  * @param updated - When this card was last modified.
218
- * @param categories - Purely for organization in your custom implementation, these categories can be set in
219
- * the dashboard composer.
220
208
  * @param expiresAt - When this card expires and should stop being shown to the user.
221
209
  * @param url - A url to open when this card is clicked.
222
210
  * @param linkText - The display text for the url.
@@ -226,6 +214,8 @@ export class CaptionedImage extends Card {
226
214
  * @param pinned - Whether to pin this card to the top of the view.
227
215
  * @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
228
216
  * @param clicked - Whether this card has ever been clicked on this device.
217
+ * @param language - The language of the card in BCP 47 format. This field is set in the campaign on the Braze dashboard.
218
+ * @param altImageText - The alternate text of the card's image to be announced when in accessibility mode.
229
219
  */
230
220
  constructor(
231
221
  id?: string,
@@ -233,9 +223,7 @@ export class CaptionedImage extends Card {
233
223
  title?: string,
234
224
  imageUrl?: string,
235
225
  description?: string,
236
- created?: Date,
237
226
  updated?: Date,
238
- categories?: string[],
239
227
  expiresAt?: Date,
240
228
  url?: string,
241
229
  linkText?: string,
@@ -244,6 +232,8 @@ export class CaptionedImage extends Card {
244
232
  pinned?: boolean,
245
233
  dismissible?: boolean,
246
234
  clicked?: boolean,
235
+ language?: string,
236
+ altImageText?: string,
247
237
  );
248
238
 
249
239
  /** The title text for this card. */
@@ -255,15 +245,6 @@ export class CaptionedImage extends Card {
255
245
  /** The body text for this card. */
256
246
  description: string;
257
247
 
258
- /** When this card was created. */
259
- created: Date | null;
260
-
261
- /**
262
- * Purely for organization in your custom implementation, these categories can be set in
263
- * the dashboard composer.
264
- */
265
- categories: string[];
266
-
267
248
  /** A url to open when this card is clicked. */
268
249
  url?: string;
269
250
 
@@ -284,23 +265,26 @@ export class CaptionedImage extends Card {
284
265
 
285
266
  /** Whether this card has ever been clicked on this device. */
286
267
  clicked: boolean;
268
+
269
+ /** The language of the card in BCP 47 format. This field is set in the campaign on the Braze dashboard. */
270
+ language?: string;
271
+
272
+ /** The alternate text of the card's image to be announced when in accessibility mode. */
273
+ altImageText?: string;
287
274
  }
288
275
 
289
276
  export class ClassicCard extends Card {
290
277
  /**
291
278
  * A card with a title, body, and optionally a small image, which can be passed to
292
- * `showFeed` or handled manually.
293
- * Subscribe to receive new cards via `subscribeToFeedUpdates`.
279
+ * `showContentCards` or handled manually.
280
+ * Subscribe to receive new cards via `subscribeToContentCardsUpdates`.
294
281
  *
295
282
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
296
283
  * @param viewed - Whether this card has been shown to the user.
297
284
  * @param title - The title text for this card.
298
285
  * @param imageUrl - The url for this card's image.
299
286
  * @param description - The body text for this card.
300
- * @param created - When this card was created.
301
287
  * @param updated - When this card was last modified.
302
- * @param categories - Purely for organization in your custom implementation, these categories can be set in
303
- * the dashboard composer.
304
288
  * @param expiresAt - When this card expires and should stop being shown to the user.
305
289
  * @param url - A url to open when this card is clicked.
306
290
  * @param linkText - The display text for the url.
@@ -310,6 +294,8 @@ export class ClassicCard extends Card {
310
294
  * @param pinned - Whether to pin this card to the top of the view.
311
295
  * @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
312
296
  * @param clicked - Whether this card has ever been clicked on this device.
297
+ * @param language - The language of the card in BCP 47 format. This field is set in the campaign on the Braze dashboard.
298
+ * @param altImageText - The alternate text of the card's image to be announced when in accessibility mode.
313
299
  */
314
300
  constructor(
315
301
  id?: string,
@@ -317,9 +303,7 @@ export class ClassicCard extends Card {
317
303
  title?: string,
318
304
  imageUrl?: string,
319
305
  description?: string,
320
- created?: Date,
321
306
  updated?: Date,
322
- categories?: string[],
323
307
  expiresAt?: Date,
324
308
  url?: string,
325
309
  linkText?: string,
@@ -328,6 +312,8 @@ export class ClassicCard extends Card {
328
312
  pinned?: boolean,
329
313
  dismissible?: boolean,
330
314
  clicked?: boolean,
315
+ language?: string,
316
+ altImageText?: string,
331
317
  );
332
318
 
333
319
  /** The title text for this card. */
@@ -339,15 +325,6 @@ export class ClassicCard extends Card {
339
325
  /** The body text for this card. */
340
326
  description: string;
341
327
 
342
- /** When this card was created. */
343
- created: Date | null;
344
-
345
- /**
346
- * Purely for organization in your custom implementation, these categories can be set in
347
- * the dashboard composer.
348
- */
349
- categories: string[];
350
-
351
328
  /** A url to open when this card is clicked. */
352
329
  url?: string;
353
330
 
@@ -368,14 +345,19 @@ export class ClassicCard extends Card {
368
345
 
369
346
  /** Whether this card has ever been clicked on this device. */
370
347
  clicked: boolean;
348
+
349
+ /** The language of the card in BCP 47 format. This field is set in the campaign on the Braze dashboard. */
350
+ language?: string;
351
+
352
+ /** The alternate text of the card's image to be announced when in accessibility mode. */
353
+ altImageText?: string;
371
354
  }
372
355
 
373
356
  export class ControlCard extends Card {
374
357
  /**
375
358
  * A card with no display that logs impressions, which can be passed to
376
- * `showFeed` or handled manually.
377
- * Not supported in legacy news feed.
378
- * Subscribe to receive new cards via `subscribeToFeedUpdates`.
359
+ * `showContentCards` or handled manually.
360
+ * Subscribe to receive new cards via `subscribeToContentCardsUpdates`.
379
361
  *
380
362
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
381
363
  * @param viewed - Whether this card has been shown to the user.
@@ -426,40 +408,6 @@ export class ContentCards {
426
408
  getUnviewedCardCount(): number;
427
409
  }
428
410
 
429
- export class Feed {
430
- /**
431
- * A collection of `Card` descendents (`ClassicCard`, `CaptionedImage`, `ImageOnly`).
432
- * Subscribe to receive feed updates via `subscribeToFeedUpdates`,
433
- * or get the currently cached feed with `getCachedFeed`.
434
- *
435
- * @param cards - Array of `Card` descendents (`ClassicCard`, `CaptionedImage`,
436
- * `ImageOnly`). Can be passed directly to `showFeed`.
437
- * @param lastUpdated - When this collection of cards was received from Braze servers. If null, it means the
438
- * feed has never been fetched for this user.
439
- */
440
- constructor(cards: Card[], lastUpdated: Date | null);
441
-
442
- /**
443
- * Array of `Card` descendents (`ClassicCard`, `CaptionedImage`, `ImageOnly`).
444
- * Can be passed directly to `showFeed`.
445
- */
446
- cards: Card[];
447
-
448
- /**
449
- * When this collection of cards was received from Braze servers. If null, it means the
450
- * content cards are still being fetched for this user.
451
- */
452
- lastUpdated: Date | null;
453
-
454
- /**
455
- * Get the current unread card count. This is useful for powering badges on your control for showing the news feed.
456
- * Note that Braze will not refresh news feed cards on new page loads (and so this function will return 0) until you
457
- * call `showFeed` or `requestFeedRefresh`. `ControlCard` cards do not count towards the
458
- * unread count.
459
- */
460
- getUnreadCardCount(): number;
461
- }
462
-
463
411
  export class ControlMessage {
464
412
  /**
465
413
  * A non-showing message placeholder that represents this user receiving the the control for a multivariate
@@ -528,7 +476,6 @@ export class InAppMessage {
528
476
  };
529
477
 
530
478
  static ClickAction: {
531
- NEWS_FEED: "NEWS_FEED";
532
479
  URI: "URI";
533
480
  NONE: "NONE";
534
481
  };
@@ -611,6 +558,9 @@ export class InAppMessage {
611
558
  */
612
559
  css?: string;
613
560
 
561
+ /** Object of string/string key/value pairs. */
562
+ messageExtras?: Record<string, string>;
563
+
614
564
  /** Whether this message is a ControlMessage. */
615
565
  isControl: false;
616
566
 
@@ -708,6 +658,9 @@ export class FullScreenMessage extends InAppMessage {
708
658
  * @param htmlId - The ID to give the parent HTML element that this message is rendered into.
709
659
  * @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
710
660
  * to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
661
+ * @param messageExtras - Object of string/string key/value pairs.
662
+ * @param language - The language of the message in BCP 47 format. This field is set in the campaign on the Braze dashboard.
663
+ * @param altImageText - The alternate text of the message's image to be announced when in accessibility mode.
711
664
  */
712
665
  constructor(
713
666
  message?: string,
@@ -738,6 +691,9 @@ export class FullScreenMessage extends InAppMessage {
738
691
  orientation?: Orientation,
739
692
  htmlId?: string,
740
693
  css?: string,
694
+ messageExtras?: Record<string, string>,
695
+ language?: string,
696
+ altImageText?: string,
741
697
  );
742
698
 
743
699
  /** How to align message text. See the `TextAlignment` enum. */
@@ -817,6 +773,15 @@ export class FullScreenMessage extends InAppMessage {
817
773
  * `Orientation` enum.
818
774
  */
819
775
  orientation: Orientation;
776
+
777
+ /** Object of string/string key/value pairs. */
778
+ messageExtras?: Record<string, string>;
779
+
780
+ /** The language of the message in BCP 47 format. This field is set in the campaign on the Braze dashboard. */
781
+ language?: string;
782
+
783
+ /** The alternate text of the message's image to be announced when in accessibility mode. */
784
+ altImageText?: string;
820
785
  }
821
786
 
822
787
  export class ModalMessage extends InAppMessage {
@@ -867,6 +832,8 @@ export class ModalMessage extends InAppMessage {
867
832
  * @param htmlId - The ID to give the parent HTML element that this message is rendered into.
868
833
  * @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
869
834
  * to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
835
+ * @param language - The language of the message in BCP 47 format. This field is set in the campaign on the Braze dashboard.
836
+ * @param altImageText - The alternate text of the message's image to be announced when in accessibility mode.
870
837
  */
871
838
  constructor(
872
839
  message?: string,
@@ -896,6 +863,9 @@ export class ModalMessage extends InAppMessage {
896
863
  cropType?: CropType,
897
864
  htmlId?: string,
898
865
  css?: string,
866
+ messageExtras?: Record<string, string>,
867
+ language?: string,
868
+ altImageText?: string,
899
869
  );
900
870
 
901
871
  /** How to align message text. See the `TextAlignment` enum. */
@@ -969,6 +939,15 @@ export class ModalMessage extends InAppMessage {
969
939
 
970
940
  /** How to crop and fit images in the allowable space. See the `CropType` enum. */
971
941
  cropType: CropType;
942
+
943
+ /** Object of string/string key/value pairs. */
944
+ messageExtras?: Record<string, string>;
945
+
946
+ /** The language of the message in BCP 47 format. This field is set in the campaign on the Braze dashboard. */
947
+ language?: string;
948
+
949
+ /** The alternate text of the message's image to be announced when in accessibility mode. */
950
+ altImageText?: string;
972
951
  }
973
952
 
974
953
  export class HtmlMessage extends InAppMessage {
@@ -991,6 +970,7 @@ export class HtmlMessage extends InAppMessage {
991
970
  * @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
992
971
  * to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
993
972
  * @param messageFields - Structured data provided by the Braze backend.
973
+ * @param messageExtras - Object of string/string key/value pairs.
994
974
  */
995
975
  constructor(
996
976
  message: string,
@@ -1004,6 +984,7 @@ export class HtmlMessage extends InAppMessage {
1004
984
  htmlId?: string,
1005
985
  css?: string,
1006
986
  messageFields?: Record<string, any>,
987
+ messageExtras?: Record<string, string>,
1007
988
  );
1008
989
 
1009
990
  /** Color of the background frame which blocks page interaction while the message is showing. */
@@ -1011,6 +992,9 @@ export class HtmlMessage extends InAppMessage {
1011
992
 
1012
993
  /** Structured data provided by the Braze backend. */
1013
994
  messageFields?: Record<string, any>;
995
+
996
+ /** Object of string/string key/value pairs. */
997
+ messageExtras?: Record<string, string>;
1014
998
  }
1015
999
 
1016
1000
  /**
@@ -1056,6 +1040,9 @@ export class SlideUpMessage extends InAppMessage {
1056
1040
  * @param htmlId - The ID to give the parent HTML element that this message is rendered into.
1057
1041
  * @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
1058
1042
  * to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
1043
+ * @param messageExtras - Object of string/string key/value pairs.
1044
+ * @param language - The language of the message in BCP 47 format. This field is set in the campaign on the Braze dashboard.
1045
+ * @param altImageText - The alternate text of the message's image to be announced when in accessibility mode.
1059
1046
  */
1060
1047
  constructor(
1061
1048
  message: string,
@@ -1079,6 +1066,9 @@ export class SlideUpMessage extends InAppMessage {
1079
1066
  animateOut?: boolean,
1080
1067
  htmlId?: string,
1081
1068
  css?: string,
1069
+ messageExtras?: Record<string, string>,
1070
+ language?: string,
1071
+ altImageText?: string,
1082
1072
  );
1083
1073
 
1084
1074
  /** How to align message text. See the `TextAlignment` enum. */
@@ -1131,6 +1121,15 @@ export class SlideUpMessage extends InAppMessage {
1131
1121
 
1132
1122
  /** Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
1133
1123
  closeButtonColor: number;
1124
+
1125
+ /** Object of string/string key/value pairs. */
1126
+ messageExtras?: Record<string, string>;
1127
+
1128
+ /** The language of the message in BCP 47 format. This field is set in the campaign on the Braze dashboard. */
1129
+ language?: string;
1130
+
1131
+ /** The alternate text of the message's image to be announced when in accessibility mode. */
1132
+ altImageText?: string;
1134
1133
  }
1135
1134
 
1136
1135
 
@@ -1667,8 +1666,7 @@ export class Banner {
1667
1666
  /** The placement ID this banner is matched to. */
1668
1667
  placementId: string;
1669
1668
 
1670
- /** HTML to display for the banner. */
1671
- html: string;
1669
+ // intentionally omitting `html` since it's not meant to be accessed by integrators directly.
1672
1670
 
1673
1671
  /** Whether this banner is a control banner. */
1674
1672
  isControl: boolean;
@@ -1679,16 +1677,9 @@ export class Banner {
1679
1677
  * calling `openSession`.
1680
1678
  *
1681
1679
  * @returns The identifier of the subscription created. This can be passed to
1682
- * `removeSubscription` to cancel the subscription.
1680
+ * `removeSubscription` to cancel the subscription. Returns undefined if the SDK has not been initialized.
1683
1681
  */
1684
- export function automaticallyShowInAppMessages(): string;
1685
-
1686
- /**
1687
- * Destroy any Braze news feed currently showing. This method will appropriately clean up any retained resources
1688
- * and also display the hiding animation, and so should be used instead of manually removing feed html from the
1689
- * DOM.
1690
- */
1691
- export function destroyFeed(): void;
1682
+ export function automaticallyShowInAppMessages(): string | undefined;
1692
1683
 
1693
1684
  /**
1694
1685
  * Hide any Braze content cards currently showing in the parent node, or if none is provided, any content cards in the page.
@@ -1716,28 +1707,6 @@ export function showContentCards(
1716
1707
  filterFunction?: (cards: Card[]) => Card[],
1717
1708
  ): void;
1718
1709
 
1719
- /**
1720
- * Display the user's news feed.
1721
- *
1722
- * @param parentNode - The HTML node to render the news feed into. If null/undefined, the feed will be
1723
- * rendered in fixed position over the right-hand side of the page and appended to the `<body>` node. If the
1724
- * parent node already has an Braze news feed as a direct descendant, the existing feed will be replaced.
1725
- * @param cards - A static set of cards to Each item in this Array should be a `Card`
1726
- * descendant. If this parameter is null/undefined, all unexpired cards from the last news feed refresh will be
1727
- * used automatically, a feed refresh will be kicked off automatically if the cached cards are more than 1 minute
1728
- * old, and the feed will automatically update when new cards are received while it is still showing. If you
1729
- * provide an explicit set of cards by using this parameter, no action will be taken when new cards are received,
1730
- * and you must subscribe to feed updates yourself with `subscribeToFeedUpdates` and request updates with
1731
- * `requestFeedRefresh` if you want to update this feed with new cards.
1732
- * @param allowedCategories - A set of categories to filter cards to. Each item in this Array should be a
1733
- * card category as set in the Braze dashboard. If omitted, all cards will be displayed.
1734
- */
1735
- export function showFeed(
1736
- parentNode?: Element | null,
1737
- cards?: Card[] | null,
1738
- allowedCategories?: string[],
1739
- ): void;
1740
-
1741
1710
  /**
1742
1711
  * Display a given in-app message.
1743
1712
  *
@@ -1747,13 +1716,13 @@ export function showFeed(
1747
1716
  * @param onDisplayCallback - Optional callback to invoke once the message is on the screen.
1748
1717
  *
1749
1718
  * @returns Whether or not the message was displayed (or, in the case of control messages, logged to
1750
- * Braze servers).
1719
+ * Braze servers). Returns undefined if the SDK has not been initialized.
1751
1720
  */
1752
1721
  export function showInAppMessage(
1753
1722
  inAppMessage: InAppMessage | ControlMessage,
1754
1723
  parentNode?: Element | null,
1755
1724
  onDisplayCallback?: () => void,
1756
- ): boolean;
1725
+ ): boolean | undefined;
1757
1726
 
1758
1727
  /**
1759
1728
  * Defers the display of given in-app message for a future pageload.
@@ -1802,28 +1771,6 @@ export function toggleContentCards(
1802
1771
  filterFunction?: (cards: Card[]) => Card[],
1803
1772
  ): void;
1804
1773
 
1805
- /**
1806
- * Toggle the Braze news feed, creating it if it does not exist, and destroying it if it does.
1807
- *
1808
- * @param parentNode - The HTML node to render the news feed into. If null/undefined, the feed will be
1809
- * rendered in fixed position over the right-hand side of the page and appended to the `<body>` node. If the
1810
- * parent node already has an Braze news feed as a direct descendant, the existing feed will be replaced.
1811
- * @param cards - A static set of cards to Each item in this Array should be a `Card`
1812
- * descendant. If this parameter is null/undefined, all unexpired cards from the last news feed refresh will be
1813
- * used automatically, a feed refresh will be kicked off automatically if the cached cards are more than 1 minute
1814
- * old, and the feed will automatically update when new cards are received while it is still showing. If you
1815
- * provide an explicit set of cards by using this parameter, no action will be taken when new cards are received,
1816
- * and you must subscribe to feed updates yourself with `subscribeToFeedUpdates` and request updates with
1817
- * `requestFeedRefresh` if you want to update this feed with new cards.
1818
- * @param allowedCategories - A set of categories to filter cards to. Each item in this Array should be a
1819
- * card category as set in the Braze dashboard. If omitted, all cards will be displayed.
1820
- */
1821
- export function toggleFeed(
1822
- parentNode?: Element | null,
1823
- cards?: Card[] | null,
1824
- allowedCategories?: string[],
1825
- ): void;
1826
-
1827
1774
  /**
1828
1775
  * When a user first uses Braze on a device they are considered "anonymous". Use this method to identify a user
1829
1776
  * with a unique ID, which enables the following:
@@ -1873,17 +1820,10 @@ export function destroy(): void;
1873
1820
  * Get all currently available cards from the last content cards refresh.
1874
1821
  *
1875
1822
  * @returns - A `ContentCards` object which includes all currently available
1876
- * `Card` objects from the last content cards refresh.
1877
- */
1878
- export function getCachedContentCards(): ContentCards;
1879
-
1880
- /**
1881
- * Get all unexpired cards from the last news feed refresh.
1882
- *
1883
- * @returns - A `Feed` object which includes all unexpired `Card` objects from the last
1884
- * news feed refresh.
1823
+ * `Card` objects from the last content cards refresh. Returns undefined if the
1824
+ * SDK has not been initialized.
1885
1825
  */
1886
- export function getCachedFeed(): Feed;
1826
+ export function getCachedContentCards(): ContentCards | undefined;
1887
1827
 
1888
1828
  /**
1889
1829
  * Retrieves the 'device id,' a randomly generated ID that is stored on the browser.
@@ -1961,18 +1901,6 @@ export function isPushPermissionGranted(): boolean | undefined;
1961
1901
  */
1962
1902
  export function isPushSupported(): boolean | undefined;
1963
1903
 
1964
- /**
1965
- * Logs that the user clicked the given card. This is done automatically when you use Braze's display module
1966
- * and should only be called if you're bypassing that and manually building the DOM for displaying the cards in
1967
- * your own code.
1968
- *
1969
- * @param card - the `Card` object that received a click
1970
- * @param forContentCards - whether to log this as a content cards event (as opposed to the legacy news feed)
1971
- *
1972
- * @returns Whether or not the event was successfully logged (to be flushed later).
1973
- */
1974
- export function logCardClick(card: Card, forContentCards?: boolean): boolean;
1975
-
1976
1904
  /**
1977
1905
  * Logs that the user dismissed the given card. This is done automatically when you use Braze's display module
1978
1906
  * and should only be called if you're bypassing that and manually building the DOM for displaying the cards in
@@ -1985,23 +1913,7 @@ export function logCardClick(card: Card, forContentCards?: boolean): boolean;
1985
1913
  export function logCardDismissal(card: Card): boolean;
1986
1914
 
1987
1915
  /**
1988
- * Logs that the user saw the given cards. This is done automatically when you use Braze's display module
1989
- * and should only be called if you're bypassing that and manually building the DOM for displaying the cards in
1990
- * your own code.
1991
- *
1992
- * @param cards - array of `Card` objects that received impressions
1993
- * @param forContentCards - whether to log this as a content cards event (as opposed to the legacy news feed)
1994
- *
1995
- * @returns Whether or not the event was successfully logged (to be flushed later).
1996
- */
1997
- export function logCardImpressions(
1998
- cards: Card[],
1999
- forContentCards?: boolean,
2000
- ): boolean;
2001
-
2002
- /**
2003
- * A convenient method to log that the user saw the given Content Cards. This method is equivalent to
2004
- * calling [`logCardImpressions` method with `forContentCards` param set to true.
1916
+ * Logs that the user saw the given Content Cards.
2005
1917
  * This is done automatically when you use Braze's display module and should only be called
2006
1918
  * if you're bypassing that and manually building the DOM for displaying content cards in
2007
1919
  * your own code.
@@ -2013,8 +1925,7 @@ export function logCardImpressions(
2013
1925
  export function logContentCardImpressions(contentCards: Card[]): boolean;
2014
1926
 
2015
1927
  /**
2016
- * A convenient method to log when user clicks on a Content Card. This method is equivalent to
2017
- * calling [`logCardClick` method with `forContentCards` param set to true.
1928
+ * Logs when user clicks on a Content Card.
2018
1929
  * This is done automatically when you use Braze's display module and should only be called
2019
1930
  * if you're bypassing that and manually building the DOM for displaying content cards in
2020
1931
  * your own code.
@@ -2042,13 +1953,6 @@ export function logCustomEvent(
2042
1953
  eventProperties?: object,
2043
1954
  ): boolean;
2044
1955
 
2045
- /**
2046
- * Logs that the news feed was displayed. This is done automatically when you use Braze's
2047
- * UI and should only be called if you're bypassing that and manually building
2048
- * the class for displaying the cards in your own code.
2049
- */
2050
- export function logFeedDisplayed(): void;
2051
-
2052
1956
  /**
2053
1957
  * Logs that the user clicked the given in-app message button. This is done automatically when the user clicks on
2054
1958
  * a button in a message generated by `showInAppMessage`,
@@ -2164,7 +2068,7 @@ export function openSession(): void;
2164
2068
  * - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
2165
2069
  *
2166
2070
  * ```
2167
- * self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.9/service-worker.js');
2071
+ * self.importScripts('https://js.appboycdn.com/web-sdk-develop/6.0/service-worker.js');
2168
2072
  * ```
2169
2073
  *
2170
2074
  * For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
@@ -2212,15 +2116,6 @@ export function requestContentCardsRefresh(
2212
2116
  errorCallback?: () => void,
2213
2117
  ): void;
2214
2118
 
2215
- /**
2216
- * Requests an immediate refresh of the news feed from Braze servers. By default, the news feed is refreshed on
2217
- * `showFeed` (when stale - see
2218
- * `showFeed` for details). If you want to refresh the feed from the
2219
- * server at another time you must call this function. Results of this refresh are reported asynchronously to
2220
- * subscriptions created via 'subscribeToFeedUpdates` .
2221
- */
2222
- export function requestFeedRefresh(): void;
2223
-
2224
2119
  /**
2225
2120
  * Requests an immediate refresh of feature flags from Braze servers. By default, feature flags are refreshed when
2226
2121
  * a new session starts. If you want to refresh feature flags from the server at another time you must call this function.
@@ -2282,9 +2177,10 @@ export function setSdkAuthenticationSignature(signature: string): boolean;
2282
2177
  *
2283
2178
  * @param sdkMetadata - An array of metadata values from `BrazeSdkMetadata`.
2284
2179
  *
2285
- * @returns Whether or not the array of metadata is valid.
2180
+ * @returns Whether or not the array of metadata is valid. Returns undefined if
2181
+ * the SDK has not been initialized.
2286
2182
  */
2287
- export function addSdkMetadata(sdkMetadata: string[]): boolean;
2183
+ export function addSdkMetadata(sdkMetadata: string[]): boolean | undefined;
2288
2184
 
2289
2185
  /**
2290
2186
  * Sets a cookie that causes all subsequent calls to the Braze Web SDK to be ignored
@@ -2309,19 +2205,6 @@ export function subscribeToContentCardsUpdates(
2309
2205
  subscriber: (cards: ContentCards) => void,
2310
2206
  ): string | undefined;
2311
2207
 
2312
- /**
2313
- * Subscribe to news feed updates. The subscriber callback will be called whenever the news feed is updated.
2314
- *
2315
- * @param subscriber - The callback function to handle new cards. This function will be
2316
- * called with a `Feed`object which includes all `Card` objects currently in the feed.
2317
- *
2318
- * @returns The identifier of the subscription created. This can be passed to `removeSubscription` to cancel
2319
- * the subscription. Returns undefined if the SDK has not been initialized.
2320
- */
2321
- export function subscribeToFeedUpdates(
2322
- subscriber: (feed: Feed) => void,
2323
- ): string | undefined;
2324
-
2325
2208
  /**
2326
2209
  * Subscribe to receive in-app messages. The subscriber callback will be called whenever a new in-app message is
2327
2210
  * triggered. This method should be called before calling `openSession`. If you are using the build of Braze's
@@ -2429,9 +2312,9 @@ export function subscribeToFeatureFlagsUpdates(
2429
2312
  /**
2430
2313
  * Gets all available feature flags.
2431
2314
  *
2432
- * @returns - A list of `FeatureFlag` objects.
2315
+ * @returns - A list of `FeatureFlag` objects. Returns undefined if the SDK has not been initialized.
2433
2316
  */
2434
- export function getAllFeatureFlags(): FeatureFlag[];
2317
+ export function getAllFeatureFlags(): FeatureFlag[] | undefined;
2435
2318
 
2436
2319
  /**
2437
2320
  * Logs impression for a given feature flag. This is limited to one impression per session per feature flag ID.
@@ -2482,33 +2365,6 @@ export function insertBanner(
2482
2365
  parentNode: HTMLElement,
2483
2366
  ): void;
2484
2367
 
2485
- /**
2486
- * Logs that the user clicked the given banner. This should generally be called through the Braze JavaScript bridge
2487
- * inside the Banner's HTML as defined in the Braze dashboard.
2488
- *
2489
- * @param banner - The `Banner` object which received the click.
2490
- * @param buttonId - An optional button ID to associate with this click for analytics.
2491
- *
2492
- * @returns - Whether the click was logged successfully, or undefined if the SDK is not intialized.
2493
- */
2494
- export function logBannerClick(
2495
- banner: Banner,
2496
- buttonId?: string,
2497
- ): boolean | undefined;
2498
-
2499
- /**
2500
- * Logs that the user saw the given banners. This is done automatically when you use Braze's display module
2501
- * and should only be called if you're bypassing that and manually building the DOM for displaying the banners in
2502
- * your own code.
2503
- *
2504
- * @param placementIds - The placement IDs of the banners that received impressions.
2505
- *
2506
- * @returns - Whether the impressions were logged successfully, or undefiend if the SDK is not initialized.
2507
- */
2508
- export function logBannerImpressions(
2509
- placementIds: Array<string>,
2510
- ): boolean | undefined;
2511
-
2512
2368
  /**
2513
2369
  * Gets all available banners.
2514
2370
  *
@@ -2635,7 +2491,7 @@ export type InitializationOptions = {
2635
2491
  * lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
2636
2492
  * option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
2637
2493
  * `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
2638
- * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.9/service-worker.js');` or by including the content
2494
+ * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/6.0/service-worker.js');` or by including the content
2639
2495
  * of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
2640
2496
  */
2641
2497
  manageServiceWorkerExternally?: boolean;