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 8.3.0 to 8.4.0

22

__tests__/index.test.js

@@ -50,5 +50,12 @@ const NativeEventEmitter = require('react-native').NativeEventEmitter;

Braze.setGoogleAdvertisingId(googleAdvertisingId, adTrackingEnabled);
expect(NativeBrazeReactModule.setGoogleAdvertisingId).toBeCalledWith(googleAdvertisingId, adTrackingEnabled);
expect(NativeBrazeReactModule.setAdTrackingEnabled).toBeCalledWith(adTrackingEnabled, googleAdvertisingId);
});
test('it calls BrazeReactBridge.setAdTrackingEnabled', () => {
const googleAdvertisingId = "some_ga_id";
const adTrackingEnabled = true;
Braze.setAdTrackingEnabled(adTrackingEnabled, googleAdvertisingId);
expect(NativeBrazeReactModule.setAdTrackingEnabled).toBeCalledWith(adTrackingEnabled, googleAdvertisingId);
});
test('it calls BrazeReactBridge.setFirstName', () => {

@@ -674,1 +681,14 @@ const first_name = "some_name";

});
test('it calls BrazeReactBridge.updateTrackingPropertyAllowList', () => {
const allowList = {
adding: [Braze.TrackingProperty.ALL_CUSTOM_ATTRIBUTES],
removing: [Braze.TrackingProperty.ANALYTICS_EVENTS, Braze.TrackingProperty.EMAIL],
addingCustomEvents: ['123', '234'],
removingCustomEvents: ['233'],
addingCustomAttributes: ['attr-1'],
removingCustomAttributes: ['attr-2', 'attr3']
};
Braze.updateTrackingPropertyAllowList(allowList);
expect(NativeBrazeReactModule.updateTrackingPropertyAllowList).toBeCalledWith(allowList);
});

3

__tests__/jest.setup.js

@@ -22,3 +22,2 @@ jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');

registerPushToken: jest.fn(),
setGoogleAdvertisingId: jest.fn(),
setFirstName: jest.fn(),

@@ -95,2 +94,4 @@ setLastName: jest.fn(),

getFeatureFlagStringProperty: jest.fn(),
setAdTrackingEnabled: jest.fn(),
updateTrackingPropertyAllowList: jest.fn()
};

@@ -97,0 +98,0 @@

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

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

