airbridge-react-native-sdk
Version:
Airbridge SDK for React Native
281 lines (280 loc) • 12.1 kB
TypeScript
import { AirbridgeTrackingLink } from './type/AirbridgeTrackingLink';
import { AirbridgeTrackingBlocklist } from './module';
export declare const createDependency: {
(): void;
Airbridge(): {
attributionModule: {
setOnAttributionReceived: (onReceived: (attribution: Record<string, string>) => void) => void;
};
deeplinkModule: {
setOnDeeplinkReceived: (onReceived: (deeplink: string) => void) => void;
};
eventModule: {
trackEvent: (category: string, semanticAttributes?: Record<string, any>, customAttributes?: Record<string, any>) => void;
};
fetchModule: {
fetchDeviceUUID: (onSuccess: (deviceUUID: string) => void, onFailure?: (error: Error) => void) => Promise<boolean>;
fetchAirbridgeGeneratedUUID: (onSuccess: (airbridgeGeneratedUUID: string) => void, onFailure?: (error: Error) => void) => Promise<boolean>;
isUninstallTrackingNotification: (notification: Record<string, any>) => boolean;
};
placementModule: {
click: (trackingLink: string, onSuccess?: () => void, onFailure?: (error: Error) => void) => Promise<boolean>;
impression: (trackingLink: string, onSuccess?: () => void, onFailure?: (error: Error) => void) => Promise<boolean>;
createTrackingLink: (channel: string, option: Record<string, any>, onSuccess: (airbridgeTrackingLink: AirbridgeTrackingLink) => void, onFailure?: (error: Error) => void) => void;
};
registerModule: {
setUserID: (id: string) => void;
clearUserID: () => void;
setUserEmail: (email: string) => void;
clearUserEmail: () => void;
setUserPhone: (phone: string) => void;
clearUserPhone: () => void;
setUserAttribute: (key: string, value: any) => void;
removeUserAttribute: (key: string) => void;
clearUserAttributes: () => void;
setUserAlias: (key: string, value: string) => void;
removeUserAlias: (key: string) => void;
clearUserAlias: () => void;
clearUser: () => void;
setDeviceAlias: (key: string, value: string) => void;
removeDeviceAlias: (key: string) => void;
clearDeviceAlias: () => void;
registerPushToken: (token: string) => void;
};
switchModule: {
enableSDK: () => void;
disableSDK: () => void;
isSDKEnabled: () => Promise<boolean>;
startTracking: () => void;
stopTracking: () => void;
isTrackingEnabled: () => Promise<boolean>;
startInAppPurchaseTracking: () => void;
stopInAppPurchaseTracking: () => void;
isInAppPurchaseTrackingEnabled: () => Promise<boolean>;
allowTrackingItem: (item: AirbridgeTrackingBlocklist) => void;
blockTrackingItem: (item: AirbridgeTrackingBlocklist) => void;
};
webInterfaceModule: {
createWebInterfaceScript: (webToken: string, postMessageScript: string) => Promise<string | undefined>;
handleWebInterfaceCommand: (command: string) => undefined;
};
} | undefined;
};
export declare class Airbridge {
/**
* Sets a listener for receiving attribution of install event.
* @param onReceived Map of attribution is delivered.
*/
static setOnAttributionReceived(onReceived: (attribution: Record<string, string>) => void): void;
/**
* Handles deeplink and deferred-deeplink.
* @param onReceived URL of deeplink is delivered.
*/
static setOnDeeplinkReceived(onReceived: (deeplink: string) => void): void;
/**
* 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: string, semanticAttributes?: Record<string, any>, customAttributes?: Record<string, any>): void;
/**
* 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: (deviceUUID: string) => void, onFailure?: (error: Error) => void): Promise<boolean>;
/**
* 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: (airbridgeGeneratedUUID: string) => void, onFailure?: (error: Error) => void): Promise<boolean>;
/**
* Indicates whether notification was sent by Airbridge to track uninstall of app.
* @param notification The notification to check.
*/
static isUninstallTrackingNotification(notification: Record<string, any>): boolean;
/**
* 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: string, onSuccess?: () => void, onFailure?: (error: Error) => void): Promise<boolean>;
/**
* 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: string, onSuccess?: () => void, onFailure?: ((error: Error) => void)): Promise<boolean>;
/**
* Sets the user ID.
* @param id The user ID.
*/
static setUserID(id: string): void;
/**
* Clear the user ID.
*/
static clearUserID(): void;
/**
* Sets the user email.
* @param email The user email.
*/
static setUserEmail(email: string): void;
/**
* Clear the user email.
*/
static clearUserEmail(): void;
/**
* Sets the user phone number.
* @param phone The user phone number.
*/
static setUserPhone(phone: string): void;
/**
* Clear the user phone number.
*/
static clearUserPhone(): void;
/**
* 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: string, value: any): void;
/**
* Removes the user attribute with the given key.
* @param key The key that uniquely identifies the user attribute.
*/
static removeUserAttribute(key: string): void;
/**
* Clears all user attributes.
*/
static clearUserAttributes(): void;
/**
* 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: string, value: string): void;
/**
* Removes the user alias with the given key.
* @param key The key that uniquely identifies the user alias.
*/
static removeUserAlias(key: string): void;
/**
* Clears all user aliases.
*/
static clearUserAlias(): void;
/**
* Clears all user information.
*/
static clearUser(): void;
/**
* 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: string, value: string): void;
/**
* Removes the device alias with the given key.
* @param key The key that uniquely identifies the device alias.
*/
static removeDeviceAlias(key: string): void;
/**
* Clears all device aliases.
*/
static clearDeviceAlias(): void;
/**
* Registers the FCM or APNS registration token to track app uninstalls.
* @param token The FCM or APNS registration token.
*/
static registerPushToken(token: string): void;
/**
* Enables the SDK.
*/
static enableSDK(): void;
/**
* Disables the SDK.
*/
static disableSDK(): void;
/**
* Checks whether the SDK is currently enabled.
* @return `true` if the SDK is enabled, `false` otherwise.
*/
static isSDKEnabled(): Promise<boolean>;
/**
* Start collecting and transferring events.
*/
static startTracking(): void;
/**
* Stop collecting and transferring events.
*/
static stopTracking(): void;
/**
* 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(): Promise<boolean>;
/**
* 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: string, postMessageScript: string): Promise<string | undefined>;
/**
* Handles commands from the web interface.
* @param command The command to handle.
*/
static handleWebInterfaceCommand(command: string): void;
/**
* 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: string, option: Record<string, any>, onSuccess: (airbridgeTrackingLink: AirbridgeTrackingLink) => void, onFailure?: (error: Error) => void): void;
/**
* Starts tracking event automatically for each user
* purchases product through in-app-purchase.
*/
static startInAppPurchaseTracking(): void;
/**
* Stops tracking event automatically for each user
* purchases product through in-app-purchase.
*/
static stopInAppPurchaseTracking(): void;
/**
* 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(): Promise<boolean>;
/**
* Allows tracking for the specified [AirbridgeTrackingBlocklist] item.
* This function removes the given item from the current TrackingBlocklist
* applied in the `airbridge.json`, enabling tracking at runtime.
*
* @param item The tracking blocklist item to allow.
*/
static allowTrackingItem(item: AirbridgeTrackingBlocklist): void;
/**
* Blocks tracking for the specified [AirbridgeTrackingBlocklist] item.
* This function adds the given item to the current TrackingBlocklist
* applied in the `airbridge.json`, disabling tracking at runtime.
*
* @param item The tracking blocklist item to block.
*/
static blockTrackingItem(item: AirbridgeTrackingBlocklist): void;
}