@braze/web-sdk 3.5.1 → 4.0.2

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 (169) hide show
  1. package/README.md +5 -11
  2. package/index.d.ts +472 -549
  3. package/package.json +9 -7
  4. package/shared-lib/braze-shared-lib.js +1 -0
  5. package/shared-lib/encoding-utils.js +1 -0
  6. package/shared-lib/event-types.js +1 -0
  7. package/shared-lib/guid.js +1 -0
  8. package/shared-lib/indexed-db-adapter.js +1 -0
  9. package/shared-lib/logger.js +1 -0
  10. package/shared-lib/supported-options.js +1 -0
  11. package/src/Card/card-manager-factory.js +1 -0
  12. package/src/Card/card-manager.js +1 -0
  13. package/src/Card/display/card-display.js +1 -0
  14. package/src/Card/index.js +1 -0
  15. package/src/Card/log-card-click.js +1 -0
  16. package/src/Card/log-card-dismissal.js +1 -0
  17. package/src/Card/log-card-impressions.js +1 -0
  18. package/src/Card/models/banner.js +1 -0
  19. package/src/Card/models/captioned-image.js +1 -0
  20. package/src/Card/models/card.js +1 -0
  21. package/src/Card/models/classic-card.js +1 -0
  22. package/src/Card/models/control-card.js +1 -0
  23. package/src/Card/models/index.js +1 -0
  24. package/src/Card/util/card-factory.js +1 -0
  25. package/src/ContentCards/content-cards-provider-factory.js +1 -0
  26. package/src/ContentCards/content-cards-provider.js +1 -0
  27. package/src/ContentCards/content-cards.js +1 -0
  28. package/src/ContentCards/get-cached-content-cards.js +1 -0
  29. package/src/ContentCards/index.js +1 -0
  30. package/src/ContentCards/log-content-cards-displayed.js +1 -0
  31. package/src/ContentCards/request-content-cards-refresh.js +1 -0
  32. package/src/ContentCards/subscribe-to-content-cards-updates.js +1 -0
  33. package/src/ContentCards/ui/hide-content-cards.js +1 -0
  34. package/src/ContentCards/ui/show-content-cards.js +1 -0
  35. package/src/ContentCards/ui/toggle-content-cards.js +1 -0
  36. package/src/Core/add-sdk-metadata.js +1 -0
  37. package/src/Core/braze-sdk-metadata.js +1 -0
  38. package/src/Core/change-user.js +1 -0
  39. package/src/Core/destroy.js +1 -0
  40. package/src/Core/device-properties.js +1 -0
  41. package/src/Core/disable-sdk.js +1 -0
  42. package/src/Core/enable-sdk.js +1 -0
  43. package/src/Core/get-device-id.js +1 -0
  44. package/src/Core/get-user.js +1 -0
  45. package/src/Core/handle-braze-action.js +1 -0
  46. package/src/Core/index.js +1 -0
  47. package/src/Core/initialize.js +1 -0
  48. package/src/Core/is-disabled.js +1 -0
  49. package/src/Core/log-custom-event.js +1 -0
  50. package/src/Core/log-purchase.js +1 -0
  51. package/src/Core/open-session.js +1 -0
  52. package/src/Core/remove-all-subscriptions.js +1 -0
  53. package/src/Core/remove-subscription.js +1 -0
  54. package/src/Core/request-immediate-data-flush.js +1 -0
  55. package/src/Core/set-logger.js +1 -0
  56. package/src/Core/set-sdk-authentication-signature.js +1 -0
  57. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -0
  58. package/src/Core/toggle-logging.js +1 -0
  59. package/src/Core/wipe-data.js +1 -0
  60. package/src/Feed/feed-provider-factory.js +1 -0
  61. package/src/Feed/feed-provider.js +1 -0
  62. package/src/Feed/feed.js +1 -0
  63. package/src/Feed/get-cached-feed.js +1 -0
  64. package/src/Feed/index.js +1 -0
  65. package/src/Feed/log-feed-displayed.js +1 -0
  66. package/src/Feed/request-feed-refresh.js +1 -0
  67. package/src/Feed/subscribe-to-feed-updates.js +1 -0
  68. package/src/Feed/ui/hide-feed.js +1 -0
  69. package/src/Feed/ui/show-feed.js +1 -0
  70. package/src/Feed/ui/toggle-feed.js +1 -0
  71. package/src/InAppMessage/display/get-animation-effect.js +1 -0
  72. package/src/InAppMessage/display/html-message-to-html.js +1 -0
  73. package/src/InAppMessage/display/in-app-message-to-html.js +1 -0
  74. package/src/InAppMessage/display/modal-utils.js +1 -0
  75. package/src/InAppMessage/in-app-message-factory.js +1 -0
  76. package/src/InAppMessage/in-app-message-manager-factory.js +1 -0
  77. package/src/InAppMessage/in-app-message-manager.js +1 -0
  78. package/src/InAppMessage/index.js +1 -0
  79. package/src/InAppMessage/log-in-app-message-button-click.js +1 -0
  80. package/src/InAppMessage/log-in-app-message-click.js +1 -0
  81. package/src/InAppMessage/log-in-app-message-html-click.js +1 -0
  82. package/src/InAppMessage/log-in-app-message-impression.js +1 -0
  83. package/src/InAppMessage/models/control-message.js +1 -0
  84. package/src/InAppMessage/models/full-screen-message.js +1 -0
  85. package/src/InAppMessage/models/html-message.js +1 -0
  86. package/src/InAppMessage/models/in-app-message-button.js +1 -0
  87. package/src/InAppMessage/models/in-app-message.js +1 -0
  88. package/src/InAppMessage/models/modal-message.js +1 -0
  89. package/src/InAppMessage/models/slide-up-message.js +1 -0
  90. package/src/InAppMessage/models/templated-in-app-message.js +1 -0
  91. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -0
  92. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +1 -0
  93. package/src/InAppMessage/ui/show-in-app-message.js +1 -0
  94. package/src/Push/index.js +1 -0
  95. package/src/Push/is-push-blocked.js +1 -0
  96. package/src/Push/is-push-permission-granted.js +1 -0
  97. package/src/Push/is-push-supported.js +1 -0
  98. package/src/Push/push-manager-factory.js +1 -0
  99. package/src/Push/push-manager.js +1 -0
  100. package/src/Push/request-push-permission.js +1 -0
  101. package/src/Push/unregister-push.js +1 -0
  102. package/src/User/index.js +1 -0
  103. package/src/User/user-manager.js +1 -0
  104. package/src/User/user.js +1 -0
  105. package/src/common/base-feed.js +1 -0
  106. package/src/common/base-provider.js +1 -0
  107. package/src/common/constants.js +1 -0
  108. package/src/common/event-logger.js +1 -0
  109. package/src/common/feed-display.js +1 -0
  110. package/src/common/translations.js +1 -0
  111. package/src/index.js +1 -0
  112. package/src/l10n/l10n-manager-factory.js +1 -0
  113. package/src/l10n/l10n-manager.js +1 -0
  114. package/src/managers/auth-manager.js +1 -0
  115. package/src/managers/braze-instance.js +1 -0
  116. package/src/managers/device-manager.js +1 -0
  117. package/src/managers/network-manager.js +1 -0
  118. package/src/managers/server-config-manager.js +1 -0
  119. package/src/managers/session-manager.js +1 -0
  120. package/src/managers/storage-manager-factory.js +1 -0
  121. package/src/managers/storage-manager.js +1 -0
  122. package/src/managers/subscription-manager.js +1 -0
  123. package/src/models/backend-errors.js +1 -0
  124. package/src/models/braze-event.js +1 -0
  125. package/src/models/braze-sdk-metadata.js +1 -0
  126. package/src/models/device.js +1 -0
  127. package/src/models/identifier.js +1 -0
  128. package/src/models/push-token.js +1 -0
  129. package/src/models/request-result.js +1 -0
  130. package/src/models/server-config.js +1 -0
  131. package/src/request-controller.js +1 -0
  132. package/src/triggers/models/custom-event-data.js +1 -0
  133. package/src/triggers/models/custom-event-property-data.js +1 -0
  134. package/src/triggers/models/filter-set.js +1 -0
  135. package/src/triggers/models/filter.js +1 -0
  136. package/src/triggers/models/in-app-message-click-data.js +1 -0
  137. package/src/triggers/models/purchase-data.js +1 -0
  138. package/src/triggers/models/purchase-property-data.js +1 -0
  139. package/src/triggers/models/push-click-data.js +1 -0
  140. package/src/triggers/models/trigger-condition.js +1 -0
  141. package/src/triggers/models/trigger-events.js +1 -0
  142. package/src/triggers/models/trigger.js +1 -0
  143. package/src/triggers/triggers-provider-factory.js +1 -0
  144. package/src/triggers/triggers-provider.js +1 -0
  145. package/src/ui/js/attach-css.js +1 -0
  146. package/src/ui/js/feed-css.js +1 -0
  147. package/src/ui/js/iam-css.js +1 -0
  148. package/src/ui/js/index.js +1 -0
  149. package/src/ui/js/load-font-awesome.js +1 -0
  150. package/src/util/base-device-parser.js +1 -0
  151. package/src/util/braze-actions.js +1 -0
  152. package/src/util/browser-detector.js +1 -0
  153. package/src/util/client-hints-parser.js +1 -0
  154. package/src/util/code-utils.js +1 -0
  155. package/src/util/color-utils.js +1 -0
  156. package/src/util/component-utils.js +1 -0
  157. package/src/util/date-utils.js +1 -0
  158. package/src/util/deprecation-utils.js +1 -0
  159. package/src/util/device-constants.js +1 -0
  160. package/src/util/dom-utils.js +1 -0
  161. package/src/util/key-codes.js +1 -0
  162. package/src/util/math.js +1 -0
  163. package/src/util/net.js +1 -0
  164. package/src/util/string-utils.js +1 -0
  165. package/src/util/url-utils.js +1 -0
  166. package/src/util/user-agent-parser.js +1 -0
  167. package/src/util/validation-utils.js +1 -0
  168. package/src/util/window-utils.js +1 -0
  169. package/appboy.min.js +0 -278
package/index.d.ts CHANGED
@@ -1,19 +1,44 @@
1
1
  /*
2
- * Type definitions for appboy-web-sdk v3.5.1
3
- * Project: https://github.com/Appboy/appboy-web-sdk
2
+ * Type definitions for @braze/web-sdk v4.0.2
3
+ * Project: https://github.com/braze-inc/braze-web-sdk
4
4
  * (c) Braze, Inc. 2022 - http://braze.com
5
- * License available at https://github.com/Appboy/appboy-web-sdk/blob/master/LICENSE
5
+ * License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
6
6
  */
7
7
 
