Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@braze/react-native-sdk

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@braze/react-native-sdk - npm Package Compare versions

Comparing version 9.0.0 to 9.1.0

8

__tests__/index.test.js

@@ -10,3 +10,3 @@ const NativeEventEmitter = require('react-native').NativeEventEmitter;

const testInAppMessageJson = `{\"message\":\"body body\",\"type\":\"MODAL\",\"text_align_message\":\"CENTER\",\"click_action\":\"NONE\",\"message_close\":\"SWIPE\",\"extras\":{\"test\":\"123\",\"foo\":\"bar\"},\"header\":\"hello\",\"text_align_header\":\"CENTER\",\"image_url\":\"https:\\/\\/github.com\\/braze-inc\\/braze-react-native-sdk\\/blob\\/master\\/.github\\/assets\\/logo-dark.png?raw=true\",\"image_style\":\"TOP\",\"btns\":[{\"id\":0,\"text\":\"button 1\",\"click_action\":\"URI\",\"uri\":\"https:\\/\\/www.google.com\",\"use_webview\":true,\"bg_color\":4294967295,\"text_color\":4279990479,\"border_color\":4279990479},{\"id\":1,\"text\":\"button 2\",\"click_action\":\"NONE\",\"bg_color\":4279990479,\"text_color\":4294967295,\"border_color\":4279990479}],\"close_btn_color\":4291085508,\"bg_color\":4294243575,\"frame_color\":3207803699,\"text_color\":4280624421,\"header_text_color\":4280624421,\"trigger_id\":\"NWJhNTMxOThiZjVjZWE0NDZiMTUzYjZiXyRfbXY9NWJhNTMxOThiZjVjZWE0NDZiMTUzYjc1JnBpPWNtcA==\"}`;
const testInAppMessageJson = `{\"message\":\"body body\",\"type\":\"MODAL\",\"text_align_message\":\"CENTER\",\"click_action\":\"NONE\",\"message_close\":\"SWIPE\",\"extras\":{\"test\":\"123\",\"foo\":\"bar\"},\"header\":\"hello\",\"text_align_header\":\"CENTER\",\"image_url\":\"https:\\/\\/github.com\\/braze-inc\\/braze-react-native-sdk\\/blob\\/master\\/.github\\/assets\\/logo-dark.png?raw=true\",\"image_style\":\"TOP\",\"btns\":[{\"id\":0,\"text\":\"button 1\",\"click_action\":\"URI\",\"uri\":\"https:\\/\\/www.google.com\",\"use_webview\":true,\"bg_color\":4294967295,\"text_color\":4279990479,\"border_color\":4279990479},{\"id\":1,\"text\":\"button 2\",\"click_action\":\"NONE\",\"bg_color\":4279990479,\"text_color\":4294967295,\"border_color\":4279990479}],\"close_btn_color\":4291085508,\"bg_color\":4294243575,\"frame_color\":3207803699,\"text_color\":4280624421,\"header_text_color\":4280624421,\"trigger_id\":\"NWJhNTMxOThiZjVjZWE0NDZiMTUzYjZiXyRfbXY9NWJhNTMxOThiZjVjZWE0NDZiMTUzYjc1JnBpPWNtcA==\", \"is_test_send\":false}`;

