@braze/web-sdk-no-amd
Version:
Braze SDK without AMD for web sites and other JS platforms.
1,178 lines (1,025 loc) • 110 kB
TypeScript
/*
* Type definitions for appboy-web-sdk v3.5.1
* Project: https://github.com/Appboy/appboy-web-sdk
* (c) Braze, Inc. 2022 - http://braze.com
* License available at https://github.com/Appboy/appboy-web-sdk/blob/master/LICENSE
*/
declare namespace appboy {
/**
* Enum to represent the allowlistable set of device properties. By default, all properties are collected.
* See the `devicePropertyAllowlist` option of `appboy.initialize` for more info.
* @readonly
* @enum {string}
*/
class DeviceProperties {
/** The name of the browser - e.g. "Chrome" */
static readonly BROWSER: string;
/** The version of the browser - e.g. "59.234.1234" */
static readonly BROWSER_VERSION: string;
/** The name of the operating system - e.g. "Android" */
static readonly OS: string;
/** The screen resolution of the device - e.g. "1024x768" */
static readonly RESOLUTION: string;
/** The language the browser is set to use - e.g. "en-us" */
static readonly LANGUAGE: string;
/** The time zone of the device - e.g. "America/New_York" */
static readonly TIME_ZONE: string;
/** The user agent string of the browser - see [this link](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent) for more info */
static readonly USER_AGENT: string;
}
/**
* Enum to represent the accepted SDK Metadata tags. See `appboy.addSdkMetadata` for more info.
*
* @readonly
* @enum {string}
*/
class BrazeSdkMetadata {
/** Use this tag if you have integrated the Braze Web SDK using Google Tag Manager */
static readonly GOOGLE_TAG_MANAGER: string;
/** Use this tag if you have integrated the Braze Web SDK using mParticle */
static readonly MPARTICLE: string;
/** Automatically added when loading Braze via Segment */
static readonly SEGMENT: string;
/** Use this tag if you have integrated the Braze Web SDK using Tealium */
static readonly TEALIUM: string;
/** Use this tag if you have imported the Braze Web SDK using npm */
static readonly NPM: string;
/** Use this tag if you have loaded the Braze Web SDK using Braze's CDN (js.appboycdn.com) */
static readonly CDN: string;
/** Automatically added when loading Braze via Shopify Integration */
static readonly SHOPIFY: string;
/** Use this tag if you have integrated or loaded the Braze Web SDK using none of the other methods */
static readonly MANUAL: string;
}
/**
* Abstract base for news feed cards. Use subclasses `ClassicCard`, `CaptionedImage`,
* `Banner`, and `ControlCard`.
*/
class Card {
/**
* Call this method if you wish to programmatically remove the card from the feed and log a dismissal. This method
* is meant to be used with the Braze UI.
*
* If you are using your own UI, this method will have no effect. Instead, you should use `logCardDismissal` to
* log analytics and then remove the card from the DOM manually.
*/
dismissCard(): void;
/** Remove all event subscriptions from this message. */
removeAllSubscriptions(): void;
/**
* Remove an event subscription that you previously subscribed to.
*
* @param subscriptionGuid - The identifier of the subscription you wish to remove, returned by the method
* you initially used to create it.
*/
removeSubscription(subscriptionGuid: string): void;
/**
* Subscribe to receive click events. The subscriber callback will be called whenever this card is clicked by the
* user.
*
* @param subscriber - The callback function to receive click events. This function will be invoked with
* no arguments when this card records a click.
*
* @returns The identifier of the subscription created. This can be passed to `Card.removeSubscription`
* to cancel the subscription.
*/
subscribeToClickedEvent(subscriber: () => void): string;
/**
* Subscribe to receive dismissed events. The subscriber callback will be called whenever this card is dismissed by the
* user.
*
* @param subscriber - The callback function to receive dismissed events. This function will be invoked with
* no arguments when this card records a dismissal.
*
* @returns The identifier of the subscription created. This can be passed to `Card.removeSubscription`
* to cancel the subscription.
*/
subscribeToDismissedEvent(subscriber: () => void): string;
/** The id of the card. This will be reported back to Braze with events for analytics purposes. */
id?: string;
/** Whether this card has been shown to the user. */
viewed: boolean;
/** When this card was last modified. */
updated: Date | null;
/** When this card expires and should stop being shown to the user. */
expiresAt: Date | null;
/** Object of string/string key/value pairs. */
extras?: Record<string, any>;
/** Whether to pin this card to the top of the view. */
pinned: boolean;
static fromContentCardsJson(jsonData: Record<string, unknown>): Card | undefined;
}
class Banner extends Card {
/**
* A card with only an image, which can be passed to `display.showFeed` or handled manually.
* Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`
*
* @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
* @param viewed - Whether this card has been shown to the user.
* @param imageUrl - The url for this card's image.
* @param created - When this card was created.
* @param updated - When this card was last modified.
* @param categories - Purely for organization in your custom implementation, these categories can be set in
* the dashboard composer.
* @param expiresAt - When this card expires and should stop being shown to the user.
* @param url - A url to open when this card is clicked.
* @param linkText - The display text for the url.
* @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances.
* @param extras - Object of string/string key/value pairs.
* @param pinned - Whether to pin this card to the top of the view.
* @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
* @param clicked - Whether this card has ever been clicked on this device.
*/
constructor(
id?: string,
viewed?: boolean,
imageUrl?: string,
created?: Date,
updated?: Date,
categories?: string[],
expiresAt?: Date,
url?: string,
linkText?: string,
aspectRatio?: number,
extras?: Record<string, any>,
pinned?: boolean,
dismissible?: boolean,
clicked?: boolean
);
/** The url for this card's image. */
imageUrl?: string;
/** When this card was created. */
created: Date | null;
/**
* Purely for organization in your custom implementation, these categories can be set in
* the dashboard composer.
*/
categories: string[];
/** A url to open when this card is clicked. */
url?: string;
/** The display text for the url. */
linkText?: string;
/** The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances. */
aspectRatio: number | null;
/** Whether this card has been dismissed. */
dismissed: boolean;
/** Whether to allow the user to dismiss this card, removing it from the view. */
dismissible: boolean;
/** Whether this card has ever been clicked on this device. */
clicked: boolean;
}
class CaptionedImage extends Card {
/**
* A card with a large image and descriptive text, which can be passed to `display.showFeed` or handled manually.
* Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`.
*
* @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
* @param viewed - Whether this card has been shown to the user.
* @param title - The title text for this card.
* @param imageUrl - The url for this card's image.
* @param description - The body text for this card.
* @param created - When this card was created.
* @param updated - When this card was last modified.
* @param categories - Purely for organization in your custom implementation, these categories can be set in
* the dashboard composer.
* @param expiresAt - When this card expires and should stop being shown to the user.
* @param url - A url to open when this card is clicked.
* @param linkText - The display text for the url.
* @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances.
* @param extras - Object of string/string key/value pairs.
* @param pinned - Whether to pin this card to the top of the view.
* @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
* @param clicked - Whether this card has ever been clicked on this device.
*/
constructor(
id?: string,
viewed?: boolean,
title?: string,
imageUrl?: string,
description?: string,
created?: Date,
updated?: Date,
categories?: string[],
expiresAt?: Date,
url?: string,
linkText?: string,
aspectRatio?: number,
extras?: Record<string, any>,
pinned?: boolean,
dismissible?: boolean,
clicked?: boolean
);
/** The title text for this card. */
title: string;
/** The url for this card's image. */
imageUrl?: string;
/** The body text for this card. */
description: string;
/** When this card was created. */
created: Date | null;
/**
* Purely for organization in your custom implementation, these categories can be set in
* the dashboard composer.
*/
categories: string[];
/** A url to open when this card is clicked. */
url?: string;
/** The display text for the url. */
linkText?: string;
/** The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances. */
aspectRatio: number | null;
/** Whether this card has been dismissed. */
dismissed: boolean;
/** Whether to allow the user to dismiss this card, removing it from the view. */
dismissible: boolean;
/** Whether this card has ever been clicked on this device. */
clicked: boolean;
}
class ClassicCard extends Card {
/**
* A card with a title, body, and optionally a small image, which can be passed to
* `display.showFeed` or handled manually.
* Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`.
*
* @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
* @param viewed - Whether this card has been shown to the user.
* @param title - The title text for this card.
* @param imageUrl - The url for this card's image.
* @param description - The body text for this card.
* @param created - When this card was created.
* @param updated - When this card was last modified.
* @param categories - Purely for organization in your custom implementation, these categories can be set in
* the dashboard composer.
* @param expiresAt - When this card expires and should stop being shown to the user.
* @param url - A url to open when this card is clicked.
* @param linkText - The display text for the url.
* @param aspectRatio - The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances.
* @param extras - Object of string/string key/value pairs.
* @param pinned - Whether to pin this card to the top of the view.
* @param dismissible - Whether to allow the user to dismiss this card, removing it from the view.
* @param clicked - Whether this card has ever been clicked on this device.
*/
constructor(
id?: string,
viewed?: boolean,
title?: string,
imageUrl?: string,
description?: string,
created?: Date,
updated?: Date,
categories?: string[],
expiresAt?: Date,
url?: string,
linkText?: string,
aspectRatio?: number,
extras?: Record<string, any>,
pinned?: boolean,
dismissible?: boolean,
clicked?: boolean
);
/** The title text for this card. */
title: string;
/** The url for this card's image. */
imageUrl?: string;
/** The body text for this card. */
description: string;
/** When this card was created. */
created: Date | null;
/**
* Purely for organization in your custom implementation, these categories can be set in
* the dashboard composer.
*/
categories: string[];
/** A url to open when this card is clicked. */
url?: string;
/** The display text for the url. */
linkText?: string;
/** The aspect ratio for this card's image. This field is meant to serve as a hint before image loading completes. Note that the field may not be supplied in certain circumstances. */
aspectRatio: number | null;
/** Whether this card has been dismissed. */
dismissed: boolean;
/** Whether to allow the user to dismiss this card, removing it from the view. */
dismissible: boolean;
/** Whether this card has ever been clicked on this device. */
clicked: boolean;
}
class ControlCard extends Card {
/**
* A card with no display that logs impressions, which can be passed to
* `display.showFeed` or handled manually.
* Not supported in legacy news feed.
* Subscribe to receive new cards via `appboy.subscribeToFeedUpdates`.
*
* @param id - The id of the card. This will be reported back to Braze with events for analytics purposes.
* @param viewed - Whether this card has been shown to the user.
* @param updated - When this card was last modified.
* @param expiresAt - When this card expires and should stop being shown to the user.
* @param extras - Object of string/string key/value pairs.
* @param pinned - Whether to pin this card to the top of the view.
*/
constructor(
id?: string,
viewed?: boolean,
updated?: Date,
expiresAt?: Date,
extras?: Record<string, any>,
pinned?: boolean
);
}
class ContentCards {
/**
* A collection of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
* If you use Appboy's display module to render content cards, you generally shouldn't need to
* interact with this class, but if you are building your own content cards class manually, use
* `appboy.getCachedContentCards` to get the most recent ContentCards object.
*
* @param cards - Array of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
* @param lastUpdated - When this collection of cards was received from Appboy servers. If null, it means the
* content cards are still being fetched for this user.
*/
constructor(cards: Card[], lastUpdated: Date | null);
/** Array of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`). */
cards: Card[];
/**
* When this collection of cards was received from Appboy servers. If null, it means the
* content cards are still being fetched for this user.
*/
lastUpdated: Date | null;
/**
* Get the current unviewed card count. This is useful for powering badges on your control for showing the content cards.
* `ControlCard` cards do not count towards the unviewed count.
*/
getUnviewedCardCount(): number;
}
class Feed {
/**
* A collection of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
* Subscribe to receive feed updates via `appboy.subscribeToFeedUpdates`,
* or get the currently cached feed with `appboy.getCachedFeed`.
*
* @param cards - Array of `Card` descendents (`ClassicCard`, `CaptionedImage`,
* `Banner`). Can be passed directly to `display.showFeed`.
* @param lastUpdated - When this collection of cards was received from Braze servers. If null, it means the
* feed has never been fetched for this user.
*/
constructor(cards: Card[], lastUpdated: Date | null);
/**
* Array of `Card` descendents (`ClassicCard`, `CaptionedImage`, `Banner`).
* Can be passed directly to `display.showFeed`.
*/
cards: Card[];
/**
* When this collection of cards was received from Appboy servers. If null, it means the
* content cards are still being fetched for this user.
*/
lastUpdated: Date | null;
/**
* Get the current unread card count. This is useful for powering badges on your control for showing the news feed.
* Note that Braze will not refresh news feed cards on new page loads (and so this function will return 0) until you
* call `display.showFeed` or `appboy.requestFeedRefresh`. `ControlCard` cards do not count towards the
* unread count.
*/
getUnreadCardCount(): number;
}
class ControlMessage {
/**
* A non-showing message placeholder that represents this user receiving the the control for a multivariate
* test. Can be passed to `display.showInAppMessage` to log the user's
* entrollment in the control or handled manually.
*
* @param triggerId - The id of the trigger that created this message. The SDK will report back this to
* Braze with in-app message analytics events.
*/
constructor(triggerId?: string);
/**
* The id of the trigger that created this message. The SDK will report back this to
* Braze with in-app message analytics events.
*/
triggerId?: string;
}
namespace InAppMessage {
type SlideFrom = "TOP" | "BOTTOM";
type ClickAction = "NEWS_FEED" | "URI" | "NONE";
type DismissType = "AUTO_DISMISS" | "SWIPE";
type OpenTarget = "NONE" | "BLANK";
type ImageStyle = "TOP" | "GRAPHIC";
type Orientation = "PORTRAIT" | "LANDSCAPE";
type TextAlignment = "START" | "CENTER" | "END";
type CropType = "CENTER_CROP" | "FIT_CENTER";
}
/**
* Abstract base for in-app messages. Use subclasses `SlideUpMessage`,
* `ModalMessage`, `FullScreenMessage`, and `HtmlMessage`.
*/
class InAppMessage {
static SlideFrom: {
TOP: "TOP";
BOTTOM: "BOTTOM";
};
static ClickAction: {
NEWS_FEED: "NEWS_FEED";
URI: "URI";
NONE: "NONE";
};
static DismissType: {
AUTO_DISMISS: "AUTO_DISMISS";
MANUAL: "SWIPE";
};
static OpenTarget: {
NONE: "NONE";
BLANK: "BLANK";
};
static ImageStyle: {
TOP: "TOP";
GRAPHIC: "GRAPHIC";
};
static Orientation: {
PORTRAIT: "PORTRAIT";
LANDSCAPE: "LANDSCAPE";
};
static TextAlignment: {
START: "START";
CENTER: "CENTER";
END: "END";
};
static CropType: {
/**
* Centers the image in the available space and crops any overflowing edges.
*/
CENTER_CROP: "CENTER_CROP";
/**
* Fits the image within the available space, causing blank space on the shorter
* axis (e.g. tall images will have bars of blank space on the left/right)
*/
FIT_CENTER: "FIT_CENTER";
};
/** The message to display to the user. */
message?: string;
/** Object of string/string key/value pairs. */
extras: Record<string, any>;
/**
* The id of the trigger that created this message. The SDK will report back this to
* Appboy with in-app message analytics events.
*/
triggerId?: string;
/**
* How the message is dismissed, via a timer or requiring interaction from the user.
* See the `InAppMessage.DismissType` enum.
*/
dismissType: InAppMessage.DismissType;
/**
* Length of time in milliseconds until auto-dismiss should occur. Only used when
* dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
*/
duration: number;
/** Whether to animate the showing of this message. */
animateIn: boolean;
/** Whether to animate the hiding of this message. */
animateOut: boolean;
/** The ID to give the parent HTML element that this message is rendered into. */
htmlId?: string;
/**
* Custom CSS to apply to the page while this element is shown. All selectors should be scoped
* to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
*/
css?: string;
/**
* Call this method if you wish to programmatically remove the message from the DOM. This method will only
* work with the Braze UI.
*/
closeMessage(): void;
/** Remove all event subscriptions from this message. */
removeAllSubscriptions(): void;
/**
* Remove an event subscription that you previously subscribed to.
*
* @param subscriptionGuid - The identifier of the subscription you wish to remove, returned by the method
* you initially used to create it.
*/
removeSubscription(subscriptionGuid: string): void;
/**
* Subscribe to receive click events. The subscriber callback will be called whenever this message is clicked by the
* user.
*
* @param subscriber - The callback function to receive click events. This function will be invoked with
* no arguments when this message records a click.
*
* @returns The identifier of the subscription created. This can be passed to `removeSubscription`
* to cancel the subscription.
*/
subscribeToClickedEvent(subscriber: () => void): string;
/**
* Subscribe to receive dismissed events. The subscriber callback will be called whenever this message is closed
* by the user, or when it's dismissed automatically (depending on the dismissType).
*
* @param subscriber - The callback function to receive dismissed events. This function will be invoked with
* no arguments when this message records a dismissal.
*
* @returns The identifier of the subscription created. This can be passed to `removeSubscription`
* to cancel the subscription.
*/
subscribeToDismissedEvent(subscriber: () => void): string;
static fromJson(jsonData: Record<string, unknown>): InAppMessage | undefined;
}
class FullScreenMessage extends InAppMessage {
/**
* A modal in-app message object which can be passed to `display.showInAppMessage`
* or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`.
*
* @param message - The message to display to the user.
* @param messageAlignment - How to align message text. See the `InAppMessage.TextAlignment` enum.
* @param extras - Object of string/string key/value pairs.
* @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
* will report back to Appboy with in-app message analytics events.
* @param cardId - If the message comes with a card, this is the id of the card that the SDK
* will report back to Appboy with in-app message analytics events.
* @param triggerId - The id of the trigger that created this message. The SDK will report back this to
* Appboy with in-app message analytics events.
* @param clickAction - Where the user should be brought when clicking on this message. See the
* `InAppMessage.ClickAction` enum.
* @param uri - If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
* user clicks on this message.
* @param openTarget - If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
* in a new tab/window. See the `InAppMessage.OpenTarget` enum.
* @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
* See the `InAppMessage.DismissType` enum.
* @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
* dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
* @param icon - A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
* [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
* @param imageUrl - Url of an image to include in this message. The message will only display an image *or*
* an icon, and will prioritize the image if present.
* @param imageStyle - Whether the image should be shown as normal on the top of the in-app message or used
* as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
* @param iconColor - Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).
* @param iconBackgroundColor - Background color of icon. Hex value with opacity (e.g. 0xff00ff00
* is opaque green).
* @param backgroundColor - Background color of entire message. Hex value with opacity (e.g.
* 0xff00ff00 is opaque green).
* @param textColor - Text color of message. Hex value with opacity (e.g. 0xff00ff00 is opaque
* green).
* @param closeButtonColor - Color of close button. Hex value with opacity (e.g. 0xff00ff00 is
* opaque green).
* @param animateIn - Whether to animate the showing of this message.
* @param animateOut - Whether to animate the hiding of this message.
* @param header - Header text to display.
* @param headerAlignment - How to align header text. See the `InAppMessage.TextAlignment` enum.
* @param headerTextColor - Color of header text. Hex value with opacity (e.g. 0xff00ff00 is
* opaque green).
* @param frameColor - Color of the background frame which blocks page interaction while the
* message is showing.
* @param buttons - Array of up to two `InAppMessageButton` objects.
* @param cropType - How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum.
* @param orientation - Whether to lay out this in-app message as a portrait or landscape. See the
* `InAppMessage.Orientation` enum.
* @param htmlId - The ID to give the parent HTML element that this message is rendered into.
* @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
* to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
*/
constructor(
message?: string,
messageAlignment?: InAppMessage.TextAlignment,
extras?: Record<string, any>,
campaignId?: string,
cardId?: string,
triggerId?: string,
clickAction?: InAppMessage.ClickAction,
uri?: string,
openTarget?: InAppMessage.OpenTarget,
dismissType?: InAppMessage.DismissType,
duration?: number,
icon?: string,
imageUrl?: string,
imageStyle?: InAppMessage.ImageStyle,
iconColor?: number,
iconBackgroundColor?: number,
backgroundColor?: number,
textColor?: number,
closeButtonColor?: number,
animateIn?: boolean,
animateOut?: boolean,
header?: string,
headerAlignment?: InAppMessage.TextAlignment,
headerTextColor?: number,
frameColor?: number,
buttons?: InAppMessageButton[],
cropType?: InAppMessage.CropType,
orientation?: InAppMessage.Orientation,
htmlId?: string,
css?: string
);
/** How to align message text. See the `InAppMessage.TextAlignment` enum. */
messageAlignment: InAppMessage.TextAlignment;
/**
* Where the user should be brought when clicking on this message. See the
* `InAppMessage.ClickAction` enum.
*/
clickAction: InAppMessage.ClickAction;
/**
* If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
* user clicks on this message.
*/
uri?: string;
/**
* If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
* in a new tab/window. See the `InAppMessage.OpenTarget` enum.
*/
openTarget: InAppMessage.OpenTarget;
/**
* A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
* [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
*/
icon?: string;
/**
* Url of an image to include in this message. The message will only display an image *or*
* an icon, and will prioritize the image if present.
*/
imageUrl?: string;
/**
* Whether the image should be shown as normal on the top of the in-app message or used
* as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
*/
imageStyle: InAppMessage.ImageStyle;
/** Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
iconColor: number;
/** Background color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
iconBackgroundColor: number;
/** Background color of entire message. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
backgroundColor: number;
/** Text color of message. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
textColor: number;
/** Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
closeButtonColor: number;
/** Header text to display. */
header?: string;
/** How to align header text. See the `InAppMessage.TextAlignment` enum. */
headerAlignment: InAppMessage.TextAlignment;
/** Color of header text. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
headerTextColor: number;
/** Color of the background frame which blocks page interaction while the message is showing. */
frameColor: number;
/** Array of up to two `InAppMessageButton` objects. */
buttons: InAppMessageButton[];
/** How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum. */
cropType: InAppMessage.CropType;
/**
* Whether to lay out this in-app message as a portrait or landscape. See the
* `InAppMessage.Orientation` enum.
*/
orientation: InAppMessage.Orientation;
}
class ModalMessage extends InAppMessage {
/**
* A modal in-app message object which can be passed to `display.showInAppMessage`
* or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`
*
* @param message - The message to display to the user.
* @param messageAlignment - How to align message text. See the `InAppMessage.TextAlignment` enum.
* @param extras - Object of string/string key/value pairs.
* @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
* will report back to Appboy with in-app message analytics events.
* @param cardId - If the message comes with a card, this is the id of the card that the SDK
* will report back to Appboy with in-app message analytics events.
* @param triggerId - The id of the trigger that created this message. The SDK will report back this to
* Appboy with in-app message analytics events.
* @param clickAction - Where the user should be brought when clicking on this message. See the
* `InAppMessage.ClickAction` enum.
* @param uri - If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
* user clicks on this message.
* @param openTarget - If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
* in a new tab/window. See the `InAppMessage.OpenTarget` enum.
* @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
* See the `InAppMessage.DismissType` enum.
* @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
* dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
* @param icon - A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
* [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
* @param imageUrl - Url of an image to include in this message. The message will only display an image *or*
* an icon, and will prioritize the image if present.
* @param imageStyle - Whether the image should be shown as normal on the top of the in-app message or used
* as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
* @param iconColor - Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).
* @param iconBackgroundColor - Background color of icon. Hex value with opacity (e.g. 0xff00ff00
* is opaque green).
* @param backgroundColor - Background color of entire message. Hex value with opacity (e.g.
* 0xff00ff00 is opaque green).
* @param textColor - Text color of message. Hex value with opacity (e.g. 0xff00ff00 is opaque
* green).
* @param closeButtonColor - Color of close button. Hex value with opacity (e.g. 0xff00ff00 is
* opaque green).
* @param animateIn - Whether to animate the showing of this message.
* @param animateOut - Whether to animate the hiding of this message.
* @param header - Header text to display.
* @param headerAlignment - How to align header text. See the `InAppMessage.TextAlignment` enum.
* @param headerTextColor - Color of header text. Hex value with opacity (e.g. 0xff00ff00 is
* opaque green).
* @param frameColor - Color of the background frame which blocks page interaction while the
* message is showing.
* @param buttons - Array of up to two`InAppMessageButton` objects.
* @param cropType - How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum.
* @param htmlId - The ID to give the parent HTML element that this message is rendered into.
* @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
* to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
*/
constructor(
message?: string,
messageAlignment?: InAppMessage.TextAlignment,
extras?: Record<string, any>,
campaignId?: string,
cardId?: string,
triggerId?: string,
clickAction?: InAppMessage.ClickAction,
uri?: string,
openTarget?: InAppMessage.OpenTarget,
dismissType?: InAppMessage.DismissType,
duration?: number,
icon?: string,
imageUrl?: string,
imageStyle?: InAppMessage.ImageStyle,
iconColor?: number,
iconBackgroundColor?: number,
backgroundColor?: number,
textColor?: number,
closeButtonColor?: number,
animateIn?: boolean,
animateOut?: boolean,
header?: string,
headerAlignment?: InAppMessage.TextAlignment,
headerTextColor?: number,
frameColor?: number,
buttons?: InAppMessageButton[],
cropType?: InAppMessage.CropType,
htmlId?: string,
css?: string
);
/** How to align message text. See the `InAppMessage.TextAlignment` enum. */
messageAlignment: InAppMessage.TextAlignment;
/**
* Where the user should be brought when clicking on this message. See the
* `InAppMessage.ClickAction` enum.
*/
clickAction: InAppMessage.ClickAction;
/**
* If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
* user clicks on this message.
*/
uri?: string;
/**
* If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
* in a new tab/window. See the `InAppMessage.OpenTarget` enum.
*/
openTarget: InAppMessage.OpenTarget;
/**
* A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
* [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
*/
icon?: string;
/**
* Url of an image to include in this message. The message will only display an image *or*
* an icon, and will prioritize the image if present.
*/
imageUrl?: string;
/**
* Whether the image should be shown as normal on the top of the in-app message or used
* as the entire content of the message. See the `InAppMessage.ImageStyle` enum.
*/
imageStyle: InAppMessage.ImageStyle;
/** Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
iconColor: number;
/** Background color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
iconBackgroundColor: number;
/** Background color of entire message. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
backgroundColor: number;
/** Text color of message. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
textColor: number;
/** Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
closeButtonColor: number;
/** Header text to display. */
header?: string;
/** How to align header text. See the `InAppMessage.TextAlignment` enum. */
headerAlignment: InAppMessage.TextAlignment;
/** Color of header text. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
headerTextColor: number;
/** Color of the background frame which blocks page interaction while the message is showing. */
frameColor: number;
/** Array of up to two`InAppMessageButton` objects. */
buttons: InAppMessageButton[];
/** How to crop and fit images in the allowable space. See the `InAppMessage.CropType` enum. */
cropType: InAppMessage.CropType;
}
class HtmlMessage extends InAppMessage {
/**
* An html-content in-app message object which can be passed to `display.showInAppMessage`
* or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`
*
* @param message - The html content to display to the user.
* @param extras - Object of string/string key/value pairs.
* @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
* will report back to Appboy with in-app message analytics events.
* @param cardId - If the message comes with a card, this is the id of the card that the SDK
* will report back to Appboy with in-app message analytics events.
* @param triggerId - The id of the trigger that created this message. The SDK will report back this to
* Appboy with in-app message analytics events.
* @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
* See the `InAppMessage.TextAlignment` enum.
* @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
* dismissType is `InAppMessage.DismissType.AUTO_DISMISS`.
* @param animateIn - Whether to animate the showing of this message.
* @param animateOut - Whether to animate the hiding of this message.
* @param frameColor - Color of the background frame which blocks page interaction while the message is showing.
* @param htmlId - The ID to give the parent HTML element that this message is rendered into.
* @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
* to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
* @param messageFields - Structured data provided by the Braze backend.
*/
constructor(
message: string,
extras?: Record<string, any>,
campaignId?: string,
cardId?: string,
triggerId?: string,
dismissType?: InAppMessage.DismissType,
duration?: number,
animateIn?: boolean,
animateOut?: boolean,
frameColor?: number,
htmlId?: string,
css?: string,
messageFields?: Record<string, any>
);
/** Color of the background frame which blocks page interaction while the message is showing. */
frameColor: number;
/** Structured data provided by the Braze backend. */
messageFields?: Record<string, any>;
}
/**
* A slide-up in-app message object which can be passed to `display.showInAppMessage`
* or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`
*/
class SlideUpMessage extends InAppMessage {
/**
* A slide-up in-app message object which can be passed to `display.showInAppMessage`
* or handled manually. Subscribe to be notified when in-app messages are triggered via `appboy.subscribeToInAppMessage`
*
* @param message - The message to display to the user.
* @param messageAlignment - How to align message text. See the `InAppMessage.TextAlignment` enum.
* @param slideFrom - Where the message should slide in from. See the `InAppMessage.SlideFrom` enum.
* @param extras - Object of string/string key/value pairs.
* @param campaignId - If the message comes with a campaign, this is the id of the campaign that the SDK
* will report back to Appboy with in-app message analytics events.
* @param cardId - If the message comes with a card, this is the id of the card that the SDK
* will report back to Appboy with in-app message analytics events.
* @param triggerId - The id of the trigger that created this message. The SDK will report back this to
* Appboy with in-app message analytics events.
* @param clickAction - Where the user should be brought when clicking on this message. See the
* `InAppMessage.ClickAction` enum.
* @param uri - If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
* user clicks on this message.
* @param openTarget - If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
* in a new tab/window. See the `InAppMessage.OpenTarget` enum.
* @param dismissType - How the message is dismissed, via a timer or requiring interaction from the user.
* See the `InAppMessage.DismissType` enum.
* @param duration - Length of time in milliseconds until auto-dismiss should occur. Only used when
* dismissType is `InAppMessage.DismissType.AUTO_DISMISS`
* @param icon - A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
* [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
* @param imageUrl - Url of an image to include in this message. The message will only display an image *or*
* an icon, and will prioritize the image if present.
* @param iconColor - Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green).
* @param iconBackgroundColor - Background color of icon. Hex value with opacity (e.g. 0xff00ff00
* is opaque green).
* @param backgroundColor - Background color of entire message. Hex value with opacity (e.g.
* 0xff00ff00 is opaque green).
* @param textColor - Text color of message. Hex value with opacity (e.g. 0xff00ff00 is opaque
* green).
* @param closeButtonColor - Color of close button. Hex value with opacity (e.g. 0xff00ff00 is
* opaque green).
* @param animateIn - Whether to animate the showing of this message.
* @param animateOut - Whether to animate the hiding of this message.
* @param htmlId - The ID to give the parent HTML element that this message is rendered into.
* @param css - Custom CSS to apply to the page while this element is shown. All selectors should be scoped
* to the htmlId of this message to prevent restyling elements outside of the message when it is shown.
*/
constructor(
message: string,
messageAlignment?: InAppMessage.TextAlignment,
slideFrom?: InAppMessage.SlideFrom,
extras?: Record<string, any>,
campaignId?: string,
cardId?: string,
triggerId?: string,
clickAction?: InAppMessage.ClickAction,
uri?: string,
openTarget?: InAppMessage.OpenTarget,
dismissType?: InAppMessage.DismissType,
duration?: number,
icon?: string,
imageUrl?: string,
iconColor?: number,
iconBackgroundColor?: number,
backgroundColor?: number,
textColor?: number,
closeButtonColor?: number,
animateIn?: boolean,
animateOut?: boolean,
htmlId?: string,
css?: string
);
/** How to align message text. See the `InAppMessage.TextAlignment` enum. */
messageAlignment: InAppMessage.TextAlignment;
/** Where the message should slide in from. See the `InAppMessage.SlideFrom` enum. */
slideFrom: InAppMessage.SlideFrom;
/**
* Where the user should be brought when clicking on this message. See the
* `InAppMessage.ClickAction` enum.
*/
clickAction: InAppMessage.ClickAction;
/**
* If ```clickAction``` is `InAppMessage.ClickAction.URI`, the URI to follow when the
* user clicks on this message.
*/
uri?: string;
/**
* If ```clickAction``` is `InAppMessage.ClickAction.URI`, whether to open clicks
* in a new tab/window. See the `InAppMessage.OpenTarget` enum.
*/
openTarget: InAppMessage.OpenTarget;
/**
* A Font Awesome unicode string, e.g. "\uf042" to fa-adjust. See
* [the Font Awesome cheatsheet](http://fortawesome.github.io/Font-Awesome/cheatsheet/) for details.
*/
icon?: string;
/**
* Url of an image to include in this message. The message will only display an image *or*
* an icon, and will prioritize the image if present.
*/
imageUrl?: string;
/** Color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
iconColor: number;
/** Background color of icon. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
iconBackgroundColor: number;
/** Background color of entire message. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
backgroundColor: number;
/** Text color of message. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
textColor: number;
/** Color of close button. Hex value with opacity (e.g. 0xff00ff00 is opaque green). */
closeButtonColor: number;
}
namespace User {
type Genders = "m" | "f" | "o" | "u" | "n" | "p";
type NotificationSubscriptionTypes = "opted_in" | "subscribed" | "unsubscribed";
}
/**
* Do not construct directly - use `appboy.getUser` to get the user object.
* User provides an object which lets you update the attributes stored by Braze for your user.
*
* This class has been designed to provide fire and forget semantics and to not impact the performance or lifecycle of
* calling code. As such, changes made to an User are enqueued locally and flushed to Braze's servers
* asynchronously.
*/
class User {
/** Enum to represent valid genders. */
static Genders: {
MALE: "m";
FEMALE: "f";
OTHER: "o";
UNKNOWN: "u";
NOT_APPLICABLE: "n";
PREFER_NOT_TO_SAY: "p";
};
/** Enum to represent notification status for email and push notifications. */
static NotificationSubscriptionTypes: {
OPTED_IN: "opted_in";
SUBSCRIBED: "subscribed";
UNSUBSCRIBED: "unsubscribed";
};
/**
* Adds an an alias for the user. (alias, label) pairs can exist on one and only one user.
* If a different user already has this alias or external user id, the alias attempt will be rejected
* on the server.
*
* @param alias - An identifier for this user.
* @param label - A label for the alias. e.g. the source of the alias, like "internal_id"
*
* @returns Whether the update was successfully enqueued.
*/
addAlias(alias: string, label: string): boolean;
/**
* Adds a string to a custom attribute string array, or creates that array if one doesn't exist.
*
* @param key - The identifier of the custom attribute. Limited to 255 characters in length, cannot begin with
* a $, and can only contain alphanumeric characters and punctuation.
* @param value - The string to be added to the array. Strings are limited to 255 characters in length, cannot
* begin with a $, and can only contain alphanumeric characters and punctuation.
*
* @returns Whether the update was successfully enqueued.
*/
addToCustomAttributeArray(key: string, value: string): boolean;
/**
* Adds a user to an email or SMS subscription group.
*
* @param subscriptionGroupId - The unique identifier of the subscription group.
*
* @returns Whether the update was successfully enqueued.
*/
addToSubscript