8
- declare namespace appboy {
9
- /**
10
- * Enum to represent the allowlistable set of device properties. By default, all properties are collected.
11
- * See the `devicePropertyAllowlist` option of `appboy.initialize` for more info.
12
8
 
9
+ /**
10
+ * Enum to represent the accepted SDK Metadata tags. See `addSdkMetadata` for more info.
11
+ *
13
12
  * @readonly
14
13
  * @enum {string}
15
14
  */
16
- class DeviceProperties {
15
+ export class BrazeSdkMetadata {
16
+ /** Automatically added when loading Braze via Google Tag Manager */
17
+ static readonly GOOGLE_TAG_MANAGER: string;
18
+ /** Automatically added when loading Braze via mParticle */
19
+ static readonly MPARTICLE: string;
20
+ /** Automatically added when loading Braze via Segment */
21
+ static readonly SEGMENT: string;
22
+ /** Automatically added when loading Braze via Tealium */
23
+ static readonly TEALIUM: string;
24
+ /** Automatically added when loading Braze via npm */
25
+ static readonly NPM: string;
26
+ /** Automatically added when loading Braze via Braze's CDN (js.appboycdn.com) */
27
+ static readonly CDN: string;
28
+ /** Automatically added when loading Braze via Shopify Integration */
29
+ static readonly SHOPIFY: string;
30
+ /** Use this tag if you have integrated or loaded the Braze Web SDK using none of the other methods */
31
+ static readonly MANUAL: string;
32
+ }
33
+
34
+ /**
35
+ * Enum to represent the allowlistable set of device properties. By default, all properties are collected.
36
+ * See the `devicePropertyAllowlist` option of `initialize` for more info.
37
+
38
+ * @readonly
39
+ * @enum {string}
40
+ */
41
+ export class DeviceProperties {
17
42
  /** The name of the browser - e.g. "Chrome" */
18
43
  static readonly BROWSER: string;
19
44
  /** The version of the browser - e.g. "59.234.1234" */
@@ -31,35 +56,10 @@ declare namespace appboy {
31
56
  }
32
57
 
33
58
  /**
34
- * Enum to represent the accepted SDK Metadata tags. See `appboy.addSdkMetadata` for more info.
35
- *
36
- * @readonly
37
- * @enum {string}
38
- */
39
- class BrazeSdkMetadata {
40
- /** Use this tag if you have integrated the Braze Web SDK using Google Tag Manager */
41
- static readonly GOOGLE_TAG_MANAGER: string;
42
- /** Use this tag if you have integrated the Braze Web SDK using mParticle */
43
- static readonly MPARTICLE: string;
44
- /** Automatically added when loading Braze via Segment */
45
- static readonly SEGMENT: string;
46
- /** Use this tag if you have integrated the Braze Web SDK using Tealium */
47
- static readonly TEALIUM: string;
48
- /** Use this tag if you have imported the Braze Web SDK using npm */
49
- static readonly NPM: string;
50
- /** Use this tag if you have loaded the Braze Web SDK using Braze's CDN (js.appboycdn.com) */
51
- static readonly CDN: string;
52
- /** Automatically added when loading Braze via Shopify Integration */
53
- static readonly SHOPIFY: string;
54
- /** Use this tag if you have integrated or loaded the Braze Web SDK using none of the other methods */
55
- static readonly MANUAL: string;
56
- }
57
-
58
- /**
59
- * Abstract base for news feed cards. Use subclasses `ClassicCard`, `CaptionedImage`,
59
+ * Abstract base for news feed and Content Cards cards. Use subclasses `ClassicCard`, `CaptionedImage`,
60
60
  * `Banner`, and `ControlCard`.
61
61
  */
62
- class Card {
62
+ export class Card {
63
63
  /**
64
64
  * Call this method if you wish to programmatically remove the card from the feed and log a dismissal. This method
65
65
  * is meant to be used with the Braze UI.
@@ -122,13 +122,13 @@ declare namespace appboy {
122
122
  /** Whether to pin this card to the top of the view. */
123
123
  pinned: boolean;
124
124
 
125
- static fromContentCardsJson(jsonData: Record<string, unknown>): Card | undefined;
125
+
126
126
  }
127
127
 
128
- class Banner extends Card {
128
+ export class Banner extends Card {
129
129
  /**
130
- * A card with only an image, which can be passed to `display.showFeed` or handled manually.
131
- * Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`
130
+ * A card with only an image, which can be passed to `showFeed` or handled manually.
131
+ * Subscribe to receive new cards via `subscribeToFeedUpdates`
132
132
  *
133
133
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
134
134
  * @param viewed - Whether this card has been shown to the user.
@@ -140,7 +140,8 @@ declare namespace appboy {
140
140
  * @param expiresAt - When this card expires and should stop being shown to the user.
141
141
  * @param url - A url to open when this card is clicked.
142
142
  * @param linkText - The display text for the url.
143
- * @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances.
143
+ * @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before
144
+ * image loading completes. Note that the field may not be supplied in certain circumstances.
144
145
  * @param extras - Object of string/string key/value pairs.
145
146
  * @param pinned - Whether to pin this card to the top of the view.
146
147
  * @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
@@ -181,7 +182,10 @@ declare namespace appboy {
181
182
  /** The display text for the url. */
182
183
  linkText?: string;
183
184
 
184
- /** The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances. */
185
+ /**
186
+ * The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes.
187
+ * Note that the field may not be supplied in certain circumstances.
188
+ * */
185
189
  aspectRatio: number | null;
186
190
 
187
191
  /** Whether this card has been dismissed. */
@@ -194,10 +198,10 @@ declare namespace appboy {
194
198
  clicked: boolean;
195
199
  }
196
200
 
197
- class CaptionedImage extends Card {
201
+ export class CaptionedImage extends Card {
198
202
  /**
199
- * A card with a large image and descriptive text, which can be passed to `display.showFeed` or handled manually.
200
- * Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`.
203
+ * A card with a large image and descriptive text, which can be passed to `showFeed` or handled manually.
204
+ * Subscribe to receive new cards via `subscribeToFeedUpdates`.
201
205
  *
202
206
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
203
207
  * @param viewed - Whether this card has been shown to the user.
@@ -211,7 +215,8 @@ declare namespace appboy {
211
215
  * @param expiresAt - When this card expires and should stop being shown to the user.
212
216
  * @param url - A url to open when this card is clicked.
213
217
  * @param linkText - The display text for the url.
214
- * @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances.
218
+ * @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before
219
+ * image loading completes. Note that the field may not be supplied in certain circumstances.
215
220
  * @param extras - Object of string/string key/value pairs.
216
221
  * @param pinned - Whether to pin this card to the top of the view.
217
222
  * @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
@@ -260,7 +265,10 @@ declare namespace appboy {
260
265
  /** The display text for the url. */
261
266
  linkText?: string;
262
267
 
263
- /** The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances. */
268
+ /**
269
+ * The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes.
270
+ * Note that the field may not be supplied in certain circumstances.
271
+ */
264
272
  aspectRatio: number | null;
265
273
 
266
274
  /** Whether this card has been dismissed. */
@@ -273,11 +281,11 @@ declare namespace appboy {
273
281
  clicked: boolean;
274
282
  }
275
283
 
276
- class ClassicCard extends Card {
284
+ export class ClassicCard extends Card {
277
285
  /**
278
286
  * A card with a title, body, and optionally a small image, which can be passed to
279
- * `display.showFeed` or handled manually.
280
- * Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`.
287
+ * `showFeed` or handled manually.
288
+ * Subscribe to receive new cards via `subscribeToFeedUpdates`.
281
289
  *
282
290
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
283
291
  * @param viewed - Whether this card has been shown to the user.
@@ -291,7 +299,8 @@ declare namespace appboy {
291
299
  * @param expiresAt - When this card expires and should stop being shown to the user.
292
300
  * @param url - A url to open when this card is clicked.
293
301
  * @param linkText - The display text for the url.
294
- * @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances.
302
+ * @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before
303
+ * image loading completes. Note that the field may not be supplied in certain circumstances.
295
304
  * @param extras - Object of string/string key/value pairs.
296
305
  * @param pinned - Whether to pin this card to the top of the view.
297
306
  * @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
@@ -340,7 +349,10 @@ declare namespace appboy {
340
349
  /** The display text for the url. */
341
350
  linkText?: string;
342
351
 
343
- /** The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances. */
352
+ /**
353
+ * The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes.
354
+ * Note that the field may not be supplied in certain circumstances.
355
+ */
344
356
  aspectRatio: number | null;
345
357
 
346
358
  /** Whether this card has been dismissed. */
@@ -353,12 +365,12 @@ declare namespace appboy {
353
365
  clicked: boolean;
354
366
  }
355
367
 
356
- class ControlCard extends Card {
368
+ export class ControlCard extends Card {
357
369
  /**
358
370
  * A card with no display that logs impressions, which can be passed to
359
- * `display.showFeed` or handled manually.
371
+ * `showFeed` or handled manually.
360
372
  * Not supported in legacy news feed.
361
- * Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`.
373
+ * Subscribe to receive new cards via `subscribeToFeedUpdates`.
362
374
  *
363
375
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
364
376
  * @param viewed - Whether this card has been shown to the user.
@@ -377,15 +389,15 @@ declare namespace appboy {
377
389
  );
378
390
  }
379
391
 
380
- class ContentCards {
392
+ export class ContentCards {
381
393
  /**
382
394
  * A collection of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
383
- * If you use Appboy's display module to render content cards, you generally shouldn't need to
395
+ * If you use Braze's UI to render content cards, you generally shouldn't need to
384
396
  * interact with this class, but if you are building your own content cards class manually, use
385
- * `appboy.getCachedContentCards` to get the most recent ContentCards object.
397
+ * `getCachedContentCards` to get the most recent ContentCards object.
386
398
  *
387
399
  * @param cards - Array of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
388
- * @param lastUpdated - When this collection of cards was received from Appboy servers. If null, it means the
400
+ * @param lastUpdated - When this collection of cards was received from Braze servers. If null, it means the
389
401
  * content cards are still being fetched for this user.
390
402
  */
391
403
  constructor(cards: Card[], lastUpdated: Date | null);
@@ -394,7 +406,7 @@ declare namespace appboy {
394
406
  cards: Card[];
395
407
 
396
408
  /**
397
- * When this collection of cards was received from Appboy servers. If null, it means the
409
+ * When this collection of cards was received from Braze servers. If null, it means the
398
410
  * content cards are still being fetched for this user.
399
411
  */
400
412
  lastUpdated: Date | null;
@@ -406,14 +418,14 @@ declare namespace appboy {
406
418
  getUnviewedCardCount(): number;
407
419
  }
408
420
 
409
- class Feed {
421
+ export class Feed {
410
422
  /**
411
423
  * A collection of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
412
- * Subscribe to receive feed updates via `appboy.subscribeToFeedUpdates`,
413
- * or get the currently cached feed with `appboy.getCachedFeed`.
424
+ * Subscribe to receive feed updates via `subscribeToFeedUpdates`,
425
+ * or get the currently cached feed with `getCachedFeed`.
414
426
  *
415
427
  * @param cards - Array of `Card` descendents (`ClassicCard`, `CaptionedImage`,
416
- * `Banner`). Can be passed directly to `display.showFeed`.
428
+ * `Banner`). Can be passed directly to `showFeed`.
417
429
  * @param lastUpdated - When this collection of cards was received from Braze servers. If null, it means the
418
430
  * feed has never been fetched for this user.
419
431
  */
@@ -421,12 +433,12 @@ declare namespace appboy {
421
433
 
422
434
  /**
423
435
  * Array of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
424
- * Can be passed directly to `display.showFeed`.
436
+ * Can be passed directly to `showFeed`.
425
437
  */
426
438
  cards: Card[];
427
439
 
428
440
  /**
429
- * When this collection of cards was received from Appboy servers. If null, it means the
441
+ * When this collection of cards was received from Braze servers. If null, it means the
430
442
  * content cards are still being fetched for this user.
431
443
  */
432
444
  lastUpdated: Date | null;
@@ -434,16 +446,16 @@ declare namespace appboy {
434
446
  /**
435
447
  * Get the current unread card count. This is useful for powering badges on your control for showing the news feed.
436
448
  * Note that Braze will not refresh news feed cards on new page loads (and so this function will return 0) until you
437
- * call `display.showFeed` or `appboy.requestFeedRefresh`. `ControlCard` cards do not count towards the
449
+ * call `showFeed` or `requestFeedRefresh`. `ControlCard` cards do not count towards the
438
450
  * unread count.
439
451
  */
440
452
  getUnreadCardCount(): number;
441
453
  }
442
454
 
443
- class ControlMessage {
455
+ export class ControlMessage {
444
456
  /**
445
457
  * A non-showing message placeholder that represents this user receiving the the control for a multivariate
446
- * test. Can be passed to `display.showInAppMessage` to log the user's
458
+ * test. Can be passed to `showInAppMessage` to log the user's
447
459
  * entrollment in the control or handled manually.
448
460
  *
449
461
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
@@ -458,29 +470,35 @@ declare namespace appboy {
458
470
  triggerId?: string;
459
471
  }
460
472
 
461
- namespace InAppMessage {
462
- type SlideFrom = "TOP" | "BOTTOM";
473
+
474
+ type SlideFrom = typeof InAppMessage.SlideFrom[keyof typeof InAppMessage.SlideFrom];
463
475
 
464
- type ClickAction = "NEWS_FEED" | "URI" | "NONE";
476
+
477
+ type ClickAction = typeof InAppMessage.ClickAction[keyof typeof InAppMessage.ClickAction];
465
478
 
466
- type DismissType = "AUTO_DISMISS" | "SWIPE";
479
+
480
+ type DismissType = typeof InAppMessage.DismissType[keyof typeof InAppMessage.DismissType];
467
481
 
468
- type OpenTarget = "NONE" | "BLANK";
482
+
483
+ type OpenTarget = typeof InAppMessage.OpenTarget[keyof typeof InAppMessage.OpenTarget];
469
484
 
470
- type ImageStyle = "TOP" | "GRAPHIC";
485
+
486
+ type ImageStyle = typeof InAppMessage.ImageStyle[keyof typeof InAppMessage.ImageStyle];
471
487
 
472
- type Orientation = "PORTRAIT" | "LANDSCAPE";
488
+
489
+ type Orientation = typeof InAppMessage.Orientation[keyof typeof InAppMessage.Orientation];
473
490
 
474
- type TextAlignment = "START" | "CENTER" | "END";
491
+
492
+ type TextAlignment = typeof InAppMessage.TextAlignment[keyof typeof InAppMessage.TextAlignment];
475
493
 
476
- type CropType = "CENTER_CROP" | "FIT_CENTER";
477
- }
494
+
495
+ type CropType = typeof InAppMessage.CropType[keyof typeof InAppMessage.CropType];
478
496
 
479
497
  /**
480
498
  * Abstract base for in-app messages. Use subclasses `SlideUpMessage`,
481
499
  * `ModalMessage`, `FullScreenMessage`, and `HtmlMessage`.
482
500
  */
483
- class InAppMessage {
501
+ export class InAppMessage {
484
502
  static SlideFrom: {
485
503
  TOP: "TOP";
486
504
  BOTTOM: "BOTTOM";
@@ -539,19 +557,19 @@ declare namespace appboy {
539
557
 
540
558
  /**
541
559
  * The id of the trigger that created this message. The SDK will report back this to
542
- * Appboy with in-app message analytics events.
560
+ * Braze with in-app message analytics events.
543
561
  */
544
562
  triggerId?: string;
545
563
 
546
564
  /**
547
565
  * How the message is dismissed, via a timer or requiring interaction from the user.
548
- * See the `InAppMessage.DismissType` enum.
566
+ * See the `DismissType` enum.
549
567
  */
550
- dismissType: InAppMessage.DismissType;
568
+ dismissType: DismissType;
551
569
 
552
570
  /**
553
571
  * Length of time in milliseconds until auto-dismiss should occur. Only used when
554
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
572
+ * dismissType is `DismissType`.AUTO_DISMISS
555
573
  */
556
574
  duration: number;
557
575
 
@@ -611,39 +629,35 @@ declare namespace appboy {
611
629
  */
612
630
  subscribeToDismissedEvent(subscriber: () => void): string;
613
631
 
614
- static fromJson(jsonData: Record<string, unknown>): InAppMessage | undefined;
632
+
615
633
  }
616
634
 
617
- class FullScreenMessage extends InAppMessage {
635
+ export class FullScreenMessage extends InAppMessage {
618
636
  /**
619
- * A modal in-app message object which can be passed to `display.showInAppMessage`
620
- * or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`.
637
+ * A modal in-app message object which can be passed to `showInAppMessage`
638
+ * or handled manually. Subscribe to be notified when in-app messages are triggered via `subscribeToInAppMessage`.
621
639
  *
622
640
  * @param message - The message to display to the user.
623
- * @param messageAlignment - How to align message text. See the `InAppMessage.TextAlignment` enum.
641
+ * @param messageAlignment - How to align message text. See the `TextAlignment` enum.
624
642
  * @param extras - Object of string/string key/value pairs.
625
- * @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
626
- * will report back to Appboy with in-app message analytics events.
627
- * @param cardId - If the message comes with a card, this is the id of the card that the SDK
628
- * will report back to Appboy with in-app message analytics events.
629
643
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
630
- * Appboy with in-app message analytics events.
644
+ * Braze with in-app message analytics events.
631
645
  * @param clickAction - Where the user should be brought when clicking on this message. See the
632
- * `InAppMessage.ClickAction` enum.
633
- * @param uri - If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
646
+ * `ClickAction` enum.
647
+ * @param uri - If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
634
648
  * user clicks on this message.
635
- * @param openTarget - If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
636
- * in a new tab/window. See the `InAppMessage.OpenTarget` enum.
649
+ * @param openTarget - If ```clickAction``` is `ClickAction`.URI, whether to open clicks
650
+ * in a new tab/window. See the `OpenTarget` enum.
637
651
  * @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
638
- * See the `InAppMessage.DismissType` enum.
652
+ * See the `DismissType` enum.
639
653
  * @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
640
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
654
+ * dismissType is `DismissType`.AUTO_DISMISS
641
655
  * @param icon - A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
642
656
  * [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
643
657
  * @param imageUrl - Url of an image to include in this message. The message will only display an image *or*
644
658
  * an icon, and will prioritize the image if present.
645
659
  * @param imageStyle - Whether the image should be shown as normal on the top of the in-app message or used
646
- * as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
660
+ * as the entire content of the message. See the `ImageStyle` enum.
647
661
  * @param iconColor - Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).
648
662
  * @param iconBackgroundColor - Background color of icon. Hex value with opacity (e.g. 0xff00ff00
649
663
  * is opaque green).
@@ -655,35 +669,33 @@ declare namespace appboy {
655
669
  * opaque green).
656
670
  * @param animateIn - Whether to animate the showing of this message.
657
671
  * @param animateOut - Whether to animate the hiding of this message.
658
- * @param header - Header text to display.
659
- * @param headerAlignment - How to align header text. See the `InAppMessage.TextAlignment` enum.
672
+ * @param header - Header text to
673
+ * @param headerAlignment - How to align header text. See the `TextAlignment` enum.
660
674
  * @param headerTextColor - Color of header text. Hex value with opacity (e.g. 0xff00ff00 is
661
675
  * opaque green).
662
676
  * @param frameColor - Color of the background frame which blocks page interaction while the
663
677
  * message is showing.
664
678
  * @param buttons - Array of up to two `InAppMessageButton` objects.
665
- * @param cropType - How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum.
679
+ * @param cropType - How to crop and fit images in the allowable space. See the `CropType` enum.
666
680
  * @param orientation - Whether to lay out this in-app message as a portrait or landscape. See the
667
- * `InAppMessage.Orientation` enum.
681
+ * `Orientation` enum.
668
682
  * @param htmlId - The ID to give the parent HTML element that this message is rendered into.
669
683
  * @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
670
684
  * to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
671
685
  */
672
686
  constructor(
673
687
  message?: string,
674
- messageAlignment?: InAppMessage.TextAlignment,
688
+ messageAlignment?: TextAlignment,
675
689
  extras?: Record<string, any>,
676
- campaignId?: string,
677
- cardId?: string,
678
690
  triggerId?: string,
679
- clickAction?: InAppMessage.ClickAction,
691
+ clickAction?: ClickAction,
680
692
  uri?: string,
681
- openTarget?: InAppMessage.OpenTarget,
682
- dismissType?: InAppMessage.DismissType,
693
+ openTarget?: OpenTarget,
694
+ dismissType?: DismissType,
683
695
  duration?: number,
684
696
  icon?: string,
685
697
  imageUrl?: string,
686
- imageStyle?: InAppMessage.ImageStyle,
698
+ imageStyle?: ImageStyle,
687
699
  iconColor?: number,
688
700
  iconBackgroundColor?: number,
689
701
  backgroundColor?: number,
@@ -692,36 +704,36 @@ declare namespace appboy {
692
704
  animateIn?: boolean,
693
705
  animateOut?: boolean,
694
706
  header?: string,
695
- headerAlignment?: InAppMessage.TextAlignment,
707
+ headerAlignment?: TextAlignment,
696
708
  headerTextColor?: number,
697
709
  frameColor?: number,
698
710
  buttons?: InAppMessageButton[],
699
- cropType?: InAppMessage.CropType,
700
- orientation?: InAppMessage.Orientation,
711
+ cropType?: CropType,
712
+ orientation?: Orientation,
701
713
  htmlId?: string,
702
714
  css?: string
703
715
  );
704
716
 
705
- /** How to align message text. See the `InAppMessage.TextAlignment` enum. */
706
- messageAlignment: InAppMessage.TextAlignment;
717
+ /** How to align message text. See the `TextAlignment` enum. */
718
+ messageAlignment: TextAlignment;
707
719
 
708
720
  /**
709
721
  * Where the user should be brought when clicking on this message. See the
710
- * `InAppMessage.ClickAction` enum.
722
+ * `ClickAction` enum.
711
723
  */
712
- clickAction: InAppMessage.ClickAction;
724
+ clickAction: ClickAction;
713
725
 
714
726
  /**
715
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
727
+ * If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
716
728
  * user clicks on this message.
717
729
  */
718
730
  uri?: string;
719
731
 
720
732
  /**
721
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
722
- * in a new tab/window. See the `InAppMessage.OpenTarget` enum.
733
+ * If ```clickAction``` is `ClickAction`.URI, whether to open clicks
734
+ * in a new tab/window. See the `OpenTarget` enum.
723
735
  */
724
- openTarget: InAppMessage.OpenTarget;
736
+ openTarget: OpenTarget;
725
737
 
726
738
  /**
727
739
  * A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
@@ -737,9 +749,9 @@ declare namespace appboy {
737
749
 
738
750
  /**
739
751
  * Whether the image should be shown as normal on the top of the in-app message or used
740
- * as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
752
+ * as the entire content of the message. See the `ImageStyle` enum.
741
753
  */
742
- imageStyle: InAppMessage.ImageStyle;
754
+ imageStyle: ImageStyle;
743
755
 
744
756
  /** Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
745
757
  iconColor: number;
@@ -756,11 +768,11 @@ declare namespace appboy {
756
768
  /** Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
757
769
  closeButtonColor: number;
758
770
 
759
- /** Header text to display. */
771
+ /** Header text to */
760
772
  header?: string;
761
773
 
762
- /** How to align header text. See the `InAppMessage.TextAlignment` enum. */
763
- headerAlignment: InAppMessage.TextAlignment;
774
+ /** How to align header text. See the `TextAlignment` enum. */
775
+ headerAlignment: TextAlignment;
764
776
 
765
777
  /** Color of header text. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
766
778
  headerTextColor: number;
@@ -771,46 +783,42 @@ declare namespace appboy {
771
783
  /** Array of up to two `InAppMessageButton` objects. */
772
784
  buttons: InAppMessageButton[];
773
785
 
774
- /** How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum. */
775
- cropType: InAppMessage.CropType;
786
+ /** How to crop and fit images in the allowable space. See the `CropType` enum. */
787
+ cropType: CropType;
776
788
 
777
789
  /**
778
790
  * Whether to lay out this in-app message as a portrait or landscape. See the
779
- * `InAppMessage.Orientation` enum.
791
+ * `Orientation` enum.
780
792
  */
781
- orientation: InAppMessage.Orientation;
793
+ orientation: Orientation;
782
794
  }
783
795
 
784
- class ModalMessage extends InAppMessage {
796
+ export class ModalMessage extends InAppMessage {
785
797
  /**
786
- * A modal in-app message object which can be passed to `display.showInAppMessage`
787
- * or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`
798
+ * A modal in-app message object which can be passed to `showInAppMessage`
799
+ * or handled manually. Subscribe to be notified when in-app messages are triggered via `subscribeToInAppMessage`
788
800
  *
789
801
  * @param message - The message to display to the user.
790
- * @param messageAlignment - How to align message text. See the `InAppMessage.TextAlignment` enum.
802
+ * @param messageAlignment - How to align message text. See the `TextAlignment` enum.
791
803
  * @param extras - Object of string/string key/value pairs.
792
- * @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
793
- * will report back to Appboy with in-app message analytics events.
794
- * @param cardId - If the message comes with a card, this is the id of the card that the SDK
795
- * will report back to Appboy with in-app message analytics events.
796
804
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
797
- * Appboy with in-app message analytics events.
805
+ * Braze with in-app message analytics events.
798
806
  * @param clickAction - Where the user should be brought when clicking on this message. See the
799
- * `InAppMessage.ClickAction` enum.
800
- * @param uri - If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
807
+ * `ClickAction` enum.
808
+ * @param uri - If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
801
809
  * user clicks on this message.
802
- * @param openTarget - If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
803
- * in a new tab/window. See the `InAppMessage.OpenTarget` enum.
810
+ * @param openTarget - If ```clickAction``` is `ClickAction`.URI, whether to open clicks
811
+ * in a new tab/window. See the `OpenTarget` enum.
804
812
  * @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
805
- * See the `InAppMessage.DismissType` enum.
813
+ * See the `DismissType` enum.
806
814
  * @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
807
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
815
+ * dismissType is `DismissType`.AUTO_DISMISS
808
816
  * @param icon - A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
809
817
  * [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
810
818
  * @param imageUrl - Url of an image to include in this message. The message will only display an image *or*
811
819
  * an icon, and will prioritize the image if present.
812
820
  * @param imageStyle - Whether the image should be shown as normal on the top of the in-app message or used
813
- * as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
821
+ * as the entire content of the message. See the `ImageStyle` enum.
814
822
  * @param iconColor - Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).
815
823
  * @param iconBackgroundColor - Background color of icon. Hex value with opacity (e.g. 0xff00ff00
816
824
  * is opaque green).
@@ -822,33 +830,31 @@ declare namespace appboy {
822
830
  * opaque green).
823
831
  * @param animateIn - Whether to animate the showing of this message.
824
832
  * @param animateOut - Whether to animate the hiding of this message.
825
- * @param header - Header text to display.
826
- * @param headerAlignment - How to align header text. See the `InAppMessage.TextAlignment` enum.
833
+ * @param header - Header text to
834
+ * @param headerAlignment - How to align header text. See the `TextAlignment` enum.
827
835
  * @param headerTextColor - Color of header text. Hex value with opacity (e.g. 0xff00ff00 is
828
836
  * opaque green).
829
837
  * @param frameColor - Color of the background frame which blocks page interaction while the
830
838
  * message is showing.
831
839
  * @param buttons - Array of up to two`InAppMessageButton` objects.
832
- * @param cropType - How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum.
840
+ * @param cropType - How to crop and fit images in the allowable space. See the `CropType` enum.
833
841
  * @param htmlId - The ID to give the parent HTML element that this message is rendered into.
834
842
  * @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
835
843
  * to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
836
844
  */
837
845
  constructor(
838
846
  message?: string,
839
- messageAlignment?: InAppMessage.TextAlignment,
847
+ messageAlignment?: TextAlignment,
840
848
  extras?: Record<string, any>,
841
- campaignId?: string,
842
- cardId?: string,
843
849
  triggerId?: string,
844
- clickAction?: InAppMessage.ClickAction,
850
+ clickAction?: ClickAction,
845
851
  uri?: string,
846
- openTarget?: InAppMessage.OpenTarget,
847
- dismissType?: InAppMessage.DismissType,
852
+ openTarget?: OpenTarget,
853
+ dismissType?: DismissType,
848
854
  duration?: number,
849
855
  icon?: string,
850
856
  imageUrl?: string,
851
- imageStyle?: InAppMessage.ImageStyle,
857
+ imageStyle?: ImageStyle,
852
858
  iconColor?: number,
853
859
  iconBackgroundColor?: number,
854
860
  backgroundColor?: number,
@@ -857,35 +863,35 @@ declare namespace appboy {
857
863
  animateIn?: boolean,
858
864
  animateOut?: boolean,
859
865
  header?: string,
860
- headerAlignment?: InAppMessage.TextAlignment,
866
+ headerAlignment?: TextAlignment,
861
867
  headerTextColor?: number,
862
868
  frameColor?: number,
863
869
  buttons?: InAppMessageButton[],
864
- cropType?: InAppMessage.CropType,
870
+ cropType?: CropType,
865
871
  htmlId?: string,
866
872
  css?: string
867
873
  );
868
874
 
869
- /** How to align message text. See the `InAppMessage.TextAlignment` enum. */
870
- messageAlignment: InAppMessage.TextAlignment;
875
+ /** How to align message text. See the `TextAlignment` enum. */
876
+ messageAlignment: TextAlignment;
871
877
 
872
878
  /**
873
879
  * Where the user should be brought when clicking on this message. See the
874
- * `InAppMessage.ClickAction` enum.
880
+ * `ClickAction` enum.
875
881
  */
876
- clickAction: InAppMessage.ClickAction;
882
+ clickAction: ClickAction;
877
883
 
878
884
  /**
879
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
885
+ * If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
880
886
  * user clicks on this message.
881
887
  */
882
888
  uri?: string;
883
889
 
884
890
  /**
885
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
886
- * in a new tab/window. See the `InAppMessage.OpenTarget` enum.
891
+ * If ```clickAction``` is `ClickAction`.URI, whether to open clicks
892
+ * in a new tab/window. See the `OpenTarget` enum.
887
893
  */
888
- openTarget: InAppMessage.OpenTarget;
894
+ openTarget: OpenTarget;
889
895
 
890
896
  /**
891
897
  * A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
@@ -901,9 +907,9 @@ declare namespace appboy {
901
907
 
902
908
  /**
903
909
  * Whether the image should be shown as normal on the top of the in-app message or used
904
- * as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
910
+ * as the entire content of the message. See the `ImageStyle` enum.
905
911
  */
906
- imageStyle: InAppMessage.ImageStyle;
912
+ imageStyle: ImageStyle;
907
913
 
908
914
  /** Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
909
915
  iconColor: number;
@@ -920,11 +926,11 @@ declare namespace appboy {
920
926
  /** Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
921
927
  closeButtonColor: number;
922
928
 
923
- /** Header text to display. */
929
+ /** Header text to */
924
930
  header?: string;
925
931
 
926
- /** How to align header text. See the `InAppMessage.TextAlignment` enum. */
927
- headerAlignment: InAppMessage.TextAlignment;
932
+ /** How to align header text. See the `TextAlignment` enum. */
933
+ headerAlignment: TextAlignment;
928
934
 
929
935
  /** Color of header text. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
930
936
  headerTextColor: number;
@@ -935,27 +941,23 @@ declare namespace appboy {
935
941
  /** Array of up to two`InAppMessageButton` objects. */
936
942
  buttons: InAppMessageButton[];
937
943
 
938
- /** How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum. */
939
- cropType: InAppMessage.CropType;
944
+ /** How to crop and fit images in the allowable space. See the `CropType` enum. */
945
+ cropType: CropType;
940
946
  }
941
947
 
942
- class HtmlMessage extends InAppMessage {
948
+ export class HtmlMessage extends InAppMessage {
943
949
  /**
944
- * An html-content in-app message object which can be passed to `display.showInAppMessage`
945
- * or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`
950
+ * An html-content in-app message object which can be passed to `showInAppMessage`
951
+ * or handled manually. Subscribe to be notified when in-app messages are triggered via `subscribeToInAppMessage`
946
952
  *
947
953
  * @param message - The html content to display to the user.
948
954
  * @param extras - Object of string/string key/value pairs.
949
- * @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
950
- * will report back to Appboy with in-app message analytics events.
951
- * @param cardId - If the message comes with a card, this is the id of the card that the SDK
952
- * will report back to Appboy with in-app message analytics events.
953
955
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
954
- * Appboy with in-app message analytics events.
956
+ * Braze with in-app message analytics events.
955
957
  * @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
956
- * See the `InAppMessage.TextAlignment` enum.
958
+ * See the `TextAlignment` enum.
957
959
  * @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
958
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`.
960
+ * dismissType is `DismissType`.AUTO_DISMISS.
959
961
  * @param animateIn - Whether to animate the showing of this message.
960
962
  * @param animateOut - Whether to animate the hiding of this message.
961
963
  * @param frameColor - Color of the background frame which blocks page interaction while the message is showing.
@@ -967,10 +969,8 @@ declare namespace appboy {
967
969
  constructor(
968
970
  message: string,
969
971
  extras?: Record<string, any>,
970
- campaignId?: string,
971
- cardId?: string,
972
972
  triggerId?: string,
973
- dismissType?: InAppMessage.DismissType,
973
+ dismissType?: DismissType,
974
974
  duration?: number,
975
975
  animateIn?: boolean,
976
976
  animateOut?: boolean,
@@ -988,34 +988,30 @@ declare namespace appboy {
988
988
  }
989
989
 
990
990
  /**
991
- * A slide-up in-app message object which can be passed to `display.showInAppMessage`
992
- * or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`
991
+ * A slide-up in-app message object which can be passed to `showInAppMessage`
992
+ * or handled manually. Subscribe to be notified when in-app messages are triggered via `subscribeToInAppMessage`
993
993
  */
994
- class SlideUpMessage extends InAppMessage {
994
+ export class SlideUpMessage extends InAppMessage {
995
995
  /**
996
- * A slide-up in-app message object which can be passed to `display.showInAppMessage`
997
- * or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`
996
+ * A slide-up in-app message object which can be passed to `showInAppMessage`
997
+ * or handled manually. Subscribe to be notified when in-app messages are triggered via `subscribeToInAppMessage`
998
998
  *
999
999
  * @param message - The message to display to the user.
1000
- * @param messageAlignment - How to align message text. See the `InAppMessage.TextAlignment` enum.
1001
- * @param slideFrom - Where the message should slide in from. See the `InAppMessage.SlideFrom` enum.
1000
+ * @param messageAlignment - How to align message text. See the `TextAlignment` enum.
1001
+ * @param slideFrom - Where the message should slide in from. See the `SlideFrom` enum.
1002
1002
  * @param extras - Object of string/string key/value pairs.
1003
- * @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
1004
- * will report back to Appboy with in-app message analytics events.
1005
- * @param cardId - If the message comes with a card, this is the id of the card that the SDK
1006
- * will report back to Appboy with in-app message analytics events.
1007
1003
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
1008
- * Appboy with in-app message analytics events.
1004
+ * Braze with in-app message analytics events.
1009
1005
  * @param clickAction - Where the user should be brought when clicking on this message. See the
1010
- * `InAppMessage.ClickAction` enum.
1011
- * @param uri - If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
1006
+ * `ClickAction` enum.
1007
+ * @param uri - If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
1012
1008
  * user clicks on this message.
1013
- * @param openTarget - If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
1014
- * in a new tab/window. See the `InAppMessage.OpenTarget` enum.
1009
+ * @param openTarget - If ```clickAction``` is `ClickAction`.URI, whether to open clicks
1010
+ * in a new tab/window. See the `OpenTarget` enum.
1015
1011
  * @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
1016
- * See the `InAppMessage.DismissType` enum.
1012
+ * See the `DismissType` enum.
1017
1013
  * @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
1018
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
1014
+ * dismissType is `DismissType`.AUTO_DISMISS
1019
1015
  * @param icon - A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
1020
1016
  * [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
1021
1017
  * @param imageUrl - Url of an image to include in this message. The message will only display an image *or*
@@ -1037,16 +1033,14 @@ declare namespace appboy {
1037
1033
  */
1038
1034
  constructor(
1039
1035
  message: string,
1040
- messageAlignment?: InAppMessage.TextAlignment,
1041
- slideFrom?: InAppMessage.SlideFrom,
1036
+ messageAlignment?: TextAlignment,
1037
+ slideFrom?: SlideFrom,
1042
1038
  extras?: Record<string, any>,
1043
- campaignId?: string,
1044
- cardId?: string,
1045
1039
  triggerId?: string,
1046
- clickAction?: InAppMessage.ClickAction,
1040
+ clickAction?: ClickAction,
1047
1041
  uri?: string,
1048
- openTarget?: InAppMessage.OpenTarget,
1049
- dismissType?: InAppMessage.DismissType,
1042
+ openTarget?: OpenTarget,
1043
+ dismissType?: DismissType,
1050
1044
  duration?: number,
1051
1045
  icon?: string,
1052
1046
  imageUrl?: string,
@@ -1061,29 +1055,29 @@ declare namespace appboy {
1061
1055
  css?: string
1062
1056
  );
1063
1057
 
1064
- /** How to align message text. See the `InAppMessage.TextAlignment` enum. */
1065
- messageAlignment: InAppMessage.TextAlignment;
1058
+ /** How to align message text. See the `TextAlignment` enum. */
1059
+ messageAlignment: TextAlignment;
1066
1060
 
1067
- /** Where the message should slide in from. See the `InAppMessage.SlideFrom` enum. */
1068
- slideFrom: InAppMessage.SlideFrom;
1061
+ /** Where the message should slide in from. See the `SlideFrom` enum. */
1062
+ slideFrom: SlideFrom;
1069
1063
 
1070
1064
  /**
1071
1065
  * Where the user should be brought when clicking on this message. See the
1072
- * `InAppMessage.ClickAction` enum.
1066
+ * `ClickAction` enum.
1073
1067
  */
1074
- clickAction: InAppMessage.ClickAction;
1068
+ clickAction: ClickAction;
1075
1069
 
1076
1070
  /**
1077
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
1071
+ * If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
1078
1072
  * user clicks on this message.
1079
1073
  */
1080
1074
  uri?: string;
1081
1075
 
1082
1076
  /**
1083
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
1084
- * in a new tab/window. See the `InAppMessage.OpenTarget` enum.
1077
+ * If ```clickAction``` is `ClickAction`.URI, whether to open clicks
1078
+ * in a new tab/window. See the `OpenTarget` enum.
1085
1079
  */
1086
- openTarget: InAppMessage.OpenTarget;
1080
+ openTarget: OpenTarget;
1087
1081
 
1088
1082
  /**
1089
1083
  * A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
@@ -1113,20 +1107,21 @@ declare namespace appboy {
1113
1107
  closeButtonColor: number;
1114
1108
  }
1115
1109
 
1116
- namespace User {
1117
- type Genders = "m" | "f" | "o" | "u" | "n" | "p";
1118
- type NotificationSubscriptionTypes = "opted_in" | "subscribed" | "unsubscribed";
1119
- }
1110
+
1111
+ type Genders = typeof User.Genders[keyof typeof User.Genders];
1112
+
1113
+
1114
+ type NotificationSubscriptionTypes = typeof User.NotificationSubscriptionTypes[keyof typeof User.NotificationSubscriptionTypes];
1120
1115
 
1121
1116
  /**
1122
- * Do not construct directly - use `appboy.getUser` to get the user object.
1117
+ * Do not construct directly - use `getUser` to get the user object.
1123
1118
  * User provides an object which lets you update the attributes stored by Braze for your user.
1124
1119
  *
1125
1120
  * This class has been designed to provide fire and forget semantics and to not impact the performance or lifecycle of
1126
1121
  * calling code. As such, changes made to an User are enqueued locally and flushed to Braze's servers
1127
1122
  * asynchronously.
1128
1123
  */
1129
- class User {
1124
+ export class User {
1130
1125
  /** Enum to represent valid genders. */
1131
1126
  static Genders: {
1132
1127
  MALE: "m";
@@ -1182,7 +1177,7 @@ declare namespace appboy {
1182
1177
  * For example:
1183
1178
  *
1184
1179
  * ```
1185
- * appboy.getUser().getUserId(function(userId) {
1180
+ * braze.getUser().getUserId(function(userId) {
1186
1181
  * console.log('The user is ' + userId);
1187
1182
  * });
1188
1183
  * ```
@@ -1225,17 +1220,7 @@ declare namespace appboy {
1225
1220
  *
1226
1221
  * @returns Whether the update was successfully enqueued.
1227
1222
  */
1228
- removeFromSubscriptionGroup(subscriptionGroupId: string): boolean;
1229
-
1230
- /**
1231
- * Sets the url for the avatar image for the user, which will be displayed on the user profile
1232
- * and throughout the Braze dashboard.
1233
- *
1234
- * @param avatarImageUrl
1235
- *
1236
- * @returns Whether the update was successfully enqueued.
1237
- */
1238
- setAvatarImageUrl(avatarImageUrl: string): boolean;
1223
+ removeFromSubscriptionGroup(subscriptionGroupId: string): boolean;
1239
1224
 
1240
1225
  /**
1241
1226
  * Sets the country for the user.
@@ -1311,12 +1296,12 @@ declare namespace appboy {
1311
1296
  * Sets whether the user should be sent email campaigns.
1312
1297
  *
1313
1298
  * @param notificationSubscriptionType - Notification setting (explicitly opted-in, subscribed, or unsubscribed).
1314
- * See the `User.NotificationSubscriptionTypes` enum.
1299
+ * See the `NotificationSubscriptionTypes` enum.
1315
1300
  *
1316
1301
  * @returns Whether the update was successfully enqueued.
1317
1302
  */
1318
1303
  setEmailNotificationSubscriptionType(
1319
- notificationSubscriptionType: User.NotificationSubscriptionTypes
1304
+ notificationSubscriptionType: NotificationSubscriptionTypes
1320
1305
  ): boolean;
1321
1306
 
1322
1307
  /**
@@ -1331,12 +1316,12 @@ declare namespace appboy {
1331
1316
  /**
1332
1317
  * Sets the gender of the user.
1333
1318
  *
1334
- * @param gender - Generally 'm' or 'f'. Accepts an explicit null value to null out attribute. Use `User.Genders`
1319
+ * @param gender - Generally 'm' or 'f'. Accepts an explicit null value to null out attribute. Use `Genders`
1335
1320
  * enum when setting this value.
1336
1321
  *
1337
1322
  * @returns Whether the update was successfully enqueued.
1338
1323
  */
1339
- setGender(gender: User.Genders | null): boolean;
1324
+ setGender(gender: Genders | null): boolean;
1340
1325
 
1341
1326
  /**
1342
1327
  * Sets the home city for the user.
@@ -1403,16 +1388,16 @@ declare namespace appboy {
1403
1388
  * Sets whether the user should be sent push campaigns.
1404
1389
  *
1405
1390
  * @param notificationSubscriptionType - Notification setting (explicitly opted-in, subscribed, or unsubscribed).
1406
- * See the `User.NotificationSubscriptionTypes` enum.
1391
+ * See the `NotificationSubscriptionTypes` enum.
1407
1392
  *
1408
1393
  * @returns Whether the update was successfully enqueued.
1409
1394
  */
1410
1395
  setPushNotificationSubscriptionType(
1411
- notificationSubscriptionType: User.NotificationSubscriptionTypes
1396
+ notificationSubscriptionType: NotificationSubscriptionTypes
1412
1397
  ): boolean;
1413
1398
  }
1414
1399
 
1415
- class InAppMessageButton {
1400
+ export class InAppMessageButton {
1416
1401
  /**
1417
1402
  * Represents a button on an `ModalMessage` or `FullScreenMessage`.
1418
1403
  *
@@ -1424,8 +1409,8 @@ declare namespace appboy {
1424
1409
  * @param borderColor - The color for the border of this button. Hex value with opacity (e.g.
1425
1410
  * 0xff00ff00 is opaque green).
1426
1411
  * @param clickAction - Where the user should be brought when clicking on this button. See the
1427
- * `InAppMessage.ClickAction` enum.
1428
- * @param uri - If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
1412
+ * `ClickAction` enum.
1413
+ * @param uri - If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
1429
1414
  * user clicks on this button.
1430
1415
  * @param id - The id for this button. Used for analytics.
1431
1416
  */
@@ -1434,7 +1419,7 @@ declare namespace appboy {
1434
1419
  backgroundColor?: number,
1435
1420
  textColor?: number,
1436
1421
  borderColor?: number,
1437
- clickAction?: InAppMessage.ClickAction,
1422
+ clickAction?: ClickAction,
1438
1423
  uri?: string,
1439
1424
  id?: number
1440
1425
  );
@@ -1462,12 +1447,12 @@ declare namespace appboy {
1462
1447
 
1463
1448
  /**
1464
1449
  * Where the user should be brought when clicking on this button. See the
1465
- * `InAppMessage.ClickAction` enum.
1450
+ * `ClickAction` enum.
1466
1451
  */
1467
- clickAction: InAppMessage.ClickAction;
1452
+ clickAction: ClickAction;
1468
1453
 
1469
1454
  /**
1470
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
1455
+ * If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
1471
1456
  * user clicks on this button.
1472
1457
  */
1473
1458
  uri?: string;
@@ -1500,131 +1485,125 @@ declare namespace appboy {
1500
1485
  }
1501
1486
 
1502
1487
  /**
1503
- * appboy.display is the public class for the UI portions of Braze's Web SDK. It is only available in
1504
- * `https://js.appboycdn.com/web-sdk-develop/3.5/appboy.min.js` and is stripped from the more minimal
1505
- * `https://js.appboycdn.com/web-sdk-develop/3.5/appboy.core.min.js`.
1488
+ * Automatically display in-app messages when they are triggered. This method should be called before
1489
+ * calling `openSession`.
1490
+ *
1491
+ * @returns The identifier of the subscription created. This can be passed to
1492
+ * `removeSubscription` to cancel the subscription.
1506
1493
  */
1507
- namespace display {
1508
- /**
1509
- * Automatically display new in-app messages when they come in from the server.
1510
- *
1511
- * @returns The identifier of the subscription created. This can be passed to
1512
- * 'appboy.removeSubscription` to cancel the subscription.
1513
- */
1514
- function automaticallyShowNewInAppMessages(): string;
1494
+ export function automaticallyShowInAppMessages(): string;
1515
1495
 
1516
- /**
1517
- * Destroy any Braze news feed currently showing. This method will appropriately clean up any retained resources
1518
- * and also display the hiding animation, and so should be used instead of manually removing feed html from the
1519
- * DOM.
1520
- */
1521
- function destroyFeed(): void;
1496
+ /**
1497
+ * Destroy any Braze news feed currently showing. This method will appropriately clean up any retained resources
1498
+ * and also display the hiding animation, and so should be used instead of manually removing feed html from the
1499
+ * DOM.
1500
+ */
1501
+ export function destroyFeed(): void;
1522
1502
 
1523
- /**
1524
- * Hide any Braze content cards currently showing in the parent node, or if none is provided, any content cards in the page.
1525
- * This method will appropriately clean up any retained resources and also display the hiding animation, and so should be
1526
- * used instead of manually removing content cards HTML from the DOM.
1527
- *
1528
- * @param parentNode - The HTML node that denotes the parent of the content cards to be hidden. If null/undefined, all content
1529
- * cards on the page will be hidden.
1530
- */
1531
- function hideContentCards(parentNode?: Element | null): void;
1503
+ /**
1504
+ * Hide any Braze content cards currently showing in the parent node, or if none is provided, any content cards in the page.
1505
+ * This method will appropriately clean up any retained resources and also display the hiding animation, and so should be
1506
+ * used instead of manually removing content cards HTML from the DOM.
1507
+ *
1508
+ * @param parentNode - The HTML node that denotes the parent of the content cards to be hidden. If null/undefined, all content
1509
+ * cards on the page will be hidden.
1510
+ */
1511
+ export function hideContentCards(parentNode?: Element | null): void;
1532
1512
 
1533
- /**
1534
- * Display the user's content cards.
1535
- *
1536
- * @param parentNode - The HTML node to render the content cards into. If null/undefined, the content
1537
- * cards will be rendered in fixed position over the right-hand side of the page and appended to the `<body>`
1538
- * node. If the parent node already has a Braze content cards view as a direct descendant, the existing content
1539
- * cards will be replaced.
1540
- * @param filterFunction - A filter/sort function for cards displayed in this view. Invoked with the
1541
- * array of `Card` objects, sorted by {pinned, date}. Expected to return an array of sorted
1542
- * `Card` objects to render for this user. If omitted, all cards will be displayed.
1543
- */
1544
- function showContentCards(
1545
- parentNode?: Element | null,
1546
- filterFunction?: (cards: appboy.Card[]) => appboy.Card[]
1547
- ): void;
1513
+ /**
1514
+ * Display the user's content cards.
1515
+ *
1516
+ * @param parentNode - The HTML node to render the content cards into. If null/undefined, the content
1517
+ * cards will be rendered in fixed position over the right-hand side of the page and appended to the `<body>`
1518
+ * node. If the parent node already has a Braze content cards view as a direct descendant, the existing content
1519
+ * cards will be replaced.
1520
+ * @param filterFunction - A filter/sort function for cards displayed in this view. Invoked with the
1521
+ * array of `Card` objects, sorted by {pinned, date}. Expected to return an array of sorted
1522
+ * `Card` objects to render for this user. If omitted, all cards will be displayed.
1523
+ */
1524
+ export function showContentCards(
1525
+ parentNode?: Element | null,
1526
+ filterFunction?: (cards: Card[]) => Card[]
1527
+ ): void;
1548
1528
 
1549
- /**
1550
- * Display the user's news feed.
1551
- *
1552
- * @param parentNode - The HTML node to render the news feed into. If null/undefined, the feed will be
1553
- * rendered in fixed position over the right-hand side of the page and appended to the `<body>` node. If the
1554
- * parent node already has an Braze news feed as a direct descendant, the existing feed will be replaced.
1555
- * @param cards - A static set of cards to display. Each item in this Array should be a `Card`
1556
- * descendant. If this parameter is null/undefined, all unexpired cards from the last news feed refresh will be
1557
- * used automatically, a feed refresh will be kicked off automatically if the cached cards are more than 1 minute
1558
- * old, and the feed will automatically update when new cards are received while it is still showing. If you
1559
- * provide an explicit set of cards by using this parameter, no action will be taken when new cards are received,
1560
- * and you must subscribe to feed updates yourself with `appboy.subscribeToFeedUpdates` and request updates with
1561
- * `appboy.requestFeedRefresh` if you want to update this feed with new cards.
1562
- * @param allowedCategories - A set of categories to filter cards to. Each item in this Array should be a
1563
- * card category as set in the Braze dashboard. If omitted, all cards will be displayed.
1564
- */
1565
- function showFeed(
1566
- parentNode?: Element | null,
1567
- cards?: appboy.Card[] | null,
1568
- allowedCategories?: string[]
1569
- ): void;
1529
+ /**
1530
+ * Display the user's news feed.
1531
+ *
1532
+ * @param parentNode - The HTML node to render the news feed into. If null/undefined, the feed will be
1533
+ * rendered in fixed position over the right-hand side of the page and appended to the `<body>` node. If the
1534
+ * parent node already has an Braze news feed as a direct descendant, the existing feed will be replaced.
1535
+ * @param cards - A static set of cards to Each item in this Array should be a `Card`
1536
+ * descendant. If this parameter is null/undefined, all unexpired cards from the last news feed refresh will be
1537
+ * used automatically, a feed refresh will be kicked off automatically if the cached cards are more than 1 minute
1538
+ * old, and the feed will automatically update when new cards are received while it is still showing. If you
1539
+ * provide an explicit set of cards by using this parameter, no action will be taken when new cards are received,
1540
+ * and you must subscribe to feed updates yourself with `subscribeToFeedUpdates` and request updates with
1541
+ * `requestFeedRefresh` if you want to update this feed with new cards.
1542
+ * @param allowedCategories - A set of categories to filter cards to. Each item in this Array should be a
1543
+ * card category as set in the Braze dashboard. If omitted, all cards will be displayed.
1544
+ */
1545
+ export function showFeed(
1546
+ parentNode?: Element | null,
1547
+ cards?: Card[] | null,
1548
+ allowedCategories?: string[]
1549
+ ): void;
1570
1550
 
1571
- /**
1572
- * Display a given in-app message.
1573
- *
1574
- * @param inAppMessage - The message to display.
1575
- * @param parentNode - The HTML node to render the in-app message into. If null/undefined, the message
1576
- * will be rendered appended within the `<body>` node.
1577
- * @param onDisplayCallback - Optional callback to invoke once the message is on the screen.
1578
- *
1579
- * @returns Whether or not the message was displayed (or, in the case of control messages, logged to
1580
- * Braze servers).
1581
- */
1582
- function showInAppMessage(
1583
- inAppMessage: appboy.InAppMessage | appboy.ControlMessage,
1584
- parentNode?: Element | null,
1585
- onDisplayCallback?: () => void
1586
- ): boolean;
1551
+ /**
1552
+ * Display a given in-app message.
1553
+ *
1554
+ * @param inAppMessage - The message to
1555
+ * @param parentNode - The HTML node to render the in-app message into. If null/undefined, the message
1556
+ * will be rendered appended within the `<body>` node.
1557
+ * @param onDisplayCallback - Optional callback to invoke once the message is on the screen.
1558
+ *
1559
+ * @returns Whether or not the message was displayed (or, in the case of control messages, logged to
1560
+ * Braze servers).
1561
+ */
1562
+ export function showInAppMessage(
1563
+ inAppMessage: InAppMessage | ControlMessage,
1564
+ parentNode?: Element | null,
1565
+ onDisplayCallback?: () => void
1566
+ ): boolean;
1587
1567
 
1588
- /**
1589
- * Toggle the display of Braze content cards, showing them if they are not shown, and hiding them if they are. If you
1590
- * wish to display multiple content cards feeds on a page simultaneously, you should use `showContentCards` and `hideContentCards`
1591
- * to show/hide each feed individually instead of this method.
1592
- *
1593
- * @param parentNode - The HTML node to render the content cards into. If null/undefined, the content
1594
- * cards will be rendered in fixed position over the right-hand side of the page and appended to the `<body>`
1595
- * node. If the parent node already has a Braze content cards view as a direct descendant, the existing content
1596
- * cards will be replaced.
1597
- * @param filterFunction - A filter/sort function for cards displayed in this view. Invoked with the
1598
- * array of `Card` objects, sorted by {pinned, date}. Expected to return an array of sorted
1599
- * `Card` objects to render for this user. If omitted, all cards will be displayed.
1600
- */
1601
- function toggleContentCards(
1602
- parentNode?: Element | null,
1603
- filterFunction?: (cards: appboy.Card[]) => appboy.Card[]
1604
- ): void;
1605
-
1606
- /**
1607
- * Toggle the Braze news feed, creating it if it does not exist, and destroying it if it does.
1608
- *
1609
- * @param parentNode - The HTML node to render the news feed into. If null/undefined, the feed will be
1610
- * rendered in fixed position over the right-hand side of the page and appended to the `<body>` node. If the
1611
- * parent node already has an Braze news feed as a direct descendant, the existing feed will be replaced.
1612
- * @param cards - A static set of cards to display. Each item in this Array should be a `Card`
1613
- * descendant. If this parameter is null/undefined, all unexpired cards from the last news feed refresh will be
1614
- * used automatically, a feed refresh will be kicked off automatically if the cached cards are more than 1 minute
1615
- * old, and the feed will automatically update when new cards are received while it is still showing. If you
1616
- * provide an explicit set of cards by using this parameter, no action will be taken when new cards are received,
1617
- * and you must subscribe to feed updates yourself with `appboy.subscribeToFeedUpdates` and request updates with
1618
- * `appboy.requestFeedRefresh` if you want to update this feed with new cards.
1619
- * @param allowedCategories - A set of categories to filter cards to. Each item in this Array should be a
1620
- * card category as set in the Braze dashboard. If omitted, all cards will be displayed.
1621
- */
1622
- function toggleFeed(
1623
- parentNode?: Element | null,
1624
- cards?: appboy.Card[] | null,
1625
- allowedCategories?: string[]
1626
- ): void;
1627
- }
1568
+ /**
1569
+ * Toggle the display of Braze content cards, showing them if they are not shown, and hiding them if they are. If you
1570
+ * wish to display multiple content cards feeds on a page simultaneously, you should use `showContentCards` and `hideContentCards`
1571
+ * to show/hide each feed individually instead of this method.
1572
+ *
1573
+ * @param parentNode - The HTML node to render the content cards into. If null/undefined, the content
1574
+ * cards will be rendered in fixed position over the right-hand side of the page and appended to the `<body>`
1575
+ * node. If the parent node already has a Braze content cards view as a direct descendant, the existing content
1576
+ * cards will be replaced.
1577
+ * @param filterFunction - A filter/sort function for cards displayed in this view. Invoked with the
1578
+ * array of `Card` objects, sorted by {pinned, date}. Expected to return an array of sorted
1579
+ * `Card` objects to render for this user. If omitted, all cards will be displayed.
1580
+ */
1581
+ export function toggleContentCards(
1582
+ parentNode?: Element | null,
1583
+ filterFunction?: (cards: Card[]) => Card[]
1584
+ ): void;
1585
+
1586
+ /**
1587
+ * Toggle the Braze news feed, creating it if it does not exist, and destroying it if it does.
1588
+ *
1589
+ * @param parentNode - The HTML node to render the news feed into. If null/undefined, the feed will be
1590
+ * rendered in fixed position over the right-hand side of the page and appended to the `<body>` node. If the
1591
+ * parent node already has an Braze news feed as a direct descendant, the existing feed will be replaced.
1592
+ * @param cards - A static set of cards to Each item in this Array should be a `Card`
1593
+ * descendant. If this parameter is null/undefined, all unexpired cards from the last news feed refresh will be
1594
+ * used automatically, a feed refresh will be kicked off automatically if the cached cards are more than 1 minute
1595
+ * old, and the feed will automatically update when new cards are received while it is still showing. If you
1596
+ * provide an explicit set of cards by using this parameter, no action will be taken when new cards are received,
1597
+ * and you must subscribe to feed updates yourself with `subscribeToFeedUpdates` and request updates with
1598
+ * `requestFeedRefresh` if you want to update this feed with new cards.
1599
+ * @param allowedCategories - A set of categories to filter cards to. Each item in this Array should be a
1600
+ * card category as set in the Braze dashboard. If omitted, all cards will be displayed.
1601
+ */
1602
+ export function toggleFeed(
1603
+ parentNode?: Element | null,
1604
+ cards?: Card[] | null,
1605
+ allowedCategories?: string[]
1606
+ ): void;
1628
1607
 
1629
1608
  /**
1630
1609
  * When a user first uses Braze on a device they are considered "anonymous". Use this method to identify a user
@@ -1663,13 +1642,13 @@ declare namespace appboy {
1663
1642
  * using the `setSdkAuthenticationSignature` method. This signature will only have an effect if the `enableSdkAuthentication`
1664
1643
  * initialization option is set to true.
1665
1644
  */
1666
- function changeUser(userId: string, signature?: string): void;
1645
+ export function changeUser(userId: string, signature?: string): void;
1667
1646
 
1668
1647
  /**
1669
- * Destroys this appboy instance, destroying all subscription callbacks and releasing member variables which
1648
+ * Destroys this `braze` instance, destroying all subscription callbacks and releasing member variables which
1670
1649
  * retain memory.
1671
1650
  */
1672
- function destroy(): void;
1651
+ export function destroy(): void;
1673
1652
 
1674
1653
  /**
1675
1654
  * Get all currently available cards from the last content cards refresh.
@@ -1677,7 +1656,7 @@ declare namespace appboy {
1677
1656
  * @returns - A `ContentCards` object which includes all currently available
1678
1657
  * `Card` objects from the last content cards refresh.
1679
1658
  */
1680
- function getCachedContentCards(): appboy.ContentCards;
1659
+ export function getCachedContentCards(): ContentCards;
1681
1660
 
1682
1661
  /**
1683
1662
  * Get all unexpired cards from the last news feed refresh.
@@ -1685,88 +1664,74 @@ declare namespace appboy {
1685
1664
  * @returns - A `Feed` object which includes all unexpired `Card` objects from the last
1686
1665
  * news feed refresh.
1687
1666
  */
1688
- function getCachedFeed(): appboy.Feed;
1667
+ export function getCachedFeed(): Feed;
1689
1668
 
1690
1669
  /**
1691
1670
  * Asynchronously retrieves the 'device id,' a randomly generated ID that is stored on the browser.
1692
1671
  * This ID resets for private browsing sessions and when website data is cleared. For example:
1693
1672
  *
1694
1673
  * ```
1695
- * appboy.getDeviceId(function(deviceId) {
1674
+ * braze.getDeviceId(function(deviceId) {
1696
1675
  * console.log('The device id is ' + deviceId);
1697
1676
  * });
1698
1677
  * ```
1699
1678
  *
1700
1679
  * @param callback - Asynchronous callback - this will be invoked with the deviceId.
1701
1680
  */
1702
- function getDeviceId(callback: (deviceId: string) => void): void;
1681
+ export function getDeviceId(callback: (deviceId: string) => void): void;
1703
1682
 
1704
1683
  /**
1705
1684
  * @returns The user currently being tracked by Braze, used for querying the tracked user id and setting
1706
- * user attributes. Should only be accessed via the `getUser` function.
1685
+ * user attributes. Should only be accessed via the `getUser` function. Returns undefined if the
1686
+ * SDK has not been initialized.
1707
1687
  */
1708
- function getUser(): appboy.User;
1688
+ export function getUser(): User | undefined;
1709
1689
 
1710
1690
  /**
1711
- * Initializes this `appboy` instance with your API key. This method must be called before other Braze methods are
1691
+ * Initializes this `braze` instance with your API key. This method must be called before other Braze methods are
1712
1692
  * invoked, and is part of the default loading snippets. Subsequent calls will be ignored until 'destroy`
1713
1693
  * is called.
1714
1694
  *
1715
1695
  * @param apiKey - Your app's Braze API Key. Your API keys can be found
1716
- * [here](https://dashboard.appboy.com/app_settings/app_settings).
1696
+ * [here](https://dashboard.braze.com/app_settings/app_settings).
1717
1697
  * @param options - Configuration options. See `InitializationOptions` for supported options.
1718
1698
  *
1719
- * @returns - Whether or not the `appboy` instance has been successfully initialized.
1699
+ * @returns - Whether or not the `braze` instance has been successfully initialized.
1720
1700
  * Reasons for returning false include a missing API key/base URL, user opt out, and ignored crawler bot activity.
1721
1701
  */
1722
- function initialize(apiKey: string, options: InitializationOptions): boolean;
1702
+ export function initialize(apiKey: string, options: InitializationOptions): boolean;
1723
1703
 
1724
1704
  /**
1725
1705
  * @returns Whether or not the user has blocked push. If the user has blocked push, they cannot be
1726
- * prompted to register again, and must manually remove the block in order to receive push.
1706
+ * prompted to register again, and must manually remove the block in order to receive push.
1707
+ * Returns undefined if the SDK has not been initialized.
1727
1708
  */
1728
- function isPushBlocked(): boolean;
1729
-
1730
- /**
1731
- * DEPRECATED - Tests whether the user has given this browser push permission (they may still be unsubscribed from
1732
- * push via `User.setPushNotificationSubscriptionType`). A true value essentially means that
1733
- * `appboy.registerAppboyPushMessages` may be called without the user being prompted. Useful for migrating existing
1734
- * non-Braze push registrations to appboy.
1735
- *
1736
- * @deprecated This function inappropriately reports whether or not the browser *currently* has an active
1737
- * registered push subscription, and does not answer the intended permissions question of whether the user has
1738
- * granted the browser push permissions.
1739
- * Please use `appboy.isPushPermissionGranted` instead. This WILL BE REMOVED.
1740
- *
1741
- * @param yesCallback - Invoked if the user has granted push access on this browser
1742
- * @param noCallback - Invoked if the user has not granted push access on this browser
1743
- */
1744
- function isPushGranted(yesCallback: () => void, noCallback: () => void): void;
1709
+ export function isPushBlocked(): boolean | undefined;
1745
1710
 
1746
1711
  /**
1747
1712
  * Tests whether the user has given this browser push permission (they may still be unsubscribed from push via
1748
1713
  * `User.setPushNotificationSubscriptionType`). A true value essentially means that
1749
- * `appboy.registerAppboyPushMessages` may be called without the
1750
- * user being prompted. Useful for migrating existing non-Braze push registrations to appboy.
1714
+ * `requestPushPermission` may be called without the user being prompted. Useful for migrating existing
1715
+ * non-Braze push registrations to Braze.
1751
1716
  *
1752
1717
  * @returns Whether or not the user has granted push permission. If this returns true,
1753
- * `appboy.registerAppboyPushMessages` may be called without the user being prompted. If this returns false,
1754
- * `appboy.registerAppboyPushMessages` may prompt the user (if `appboy.isPushSupported` returns true) or do
1755
- * nothing (if `appboy.isPushSupported` returns false)
1718
+ * `requestPushPermission` may be called without the user being prompted. If this returns false,
1719
+ * `requestPushPermission` may prompt the user (if `isPushSupported` returns true) or do
1720
+ * nothing (if `isPushSupported` returns false). Returns undefined if the SDK has not been initialized.
1756
1721
  */
1757
- function isPushPermissionGranted(): boolean;
1722
+ export function isPushPermissionGranted(): boolean | undefined;
1758
1723
 
1759
1724
  /**
1760
1725
  * The [W3C Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) is partially supported
1761
1726
  * across the browser landscape. This method allows you to programmatically determine whether push is supported
1762
1727
  * in the current browser, and whether to show push-related user class elements to the user.
1763
1728
  *
1764
- * @returns Whether or not push is supported in this environment.
1729
+ * @returns Whether or not push is supported in this environment. Returns undefined if the SDK has not been initialized.
1765
1730
  */
1766
- function isPushSupported(): boolean;
1731
+ export function isPushSupported(): boolean | undefined;
1767
1732
 
1768
1733
  /**
1769
- * Logs that the user clicked the given card. This is done automatically when you use Appboy's display module
1734
+ * Logs that the user clicked the given card. This is done automatically when you use Braze's display module
1770
1735
  * and should only be called if you're bypassing that and manually building the DOM for displaying the cards in
1771
1736
  * your own code.
1772
1737
  *
@@ -1775,10 +1740,10 @@ declare namespace appboy {
1775
1740
  *
1776
1741
  * @returns Whether or not the event was successfully logged (to be flushed later).
1777
1742
  */
1778
- function logCardClick(card: appboy.Card, forContentCards?: boolean): boolean;
1743
+ export function logCardClick(card: Card, forContentCards?: boolean): boolean;
1779
1744
 
1780
1745
  /**
1781
- * Logs that the user dismissed the given card. This is done automatically when you use Appboy's display module
1746
+ * Logs that the user dismissed the given card. This is done automatically when you use Braze's display module
1782
1747
  * and should only be called if you're bypassing that and manually building the DOM for displaying the cards in
1783
1748
  * your own code.
1784
1749
  *
@@ -1786,10 +1751,10 @@ declare namespace appboy {
1786
1751
  *
1787
1752
  * @returns Whether or not the event was successfully logged (to be flushed later).
1788
1753
  */
1789
- function logCardDismissal(card: appboy.Card): boolean;
1754
+ export function logCardDismissal(card: Card): boolean;
1790
1755
 
1791
1756
  /**
1792
- * Logs that the user saw the given cards. This is done automatically when you use Appboy's display module
1757
+ * Logs that the user saw the given cards. This is done automatically when you use Braze's display module
1793
1758
  * and should only be called if you're bypassing that and manually building the DOM for displaying the cards in
1794
1759
  * your own code.
1795
1760
  *
@@ -1798,25 +1763,23 @@ declare namespace appboy {
1798
1763
  *
1799
1764
  * @returns Whether or not the event was successfully logged (to be flushed later).
1800
1765
  */
1801
- function logCardImpressions(
1802
- cards: appboy.Card[],
1766
+ export function logCardImpressions(
1767
+ cards: Card[],
1803
1768
  forContentCards?: boolean
1804
1769
  ): boolean;
1805
1770
 
1806
1771
  /**
1807
- * Logs that the content cards were displayed. This is done automatically when you use Appboy's
1808
- * display module and should only be called if you're bypassing that and manually building
1772
+ * Logs that the content cards were displayed. This is done automatically when you use Braze's
1773
+ * UI and should only be called if you're bypassing that and manually building
1809
1774
  * the class for displaying the cards in your own code.
1810
1775
  */
1811
- function logContentCardsDisplayed(): boolean;
1776
+ export function logContentCardsDisplayed(): boolean;
1812
1777
 
1813
1778
  /**
1814
1779
  * Reports that the current user performed a custom named event.
1815
1780
  *
1816
- * @param eventName - The identifier for the event to track. Best practice is to track generic events
1817
- * useful for segmenting, instead of specific user actions (i.e. track watched_sports_video instead of
1818
- * watched_video_adrian_peterson_td_mnf). Value is limited to 255 characters in length, cannot begin with a $,
1819
- * and can only contain alphanumeric characters and punctuation.
1781
+ * @param eventName - The identifier for the event to track. Value is limited to 255 characters in length,
1782
+ * cannot begin with a $, and can only contain alphanumeric characters and punctuation.
1820
1783
  * @param eventProperties - Hash of properties for this event. Keys are limited to 255 characters in length, cannot begin
1821
1784
  * with a $, and can only contain alphanumeric characters and punctuation. Values can be numeric, boolean, Date objects,
1822
1785
  * strings 255 characters or shorter, or nested objects whose values can be numeric, boolean, Date objects, arrays, strings,
@@ -1824,18 +1787,18 @@ declare namespace appboy {
1824
1787
  *
1825
1788
  * @returns Whether or not the event was successfully logged (to be flushed later).
1826
1789
  */
1827
- function logCustomEvent(eventName: string, eventProperties?: object): boolean;
1790
+ export function logCustomEvent(eventName: string, eventProperties?: object): boolean;
1828
1791
 
1829
1792
  /**
1830
- * Logs that the news feed was displayed. This is done automatically when you use Appboy's
1831
- * display module and should only be called if you're bypassing that and manually building
1793
+ * Logs that the news feed was displayed. This is done automatically when you use Braze's
1794
+ * UI and should only be called if you're bypassing that and manually building
1832
1795
  * the class for displaying the cards in your own code.
1833
1796
  */
1834
- function logFeedDisplayed(): void;
1797
+ export function logFeedDisplayed(): void;
1835
1798
 
1836
1799
  /**
1837
1800
  * Logs that the user clicked the given in-app message button. This is done automatically when the user clicks on
1838
- * a button in a message generated by `display.showInAppMessage`,
1801
+ * a button in a message generated by `showInAppMessage`,
1839
1802
  * and should only be called if you're bypassing that method and manually displaying the message in your own
1840
1803
  * code.
1841
1804
  *
@@ -1844,25 +1807,25 @@ declare namespace appboy {
1844
1807
  *
1845
1808
  * @returns Whether or not the event was successfully logged (to be flushed later).
1846
1809
  */
1847
- function logInAppMessageButtonClick(
1848
- button: appboy.InAppMessageButton,
1849
- inAppMessage: appboy.InAppMessage
1810
+ export function logInAppMessageButtonClick(
1811
+ button: InAppMessageButton,
1812
+ inAppMessage: InAppMessage
1850
1813
  ): boolean;
1851
1814
 
1852
1815
  /**
1853
1816
  * Logs that the user clicked the given in-app message. This is done automatically when the user clicks on a
1854
- * message generated by `display.showInAppMessage`, and should
1817
+ * message generated by `showInAppMessage`, and should
1855
1818
  * only be called if you're bypassing that method and manually displaying the message in your own code.
1856
1819
  *
1857
1820
  * @param inAppMessage
1858
1821
  *
1859
1822
  * @returns Whether or not the event was successfully logged (to be flushed later).
1860
1823
  */
1861
- function logInAppMessageClick(inAppMessage: appboy.InAppMessage): boolean;
1824
+ export function logInAppMessageClick(inAppMessage: InAppMessage): boolean;
1862
1825
 
1863
1826
  /**
1864
1827
  * Logs that the user clicked on a link in an html in-app message. This is done automatically when the user clicks
1865
- * on a message generated by `display.showInAppMessage`, and should
1828
+ * on a message generated by `showInAppMessage`, and should
1866
1829
  * only be called if you're bypassing that method and manually displaying the message in your own code.
1867
1830
  *
1868
1831
  * @param inAppMessage - The message that was clicked
@@ -1871,22 +1834,22 @@ declare namespace appboy {
1871
1834
  *
1872
1835
  * @returns Whether or not the event was successfully logged (to be flushed later).
1873
1836
  */
1874
- function logInAppMessageHtmlClick(
1875
- inAppMessage: appboy.HtmlMessage,
1837
+ export function logInAppMessageHtmlClick(
1838
+ inAppMessage: HtmlMessage,
1876
1839
  buttonId?: string,
1877
1840
  url?: string
1878
1841
  ): boolean;
1879
1842
 
1880
1843
  /**
1881
- * Logs that the user saw the given in-app message. This is performed automatically when you use `display.showInAppMessage`,
1844
+ * Logs that the user saw the given in-app message. This is performed automatically when you use `showInAppMessage`,
1882
1845
  * and should only be called if you're bypassing that method and manually displaying the message in your own code.
1883
1846
  *
1884
1847
  * @param inAppMessage
1885
1848
  *
1886
1849
  * @returns Whether or not the event was successfully logged (to be flushed later).
1887
1850
  */
1888
- function logInAppMessageImpression(
1889
- inAppMessage: appboy.InAppMessage | appboy.ControlMessage
1851
+ export function logInAppMessageImpression(
1852
+ inAppMessage: InAppMessage | ControlMessage
1890
1853
  ): boolean;
1891
1854
 
1892
1855
  /**
@@ -1917,7 +1880,7 @@ declare namespace appboy {
1917
1880
  *
1918
1881
  * @returns Whether or not the purchase was successfully attached to the session (to be flushed later).
1919
1882
  */
1920
- function logPurchase(
1883
+ export function logPurchase(
1921
1884
  productId: string,
1922
1885
  price: number,
1923
1886
  currencyCode?: string,
@@ -1930,12 +1893,12 @@ declare namespace appboy {
1930
1893
  * When a new session is opened, syncs triggered In-App Messages and Content Cards. If the user has previously
1931
1894
  * granted the site permission to send push, automatically sends the push registration to the Braze backend.
1932
1895
  */
1933
- function openSession(): void;
1896
+ export function openSession(): void;
1934
1897
 
1935
1898
  /**
1936
1899
  * Register this browser environment to receive web push for this user. Supports browsers which implement the
1937
1900
  * [W3C Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) (browsers in which
1938
- * `appboy.isPushSupported` returns true). If push is supported and the user is not already subscribed,
1901
+ * `isPushSupported` returns true). If push is supported and the user is not already subscribed,
1939
1902
  * this method will cause the browser to immediately request push permission from the user.
1940
1903
  *
1941
1904
  * In order to properly use this feature, there are some integration steps required on your end:
@@ -1944,10 +1907,10 @@ declare namespace appboy {
1944
1907
  * - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
1945
1908
  *
1946
1909
  * ```
1947
- * self.importScripts('https://js.appboycdn.com/web-sdk-develop/3.5/service-worker.js');
1910
+ * self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.0/service-worker.js');
1948
1911
  * ```
1949
1912
  *
1950
- * For more details, see [Our Product Documentation](https://www.appboy.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
1913
+ * For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
1951
1914
  *
1952
1915
  * @param successCallback - When the user subscribes to push successfully this callback will be
1953
1916
  * invoked with the user's endpoint, public key, and user auth key (endpoint, publicKey, userAuth).
@@ -1955,7 +1918,7 @@ declare namespace appboy {
1955
1918
  * is temporary, it will be invoked with a parameter of `true` - otherwise it will be invoked with a parameter
1956
1919
  * of `false`.
1957
1920
  */
1958
- function registerAppboyPushMessages(
1921
+ export function requestPushPermission(
1959
1922
  successCallback?: (
1960
1923
  endpoint: string,
1961
1924
  publicKey: string,
@@ -1967,7 +1930,7 @@ declare namespace appboy {
1967
1930
  /**
1968
1931
  * Remove all event subscriptions.
1969
1932
  */
1970
- function removeAllSubscriptions(): void;
1933
+ export function removeAllSubscriptions(): void;
1971
1934
 
1972
1935
  /**
1973
1936
  * Remove an event subscription that you previously subscribed to.
@@ -1975,10 +1938,10 @@ declare namespace appboy {
1975
1938
  * @param subscriptionGuid - The identifier of the subscription you wish to remove, returned by the method
1976
1939
  * you initially used to create it.
1977
1940
  */
1978
- function removeSubscription(subscriptionGuid: string): void;
1941
+ export function removeSubscription(subscriptionGuid: string): void;
1979
1942
 
1980
1943
  /**
1981
- * Requests an immediate refresh of content cards from Appboy servers. By default, content cards are refreshed when
1944
+ * Requests an immediate refresh of content cards from Braze servers. By default, content cards are refreshed when
1982
1945
  * a new session opens (see 'openSession` for more details), and when the user refreshes content cards manually via
1983
1946
  * the refresh button. If you want to refresh content cards from the server at another time you must call this function.
1984
1947
  *
@@ -1987,16 +1950,16 @@ declare namespace appboy {
1987
1950
  * a request has completed regardless of whether new cards were returned.
1988
1951
  * @param errorCallback - Callback that is invoked when an error occurs during the refresh.
1989
1952
  */
1990
- function requestContentCardsRefresh(successCallback?: () => void, errorCallback?: () => void): void;
1953
+ export function requestContentCardsRefresh(successCallback?: () => void, errorCallback?: () => void): void;
1991
1954
 
1992
1955
  /**
1993
1956
  * Requests an immediate refresh of the news feed from Braze servers. By default, the news feed is refreshed on
1994
- * `display.showFeed` (when stale - see
1995
- * `display.showFeed` for details). If you want to refresh the feed from the
1957
+ * `showFeed` (when stale - see
1958
+ * `showFeed` for details). If you want to refresh the feed from the
1996
1959
  * server at another time you must call this function. Results of this refresh are reported asynchronously to
1997
1960
  * subscriptions created via 'subscribeToFeedUpdates` .
1998
1961
  */
1999
- function requestFeedRefresh(): void;
1962
+ export function requestFeedRefresh(): void;
2000
1963
 
2001
1964
  /**
2002
1965
  * By default, data logged to Braze through the SDK is queued locally (in HTML 5 localStorage when available, and
@@ -2008,25 +1971,20 @@ declare namespace appboy {
2008
1971
  * whether or not the flush was successful. If the flush is unsuccessful, pending data will be
2009
1972
  * flushed during the next successful flush.
2010
1973
  */
2011
- function requestImmediateDataFlush(
1974
+ export function requestImmediateDataFlush(
2012
1975
  callback?: (success: boolean) => void
2013
1976
  ): void;
2014
1977
 
2015
- /**
2016
- * @deprecated This method has been deprecated in favor of `enableSDK`, which has the same functionality.
2017
- */
2018
- function resumeWebTracking(): void;
2019
-
2020
1978
  /**
2021
1979
  * Removes the cookie set by `disableSDK`, causing subsequent calls to the Braze Web SDK to function. You must
2022
1980
  * call `initialize` after calling this method before calling subsequent methods.
2023
1981
  */
2024
- function enableSDK(): void;
1982
+ export function enableSDK(): void;
2025
1983
 
2026
1984
  /**
2027
- * Getter method to determine if the SDK is disabled based on whether the cookie set by `stopWebTracking` exists
1985
+ * Getter method to determine if the SDK is disabled based on whether the cookie set by `disableSdk` exists
2028
1986
  */
2029
- function isDisabled(): boolean;
1987
+ export function isDisabled(): boolean;
2030
1988
 
2031
1989
  /**
2032
1990
  * By default, Braze logs to the browser console. Call this method to set a custom log action and enable debug-level log statements.
@@ -2034,7 +1992,7 @@ declare namespace appboy {
2034
1992
  * @param loggerFunction - A function to invoke with log messages. Should accept a single string
2035
1993
  * parameter for message.
2036
1994
  */
2037
- function setLogger(loggerFunction: (message: string) => void): void;
1995
+ export function setLogger(loggerFunction: (message: string) => void): void;
2038
1996
 
2039
1997
  /**
2040
1998
  * Sets the signature to be used to authenticate the current user. You can also set the signature when calling `changeUser`.
@@ -2044,21 +2002,16 @@ declare namespace appboy {
2044
2002
  *
2045
2003
  * @returns Whether or not the signature is valid.
2046
2004
  */
2047
- function setSdkAuthenticationSignature(signature: string): boolean;
2005
+ export function setSdkAuthenticationSignature(signature: string): boolean;
2048
2006
 
2049
2007
  /**
2050
- * Adds SDK Metadata, which you can use to self-report how you load and integrate the Braze SDK.
2008
+ * Adds SDK Metadata. This method is automatically called based on the integration method.
2051
2009
  *
2052
2010
  * @param sdkMetadata - An array of metadata values from `BrazeSdkMetadata`.
2053
2011
  *
2054
2012
  * @returns Whether or not the array of metadata is valid.
2055
2013
  */
2056
- function addSdkMetadata(sdkMetadata: string[]): boolean;
2057
-
2058
- /**
2059
- * @deprecated This method has been deprecated in favor of `disableSDK`, which has the same functionality.
2060
- */
2061
- function stopWebTracking(): void;
2014
+ export function addSdkMetadata(sdkMetadata: string[]): boolean;
2062
2015
 
2063
2016
  /**
2064
2017
  * Sets a cookie that causes all subsequent calls to the Braze Web SDK to be ignored
@@ -2066,10 +2019,11 @@ declare namespace appboy {
2066
2019
  * If you have multiple subdomains, this method MUST be called from the same subdomain that push was registered from to work properly.
2067
2020
  * This is useful for customer opt-outs. If the customer clears website data, tracking will resume.
2068
2021
  */
2069
- function disableSDK(): void;
2022
+ export function disableSDK(): void;
2070
2023
 
2071
2024
  /**
2072
- * Subscribe to content cards updates. The subscriber callback will be called whenever content cards are updated.
2025
+ * Subscribe to content cards updates. The subscriber callback will be called whenever content cards are updated. This method
2026
+ * should be called before calling `openSession`.
2073
2027
  *
2074
2028
  * @param subscriber - The callback function to handle new cards. This function will be called with a `ContentCards`
2075
2029
  * object which includes all currently available `Card` objects. If you want to be notified when a refresh has completed
@@ -2077,8 +2031,8 @@ declare namespace appboy {
2077
2031
  *
2078
2032
  * @returns The identifier of the subscription created. This can be passed to `removeSubscription` to cancel the subscription.
2079
2033
  */
2080
- function subscribeToContentCardsUpdates(
2081
- subscriber: (cards: appboy.ContentCards) => void
2034
+ export function subscribeToContentCardsUpdates(
2035
+ subscriber: (cards: ContentCards) => void
2082
2036
  ): string;
2083
2037
 
2084
2038
  /**
@@ -2087,61 +2041,36 @@ declare namespace appboy {
2087
2041
  * @param subscriber - The callback function to handle new cards. This function will be
2088
2042
  * called with a `Feed`object which includes all `Card` objects currently in the feed.
2089
2043
  *
2090
- * @returns The identifier of the subscription created. This can be passed to
2091
- * `removeSubscription` to cancel the subscription.
2044
+ * @returns The identifier of the subscription created. This can be passed to `removeSubscription` to cancel
2045
+ * the subscription. Returns undefined if the SDK has not been initialized.
2092
2046
  */
2093
- function subscribeToFeedUpdates(
2094
- subscriber: (feed: appboy.Feed) => void
2095
- ): string;
2047
+ export function subscribeToFeedUpdates(
2048
+ subscriber: (feed: Feed) => void
2049
+ ): string | undefined;
2096
2050
 
2097
2051
  /**
2098
2052
  * Subscribe to receive in-app messages. The subscriber callback will be called whenever a new in-app message is
2099
- * triggered. If you are using the build of Braze's library with UI, the most basic usage of this would be
2053
+ * triggered. This method should be called before calling `openSession`. If you are using the build of Braze's
2054
+ * library with UI, the most basic usage of this would be
2055
+ *
2100
2056
  * ```
2101
- * appboy.subscribeToInAppMessage(function(inAppMessage) {
2102
- * appboy.display.showInAppMessage(inAppMessage);
2057
+ * braze.subscribeToInAppMessage(function(inAppMessage) {
2058
+ * braze.showInAppMessage(inAppMessage);
2103
2059
  * });
2104
2060
  * ```
2105
2061
  * @param callback - The callback function to handle the in-app message. This function will be
2106
2062
  * called with an `InAppMessage` or a `ControlMessage` object. If you are using the build
2107
- * of Braze's library with UI, you may wish to call `display.showInAppMessage`
2063
+ * of Braze's library with UI, you may wish to call `showInAppMessage`
2108
2064
  * with the provided message.
2109
2065
  *
2110
- * @returns The identifier of the subscription created. This can be passed to
2111
- * 'removeSubscription` to cancel the subscription.
2112
- */
2113
- function subscribeToInAppMessage(
2114
- callback: (
2115
- inAppMessage: appboy.InAppMessage | appboy.ControlMessage
2116
- ) => void
2117
- ): string;
2118
-
2119
- /**
2120
- * DEPRECATED - Subscribe to receive in-app messages. The subscriber callback will be called whenever new in-app messages are
2121
- * triggered. If you are using the build of Braze's library with UI, the most basic usage of this would be
2122
- * ```
2123
- * appboy.subscribeToNewInAppMessages(function(inAppMessages) {
2124
- * appboy.display.showInAppMessage(inAppMessages[0]);
2125
- * return inAppMessages.slice(1);
2126
- * });
2127
- * ```
2128
- * @deprecated Since Web SDK 2.4.0, this function has been replaced by `appboy.subscribeToInAppMessage`,
2129
- * which has a simpler interface. This function will be removed in a future release.
2130
- *
2131
- * @param subscriber - The callback function to handle new in-app messages. This function will be
2132
- * called with an array of all currently unhandled `InAppMessage` or `ControlMessage` objects.
2133
- * If you are using the build of Braze's library with UI, you may wish to call `display.showInAppMessage`
2134
- * with one or more messages. This function should return an array of any messages that you wish to remain
2135
- * unhandled and retained until the next time subscriber is called.
2136
- *
2137
- * @returns The identifier of the subscription created. This can be passed to
2138
- * 'removeSubscription` to cancel the subscription.
2066
+ * @returns The identifier of the subscription created. This can be passed to 'removeSubscription` to cancel
2067
+ * the subscription. Returns undefined if the SDK has not been initialized.
2139
2068
  */
2140
- function subscribeToNewInAppMessages(
2069
+ export function subscribeToInAppMessage(
2141
2070
  callback: (
2142
- inAppMessage: Array<appboy.InAppMessage | appboy.ControlMessage>
2071
+ inAppMessage: InAppMessage | ControlMessage
2143
2072
  ) => void
2144
- ): string;
2073
+ ): string | undefined;
2145
2074
 
2146
2075
  /**
2147
2076
  * Subscribe to be notified of network request failures that occured due to an SDK Authentication error. This
@@ -2152,33 +2081,23 @@ declare namespace appboy {
2152
2081
  * invoked with an object containing the `errorCode`, `reason` for the error, the `userId` of the request (if the
2153
2082
  * user is not anonymous), and the authentication `signature` that caused the error.
2154
2083
  *
2155
- * @returns The identifier of the subscription created. This can be passed to
2156
- * 'removeSubscription` to cancel the subscription.
2084
+ * @returns The identifier of the subscription created. This can be passed to 'removeSubscription` to cancel
2085
+ * the subscription. Returns undefined if the SDK has not been initialized.
2157
2086
  */
2158
- function subscribeToSdkAuthenticationFailures(subscriber: (
2087
+ export function subscribeToSdkAuthenticationFailures(subscriber: (
2159
2088
  error: {
2160
2089
  errorCode: string,
2161
2090
  reason?: string,
2162
2091
  userId?: string,
2163
2092
  signature?: string
2164
2093
  }
2165
- ) => void): string;
2094
+ ) => void): string | undefined;
2166
2095
 
2167
2096
  /**
2168
2097
  * By default, Braze silences its logging to prevent spamming production js consoles. Call this method to
2169
2098
  * toggle logging.
2170
2099
  */
2171
- function toggleAppboyLogging(): void;
2172
-
2173
- /**
2174
- * Causes the Braze Web SDK to begin continuously collecting the user's location while your website is visible in
2175
- * the foreground of their browser, for the duration of this page load. This will cause the browser to request
2176
- * permission from the user if they have not already granted or denied it.
2177
- *
2178
- * @deprecated This method has been deprecated in favor of using the native [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API)
2179
- * and passing the location data to `User.setLastKnownLocation`.
2180
- */
2181
- function trackLocation(): void;
2100
+ export function toggleLogging(): void;
2182
2101
 
2183
2102
  /**
2184
2103
  * Unregisters push notifications on this browser.
@@ -2189,7 +2108,7 @@ declare namespace appboy {
2189
2108
  * callback will be invoked.
2190
2109
  * @param errorCallback - If the unsubscribe fails for unknown reasons, this callback will be invoked.
2191
2110
  */
2192
- function unregisterAppboyPushMessages(
2111
+ export function unregisterPush(
2193
2112
  successCallback?: () => void,
2194
2113
  errorCallback?: () => void
2195
2114
  ): void;
@@ -2197,13 +2116,20 @@ declare namespace appboy {
2197
2116
  /**
2198
2117
  * Removes all locally stored SDK data, causing the user to be seen in subsequent calls as a new anonymous user on a new device.
2199
2118
  */
2200
- function wipeData(): void;
2119
+ export function wipeData(): void;
2120
+
2121
+ /**
2122
+ * Handle links from within a message. This method will redirect valid links, or will parse and handle valid Braze Click Actions (brazeActions://).
2123
+ * @param url - a valid URL, or a valid brazeActions URL with scheme brazeActions://v{versionInt}/{base64string}
2124
+ * @param openLinkInNewTab - Whether the URL should be opened in a new tab. Defaults to false.
2125
+ */
2126
+ export function handleBrazeAction(url: string, openLinkInNewTab?: boolean): void;
2201
2127
 
2202
2128
  /**
2203
2129
  * Supported initialization options
2204
2130
  *
2205
2131
  */
2206
- type InitializationOptions = {
2132
+ export type InitializationOptions = {
2207
2133
  /**
2208
2134
  * By default, the Braze Web SDK ignores activity from known spiders or web crawlers, such as Google, based
2209
2135
  * on the user agent string. This saves data points, makes analytics more accurate, and may improve page rank.
@@ -2225,7 +2151,7 @@ declare namespace appboy {
2225
2151
  /**
2226
2152
  * This option is required to configure the Braze Web SDK to use the appropriate endpoint for your integration - for example:
2227
2153
  * ```
2228
- * appboy.initialize('YOUR-API-KEY-HERE', { baseUrl: 'sdk.iad-03.appboy.com' })
2154
+ * braze.initialize('YOUR-API-KEY-HERE', { baseUrl: 'sdk.iad-03.braze.com' })
2229
2155
  * ```
2230
2156
  */
2231
2157
  baseUrl: string;
@@ -2244,11 +2170,7 @@ declare namespace appboy {
2244
2170
  */
2245
2171
  devicePropertyAllowlist?: string[];
2246
2172
  /**
2247
- * @deprecated This initialization option is deprecated in favor of `devicePropertyAllowlist`, which has the same functionality.
2248
- */
2249
- devicePropertyWhitelist?: string[];
2250
- /**
2251
- * By default, users who have already granted web push permission (e.g. through `appboy.registerAppboyPushMessages` or from
2173
+ * By default, users who have already granted web push permission (e.g. through `requestPushPermission` or from
2252
2174
  * a prior push provider) will sync their push token with the Braze backend automatically on new session to ensure deliverability.
2253
2175
  * To disable this behavior, set this option to true.
2254
2176
  */
@@ -2270,7 +2192,7 @@ declare namespace appboy {
2270
2192
  enableHtmlInAppMessages?: boolean;
2271
2193
  /**
2272
2194
  * Set to true to enable logging by default. Note that this will cause Braze to log to the javascript console, which is visible
2273
- * to all users! You should probably remove this or provide an alternate logger with `appboy.setLogger` before you release
2195
+ * to all users! You should probably remove this or provide an alternate logger with `setLogger` before you release
2274
2196
  * your page to production.
2275
2197
  */
2276
2198
  enableLogging?: boolean;
@@ -2280,8 +2202,8 @@ declare namespace appboy {
2280
2202
  */
2281
2203
  enableSdkAuthentication?: boolean
2282
2204
  /**
2283
- * By default, the Braze SDK will show In-App Messages with a z-index of 1040 for the screen overlay, 1050 for the actual in-app message,
2284
- * and 1060 for the message's close button. Provide a value for this option to override these default z-indexes. The value provided
2205
+ * By default, the Braze SDK will show In-App Messages with a z-index of 9001 for the screen overlay, 9011 for the actual in-app message,
2206
+ * and 9021 for the message's close button. Provide a value for this option to override these default z-indexes. The value provided
2285
2207
  * will be used for the backdrop, `value + 1` will be used for the in-app message, and `value + 2` will be used for the close button.
2286
2208
  */
2287
2209
  inAppMessageZIndex?: number
@@ -2294,12 +2216,12 @@ declare namespace appboy {
2294
2216
  */
2295
2217
  localization?: string;
2296
2218
  /**
2297
- * By default, `appboy.registerAppboyPushMessages`/`appboy.unregisterAppboyPushMessages` assume that they control and can
2219
+ * By default, `requestPushPermission`/`unregisterPush` assume that they control and can
2298
2220
  * register and unregister the site's service worker. If you have your own service worker that you register and control the
2299
2221
  * lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
2300
2222
  * option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
2301
- * `appboy.registerAppboyPushMessages`, and ensure that it contains Braze's service worker code, either with
2302
- * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/3.5/service-worker.js');` or by including the content
2223
+ * `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
2224
+ * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.0/service-worker.js');` or by including the content
2303
2225
  * of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
2304
2226
  */
2305
2227
  manageServiceWorkerExternally?: boolean;
@@ -2342,7 +2264,7 @@ declare namespace appboy {
2342
2264
  * root directory of your web server at `/service-worker.js`. If you want to host your service worker at a different path
2343
2265
  * on that server, provide a value for this option that is the absolute path to the file, e.g. `/mycustompath/my-worker.js`.
2344
2266
  * VERY IMPORTANT: setting a value here limits the scope of push notifications on your site. For instance, in the above
2345
- * example, because the service worker file is located within the `/mycustompath/` directory, `appboy.registerAppboyPushMessages`
2267
+ * example, because the service worker file is located within the `/mycustompath/` directory, `requestPushPermission`
2346
2268
  * MAY ONLY BE CALLED from web pages that start with `http://yoursite.com/mycustompath/`.
2347
2269
  */
2348
2270
  serviceWorkerLocation?: string;
@@ -2352,6 +2274,7 @@ declare namespace appboy {
2352
2274
  */
2353
2275
  sessionTimeoutInSeconds?: number;
2354
2276
  };
2355
- }
2356
2277
 
2357
- export default appboy;
2278
+
2279
+
2280
+