@@ -13,2 +13,3 @@ import {

Genders,
TrackingProperty,
ContentCardTypes,

@@ -30,2 +31,3 @@ Events,

static Genders = Genders;
static TrackingProperty = TrackingProperty;
static ContentCardTypes = ContentCardTypes;

@@ -204,5 +206,5 @@ static Events = Events;

static setGoogleAdvertisingId(googleAdvertisingId, adTrackingEnabled) {
this.bridge.setGoogleAdvertisingId(
googleAdvertisingId,
adTrackingEnabled
this.bridge.setAdTrackingEnabled(
adTrackingEnabled,
googleAdvertisingId
);

@@ -937,3 +939,55 @@ }

/**
* This method informs Braze whether ad-tracking has been enabled for this device. Note that the SDK does not
* automatically collect this data.
*
* @param {string} adTrackingEnabled - Whether ad-tracking is enabled.
* @param {string} googleAdvertisingId - The Google Advertising ID. (Android only)
*/
static setAdTrackingEnabled(adTrackingEnabled, googleAdvertisingId) {
return this.bridge.setAdTrackingEnabled(
adTrackingEnabled,
googleAdvertisingId
);
}
/**
* Updates the list of data types you wish to declare or remove as tracked user data.
*
* For more details, refer to Braze's [Privacy Manifest documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/swift/privacy_manifest/).
*
* No-op on Android.
*
* @param {TrackingPropertyAllowList} allowList - The list of tracking properties to update.
*/
static updateTrackingPropertyAllowList(allowList) {
if (allowList.adding && !this.isValidTrackingPropertyArray(allowList.adding)) {
console.log("'adding' property must be an array of strings. Setting array to empty.");
allowList.adding = [];
}
if (allowList.removing && !this.isValidTrackingPropertyArray(allowList.removing)) {
console.log("'removing' property must be an array of strings. Setting array to empty.");
allowList.removing = [];
}
if (allowList.addingCustomEvents && !this.isValidTrackingPropertyArray(allowList.addingCustomEvents)) {
console.log("'addingCustomEvents' property must be an array of strings. Setting array to empty.");
allowList.addingCustomEvents = [];
}
if (allowList.removingCustomEvents && !this.isValidTrackingPropertyArray(allowList.removingCustomEvents)) {
console.log("'removingCustomEvents' property must be an array of strings. Setting array to empty.");
allowList.removingCustomEvents = [];
}
if (allowList.addingCustomAttributes && !this.isValidTrackingPropertyArray(allowList.addingCustomAttributes)) {
console.log("'addingCustomAttributes' property must be an array of strings. Setting array to empty.");
allowList.addingCustomAttributes = [];
}
if (allowList.removingCustomAttributes && !this.isValidTrackingPropertyArray(allowList.removingCustomAttributes)) {
console.log("'removingCustomAttributes' property must be an array of strings. Setting array to empty.");
allowList.removingCustomAttributes = [];
}
return this.bridge.updateTrackingPropertyAllowList(allowList);
}
// Events
/**

@@ -952,2 +1006,14 @@ * Subscribes to the specific SDK event.

}
// Helper Functions
/**
* Validates an array to be processed in the `TrackingPropertyAllowList`.
*
* @param {array} array
* @returns Whether the array is valid according to the tracking property allow list.
*/
static isValidTrackingPropertyArray(array) {
return Array.isArray(array) && array.every(item => typeof item === 'string');
}
}

@@ -177,2 +177,4 @@ // Definitions by: ahanriat <https://github.com/ahanriat>

/**
* @deprecated This method is deprecated in favor of `setAdTrackingEnabled`.
*
* This method sets the Google Advertising ID and associated ad-tracking enabled field for this device. Note that the

@@ -192,2 +194,22 @@ * SDK does not automatically collect this data.

/**
* This method informs Braze whether ad-tracking has been enabled for this device. Note that the SDK does not
* automatically collect this data.
*
* @param {string} adTrackingEnabled - Whether ad-tracking is enabled.
* @param {string} googleAdvertisingId - The Google Advertising ID. (Android only)
*/
export function setAdTrackingEnabled(adTrackingEnabled: boolean, googleAdvertisingId?: string): void;
/**
* Updates the list of data types you wish to declare or remove as tracked user data.
*
* For more details, refer to Braze's [Privacy Manifest documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/swift/privacy_manifest/).
*
* No-op on Android.
*
* @param {TrackingPropertyAllowList} allowList - The list of tracking properties to update.
*/
export function updateTrackingPropertyAllowList(allowList: TrackingPropertyAllowList): void;
/**
* Adds the user to a subscription group.

@@ -840,2 +862,9 @@ * @param {string} groupId - The string UUID corresponding to the subscription group, provided by the Braze dashboard.

interface BrazeContentCardType {
CLASSIC: 'Classic';
IMAGE_ONLY: 'ImageOnly';
CAPTIONED: 'Captioned';
}
export const ContentCardTypes: BrazeContentCardType;
interface BrazeCardCategory {

@@ -861,2 +890,44 @@ ADVERTISING: 'advertising';

interface BrazeTrackingProperty {
ALL_CUSTOM_ATTRIBUTES: 'all_custom_attributes';
ALL_CUSTOM_EVENTS: 'all_custom_events';
ANALYTICS_EVENTS: 'analytics_events';
ATTRIBUTION_DATA: 'attribution_data';
COUNTRY: 'country';
DATE_OF_BIRTH: 'dob';
DEVICE_DATA: 'device_data';
EMAIL: 'email';
EMAIL_SUBSCRIPTION_STATE: 'email_subscription_state';
EVERYTHING: 'everything';
FIRST_NAME: 'first_name';
GENDER: 'gender';
HOME_CITY: 'home_city';
LANGUAGE: 'language';
LAST_NAME: 'last_name';
NOTIFICATION_SUBSCRIPTION_STATE: 'notification_subscription_state';
PHONE_NUMBER: 'phone_number';
PUSH_TOKEN: 'push_token';
}
export const TrackingProperty: BrazeTrackingProperty;
export interface TrackingPropertyAllowList {
/* Tracking properties you wish to add to your allowlist */
adding?: BrazeTrackingProperty[keyof BrazeTrackingProperty][],
/* Tracking properties you wish to remove from your allowlist */
removing?: BrazeTrackingProperty[keyof BrazeTrackingProperty][],
/* Custom event strings you wish to add to your current allowlist. */
addingCustomEvents?: string[],
/* Custom event strings you wish to remove from your current allowlist. */
removingCustomEvents?: string[],
/* Custom attribute strings you wish to add to your current allowlist. */
addingCustomAttributes?: string[],
/* Custom attribute strings you wish to remove from your current allowlist. */
removingCustomAttributes?: string[],
}
interface NotificationSubscriptionType {

@@ -863,0 +934,0 @@ OPTED_IN: 'optedin';

@@ -26,2 +26,25 @@ // Enums

export const TrackingProperty = {
ALL_CUSTOM_ATTRIBUTES: 'all_custom_attributes',
ALL_CUSTOM_EVENTS: 'all_custom_events',
ANALYTICS_EVENTS: 'analytics_events',
ATTRIBUTION_DATA: 'attribution_data',
COUNTRY: 'country',
CUSTOM_ATTRIBUTE: 'custom_attribute',
CUSTOM_EVENT: 'custom_event',
DATE_OF_BIRTH: 'dob',
DEVICE_DATA: 'device_data',
EMAIL: 'email',
EMAIL_SUBSCRIPTION_STATE: 'email_subscription_state',
EVERYTHING: 'everything',
FIRST_NAME: 'first_name',
GENDER: 'gender',
HOME_CITY: 'home_city',
LANGUAGE: 'language',
LAST_NAME: 'last_name',
NOTIFICATION_SUBSCRIPTION_STATE: 'notification_subscription_state',
PHONE_NUMBER: 'phone_number',
PUSH_TOKEN: 'push_token',
};
export const ContentCardTypes = {

@@ -28,0 +51,0 @@ CLASSIC: 'Classic',

@@ -29,6 +29,2 @@ import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';

registerPushToken(token: string): void;
setGoogleAdvertisingId(
googleAdvertisingId: string,
adTrackingEnabled: boolean
): void;
addToSubscriptionGroup(

@@ -201,2 +197,4 @@ groupId: string,

logFeatureFlagImpression(flagId: string): void;
setAdTrackingEnabled(adTrackingEnabled: boolean, googleAdvertisingId: string): void;
updateTrackingPropertyAllowList(allowList: Object): void;

@@ -203,0 +201,0 @@ // NativeEventEmitter methods for the New Architecture.

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

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