@braze/web-sdk 3.4.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +5 -11
  2. package/index.d.ts +490 -513
  3. package/package.json +8 -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 -275
package/index.d.ts CHANGED
@@ -1,19 +1,44 @@
1
1
  /*
2
- * Type definitions for appboy-web-sdk v3.4.1
3
- * Project: https://github.com/Appboy/appboy-web-sdk
4
- * (c) Braze, Inc. 2021 - http://braze.com
5
- * License available at https://github.com/Appboy/appboy-web-sdk/blob/master/LICENSE
2
+ * Type definitions for @braze/web-sdk v4.0.0
3
+ * Project: https://github.com/braze-inc/braze-web-sdk
4
+ * (c) Braze, Inc. 2022 - http://braze.com
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,14 +56,16 @@ declare namespace appboy {
31
56
  }
32
57
 
33
58
  /**
34
- * Abstract base for news feed cards. Use subclasses `ClassicCard`, `CaptionedImage`,
59
+ * Abstract base for news feed and Content Cards cards. Use subclasses `ClassicCard`, `CaptionedImage`,
35
60
  * `Banner`, and `ControlCard`.
36
61
  */
37
- class Card {
62
+ export class Card {
38
63
  /**
39
64
  * Call this method if you wish to programmatically remove the card from the feed and log a dismissal. This method
40
- * is meant to be used with the Braze UI. If you are using your own UI, you should use `appboy.logCardDismissal`
41
- * to log analytics.
65
+ * is meant to be used with the Braze UI.
66
+ *
67
+ * If you are using your own UI, this method will have no effect. Instead, you should use `logCardDismissal` to
68
+ * log analytics and then remove the card from the DOM manually.
42
69
  */
43
70
  dismissCard(): void;
44
71
 
@@ -94,12 +121,14 @@ declare namespace appboy {
94
121
 
95
122
  /** Whether to pin this card to the top of the view. */
96
123
  pinned: boolean;
124
+
125
+
97
126
  }
98
127
 
99
- class Banner extends Card {
128
+ export class Banner extends Card {
100
129
  /**
101
- * A card with only an image, which can be passed to `display.showFeed` or handled manually.
102
- * 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`
103
132
  *
104
133
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
105
134
  * @param viewed - Whether this card has been shown to the user.
@@ -111,7 +140,8 @@ declare namespace appboy {
111
140
  * @param expiresAt - When this card expires and should stop being shown to the user.
112
141
  * @param url - A url to open when this card is clicked.
113
142
  * @param linkText - The display text for the url.
114
- * @param aspectRatio - The aspect ratio for this card's image.
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.
115
145
  * @param extras - Object of string/string key/value pairs.
116
146
  * @param pinned - Whether to pin this card to the top of the view.
117
147
  * @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
@@ -152,7 +182,10 @@ declare namespace appboy {
152
182
  /** The display text for the url. */
153
183
  linkText?: string;
154
184
 
155
- /** The aspect ratio for this card's image. */
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
+ * */
156
189
  aspectRatio: number | null;
157
190
 
158
191
  /** Whether this card has been dismissed. */
@@ -165,10 +198,10 @@ declare namespace appboy {
165
198
  clicked: boolean;
166
199
  }
167
200
 
168
- class CaptionedImage extends Card {
201
+ export class CaptionedImage extends Card {
169
202
  /**
170
- * A card with a large image and descriptive text, which can be passed to `display.showFeed` or handled manually.
171
- * 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`.
172
205
  *
173
206
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
174
207
  * @param viewed - Whether this card has been shown to the user.
@@ -182,7 +215,8 @@ declare namespace appboy {
182
215
  * @param expiresAt - When this card expires and should stop being shown to the user.
183
216
  * @param url - A url to open when this card is clicked.
184
217
  * @param linkText - The display text for the url.
185
- * @param aspectRatio - The aspect ratio for this card's image.
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.
186
220
  * @param extras - Object of string/string key/value pairs.
187
221
  * @param pinned - Whether to pin this card to the top of the view.
188
222
  * @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
@@ -231,7 +265,10 @@ declare namespace appboy {
231
265
  /** The display text for the url. */
232
266
  linkText?: string;
233
267
 
234
- /** The aspect ratio for this card's image. */
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
+ */
235
272
  aspectRatio: number | null;
236
273
 
237
274
  /** Whether this card has been dismissed. */
@@ -244,11 +281,11 @@ declare namespace appboy {
244
281
  clicked: boolean;
245
282
  }
246
283
 
247
- class ClassicCard extends Card {
284
+ export class ClassicCard extends Card {
248
285
  /**
249
286
  * A card with a title, body, and optionally a small image, which can be passed to
250
- * `display.showFeed` or handled manually.
251
- * Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`.
287
+ * `showFeed` or handled manually.
288
+ * Subscribe to receive new cards via `subscribeToFeedUpdates`.
252
289
  *
253
290
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
254
291
  * @param viewed - Whether this card has been shown to the user.
@@ -262,7 +299,8 @@ declare namespace appboy {
262
299
  * @param expiresAt - When this card expires and should stop being shown to the user.
263
300
  * @param url - A url to open when this card is clicked.
264
301
  * @param linkText - The display text for the url.
265
- * @param aspectRatio - The aspect ratio for this card's image.
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.
266
304
  * @param extras - Object of string/string key/value pairs.
267
305
  * @param pinned - Whether to pin this card to the top of the view.
268
306
  * @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
@@ -311,7 +349,10 @@ declare namespace appboy {
311
349
  /** The display text for the url. */
312
350
  linkText?: string;
313
351
 
314
- /** The aspect ratio for this card's image. */
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
+ */
315
356
  aspectRatio: number | null;
316
357
 
317
358
  /** Whether this card has been dismissed. */
@@ -324,12 +365,12 @@ declare namespace appboy {
324
365
  clicked: boolean;
325
366
  }
326
367
 
327
- class ControlCard extends Card {
368
+ export class ControlCard extends Card {
328
369
  /**
329
370
  * A card with no display that logs impressions, which can be passed to
330
- * `display.showFeed` or handled manually.
371
+ * `showFeed` or handled manually.
331
372
  * Not supported in legacy news feed.
332
- * Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`.
373
+ * Subscribe to receive new cards via `subscribeToFeedUpdates`.
333
374
  *
334
375
  * @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
335
376
  * @param viewed - Whether this card has been shown to the user.
@@ -348,15 +389,15 @@ declare namespace appboy {
348
389
  );
349
390
  }
350
391
 
351
- class ContentCards {
392
+ export class ContentCards {
352
393
  /**
353
394
  * A collection of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
354
- * 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
355
396
  * interact with this class, but if you are building your own content cards class manually, use
356
- * `appboy.getCachedContentCards` to get the most recent ContentCards object.
397
+ * `getCachedContentCards` to get the most recent ContentCards object.
357
398
  *
358
399
  * @param cards - Array of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
359
- * @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
360
401
  * content cards are still being fetched for this user.
361
402
  */
362
403
  constructor(cards: Card[], lastUpdated: Date | null);
@@ -365,7 +406,7 @@ declare namespace appboy {
365
406
  cards: Card[];
366
407
 
367
408
  /**
368
- * 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
369
410
  * content cards are still being fetched for this user.
370
411
  */
371
412
  lastUpdated: Date | null;
@@ -377,14 +418,14 @@ declare namespace appboy {
377
418
  getUnviewedCardCount(): number;
378
419
  }
379
420
 
380
- class Feed {
421
+ export class Feed {
381
422
  /**
382
423
  * A collection of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
383
- * Subscribe to receive feed updates via `appboy.subscribeToFeedUpdates`,
384
- * 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`.
385
426
  *
386
427
  * @param cards - Array of `Card` descendents (`ClassicCard`, `CaptionedImage`,
387
- * `Banner`). Can be passed directly to `display.showFeed`.
428
+ * `Banner`). Can be passed directly to `showFeed`.
388
429
  * @param lastUpdated - When this collection of cards was received from Braze servers. If null, it means the
389
430
  * feed has never been fetched for this user.
390
431
  */
@@ -392,12 +433,12 @@ declare namespace appboy {
392
433
 
393
434
  /**
394
435
  * Array of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
395
- * Can be passed directly to `display.showFeed`.
436
+ * Can be passed directly to `showFeed`.
396
437
  */
397
438
  cards: Card[];
398
439
 
399
440
  /**
400
- * 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
401
442
  * content cards are still being fetched for this user.
402
443
  */
403
444
  lastUpdated: Date | null;
@@ -405,16 +446,16 @@ declare namespace appboy {
405
446
  /**
406
447
  * Get the current unread card count. This is useful for powering badges on your control for showing the news feed.
407
448
  * Note that Braze will not refresh news feed cards on new page loads (and so this function will return 0) until you
408
- * 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
409
450
  * unread count.
410
451
  */
411
452
  getUnreadCardCount(): number;
412
453
  }
413
454
 
414
- class ControlMessage {
455
+ export class ControlMessage {
415
456
  /**
416
457
  * A non-showing message placeholder that represents this user receiving the the control for a multivariate
417
- * test. Can be passed to `display.showInAppMessage` to log the user's
458
+ * test. Can be passed to `showInAppMessage` to log the user's
418
459
  * entrollment in the control or handled manually.
419
460
  *
420
461
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
@@ -429,29 +470,35 @@ declare namespace appboy {
429
470
  triggerId?: string;
430
471
  }
431
472
 
432
- namespace InAppMessage {
433
- type SlideFrom = "TOP" | "BOTTOM";
473
+
474
+ type SlideFrom = typeof InAppMessage.SlideFrom[keyof typeof InAppMessage.SlideFrom];
434
475
 
435
- type ClickAction = "NEWS_FEED" | "URI" | "NONE";
476
+
477
+ type ClickAction = typeof InAppMessage.ClickAction[keyof typeof InAppMessage.ClickAction];
436
478
 
437
- type DismissType = "AUTO_DISMISS" | "SWIPE";
479
+
480
+ type DismissType = typeof InAppMessage.DismissType[keyof typeof InAppMessage.DismissType];
438
481
 
439
- type OpenTarget = "NONE" | "BLANK";
482
+
483
+ type OpenTarget = typeof InAppMessage.OpenTarget[keyof typeof InAppMessage.OpenTarget];
440
484
 
441
- type ImageStyle = "TOP" | "GRAPHIC";
485
+
486
+ type ImageStyle = typeof InAppMessage.ImageStyle[keyof typeof InAppMessage.ImageStyle];
442
487
 
443
- type Orientation = "PORTRAIT" | "LANDSCAPE";
488
+
489
+ type Orientation = typeof InAppMessage.Orientation[keyof typeof InAppMessage.Orientation];
444
490
 
445
- type TextAlignment = "START" | "CENTER" | "END";
491
+
492
+ type TextAlignment = typeof InAppMessage.TextAlignment[keyof typeof InAppMessage.TextAlignment];
446
493
 
447
- type CropType = "CENTER_CROP" | "FIT_CENTER";
448
- }
494
+
495
+ type CropType = typeof InAppMessage.CropType[keyof typeof InAppMessage.CropType];
449
496
 
450
497
  /**
451
498
  * Abstract base for in-app messages. Use subclasses `SlideUpMessage`,
452
499
  * `ModalMessage`, `FullScreenMessage`, and `HtmlMessage`.
453
500
  */
454
- class InAppMessage {
501
+ export class InAppMessage {
455
502
  static SlideFrom: {
456
503
  TOP: "TOP";
457
504
  BOTTOM: "BOTTOM";
@@ -510,19 +557,19 @@ declare namespace appboy {
510
557
 
511
558
  /**
512
559
  * The id of the trigger that created this message. The SDK will report back this to
513
- * Appboy with in-app message analytics events.
560
+ * Braze with in-app message analytics events.
514
561
  */
515
562
  triggerId?: string;
516
563
 
517
564
  /**
518
565
  * How the message is dismissed, via a timer or requiring interaction from the user.
519
- * See the `InAppMessage.DismissType` enum.
566
+ * See the `DismissType` enum.
520
567
  */
521
- dismissType: InAppMessage.DismissType;
568
+ dismissType: DismissType;
522
569
 
523
570
  /**
524
571
  * Length of time in milliseconds until auto-dismiss should occur. Only used when
525
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
572
+ * dismissType is `DismissType`.AUTO_DISMISS
526
573
  */
527
574
  duration: number;
528
575
 
@@ -582,39 +629,35 @@ declare namespace appboy {
582
629
  */
583
630
  subscribeToDismissedEvent(subscriber: () => void): string;
584
631
 
585
- static fromJson(jsonData: Record<string, unknown>): InAppMessage | undefined;
632
+
586
633
  }
587
634
 
588
- class FullScreenMessage extends InAppMessage {
635
+ export class FullScreenMessage extends InAppMessage {
589
636
  /**
590
- * A modal in-app message object which can be passed to `display.showInAppMessage`
591
- * 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`.
592
639
  *
593
640
  * @param message - The message to display to the user.
594
- * @param messageAlignment - How to align message text. See the `InAppMessage.TextAlignment` enum.
641
+ * @param messageAlignment - How to align message text. See the `TextAlignment` enum.
595
642
  * @param extras - Object of string/string key/value pairs.
596
- * @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
597
- * will report back to Appboy with in-app message analytics events.
598
- * @param cardId - If the message comes with a card, this is the id of the card that the SDK
599
- * will report back to Appboy with in-app message analytics events.
600
643
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
601
- * Appboy with in-app message analytics events.
644
+ * Braze with in-app message analytics events.
602
645
  * @param clickAction - Where the user should be brought when clicking on this message. See the
603
- * `InAppMessage.ClickAction` enum.
604
- * @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
605
648
  * user clicks on this message.
606
- * @param openTarget - If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
607
- * 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.
608
651
  * @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
609
- * See the `InAppMessage.DismissType` enum.
652
+ * See the `DismissType` enum.
610
653
  * @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
611
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
654
+ * dismissType is `DismissType`.AUTO_DISMISS
612
655
  * @param icon - A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
613
656
  * [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
614
657
  * @param imageUrl - Url of an image to include in this message. The message will only display an image *or*
615
658
  * an icon, and will prioritize the image if present.
616
659
  * @param imageStyle - Whether the image should be shown as normal on the top of the in-app message or used
617
- * as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
660
+ * as the entire content of the message. See the `ImageStyle` enum.
618
661
  * @param iconColor - Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).
619
662
  * @param iconBackgroundColor - Background color of icon. Hex value with opacity (e.g. 0xff00ff00
620
663
  * is opaque green).
@@ -626,35 +669,33 @@ declare namespace appboy {
626
669
  * opaque green).
627
670
  * @param animateIn - Whether to animate the showing of this message.
628
671
  * @param animateOut - Whether to animate the hiding of this message.
629
- * @param header - Header text to display.
630
- * @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.
631
674
  * @param headerTextColor - Color of header text. Hex value with opacity (e.g. 0xff00ff00 is
632
675
  * opaque green).
633
676
  * @param frameColor - Color of the background frame which blocks page interaction while the
634
677
  * message is showing.
635
678
  * @param buttons - Array of up to two `InAppMessageButton` objects.
636
- * @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.
637
680
  * @param orientation - Whether to lay out this in-app message as a portrait or landscape. See the
638
- * `InAppMessage.Orientation` enum.
681
+ * `Orientation` enum.
639
682
  * @param htmlId - The ID to give the parent HTML element that this message is rendered into.
640
683
  * @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
641
684
  * to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
642
685
  */
643
686
  constructor(
644
687
  message?: string,
645
- messageAlignment?: InAppMessage.TextAlignment,
688
+ messageAlignment?: TextAlignment,
646
689
  extras?: Record<string, any>,
647
- campaignId?: string,
648
- cardId?: string,
649
690
  triggerId?: string,
650
- clickAction?: InAppMessage.ClickAction,
691
+ clickAction?: ClickAction,
651
692
  uri?: string,
652
- openTarget?: InAppMessage.OpenTarget,
653
- dismissType?: InAppMessage.DismissType,
693
+ openTarget?: OpenTarget,
694
+ dismissType?: DismissType,
654
695
  duration?: number,
655
696
  icon?: string,
656
697
  imageUrl?: string,
657
- imageStyle?: InAppMessage.ImageStyle,
698
+ imageStyle?: ImageStyle,
658
699
  iconColor?: number,
659
700
  iconBackgroundColor?: number,
660
701
  backgroundColor?: number,
@@ -663,36 +704,36 @@ declare namespace appboy {
663
704
  animateIn?: boolean,
664
705
  animateOut?: boolean,
665
706
  header?: string,
666
- headerAlignment?: InAppMessage.TextAlignment,
707
+ headerAlignment?: TextAlignment,
667
708
  headerTextColor?: number,
668
709
  frameColor?: number,
669
710
  buttons?: InAppMessageButton[],
670
- cropType?: InAppMessage.CropType,
671
- orientation?: InAppMessage.Orientation,
711
+ cropType?: CropType,
712
+ orientation?: Orientation,
672
713
  htmlId?: string,
673
714
  css?: string
674
715
  );
675
716
 
676
- /** How to align message text. See the `InAppMessage.TextAlignment` enum. */
677
- messageAlignment: InAppMessage.TextAlignment;
717
+ /** How to align message text. See the `TextAlignment` enum. */
718
+ messageAlignment: TextAlignment;
678
719
 
679
720
  /**
680
721
  * Where the user should be brought when clicking on this message. See the
681
- * `InAppMessage.ClickAction` enum.
722
+ * `ClickAction` enum.
682
723
  */
683
- clickAction: InAppMessage.ClickAction;
724
+ clickAction: ClickAction;
684
725
 
685
726
  /**
686
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
727
+ * If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
687
728
  * user clicks on this message.
688
729
  */
689
730
  uri?: string;
690
731
 
691
732
  /**
692
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
693
- * 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.
694
735
  */
695
- openTarget: InAppMessage.OpenTarget;
736
+ openTarget: OpenTarget;
696
737
 
697
738
  /**
698
739
  * A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
@@ -708,9 +749,9 @@ declare namespace appboy {
708
749
 
709
750
  /**
710
751
  * Whether the image should be shown as normal on the top of the in-app message or used
711
- * as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
752
+ * as the entire content of the message. See the `ImageStyle` enum.
712
753
  */
713
- imageStyle: InAppMessage.ImageStyle;
754
+ imageStyle: ImageStyle;
714
755
 
715
756
  /** Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
716
757
  iconColor: number;
@@ -727,11 +768,11 @@ declare namespace appboy {
727
768
  /** Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
728
769
  closeButtonColor: number;
729
770
 
730
- /** Header text to display. */
771
+ /** Header text to */
731
772
  header?: string;
732
773
 
733
- /** How to align header text. See the `InAppMessage.TextAlignment` enum. */
734
- headerAlignment: InAppMessage.TextAlignment;
774
+ /** How to align header text. See the `TextAlignment` enum. */
775
+ headerAlignment: TextAlignment;
735
776
 
736
777
  /** Color of header text. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
737
778
  headerTextColor: number;
@@ -742,46 +783,42 @@ declare namespace appboy {
742
783
  /** Array of up to two `InAppMessageButton` objects. */
743
784
  buttons: InAppMessageButton[];
744
785
 
745
- /** How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum. */
746
- cropType: InAppMessage.CropType;
786
+ /** How to crop and fit images in the allowable space. See the `CropType` enum. */
787
+ cropType: CropType;
747
788
 
748
789
  /**
749
790
  * Whether to lay out this in-app message as a portrait or landscape. See the
750
- * `InAppMessage.Orientation` enum.
791
+ * `Orientation` enum.
751
792
  */
752
- orientation: InAppMessage.Orientation;
793
+ orientation: Orientation;
753
794
  }
754
795
 
755
- class ModalMessage extends InAppMessage {
796
+ export class ModalMessage extends InAppMessage {
756
797
  /**
757
- * A modal in-app message object which can be passed to `display.showInAppMessage`
758
- * 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`
759
800
  *
760
801
  * @param message - The message to display to the user.
761
- * @param messageAlignment - How to align message text. See the `InAppMessage.TextAlignment` enum.
802
+ * @param messageAlignment - How to align message text. See the `TextAlignment` enum.
762
803
  * @param extras - Object of string/string key/value pairs.
763
- * @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
764
- * will report back to Appboy with in-app message analytics events.
765
- * @param cardId - If the message comes with a card, this is the id of the card that the SDK
766
- * will report back to Appboy with in-app message analytics events.
767
804
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
768
- * Appboy with in-app message analytics events.
805
+ * Braze with in-app message analytics events.
769
806
  * @param clickAction - Where the user should be brought when clicking on this message. See the
770
- * `InAppMessage.ClickAction` enum.
771
- * @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
772
809
  * user clicks on this message.
773
- * @param openTarget - If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
774
- * 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.
775
812
  * @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
776
- * See the `InAppMessage.DismissType` enum.
813
+ * See the `DismissType` enum.
777
814
  * @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
778
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
815
+ * dismissType is `DismissType`.AUTO_DISMISS
779
816
  * @param icon - A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
780
817
  * [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
781
818
  * @param imageUrl - Url of an image to include in this message. The message will only display an image *or*
782
819
  * an icon, and will prioritize the image if present.
783
820
  * @param imageStyle - Whether the image should be shown as normal on the top of the in-app message or used
784
- * as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
821
+ * as the entire content of the message. See the `ImageStyle` enum.
785
822
  * @param iconColor - Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).
786
823
  * @param iconBackgroundColor - Background color of icon. Hex value with opacity (e.g. 0xff00ff00
787
824
  * is opaque green).
@@ -793,33 +830,31 @@ declare namespace appboy {
793
830
  * opaque green).
794
831
  * @param animateIn - Whether to animate the showing of this message.
795
832
  * @param animateOut - Whether to animate the hiding of this message.
796
- * @param header - Header text to display.
797
- * @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.
798
835
  * @param headerTextColor - Color of header text. Hex value with opacity (e.g. 0xff00ff00 is
799
836
  * opaque green).
800
837
  * @param frameColor - Color of the background frame which blocks page interaction while the
801
838
  * message is showing.
802
839
  * @param buttons - Array of up to two`InAppMessageButton` objects.
803
- * @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.
804
841
  * @param htmlId - The ID to give the parent HTML element that this message is rendered into.
805
842
  * @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
806
843
  * to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
807
844
  */
808
845
  constructor(
809
846
  message?: string,
810
- messageAlignment?: InAppMessage.TextAlignment,
847
+ messageAlignment?: TextAlignment,
811
848
  extras?: Record<string, any>,
812
- campaignId?: string,
813
- cardId?: string,
814
849
  triggerId?: string,
815
- clickAction?: InAppMessage.ClickAction,
850
+ clickAction?: ClickAction,
816
851
  uri?: string,
817
- openTarget?: InAppMessage.OpenTarget,
818
- dismissType?: InAppMessage.DismissType,
852
+ openTarget?: OpenTarget,
853
+ dismissType?: DismissType,
819
854
  duration?: number,
820
855
  icon?: string,
821
856
  imageUrl?: string,
822
- imageStyle?: InAppMessage.ImageStyle,
857
+ imageStyle?: ImageStyle,
823
858
  iconColor?: number,
824
859
  iconBackgroundColor?: number,
825
860
  backgroundColor?: number,
@@ -828,35 +863,35 @@ declare namespace appboy {
828
863
  animateIn?: boolean,
829
864
  animateOut?: boolean,
830
865
  header?: string,
831
- headerAlignment?: InAppMessage.TextAlignment,
866
+ headerAlignment?: TextAlignment,
832
867
  headerTextColor?: number,
833
868
  frameColor?: number,
834
869
  buttons?: InAppMessageButton[],
835
- cropType?: InAppMessage.CropType,
870
+ cropType?: CropType,
836
871
  htmlId?: string,
837
872
  css?: string
838
873
  );
839
874
 
840
- /** How to align message text. See the `InAppMessage.TextAlignment` enum. */
841
- messageAlignment: InAppMessage.TextAlignment;
875
+ /** How to align message text. See the `TextAlignment` enum. */
876
+ messageAlignment: TextAlignment;
842
877
 
843
878
  /**
844
879
  * Where the user should be brought when clicking on this message. See the
845
- * `InAppMessage.ClickAction` enum.
880
+ * `ClickAction` enum.
846
881
  */
847
- clickAction: InAppMessage.ClickAction;
882
+ clickAction: ClickAction;
848
883
 
849
884
  /**
850
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
885
+ * If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
851
886
  * user clicks on this message.
852
887
  */
853
888
  uri?: string;
854
889
 
855
890
  /**
856
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
857
- * 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.
858
893
  */
859
- openTarget: InAppMessage.OpenTarget;
894
+ openTarget: OpenTarget;
860
895
 
861
896
  /**
862
897
  * A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
@@ -872,9 +907,9 @@ declare namespace appboy {
872
907
 
873
908
  /**
874
909
  * Whether the image should be shown as normal on the top of the in-app message or used
875
- * as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
910
+ * as the entire content of the message. See the `ImageStyle` enum.
876
911
  */
877
- imageStyle: InAppMessage.ImageStyle;
912
+ imageStyle: ImageStyle;
878
913
 
879
914
  /** Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
880
915
  iconColor: number;
@@ -891,11 +926,11 @@ declare namespace appboy {
891
926
  /** Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
892
927
  closeButtonColor: number;
893
928
 
894
- /** Header text to display. */
929
+ /** Header text to */
895
930
  header?: string;
896
931
 
897
- /** How to align header text. See the `InAppMessage.TextAlignment` enum. */
898
- headerAlignment: InAppMessage.TextAlignment;
932
+ /** How to align header text. See the `TextAlignment` enum. */
933
+ headerAlignment: TextAlignment;
899
934
 
900
935
  /** Color of header text. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
901
936
  headerTextColor: number;
@@ -906,27 +941,23 @@ declare namespace appboy {
906
941
  /** Array of up to two`InAppMessageButton` objects. */
907
942
  buttons: InAppMessageButton[];
908
943
 
909
- /** How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum. */
910
- cropType: InAppMessage.CropType;
944
+ /** How to crop and fit images in the allowable space. See the `CropType` enum. */
945
+ cropType: CropType;
911
946
  }
912
947
 
913
- class HtmlMessage extends InAppMessage {
948
+ export class HtmlMessage extends InAppMessage {
914
949
  /**
915
- * An html-content in-app message object which can be passed to `display.showInAppMessage`
916
- * 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`
917
952
  *
918
953
  * @param message - The html content to display to the user.
919
954
  * @param extras - Object of string/string key/value pairs.
920
- * @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
921
- * will report back to Appboy with in-app message analytics events.
922
- * @param cardId - If the message comes with a card, this is the id of the card that the SDK
923
- * will report back to Appboy with in-app message analytics events.
924
955
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
925
- * Appboy with in-app message analytics events.
956
+ * Braze with in-app message analytics events.
926
957
  * @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
927
- * See the `InAppMessage.TextAlignment` enum.
958
+ * See the `TextAlignment` enum.
928
959
  * @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
929
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`.
960
+ * dismissType is `DismissType`.AUTO_DISMISS.
930
961
  * @param animateIn - Whether to animate the showing of this message.
931
962
  * @param animateOut - Whether to animate the hiding of this message.
932
963
  * @param frameColor - Color of the background frame which blocks page interaction while the message is showing.
@@ -938,10 +969,8 @@ declare namespace appboy {
938
969
  constructor(
939
970
  message: string,
940
971
  extras?: Record<string, any>,
941
- campaignId?: string,
942
- cardId?: string,
943
972
  triggerId?: string,
944
- dismissType?: InAppMessage.DismissType,
973
+ dismissType?: DismissType,
945
974
  duration?: number,
946
975
  animateIn?: boolean,
947
976
  animateOut?: boolean,
@@ -959,34 +988,30 @@ declare namespace appboy {
959
988
  }
960
989
 
961
990
  /**
962
- * A slide-up in-app message object which can be passed to `display.showInAppMessage`
963
- * 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`
964
993
  */
965
- class SlideUpMessage extends InAppMessage {
994
+ export class SlideUpMessage extends InAppMessage {
966
995
  /**
967
- * A slide-up in-app message object which can be passed to `display.showInAppMessage`
968
- * 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`
969
998
  *
970
999
  * @param message - The message to display to the user.
971
- * @param messageAlignment - How to align message text. See the `InAppMessage.TextAlignment` enum.
972
- * @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.
973
1002
  * @param extras - Object of string/string key/value pairs.
974
- * @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
975
- * will report back to Appboy with in-app message analytics events.
976
- * @param cardId - If the message comes with a card, this is the id of the card that the SDK
977
- * will report back to Appboy with in-app message analytics events.
978
1003
  * @param triggerId - The id of the trigger that created this message. The SDK will report back this to
979
- * Appboy with in-app message analytics events.
1004
+ * Braze with in-app message analytics events.
980
1005
  * @param clickAction - Where the user should be brought when clicking on this message. See the
981
- * `InAppMessage.ClickAction` enum.
982
- * @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
983
1008
  * user clicks on this message.
984
- * @param openTarget - If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
985
- * 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.
986
1011
  * @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
987
- * See the `InAppMessage.DismissType` enum.
1012
+ * See the `DismissType` enum.
988
1013
  * @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
989
- * dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
1014
+ * dismissType is `DismissType`.AUTO_DISMISS
990
1015
  * @param icon - A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
991
1016
  * [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
992
1017
  * @param imageUrl - Url of an image to include in this message. The message will only display an image *or*
@@ -1008,16 +1033,14 @@ declare namespace appboy {
1008
1033
  */
1009
1034
  constructor(
1010
1035
  message: string,
1011
- messageAlignment?: InAppMessage.TextAlignment,
1012
- slideFrom?: InAppMessage.SlideFrom,
1036
+ messageAlignment?: TextAlignment,
1037
+ slideFrom?: SlideFrom,
1013
1038
  extras?: Record<string, any>,
1014
- campaignId?: string,
1015
- cardId?: string,
1016
1039
  triggerId?: string,
1017
- clickAction?: InAppMessage.ClickAction,
1040
+ clickAction?: ClickAction,
1018
1041
  uri?: string,
1019
- openTarget?: InAppMessage.OpenTarget,
1020
- dismissType?: InAppMessage.DismissType,
1042
+ openTarget?: OpenTarget,
1043
+ dismissType?: DismissType,
1021
1044
  duration?: number,
1022
1045
  icon?: string,
1023
1046
  imageUrl?: string,
@@ -1032,29 +1055,29 @@ declare namespace appboy {
1032
1055
  css?: string
1033
1056
  );
1034
1057
 
1035
- /** How to align message text. See the `InAppMessage.TextAlignment` enum. */
1036
- messageAlignment: InAppMessage.TextAlignment;
1058
+ /** How to align message text. See the `TextAlignment` enum. */
1059
+ messageAlignment: TextAlignment;
1037
1060
 
1038
- /** Where the message should slide in from. See the `InAppMessage.SlideFrom` enum. */
1039
- slideFrom: InAppMessage.SlideFrom;
1061
+ /** Where the message should slide in from. See the `SlideFrom` enum. */
1062
+ slideFrom: SlideFrom;
1040
1063
 
1041
1064
  /**
1042
1065
  * Where the user should be brought when clicking on this message. See the
1043
- * `InAppMessage.ClickAction` enum.
1066
+ * `ClickAction` enum.
1044
1067
  */
1045
- clickAction: InAppMessage.ClickAction;
1068
+ clickAction: ClickAction;
1046
1069
 
1047
1070
  /**
1048
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
1071
+ * If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
1049
1072
  * user clicks on this message.
1050
1073
  */
1051
1074
  uri?: string;
1052
1075
 
1053
1076
  /**
1054
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
1055
- * 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.
1056
1079
  */
1057
- openTarget: InAppMessage.OpenTarget;
1080
+ openTarget: OpenTarget;
1058
1081
 
1059
1082
  /**
1060
1083
  * A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
@@ -1084,20 +1107,21 @@ declare namespace appboy {
1084
1107
  closeButtonColor: number;
1085
1108
  }
1086
1109
 
1087
- namespace User {
1088
- type Genders = "m" | "f" | "o" | "u" | "n" | "p";
1089
- type NotificationSubscriptionTypes = "opted_in" | "subscribed" | "unsubscribed";
1090
- }
1110
+
1111
+ type Genders = typeof User.Genders[keyof typeof User.Genders];
1112
+
1113
+
1114
+ type NotificationSubscriptionTypes = typeof User.NotificationSubscriptionTypes[keyof typeof User.NotificationSubscriptionTypes];
1091
1115
 
1092
1116
  /**
1093
- * Do not construct directly - use `appboy.getUser` to get the user object.
1117
+ * Do not construct directly - use `getUser` to get the user object.
1094
1118
  * User provides an object which lets you update the attributes stored by Braze for your user.
1095
1119
  *
1096
1120
  * This class has been designed to provide fire and forget semantics and to not impact the performance or lifecycle of
1097
1121
  * calling code. As such, changes made to an User are enqueued locally and flushed to Braze's servers
1098
1122
  * asynchronously.
1099
1123
  */
1100
- class User {
1124
+ export class User {
1101
1125
  /** Enum to represent valid genders. */
1102
1126
  static Genders: {
1103
1127
  MALE: "m";
@@ -1153,7 +1177,7 @@ declare namespace appboy {
1153
1177
  * For example:
1154
1178
  *
1155
1179
  * ```
1156
- * appboy.getUser().getUserId(function(userId) {
1180
+ * braze.getUser().getUserId(function(userId) {
1157
1181
  * console.log('The user is ' + userId);
1158
1182
  * });
1159
1183
  * ```
@@ -1196,17 +1220,7 @@ declare namespace appboy {
1196
1220
  *
1197
1221
  * @returns Whether the update was successfully enqueued.
1198
1222
  */
1199
- removeFromSubscriptionGroup(subscriptionGroupId: string): boolean;
1200
-
1201
- /**
1202
- * Sets the url for the avatar image for the user, which will be displayed on the user profile
1203
- * and throughout the Braze dashboard.
1204
- *
1205
- * @param avatarImageUrl
1206
- *
1207
- * @returns Whether the update was successfully enqueued.
1208
- */
1209
- setAvatarImageUrl(avatarImageUrl: string): boolean;
1223
+ removeFromSubscriptionGroup(subscriptionGroupId: string): boolean;
1210
1224
 
1211
1225
  /**
1212
1226
  * Sets the country for the user.
@@ -1282,12 +1296,12 @@ declare namespace appboy {
1282
1296
  * Sets whether the user should be sent email campaigns.
1283
1297
  *
1284
1298
  * @param notificationSubscriptionType - Notification setting (explicitly opted-in, subscribed, or unsubscribed).
1285
- * See the `User.NotificationSubscriptionTypes` enum.
1299
+ * See the `NotificationSubscriptionTypes` enum.
1286
1300
  *
1287
1301
  * @returns Whether the update was successfully enqueued.
1288
1302
  */
1289
1303
  setEmailNotificationSubscriptionType(
1290
- notificationSubscriptionType: User.NotificationSubscriptionTypes
1304
+ notificationSubscriptionType: NotificationSubscriptionTypes
1291
1305
  ): boolean;
1292
1306
 
1293
1307
  /**
@@ -1302,12 +1316,12 @@ declare namespace appboy {
1302
1316
  /**
1303
1317
  * Sets the gender of the user.
1304
1318
  *
1305
- * @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`
1306
1320
  * enum when setting this value.
1307
1321
  *
1308
1322
  * @returns Whether the update was successfully enqueued.
1309
1323
  */
1310
- setGender(gender: User.Genders | null): boolean;
1324
+ setGender(gender: Genders | null): boolean;
1311
1325
 
1312
1326
  /**
1313
1327
  * Sets the home city for the user.
@@ -1374,16 +1388,16 @@ declare namespace appboy {
1374
1388
  * Sets whether the user should be sent push campaigns.
1375
1389
  *
1376
1390
  * @param notificationSubscriptionType - Notification setting (explicitly opted-in, subscribed, or unsubscribed).
1377
- * See the `User.NotificationSubscriptionTypes` enum.
1391
+ * See the `NotificationSubscriptionTypes` enum.
1378
1392
  *
1379
1393
  * @returns Whether the update was successfully enqueued.
1380
1394
  */
1381
1395
  setPushNotificationSubscriptionType(
1382
- notificationSubscriptionType: User.NotificationSubscriptionTypes
1396
+ notificationSubscriptionType: NotificationSubscriptionTypes
1383
1397
  ): boolean;
1384
1398
  }
1385
1399
 
1386
- class InAppMessageButton {
1400
+ export class InAppMessageButton {
1387
1401
  /**
1388
1402
  * Represents a button on an `ModalMessage` or `FullScreenMessage`.
1389
1403
  *
@@ -1395,8 +1409,8 @@ declare namespace appboy {
1395
1409
  * @param borderColor - The color for the border of this button. Hex value with opacity (e.g.
1396
1410
  * 0xff00ff00 is opaque green).
1397
1411
  * @param clickAction - Where the user should be brought when clicking on this button. See the
1398
- * `InAppMessage.ClickAction` enum.
1399
- * @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
1400
1414
  * user clicks on this button.
1401
1415
  * @param id - The id for this button. Used for analytics.
1402
1416
  */
@@ -1405,7 +1419,7 @@ declare namespace appboy {
1405
1419
  backgroundColor?: number,
1406
1420
  textColor?: number,
1407
1421
  borderColor?: number,
1408
- clickAction?: InAppMessage.ClickAction,
1422
+ clickAction?: ClickAction,
1409
1423
  uri?: string,
1410
1424
  id?: number
1411
1425
  );
@@ -1433,12 +1447,12 @@ declare namespace appboy {
1433
1447
 
1434
1448
  /**
1435
1449
  * Where the user should be brought when clicking on this button. See the
1436
- * `InAppMessage.ClickAction` enum.
1450
+ * `ClickAction` enum.
1437
1451
  */
1438
- clickAction: InAppMessage.ClickAction;
1452
+ clickAction: ClickAction;
1439
1453
 
1440
1454
  /**
1441
- * If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
1455
+ * If ```clickAction``` is `ClickAction`.URI, the URI to follow when the
1442
1456
  * user clicks on this button.
1443
1457
  */
1444
1458
  uri?: string;
@@ -1471,131 +1485,125 @@ declare namespace appboy {
1471
1485
  }
1472
1486
 
1473
1487
  /**
1474
- * appboy.display is the public class for the UI portions of Braze's Web SDK. It is only available in
1475
- * `https://js.appboycdn.com/web-sdk-develop/3.4/appboy.min.js` and is stripped from the more minimal
1476
- * `https://js.appboycdn.com/web-sdk-develop/3.4/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.
1477
1493
  */
1478
- namespace display {
1479
- /**
1480
- * Automatically display new in-app messages when they come in from the server.
1481
- *
1482
- * @returns The identifier of the subscription created. This can be passed to
1483
- * 'appboy.removeSubscription` to cancel the subscription.
1484
- */
1485
- function automaticallyShowNewInAppMessages(): string;
1494
+ export function automaticallyShowInAppMessages(): string;
1486
1495
 
1487
- /**
1488
- * Destroy any Braze news feed currently showing. This method will appropriately clean up any retained resources
1489
- * and also display the hiding animation, and so should be used instead of manually removing feed html from the
1490
- * DOM.
1491
- */
1492
- 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;
1493
1502
 
1494
- /**
1495
- * Hide any Braze content cards currently showing in the parent node, or if none is provided, any content cards in the page.
1496
- * This method will appropriately clean up any retained resources and also display the hiding animation, and so should be
1497
- * used instead of manually removing content cards HTML from the DOM.
1498
- *
1499
- * @param parentNode - The HTML node that denotes the parent of the content cards to be hidden. If null/undefined, all content
1500
- * cards on the page will be hidden.
1501
- */
1502
- 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;
1503
1512
 
1504
- /**
1505
- * Display the user's content cards.
1506
- *
1507
- * @param parentNode - The HTML node to render the content cards into. If null/undefined, the content
1508
- * cards will be rendered in fixed position over the right-hand side of the page and appended to the `<body>`
1509
- * node. If the parent node already has a Braze content cards view as a direct descendant, the existing content
1510
- * cards will be replaced.
1511
- * @param filterFunction - A filter/sort function for cards displayed in this view. Invoked with the
1512
- * array of `Card` objects, sorted by {pinned, date}. Expected to return an array of sorted
1513
- * `Card` objects to render for this user. If omitted, all cards will be displayed.
1514
- */
1515
- function showContentCards(
1516
- parentNode?: Element | null,
1517
- filterFunction?: (cards: appboy.Card[]) => appboy.Card[]
1518
- ): 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;
1519
1528
 
1520
- /**
1521
- * Display the user's news feed.
1522
- *
1523
- * @param parentNode - The HTML node to render the news feed into. If null/undefined, the feed will be
1524
- * rendered in fixed position over the right-hand side of the page and appended to the `<body>` node. If the
1525
- * parent node already has an Braze news feed as a direct descendant, the existing feed will be replaced.
1526
- * @param cards - A static set of cards to display. Each item in this Array should be a `Card`
1527
- * descendant. If this parameter is null/undefined, all unexpired cards from the last news feed refresh will be
1528
- * used automatically, a feed refresh will be kicked off automatically if the cached cards are more than 1 minute
1529
- * old, and the feed will automatically update when new cards are received while it is still showing. If you
1530
- * provide an explicit set of cards by using this parameter, no action will be taken when new cards are received,
1531
- * and you must subscribe to feed updates yourself with `appboy.subscribeToFeedUpdates` and request updates with
1532
- * `appboy.requestFeedRefresh` if you want to update this feed with new cards.
1533
- * @param allowedCategories - A set of categories to filter cards to. Each item in this Array should be a
1534
- * card category as set in the Braze dashboard. If omitted, all cards will be displayed.
1535
- */
1536
- function showFeed(
1537
- parentNode?: Element | null,
1538
- cards?: appboy.Card[] | null,
1539
- allowedCategories?: string[]
1540
- ): 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;
1541
1550
 
1542
- /**
1543
- * Display a given in-app message.
1544
- *
1545
- * @param inAppMessage - The message to display.
1546
- * @param parentNode - The HTML node to render the in-app message into. If null/undefined, the message
1547
- * will be rendered appended within the `<body>` node.
1548
- * @param onDisplayCallback - Optional callback to invoke once the message is on the screen.
1549
- *
1550
- * @returns Whether or not the message was displayed (or, in the case of control messages, logged to
1551
- * Braze servers).
1552
- */
1553
- function showInAppMessage(
1554
- inAppMessage: appboy.InAppMessage | appboy.ControlMessage,
1555
- parentNode?: Element | null,
1556
- onDisplayCallback?: () => void
1557
- ): 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;
1558
1567
 
1559
- /**
1560
- * Toggle the display of Braze content cards, showing them if they are not shown, and hiding them if they are. If you
1561
- * wish to display multiple content cards feeds on a page simultaneously, you should use `showContentCards` and `hideContentCards`
1562
- * to show/hide each feed individually instead of this method.
1563
- *
1564
- * @param parentNode - The HTML node to render the content cards into. If null/undefined, the content
1565
- * cards will be rendered in fixed position over the right-hand side of the page and appended to the `<body>`
1566
- * node. If the parent node already has a Braze content cards view as a direct descendant, the existing content
1567
- * cards will be replaced.
1568
- * @param filterFunction - A filter/sort function for cards displayed in this view. Invoked with the
1569
- * array of `Card` objects, sorted by {pinned, date}. Expected to return an array of sorted
1570
- * `Card` objects to render for this user. If omitted, all cards will be displayed.
1571
- */
1572
- function toggleContentCards(
1573
- parentNode?: Element | null,
1574
- filterFunction?: (cards: appboy.Card[]) => appboy.Card[]
1575
- ): void;
1576
-
1577
- /**
1578
- * Toggle the Braze news feed, creating it if it does not exist, and destroying it if it does.
1579
- *
1580
- * @param parentNode - The HTML node to render the news feed into. If null/undefined, the feed will be
1581
- * rendered in fixed position over the right-hand side of the page and appended to the `<body>` node. If the
1582
- * parent node already has an Braze news feed as a direct descendant, the existing feed will be replaced.
1583
- * @param cards - A static set of cards to display. Each item in this Array should be a `Card`
1584
- * descendant. If this parameter is null/undefined, all unexpired cards from the last news feed refresh will be
1585
- * used automatically, a feed refresh will be kicked off automatically if the cached cards are more than 1 minute
1586
- * old, and the feed will automatically update when new cards are received while it is still showing. If you
1587
- * provide an explicit set of cards by using this parameter, no action will be taken when new cards are received,
1588
- * and you must subscribe to feed updates yourself with `appboy.subscribeToFeedUpdates` and request updates with
1589
- * `appboy.requestFeedRefresh` if you want to update this feed with new cards.
1590
- * @param allowedCategories - A set of categories to filter cards to. Each item in this Array should be a
1591
- * card category as set in the Braze dashboard. If omitted, all cards will be displayed.
1592
- */
1593
- function toggleFeed(
1594
- parentNode?: Element | null,
1595
- cards?: appboy.Card[] | null,
1596
- allowedCategories?: string[]
1597
- ): void;
1598
- }
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;
1599
1607
 
1600
1608
  /**
1601
1609
  * When a user first uses Braze on a device they are considered "anonymous". Use this method to identify a user
@@ -1629,17 +1637,18 @@ declare namespace appboy {
1629
1637
  * to target while logged out and switching back to that user ID as part of your app's logout process.
1630
1638
  *
1631
1639
  * @param userId - A unique identifier for this user. Limit 997 bytes.
1640
+ * These User IDs should be private and not easily guessable (e.g. not a plain email address or username).
1632
1641
  * @param signature - An encrypted signature to be used to authenticate the current user. You can update the signature
1633
1642
  * using the `setSdkAuthenticationSignature` method. This signature will only have an effect if the `enableSdkAuthentication`
1634
1643
  * initialization option is set to true.
1635
1644
  */
1636
- function changeUser(userId: string, signature?: string): void;
1645
+ export function changeUser(userId: string, signature?: string): void;
1637
1646
 
1638
1647
  /**
1639
- * 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
1640
1649
  * retain memory.
1641
1650
  */
1642
- function destroy(): void;
1651
+ export function destroy(): void;
1643
1652
 
1644
1653
  /**
1645
1654
  * Get all currently available cards from the last content cards refresh.
@@ -1647,7 +1656,7 @@ declare namespace appboy {
1647
1656
  * @returns - A `ContentCards` object which includes all currently available
1648
1657
  * `Card` objects from the last content cards refresh.
1649
1658
  */
1650
- function getCachedContentCards(): appboy.ContentCards;
1659
+ export function getCachedContentCards(): ContentCards;
1651
1660
 
1652
1661
  /**
1653
1662
  * Get all unexpired cards from the last news feed refresh.
@@ -1655,88 +1664,74 @@ declare namespace appboy {
1655
1664
  * @returns - A `Feed` object which includes all unexpired `Card` objects from the last
1656
1665
  * news feed refresh.
1657
1666
  */
1658
- function getCachedFeed(): appboy.Feed;
1667
+ export function getCachedFeed(): Feed;
1659
1668
 
1660
1669
  /**
1661
1670
  * Asynchronously retrieves the 'device id,' a randomly generated ID that is stored on the browser.
1662
1671
  * This ID resets for private browsing sessions and when website data is cleared. For example:
1663
1672
  *
1664
1673
  * ```
1665
- * appboy.getDeviceId(function(deviceId) {
1674
+ * braze.getDeviceId(function(deviceId) {
1666
1675
  * console.log('The device id is ' + deviceId);
1667
1676
  * });
1668
1677
  * ```
1669
1678
  *
1670
1679
  * @param callback - Asynchronous callback - this will be invoked with the deviceId.
1671
1680
  */
1672
- function getDeviceId(callback: (deviceId: string) => void): void;
1681
+ export function getDeviceId(callback: (deviceId: string) => void): void;
1673
1682
 
1674
1683
  /**
1675
1684
  * @returns The user currently being tracked by Braze, used for querying the tracked user id and setting
1676
- * 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.
1677
1687
  */
1678
- function getUser(): appboy.User;
1688
+ export function getUser(): User | undefined;
1679
1689
 
1680
1690
  /**
1681
- * 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
1682
1692
  * invoked, and is part of the default loading snippets. Subsequent calls will be ignored until 'destroy`
1683
1693
  * is called.
1684
1694
  *
1685
1695
  * @param apiKey - Your app's Braze API Key. Your API keys can be found
1686
- * [here](https://dashboard.appboy.com/app_settings/app_settings).
1696
+ * [here](https://dashboard.braze.com/app_settings/app_settings).
1687
1697
  * @param options - Configuration options. See `InitializationOptions` for supported options.
1688
1698
  *
1689
- * @returns - Whether or not the `appboy` instance has been successfully initialized.
1699
+ * @returns - Whether or not the `braze` instance has been successfully initialized.
1690
1700
  * Reasons for returning false include a missing API key/base URL, user opt out, and ignored crawler bot activity.
1691
1701
  */
1692
- function initialize(apiKey: string, options: InitializationOptions): boolean;
1702
+ export function initialize(apiKey: string, options: InitializationOptions): boolean;
1693
1703
 
1694
1704
  /**
1695
1705
  * @returns Whether or not the user has blocked push. If the user has blocked push, they cannot be
1696
- * prompted to register again, and must manually remove the block in order to receive push.
1697
- */
1698
- function isPushBlocked(): boolean;
1699
-
1700
- /**
1701
- * DEPRECATED - Tests whether the user has given this browser push permission (they may still be unsubscribed from
1702
- * push via `User.setPushNotificationSubscriptionType`). A true value essentially means that
1703
- * `appboy.registerAppboyPushMessages` may be called without the user being prompted. Useful for migrating existing
1704
- * non-Braze push registrations to appboy.
1705
- *
1706
- * @deprecated This function inappropriately reports whether or not the browser *currently* has an active
1707
- * registered push subscription, and does not answer the intended permissions question of whether the user has
1708
- * granted the browser push permissions.
1709
- * Please use `appboy.isPushPermissionGranted` instead. This WILL BE REMOVED.
1710
- *
1711
- * @param yesCallback - Invoked if the user has granted push access on this browser
1712
- * @param noCallback - Invoked if the user has not granted push access on this browser
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.
1713
1708
  */
1714
- function isPushGranted(yesCallback: () => void, noCallback: () => void): void;
1709
+ export function isPushBlocked(): boolean | undefined;
1715
1710
 
1716
1711
  /**
1717
1712
  * Tests whether the user has given this browser push permission (they may still be unsubscribed from push via
1718
1713
  * `User.setPushNotificationSubscriptionType`). A true value essentially means that
1719
- * `appboy.registerAppboyPushMessages` may be called without the
1720
- * 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.
1721
1716
  *
1722
1717
  * @returns Whether or not the user has granted push permission. If this returns true,
1723
- * `appboy.registerAppboyPushMessages` may be called without the user being prompted. If this returns false,
1724
- * `appboy.registerAppboyPushMessages` may prompt the user (if `appboy.isPushSupported` returns true) or do
1725
- * 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.
1726
1721
  */
1727
- function isPushPermissionGranted(): boolean;
1722
+ export function isPushPermissionGranted(): boolean | undefined;
1728
1723
 
1729
1724
  /**
1730
1725
  * The [W3C Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) is partially supported
1731
1726
  * across the browser landscape. This method allows you to programmatically determine whether push is supported
1732
1727
  * in the current browser, and whether to show push-related user class elements to the user.
1733
1728
  *
1734
- * @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.
1735
1730
  */
1736
- function isPushSupported(): boolean;
1731
+ export function isPushSupported(): boolean | undefined;
1737
1732
 
1738
1733
  /**
1739
- * 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
1740
1735
  * and should only be called if you're bypassing that and manually building the DOM for displaying the cards in
1741
1736
  * your own code.
1742
1737
  *
@@ -1745,10 +1740,10 @@ declare namespace appboy {
1745
1740
  *
1746
1741
  * @returns Whether or not the event was successfully logged (to be flushed later).
1747
1742
  */
1748
- function logCardClick(card: appboy.Card, forContentCards?: boolean): boolean;
1743
+ export function logCardClick(card: Card, forContentCards?: boolean): boolean;
1749
1744
 
1750
1745
  /**
1751
- * 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
1752
1747
  * and should only be called if you're bypassing that and manually building the DOM for displaying the cards in
1753
1748
  * your own code.
1754
1749
  *
@@ -1756,10 +1751,10 @@ declare namespace appboy {
1756
1751
  *
1757
1752
  * @returns Whether or not the event was successfully logged (to be flushed later).
1758
1753
  */
1759
- function logCardDismissal(card: appboy.Card): boolean;
1754
+ export function logCardDismissal(card: Card): boolean;
1760
1755
 
1761
1756
  /**
1762
- * 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
1763
1758
  * and should only be called if you're bypassing that and manually building the DOM for displaying the cards in
1764
1759
  * your own code.
1765
1760
  *
@@ -1768,25 +1763,23 @@ declare namespace appboy {
1768
1763
  *
1769
1764
  * @returns Whether or not the event was successfully logged (to be flushed later).
1770
1765
  */
1771
- function logCardImpressions(
1772
- cards: appboy.Card[],
1766
+ export function logCardImpressions(
1767
+ cards: Card[],
1773
1768
  forContentCards?: boolean
1774
1769
  ): boolean;
1775
1770
 
1776
1771
  /**
1777
- * Logs that the content cards were displayed. This is done automatically when you use Appboy's
1778
- * 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
1779
1774
  * the class for displaying the cards in your own code.
1780
1775
  */
1781
- function logContentCardsDisplayed(): boolean;
1776
+ export function logContentCardsDisplayed(): boolean;
1782
1777
 
1783
1778
  /**
1784
1779
  * Reports that the current user performed a custom named event.
1785
1780
  *
1786
- * @param eventName - The identifier for the event to track. Best practice is to track generic events
1787
- * useful for segmenting, instead of specific user actions (i.e. track watched_sports_video instead of
1788
- * watched_video_adrian_peterson_td_mnf). Value is limited to 255 characters in length, cannot begin with a $,
1789
- * 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.
1790
1783
  * @param eventProperties - Hash of properties for this event. Keys are limited to 255 characters in length, cannot begin
1791
1784
  * with a $, and can only contain alphanumeric characters and punctuation. Values can be numeric, boolean, Date objects,
1792
1785
  * strings 255 characters or shorter, or nested objects whose values can be numeric, boolean, Date objects, arrays, strings,
@@ -1794,18 +1787,18 @@ declare namespace appboy {
1794
1787
  *
1795
1788
  * @returns Whether or not the event was successfully logged (to be flushed later).
1796
1789
  */
1797
- function logCustomEvent(eventName: string, eventProperties?: object): boolean;
1790
+ export function logCustomEvent(eventName: string, eventProperties?: object): boolean;
1798
1791
 
1799
1792
  /**
1800
- * Logs that the news feed was displayed. This is done automatically when you use Appboy's
1801
- * 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
1802
1795
  * the class for displaying the cards in your own code.
1803
1796
  */
1804
- function logFeedDisplayed(): void;
1797
+ export function logFeedDisplayed(): void;
1805
1798
 
1806
1799
  /**
1807
1800
  * Logs that the user clicked the given in-app message button. This is done automatically when the user clicks on
1808
- * a button in a message generated by `display.showInAppMessage`,
1801
+ * a button in a message generated by `showInAppMessage`,
1809
1802
  * and should only be called if you're bypassing that method and manually displaying the message in your own
1810
1803
  * code.
1811
1804
  *
@@ -1814,25 +1807,25 @@ declare namespace appboy {
1814
1807
  *
1815
1808
  * @returns Whether or not the event was successfully logged (to be flushed later).
1816
1809
  */
1817
- function logInAppMessageButtonClick(
1818
- button: appboy.InAppMessageButton,
1819
- inAppMessage: appboy.InAppMessage
1810
+ export function logInAppMessageButtonClick(
1811
+ button: InAppMessageButton,
1812
+ inAppMessage: InAppMessage
1820
1813
  ): boolean;
1821
1814
 
1822
1815
  /**
1823
1816
  * Logs that the user clicked the given in-app message. This is done automatically when the user clicks on a
1824
- * message generated by `display.showInAppMessage`, and should
1817
+ * message generated by `showInAppMessage`, and should
1825
1818
  * only be called if you're bypassing that method and manually displaying the message in your own code.
1826
1819
  *
1827
1820
  * @param inAppMessage
1828
1821
  *
1829
1822
  * @returns Whether or not the event was successfully logged (to be flushed later).
1830
1823
  */
1831
- function logInAppMessageClick(inAppMessage: appboy.InAppMessage): boolean;
1824
+ export function logInAppMessageClick(inAppMessage: InAppMessage): boolean;
1832
1825
 
1833
1826
  /**
1834
1827
  * Logs that the user clicked on a link in an html in-app message. This is done automatically when the user clicks
1835
- * on a message generated by `display.showInAppMessage`, and should
1828
+ * on a message generated by `showInAppMessage`, and should
1836
1829
  * only be called if you're bypassing that method and manually displaying the message in your own code.
1837
1830
  *
1838
1831
  * @param inAppMessage - The message that was clicked
@@ -1841,22 +1834,22 @@ declare namespace appboy {
1841
1834
  *
1842
1835
  * @returns Whether or not the event was successfully logged (to be flushed later).
1843
1836
  */
1844
- function logInAppMessageHtmlClick(
1845
- inAppMessage: appboy.HtmlMessage,
1837
+ export function logInAppMessageHtmlClick(
1838
+ inAppMessage: HtmlMessage,
1846
1839
  buttonId?: string,
1847
1840
  url?: string
1848
1841
  ): boolean;
1849
1842
 
1850
1843
  /**
1851
- * 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`,
1852
1845
  * and should only be called if you're bypassing that method and manually displaying the message in your own code.
1853
1846
  *
1854
1847
  * @param inAppMessage
1855
1848
  *
1856
1849
  * @returns Whether or not the event was successfully logged (to be flushed later).
1857
1850
  */
1858
- function logInAppMessageImpression(
1859
- inAppMessage: appboy.InAppMessage | appboy.ControlMessage
1851
+ export function logInAppMessageImpression(
1852
+ inAppMessage: InAppMessage | ControlMessage
1860
1853
  ): boolean;
1861
1854
 
1862
1855
  /**
@@ -1887,7 +1880,7 @@ declare namespace appboy {
1887
1880
  *
1888
1881
  * @returns Whether or not the purchase was successfully attached to the session (to be flushed later).
1889
1882
  */
1890
- function logPurchase(
1883
+ export function logPurchase(
1891
1884
  productId: string,
1892
1885
  price: number,
1893
1886
  currencyCode?: string,
@@ -1900,12 +1893,12 @@ declare namespace appboy {
1900
1893
  * When a new session is opened, syncs triggered In-App Messages and Content Cards. If the user has previously
1901
1894
  * granted the site permission to send push, automatically sends the push registration to the Braze backend.
1902
1895
  */
1903
- function openSession(): void;
1896
+ export function openSession(): void;
1904
1897
 
1905
1898
  /**
1906
1899
  * Register this browser environment to receive web push for this user. Supports browsers which implement the
1907
1900
  * [W3C Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) (browsers in which
1908
- * `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,
1909
1902
  * this method will cause the browser to immediately request push permission from the user.
1910
1903
  *
1911
1904
  * In order to properly use this feature, there are some integration steps required on your end:
@@ -1914,10 +1907,10 @@ declare namespace appboy {
1914
1907
  * - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
1915
1908
  *
1916
1909
  * ```
1917
- * self.importScripts('https://js.appboycdn.com/web-sdk-develop/3.4/service-worker.js');
1910
+ * self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.0/service-worker.js');
1918
1911
  * ```
1919
1912
  *
1920
- * 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).
1921
1914
  *
1922
1915
  * @param successCallback - When the user subscribes to push successfully this callback will be
1923
1916
  * invoked with the user's endpoint, public key, and user auth key (endpoint, publicKey, userAuth).
@@ -1925,7 +1918,7 @@ declare namespace appboy {
1925
1918
  * is temporary, it will be invoked with a parameter of `true` - otherwise it will be invoked with a parameter
1926
1919
  * of `false`.
1927
1920
  */
1928
- function registerAppboyPushMessages(
1921
+ export function requestPushPermission(
1929
1922
  successCallback?: (
1930
1923
  endpoint: string,
1931
1924
  publicKey: string,
@@ -1937,7 +1930,7 @@ declare namespace appboy {
1937
1930
  /**
1938
1931
  * Remove all event subscriptions.
1939
1932
  */
1940
- function removeAllSubscriptions(): void;
1933
+ export function removeAllSubscriptions(): void;
1941
1934
 
1942
1935
  /**
1943
1936
  * Remove an event subscription that you previously subscribed to.
@@ -1945,10 +1938,10 @@ declare namespace appboy {
1945
1938
  * @param subscriptionGuid - The identifier of the subscription you wish to remove, returned by the method
1946
1939
  * you initially used to create it.
1947
1940
  */
1948
- function removeSubscription(subscriptionGuid: string): void;
1941
+ export function removeSubscription(subscriptionGuid: string): void;
1949
1942
 
1950
1943
  /**
1951
- * 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
1952
1945
  * a new session opens (see 'openSession` for more details), and when the user refreshes content cards manually via
1953
1946
  * the refresh button. If you want to refresh content cards from the server at another time you must call this function.
1954
1947
  *
@@ -1957,16 +1950,16 @@ declare namespace appboy {
1957
1950
  * a request has completed regardless of whether new cards were returned.
1958
1951
  * @param errorCallback - Callback that is invoked when an error occurs during the refresh.
1959
1952
  */
1960
- function requestContentCardsRefresh(successCallback?: () => void, errorCallback?: () => void): void;
1953
+ export function requestContentCardsRefresh(successCallback?: () => void, errorCallback?: () => void): void;
1961
1954
 
1962
1955
  /**
1963
1956
  * Requests an immediate refresh of the news feed from Braze servers. By default, the news feed is refreshed on
1964
- * `display.showFeed` (when stale - see
1965
- * `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
1966
1959
  * server at another time you must call this function. Results of this refresh are reported asynchronously to
1967
1960
  * subscriptions created via 'subscribeToFeedUpdates` .
1968
1961
  */
1969
- function requestFeedRefresh(): void;
1962
+ export function requestFeedRefresh(): void;
1970
1963
 
1971
1964
  /**
1972
1965
  * By default, data logged to Braze through the SDK is queued locally (in HTML 5 localStorage when available, and
@@ -1978,15 +1971,20 @@ declare namespace appboy {
1978
1971
  * whether or not the flush was successful. If the flush is unsuccessful, pending data will be
1979
1972
  * flushed during the next successful flush.
1980
1973
  */
1981
- function requestImmediateDataFlush(
1974
+ export function requestImmediateDataFlush(
1982
1975
  callback?: (success: boolean) => void
1983
1976
  ): void;
1984
1977
 
1985
1978
  /**
1986
- * Removes the cookie set by `stopWebTracking`, causing subsequent calls to the Braze Web SDK to function. You must
1979
+ * Removes the cookie set by `disableSDK`, causing subsequent calls to the Braze Web SDK to function. You must
1987
1980
  * call `initialize` after calling this method before calling subsequent methods.
1988
1981
  */
1989
- function resumeWebTracking(): void;
1982
+ export function enableSDK(): void;
1983
+
1984
+ /**
1985
+ * Getter method to determine if the SDK is disabled based on whether the cookie set by `disableSdk` exists
1986
+ */
1987
+ export function isDisabled(): boolean;
1990
1988
 
1991
1989
  /**
1992
1990
  * By default, Braze logs to the browser console. Call this method to set a custom log action and enable debug-level log statements.
@@ -1994,7 +1992,7 @@ declare namespace appboy {
1994
1992
  * @param loggerFunction - A function to invoke with log messages. Should accept a single string
1995
1993
  * parameter for message.
1996
1994
  */
1997
- function setLogger(loggerFunction: (message: string) => void): void;
1995
+ export function setLogger(loggerFunction: (message: string) => void): void;
1998
1996
 
1999
1997
  /**
2000
1998
  * Sets the signature to be used to authenticate the current user. You can also set the signature when calling `changeUser`.
@@ -2004,7 +2002,16 @@ declare namespace appboy {
2004
2002
  *
2005
2003
  * @returns Whether or not the signature is valid.
2006
2004
  */
2007
- function setSdkAuthenticationSignature(signature: string): boolean;
2005
+ export function setSdkAuthenticationSignature(signature: string): boolean;
2006
+
2007
+ /**
2008
+ * Adds SDK Metadata. This method is automatically called based on the integration method.
2009
+ *
2010
+ * @param sdkMetadata - An array of metadata values from `BrazeSdkMetadata`.
2011
+ *
2012
+ * @returns Whether or not the array of metadata is valid.
2013
+ */
2014
+ export function addSdkMetadata(sdkMetadata: string[]): boolean;
2008
2015
 
2009
2016
  /**
2010
2017
  * Sets a cookie that causes all subsequent calls to the Braze Web SDK to be ignored
@@ -2012,10 +2019,11 @@ declare namespace appboy {
2012
2019
  * If you have multiple subdomains, this method MUST be called from the same subdomain that push was registered from to work properly.
2013
2020
  * This is useful for customer opt-outs. If the customer clears website data, tracking will resume.
2014
2021
  */
2015
- function stopWebTracking(): void;
2022
+ export function disableSDK(): void;
2016
2023
 
2017
2024
  /**
2018
- * 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`.
2019
2027
  *
2020
2028
  * @param subscriber - The callback function to handle new cards. This function will be called with a `ContentCards`
2021
2029
  * object which includes all currently available `Card` objects. If you want to be notified when a refresh has completed
@@ -2023,8 +2031,8 @@ declare namespace appboy {
2023
2031
  *
2024
2032
  * @returns The identifier of the subscription created. This can be passed to `removeSubscription` to cancel the subscription.
2025
2033
  */
2026
- function subscribeToContentCardsUpdates(
2027
- subscriber: (cards: appboy.ContentCards) => void
2034
+ export function subscribeToContentCardsUpdates(
2035
+ subscriber: (cards: ContentCards) => void
2028
2036
  ): string;
2029
2037
 
2030
2038
  /**
@@ -2033,61 +2041,36 @@ declare namespace appboy {
2033
2041
  * @param subscriber - The callback function to handle new cards. This function will be
2034
2042
  * called with a `Feed`object which includes all `Card` objects currently in the feed.
2035
2043
  *
2036
- * @returns The identifier of the subscription created. This can be passed to
2037
- * `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.
2038
2046
  */
2039
- function subscribeToFeedUpdates(
2040
- subscriber: (feed: appboy.Feed) => void
2041
- ): string;
2047
+ export function subscribeToFeedUpdates(
2048
+ subscriber: (feed: Feed) => void
2049
+ ): string | undefined;
2042
2050
 
2043
2051
  /**
2044
2052
  * Subscribe to receive in-app messages. The subscriber callback will be called whenever a new in-app message is
2045
- * 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
+ *
2046
2056
  * ```
2047
- * appboy.subscribeToInAppMessage(function(inAppMessage) {
2048
- * appboy.display.showInAppMessage(inAppMessage);
2057
+ * braze.subscribeToInAppMessage(function(inAppMessage) {
2058
+ * braze.showInAppMessage(inAppMessage);
2049
2059
  * });
2050
2060
  * ```
2051
2061
  * @param callback - The callback function to handle the in-app message. This function will be
2052
2062
  * called with an `InAppMessage` or a `ControlMessage` object. If you are using the build
2053
- * 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`
2054
2064
  * with the provided message.
2055
2065
  *
2056
- * @returns The identifier of the subscription created. This can be passed to
2057
- * 'removeSubscription` to cancel the subscription.
2058
- */
2059
- function subscribeToInAppMessage(
2060
- callback: (
2061
- inAppMessage: appboy.InAppMessage | appboy.ControlMessage
2062
- ) => void
2063
- ): string;
2064
-
2065
- /**
2066
- * DEPRECATED - Subscribe to receive in-app messages. The subscriber callback will be called whenever new in-app messages are
2067
- * triggered. If you are using the build of Braze's library with UI, the most basic usage of this would be
2068
- * ```
2069
- * appboy.subscribeToNewInAppMessages(function(inAppMessages) {
2070
- * appboy.display.showInAppMessage(inAppMessages[0]);
2071
- * return inAppMessages.slice(1);
2072
- * });
2073
- * ```
2074
- * @deprecated Since Web SDK 2.4.0, this function has been replaced by `appboy.subscribeToInAppMessage`,
2075
- * which has a simpler interface. This function will be removed in a future release.
2076
- *
2077
- * @param subscriber - The callback function to handle new in-app messages. This function will be
2078
- * called with an array of all currently unhandled `InAppMessage` or `ControlMessage` objects.
2079
- * If you are using the build of Braze's library with UI, you may wish to call `display.showInAppMessage`
2080
- * with one or more messages. This function should return an array of any messages that you wish to remain
2081
- * unhandled and retained until the next time subscriber is called.
2082
- *
2083
- * @returns The identifier of the subscription created. This can be passed to
2084
- * '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.
2085
2068
  */
2086
- function subscribeToNewInAppMessages(
2069
+ export function subscribeToInAppMessage(
2087
2070
  callback: (
2088
- inAppMessage: Array<appboy.InAppMessage | appboy.ControlMessage>
2071
+ inAppMessage: InAppMessage | ControlMessage
2089
2072
  ) => void
2090
- ): string;
2073
+ ): string | undefined;
2091
2074
 
2092
2075
  /**
2093
2076
  * Subscribe to be notified of network request failures that occured due to an SDK Authentication error. This
@@ -2098,33 +2081,23 @@ declare namespace appboy {
2098
2081
  * invoked with an object containing the `errorCode`, `reason` for the error, the `userId` of the request (if the
2099
2082
  * user is not anonymous), and the authentication `signature` that caused the error.
2100
2083
  *
2101
- * @returns The identifier of the subscription created. This can be passed to
2102
- * '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.
2103
2086
  */
2104
- function subscribeToSdkAuthenticationFailures(subscriber: (
2087
+ export function subscribeToSdkAuthenticationFailures(subscriber: (
2105
2088
  error: {
2106
2089
  errorCode: string,
2107
2090
  reason?: string,
2108
2091
  userId?: string,
2109
2092
  signature?: string
2110
2093
  }
2111
- ) => void): string;
2094
+ ) => void): string | undefined;
2112
2095
 
2113
2096
  /**
2114
2097
  * By default, Braze silences its logging to prevent spamming production js consoles. Call this method to
2115
2098
  * toggle logging.
2116
2099
  */
2117
- function toggleAppboyLogging(): void;
2118
-
2119
- /**
2120
- * Causes the Braze Web SDK to begin continuously collecting the user's location while your website is visible in
2121
- * the foreground of their browser, for the duration of this page load. This will cause the browser to request
2122
- * permission from the user if they have not already granted or denied it.
2123
- *
2124
- * @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)
2125
- * and passing the location data to `User.setLastKnownLocation`.
2126
- */
2127
- function trackLocation(): void;
2100
+ export function toggleLogging(): void;
2128
2101
 
2129
2102
  /**
2130
2103
  * Unregisters push notifications on this browser.
@@ -2135,7 +2108,7 @@ declare namespace appboy {
2135
2108
  * callback will be invoked.
2136
2109
  * @param errorCallback - If the unsubscribe fails for unknown reasons, this callback will be invoked.
2137
2110
  */
2138
- function unregisterAppboyPushMessages(
2111
+ export function unregisterPush(
2139
2112
  successCallback?: () => void,
2140
2113
  errorCallback?: () => void
2141
2114
  ): void;
@@ -2143,13 +2116,20 @@ declare namespace appboy {
2143
2116
  /**
2144
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.
2145
2118
  */
2146
- 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;
2147
2127
 
2148
2128
  /**
2149
2129
  * Supported initialization options
2150
2130
  *
2151
2131
  */
2152
- type InitializationOptions = {
2132
+ export type InitializationOptions = {
2153
2133
  /**
2154
2134
  * By default, the Braze Web SDK ignores activity from known spiders or web crawlers, such as Google, based
2155
2135
  * on the user agent string. This saves data points, makes analytics more accurate, and may improve page rank.
@@ -2171,7 +2151,7 @@ declare namespace appboy {
2171
2151
  /**
2172
2152
  * This option is required to configure the Braze Web SDK to use the appropriate endpoint for your integration - for example:
2173
2153
  * ```
2174
- * 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' })
2175
2155
  * ```
2176
2156
  */
2177
2157
  baseUrl: string;
@@ -2190,11 +2170,7 @@ declare namespace appboy {
2190
2170
  */
2191
2171
  devicePropertyAllowlist?: string[];
2192
2172
  /**
2193
- * @deprecated This initialization option is deprecated in favor of `devicePropertyAllowlist`, which has the same functionality.
2194
- */
2195
- devicePropertyWhitelist?: string[];
2196
- /**
2197
- * 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
2198
2174
  * a prior push provider) will sync their push token with the Braze backend automatically on new session to ensure deliverability.
2199
2175
  * To disable this behavior, set this option to true.
2200
2176
  */
@@ -2216,7 +2192,7 @@ declare namespace appboy {
2216
2192
  enableHtmlInAppMessages?: boolean;
2217
2193
  /**
2218
2194
  * Set to true to enable logging by default. Note that this will cause Braze to log to the javascript console, which is visible
2219
- * 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
2220
2196
  * your page to production.
2221
2197
  */
2222
2198
  enableLogging?: boolean;
@@ -2226,8 +2202,8 @@ declare namespace appboy {
2226
2202
  */
2227
2203
  enableSdkAuthentication?: boolean
2228
2204
  /**
2229
- * 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,
2230
- * 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
2231
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.
2232
2208
  */
2233
2209
  inAppMessageZIndex?: number
@@ -2240,12 +2216,12 @@ declare namespace appboy {
2240
2216
  */
2241
2217
  localization?: string;
2242
2218
  /**
2243
- * By default, `appboy.registerAppboyPushMessages`/`appboy.unregisterAppboyPushMessages` assume that they control and can
2219
+ * By default, `requestPushPermission`/`unregisterPush` assume that they control and can
2244
2220
  * register and unregister the site's service worker. If you have your own service worker that you register and control the
2245
2221
  * lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
2246
2222
  * option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
2247
- * `appboy.registerAppboyPushMessages`, and ensure that it contains Braze's service worker code, either with
2248
- * `self.importScripts('https://js.appboycdn.com/web-sdk-develop/3.4/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
2249
2225
  * of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
2250
2226
  */
2251
2227
  manageServiceWorkerExternally?: boolean;
@@ -2288,7 +2264,7 @@ declare namespace appboy {
2288
2264
  * root directory of your web server at `/service-worker.js`. If you want to host your service worker at a different path
2289
2265
  * on that server, provide a value for this option that is the absolute path to the file, e.g. `/mycustompath/my-worker.js`.
2290
2266
  * VERY IMPORTANT: setting a value here limits the scope of push notifications on your site. For instance, in the above
2291
- * 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`
2292
2268
  * MAY ONLY BE CALLED from web pages that start with `http://yoursite.com/mycustompath/`.
2293
2269
  */
2294
2270
  serviceWorkerLocation?: string;
@@ -2298,6 +2274,7 @@ declare namespace appboy {
2298
2274
  */
2299
2275
  sessionTimeoutInSeconds?: number;
2300
2276
  };
2301
- }
2302
2277
 
2303
- export default appboy;
2278
+
2279
+
2280
+