@@ -529,5 +529,6 @@ afterEach(() => {

const testButtons = [];
const testIsTestSend = true;
testButtons.push(new Braze.BrazeButton(JSON.parse(testButton0)));
testButtons.push(new Braze.BrazeButton(JSON.parse(testButton1)));
const testJson = `{\"message\":\"${testMessageBody}\",\"type\":\"${testMessageType}\",\"text_align_message\":\"CENTER\",\"click_action\":\"${testClickAction}\",\"message_close\":\"SWIPE\",\"extras\":${testExtras},\"header\":\"${testHeader}\",\"text_align_header\":\"CENTER\",\"image_url\":\"${testImageUrl}\",\"image_style\":\"TOP\",\"btns\":${testButtonString},\"close_btn_color\":4291085508,\"bg_color\":4294243575,\"frame_color\":3207803699,\"text_color\":4280624421,\"header_text_color\":4280624421,\"trigger_id\":\"NWJhNTMxOThiZjVjZWE0NDZiMTUzYjZiXyRfbXY9NWJhNTMxOThiZjVjZWE0NDZiMTUzYjc1JnBpPWNtcA==\",\"uri\":\"${testUri}\",\"zipped_assets_url\":\"${testZippedAssetsUrl}\",\"duration\":${testDuration},\"message_close\":\"${testDismissType}\",\"use_webview\":${testUseWebView}}`
const testJson = `{\"message\":\"${testMessageBody}\",\"type\":\"${testMessageType}\",\"text_align_message\":\"CENTER\",\"click_action\":\"${testClickAction}\",\"message_close\":\"SWIPE\",\"extras\":${testExtras},\"header\":\"${testHeader}\",\"text_align_header\":\"CENTER\",\"image_url\":\"${testImageUrl}\",\"image_style\":\"TOP\",\"btns\":${testButtonString},\"close_btn_color\":4291085508,\"bg_color\":4294243575,\"frame_color\":3207803699,\"text_color\":4280624421,\"header_text_color\":4280624421,\"trigger_id\":\"NWJhNTMxOThiZjVjZWE0NDZiMTUzYjZiXyRfbXY9NWJhNTMxOThiZjVjZWE0NDZiMTUzYjc1JnBpPWNtcA==\",\"uri\":\"${testUri}\",\"zipped_assets_url\":\"${testZippedAssetsUrl}\",\"duration\":${testDuration},\"message_close\":\"${testDismissType}\",\"use_webview\":${testUseWebView}, \"is_test_send\":${testIsTestSend}}`
const inAppMessage = new Braze.BrazeInAppMessage(testJson);

@@ -547,2 +548,3 @@ expect(inAppMessage.message).toBe(testMessageBody);

expect(inAppMessage.buttons).toEqual(testButtons);
expect(inAppMessage.isTestSend).toEqual(testIsTestSend);
});

@@ -563,2 +565,3 @@

const defaultButtons = [];
const defaultIsTestSend = false;
const testJson = `{}`;

@@ -579,2 +582,3 @@ const inAppMessage = new Braze.BrazeInAppMessage(testJson);

expect(inAppMessage.buttons).toEqual(defaultButtons);
expect(inAppMessage.isTestSend).toEqual(defaultIsTestSend);
});

@@ -581,0 +585,0 @@

