airbridge-react-native-sdk
Version:
Airbridge SDK for React Native
312 lines • 13.3 kB
JavaScript
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _a, _Airbridge_dependency;
import { createAttributionModule } from './module/Attribution';
import { createDeeplinkModule } from './module/Deeplink';
import { createEventModule } from './module/Event';
import { createFetchModule } from './module/Fetch';
import { createPlacementModule } from './module/Placement';
import { createRegisterModule } from './module/Register';
import { createSwitchModule } from './module/Switch';
import { createWebInterfaceModule } from './module/WebInterface';
export const createDependency = () => { };
createDependency.Airbridge = () => ({
attributionModule: createAttributionModule(),
deeplinkModule: createDeeplinkModule(),
eventModule: createEventModule(),
fetchModule: createFetchModule(),
placementModule: createPlacementModule(),
registerModule: createRegisterModule(),
switchModule: createSwitchModule(),
webInterfaceModule: createWebInterfaceModule(),
});
export class Airbridge {
// attribution
/**
* Sets a listener for receiving attribution of install event.
* @param onReceived Map of attribution is delivered.
*/
static setOnAttributionReceived(onReceived) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).attributionModule.setOnAttributionReceived(onReceived);
}
// deeplink
/**
* Handles deeplink and deferred-deeplink.
* @param onReceived URL of deeplink is delivered.
*/
static setOnDeeplinkReceived(onReceived) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).deeplinkModule.setOnDeeplinkReceived(onReceived);
}
// event
/**
* Tracks user behavior through event tracking with attributes.
* @param category Name of event.
* @param semanticAttributes Additional attributes of the event that defined by Airbridge.
* @param customAttributes Additional attributes of the event.
*/
static trackEvent(category, semanticAttributes, customAttributes) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).eventModule.trackEvent(category, semanticAttributes, customAttributes);
}
// fetch
/**
* Fetch deviceUUID of SDK.
* @param onSuccess Callback to be invoked when deviceUUID is successfully handled.
* @param onFailure Callback to be invoked when any error occurs.
*/
static fetchDeviceUUID(onSuccess, onFailure) {
return __classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).fetchModule.fetchDeviceUUID(onSuccess, onFailure);
}
/**
* Fetch airbridgeGeneratedUUID of SDK.
* @param onSuccess Callback to be invoked when airbridgeGeneratedUUID is successfully handled.
* @param onFailure Callback to be invoked when any error occurs.
*/
static fetchAirbridgeGeneratedUUID(onSuccess, onFailure) {
return __classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).fetchModule.fetchAirbridgeGeneratedUUID(onSuccess, onFailure);
}
/**
* Indicates whether notification was sent by Airbridge to track uninstall of app.
* @param notification The notification to check.
*/
static isUninstallTrackingNotification(notification) {
return __classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).fetchModule.isUninstallTrackingNotification(notification);
}
// placement
/**
* Notifies that an in-app area within an app has been clicked on by the user.
* @param trackingLink tracking link uri
* @param onSuccess Callback to be invoked when tracking link is successfully handled.
* @param onFailure Callback to be invoked when any error occurs.
* @return `true` if all of the following conditions are met below, `false` otherwise.
* - If the SDK is initialized and enabled.
* - If tracking link is successfully handled.
*/
static click(trackingLink, onSuccess, onFailure) {
return __classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).placementModule.click(trackingLink, onSuccess, onFailure);
}
/**
* Notifies that the in-app area within the app has been exposed to the user.
* @param trackingLink tracking link uri
* @param onSuccess Callback to be invoked when tracking link is successfully handled.
* @param onFailure Callback to be invoked when any error occurs.
* @return `true` if all of the following conditions are met below, `false` otherwise.
* - If the SDK is initialized and enabled.
* - If tracking link is successfully handled.
*/
static impression(trackingLink, onSuccess, onFailure) {
return __classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).placementModule.impression(trackingLink, onSuccess, onFailure);
}
// register
/**
* Sets the user ID.
* @param id The user ID.
*/
static setUserID(id) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.setUserID(id);
}
/**
* Clear the user ID.
*/
static clearUserID() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.clearUserID();
}
/**
* Sets the user email.
* @param email The user email.
*/
static setUserEmail(email) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.setUserEmail(email);
}
/**
* Clear the user email.
*/
static clearUserEmail() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.clearUserEmail();
}
/**
* Sets the user phone number.
* @param phone The user phone number.
*/
static setUserPhone(phone) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.setUserPhone(phone);
}
/**
* Clear the user phone number.
*/
static clearUserPhone() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.clearUserPhone();
}
/**
* Sets the key, value pair to the user attribute.
* @param key The key that uniquely identifies the user attribute.
* @param value The value to set for the user attribute.
*/
static setUserAttribute(key, value) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.setUserAttribute(key, value);
}
/**
* Removes the user attribute with the given key.
* @param key The key that uniquely identifies the user attribute.
*/
static removeUserAttribute(key) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.removeUserAttribute(key);
}
/**
* Clears all user attributes.
*/
static clearUserAttributes() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.clearUserAttributes();
}
/**
* Sets the key, value pair to the user alias.
* @param key The key that uniquely identifies the user alias.
* @param value The value to set for the user alias.
*/
static setUserAlias(key, value) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.setUserAlias(key, value);
}
/**
* Removes the user alias with the given key.
* @param key The key that uniquely identifies the user alias.
*/
static removeUserAlias(key) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.removeUserAlias(key);
}
/**
* Clears all user aliases.
*/
static clearUserAlias() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.clearUserAlias();
}
/**
* Clears all user information.
*/
static clearUser() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.clearUser();
}
/**
* Sets the key, value pair to the device alias.
* @param key The key that uniquely identifies the device alias.
* @param value The value to set for the device alias.
*/
static setDeviceAlias(key, value) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.setDeviceAlias(key, value);
}
/**
* Removes the device alias with the given key.
* @param key The key that uniquely identifies the device alias.
*/
static removeDeviceAlias(key) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.removeDeviceAlias(key);
}
/**
* Clears all device aliases.
*/
static clearDeviceAlias() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.clearDeviceAlias();
}
/**
* Registers the FCM or APNS registration token to track app uninstalls.
* @param token The FCM or APNS registration token.
*/
static registerPushToken(token) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).registerModule.registerPushToken(token);
}
// switch
/**
* Enables the SDK.
*/
static enableSDK() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).switchModule.enableSDK();
}
/**
* Disables the SDK.
*/
static disableSDK() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).switchModule.disableSDK();
}
/**
* Checks whether the SDK is currently enabled.
* @return `true` if the SDK is enabled, `false` otherwise.
*/
static isSDKEnabled() {
return __classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).switchModule.isSDKEnabled();
}
/**
* Start collecting and transferring events.
*/
static startTracking() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).switchModule.startTracking();
}
/**
* Stop collecting and transferring events.
*/
static stopTracking() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).switchModule.stopTracking();
}
/**
* Checks whether the tracking feature of SDK is currently enabled.
* @return `true` if the tracking feature of SDK tracking is enabled,`false` otherwise.
*/
static isTrackingEnabled() {
return __classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).switchModule.isTrackingEnabled();
}
// web interface
/**
* Creates a script that initialize the web interface.
* @param webToken The token to initialize Airbridge Web SDK.
* @param postMessageScript The JavaScript code to post commands from web to app.
* @return web interface script
*/
static createWebInterfaceScript(webToken, postMessageScript) {
return __classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).webInterfaceModule.createWebInterfaceScript(webToken, postMessageScript);
}
/**
* Handles commands from the web interface.
* @param command The command to handle.
*/
static handleWebInterfaceCommand(command) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).webInterfaceModule.handleWebInterfaceCommand(command);
}
/**
* Creates a tracking-link using airbridge-server that move user
* to specific page of app and track click-event.
*
* @param channel The channel of tracking-link.
* @param option The option to create tracking-link.
* @param onSuccess Created tracking-link is delivered if succeed.
* @param onFailure Error is delivered if failed.
*/
static createTrackingLink(channel, option, onSuccess, onFailure) {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).placementModule.createTrackingLink(channel, option, onSuccess, onFailure);
}
/**
* Starts tracking event automatically for each user
* purchases product through in-app-purchase.
*/
static startInAppPurchaseTracking() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).switchModule.startInAppPurchaseTracking();
}
/**
* Stops tracking event automatically for each user
* purchases product through in-app-purchase.
*/
static stopInAppPurchaseTracking() {
__classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).switchModule.stopInAppPurchaseTracking();
}
/**
* Indicates that SDK can track event automatically for each user
* purchases product through in-app-purchase.
*
* @return `true` if the SDK is enabled for in-app-purchase tracking, `false` otherwise.
*/
static isInAppPurchaseTrackingEnabled() {
return __classPrivateFieldGet(this, _a, "f", _Airbridge_dependency).switchModule.isInAppPurchaseTrackingEnabled();
}
}
_a = Airbridge;
_Airbridge_dependency = { value: createDependency.Airbridge() };
//# sourceMappingURL=Airbridge.js.map