{
"name": "@braze/react-native-sdk",
"version": "9.0.0",
"version": "9.1.0",
"description": "Braze SDK for React Native.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -402,29 +402,73 @@ // Definitions by: ahanriat <https://github.com/ahanriat>

/**
* [Braze News Feed](https://www.braze.com/docs/user_guide/engagement_tools/news_feed)
*/
export interface NewsFeedCardBase {
/** The card identifier. */
id: string;
/** The card creation timestamp. */
created: number;
/** The card last update timestamp. */
updated: number;
/** The card viewed state. */
viewed: boolean;
/** The card image URL. */
url?: string;
/** The card extras dictionary (default: `[:]`) */
extras: { [key: string]: string };
}
/**
* The Banner News Feed Card, extending NewsFeedCardBase.
*/
export interface BannerNewsFeedCard extends NewsFeedCardBase {
/** The News Feed Card type. */
type: 'Banner';
/** The card image URL. */
image: string;
/** The card image aspect ratio */
imageAspectRatio: number;
}
/**
* The Captioned News Feed Card, extending NewsFeedCardBase.
*/
export interface CaptionedNewsFeedCard extends NewsFeedCardBase {
/** The News Feed Card type. */
type: 'Captioned';
/** The card image URL. */
image: string;
/** The card title. */
title: string;
/** The card description. */
cardDescription: string;
/** (Optional) The card domain. */
domain?: string;
}
/**
* The Text Announcement News Feed Card, extending NewsFeedCardBase.
*/
export interface TextAnnouncementNewsFeedCard extends NewsFeedCardBase {
/** The News Feed Card type. */
type: 'TextAnnouncement';
/** The card title. */
title: string;
/** The card description. */
cardDescription: string;
/** (Optional) The card domain. */
domain?: string;

@@ -458,37 +502,116 @@ }

// Content Cards
/**
* [Braze Content Cards](https://www.braze.com/docs/developer_guide/platform_integration_guides/react_native/content_cards/)
*/
export interface ContentCardBase {
/** The card's ID. */
id: string;
/** The UNIX timestamp of the card's creation time from Braze dashboard. */
created: number;
/** The UNIX timestamp of the card's expiration time. When the value is less than 0, it means the card never expires. */
expiresAt: number;
/** Indicates whether the card has been read or is unread by the user. Note: This does not log analytics. */
viewed: boolean;
/**
* Indicates whether the card has been clicked by the user.
* Note: Clicks are stored on disk, so subsequent instances of this card will retain its clicked state upon recreation.
*/
clicked: boolean;
/** Indicates whether the card is pinned. */
pinned: boolean;
/** Indicates whether the card has been dismissed. Marking a card as dismissed that has already been dismissed will be a no-op. */
dismissed: boolean;
/** Indicates whether the card is dismissible by the user. */
dismissible: boolean;
/** (Optional) The url string associated with the card click action. */
url?: string;
/**
* Indicates whether URLs for this card should be opened in Braze's WebView or not.
* When false, the URL will be opened by the OS and web URLs will be opened in an external web browser app.
*/
openURLInWebView: boolean;
/** Indicates whether this card is a control card. Control cards should not be displayed to the user. */
isControl: boolean;
/** A map of key-value pair extras for this card. */
extras: { [key: string]: string };
}
/**
* The Classic Content Card, extending ContentCardBase.
*/
export interface ClassicContentCard extends ContentCardBase {
/** The Content Card type. */
type: 'Classic';
/** (Optional) The URL of the card's image. */
image?: string;
/** The title text for the card. */
title: string;
/** The description text for the card. */
cardDescription: string;
/**
* (Optional) The link text for the property URL, e.g., "blog.appboy.com". It can be displayed on the card's
* UI to indicate the action/direction of clicking on the card.
*/
domain?: string;
}
/**
* The Image Only Content Card, extending ContentCardBase.
*/
export interface ImageOnlyContentCard extends ContentCardBase {
/** The Content Card type. */
type: 'ImageOnly';
/** The URL of the card's image. */
image: string;
/**
* The aspect ratio of the card's image. It is meant to serve as a hint before image loading completes.
* Note that the property may not be supplied in certain circumstances.
*/
imageAspectRatio: number;
}
/**
* The Captioned Content Card, extending ContentCardBase.
*/
export interface CaptionedContentCard extends ContentCardBase {
/** The Content Card type. */
type: 'Captioned';
/** The URL of the card's image. */
image: string;
/**
* The aspect ratio of the card's image. It is meant to serve as a hint before image loading completes.
* Note that the property may not be supplied in certain circumstances.
*/
imageAspectRatio: number;
/** The title text for the card. */
title: string;
/** The description text for the card. */
cardDescription: string;
/**
* (Optional) The link text for the property URL, e.g., "blog.appboy.com". It can be displayed on the card's
* UI to indicate the action/direction of clicking on the card.
*/
domain?: string;

@@ -716,3 +839,3 @@ }

* Notifies the bridge of a listener being added.
* @param {Events} event
* @param {Events} event - Describes the event being added.
*/

@@ -723,17 +846,38 @@ export function addListener(

/**
* A Feature Flag property of type String.
*/
export interface FeatureFlagStringProperty {
/** The type of Feature Flag property. */
type: "string";
/** The value of the property. */
value: string;
}
/**
* A Feature Flag property of type Number.
*/
export interface FeatureFlagNumberProperty {
/** The type of Feature Flag property. */
type: "number";
/** The value of the property. */
value: number;
}
/**
* A Feature Flag property of type Boolean.
*/
export interface FeatureFlagBooleanProperty {
/** The type of Feature Flag property. */
type: "boolean";
/** The value of the property. */
value: boolean;
}
/**
* [Braze Feature Flags](https://www.braze.com/docs/developer_guide/platform_wide/feature_flags)
*/
export class FeatureFlag {

@@ -813,27 +957,74 @@ /** Indicates whether or not this feature flag is enabled. */

/**
* [Braze In-App Message](https://www.braze.com/docs/developer_guide/platform_integration_guides/react_native/inapp_messages/)
*/
export class BrazeInAppMessage {
constructor(_data: string);
/** The message JSON representation. */
inAppMessageJsonString: string;
/** The message text. */
message: string;
/** The message header. */
header: string;
/** The URI associated with the button click action. */
uri: string;
/** The message image URL. */
imageUrl: string;
/** The zipped assets prepared to display HTML content. */
zippedAssetsUrl: string;
/** Indicates whether the button click action should redirect using a web view. */
useWebView: boolean;
/** The message display duration. */
duration: number;
/** The button click action. */
clickAction: BrazeClickAction[keyof BrazeClickAction];
/** The message close type. */
dismissType: BrazeDismissType[keyof BrazeDismissType];
/** The in-app message type supported by the SDK. */
messageType: BrazeMessageType[keyof BrazeMessageType];
/** The message extras dictionary (default: `[:]`) */
extras: { [key: string]: string };
/** The list of buttons on the in-app message. */
buttons: [BrazeButton];
/** Specifies whether the message was delivered as a test send (default: `false`). */
isTestSend: boolean;
/** The message as a String representation. */
toString(): string;
}
/**
* A button on an In-App Message.
*/
export class BrazeButton {
constructor(_data: string);
/** The text on the button. */
text: string;
/** The URI associated with the button click action. */
uri: string;
/** Indicates whether the button click action should redirect using a web view. */
useWebView: boolean;
/** The type of click action processed when the user clicks on the button. */
clickAction: BrazeClickAction[keyof BrazeClickAction];
/** The button ID on the message. */
id: number;
/** The button as a String representation. */
toString(): string;

@@ -844,5 +1035,13 @@ }

/**
* The click action type of the In-App Message.
*/
interface BrazeClickAction {
/** Opens the NewsFeed on click. */
NEWS_FEED: 'news_feed';
/** Opens the URI on click, optionally using a web view. */
URI: 'uri';
/** No action on click. */
NONE: 'none';

@@ -852,4 +1051,10 @@ }

/**
* The message close type of the In-App Message.
*/
interface BrazeDismissType {
/** Dismisses the message on user swipe. */
SWIPE: 'swipe';
/** Dismisses the message automatically */
AUTO_DISMISS: 'auto_dismiss';

@@ -859,6 +1064,16 @@ }

/**
* The In-App Message types supported by the SDK.
*/
interface BrazeMessageType {
/** The Slideup message type. */
SLIDEUP: 'slideup';
/** The Modal message type. */
MODAL: 'modal';
/** The Full message type. */
FULL: 'full';
/** The HtmlFull message type. */
HTML_FULL: 'html_full';

@@ -868,5 +1083,13 @@ }

/**
* The Content Card types supported by the Braze SDK.
*/
interface BrazeContentCardType {
/** The Classic Content Card type. */
CLASSIC: 'Classic';
/** The Image Only Content Card type. */
IMAGE_ONLY: 'ImageOnly';
/** The Captioned Image Content Card type. */
CAPTIONED: 'Captioned';

@@ -876,8 +1099,22 @@ }

/**
* The NewsFeed Card categories supported by the SDK.
*/
interface BrazeCardCategory {
/** The advertising category. */
ADVERTISING: 'advertising';
/** The announcements category. */
ANNOUNCEMENTS: 'announcements';
/** The news category. */
NEWS: 'news';
/** The social category. */
SOCIAL: 'social';
/** No specific category. */
NO_CATEGORY: 'no_category';
/** All categories. */
ALL: 'all';

@@ -887,8 +1124,22 @@ }

/**
* The gender values supported by the Braze SDK.
*/
interface GenderTypes {
/** Male */
MALE: 'm';
/** Female */
FEMALE: 'f';
/** Not Applicable */
NOT_APPLICABLE: 'n';
/** Other */
OTHER: 'o';
/** Prefer Not To Say */
PREFER_NOT_TO_SAY: 'p';
/** Unknown */
UNKNOWN: 'u';

@@ -898,20 +1149,62 @@ }

/**
* The category of Braze SDK properties to be marked for user tracking.
*/
interface BrazeTrackingProperty {
/** Mark all custom attributes for tracking. */
ALL_CUSTOM_ATTRIBUTES: 'all_custom_attributes';
/** Mark all custom events for tracking. */
ALL_CUSTOM_EVENTS: 'all_custom_events';
/** Braze events for analytics. */
ANALYTICS_EVENTS: 'analytics_events';
/** The user's attribution data. */
ATTRIBUTION_DATA: 'attribution_data';
/** The user's country. */
COUNTRY: 'country';
/** The user's date of birth. */
DATE_OF_BIRTH: 'dob';
/** The user's device data. */
DEVICE_DATA: 'device_data';
/** The user's email address. */
EMAIL: 'email';
/** The user's email subscription state. */
EMAIL_SUBSCRIPTION_STATE: 'email_subscription_state';
/**
* Mark every user data for tracking.
*
* Adding this property will cause other cases to be a no-op as everything will be routed to the tracking domain.
*/
EVERYTHING: 'everything';
/** The user's first name. */
FIRST_NAME: 'first_name';
/** The user's gender. */
GENDER: 'gender';
/** The user's home city. */
HOME_CITY: 'home_city';
/** The user's language. */
LANGUAGE: 'language';
/** The user's last name. */
LAST_NAME: 'last_name';
/** The user's notification subscription state. */
NOTIFICATION_SUBSCRIPTION_STATE: 'notification_subscription_state';
/** The user's phone number. */
PHONE_NUMBER: 'phone_number';
/** The user's push token. */
PUSH_TOKEN: 'push_token';

@@ -921,2 +1214,7 @@ }

/**
* The list of properties to be collected for tracking users (default: an empty list).
*
* The SDK will route collection of any of these data into a separate tracking endpoint, which must be declared in the privacy manifest.
*/
export interface TrackingPropertyAllowList {

@@ -942,5 +1240,13 @@ /* Tracking properties you wish to add to your allowlist */

/**
* The possible notification subscription states supported by the Braze SDK.
*/
interface NotificationSubscriptionType {
/** Subscribed, and explicitly opted in. */
OPTED_IN: 'optedin';
/** Subscribed, but not explicitly opted in. */
SUBSCRIBED: 'subscribed';
/** Unsubscribed and/or explicitly opted out. */
UNSUBSCRIBED: 'unsubscribed';

@@ -950,6 +1256,16 @@ }

/**
* An SDK authentication error event.
*/
export interface SDKAuthenticationErrorType {
/** Error code describing the cause of the signature authentication failure. */
error_code: string;
/** The External User ID on the failed request. */
user_id: string;
/** The original SDK authentication signature. */
original_signature: string;
/** Human-readable cause of the signature authentication failure. */
reason: string;

@@ -1037,6 +1353,13 @@ }

/**
* Received an updated list of Content Cards from the Braze SDK.
*/
export interface ContentCardsUpdatedEvent {
/** A list of Content Cards in this update. */
cards: ContentCard[];
}
/**
* An event received from the Braze SDK.
*/
interface BrazeEvent {

@@ -1043,0 +1366,0 @@ /** Callback passes an object with the `cards` as of the latest refresh. */

@@ -79,2 +79,6 @@ import { Button } from './button';

}
const isTestSendJson = inAppMessageJson['is_test_send'];
this.isTestSend =
typeof isTestSendJson === 'boolean' ? isTestSendJson : false;
}

@@ -81,0 +85,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc