mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-07 09:49:07 +00:00
feat(react-native-appsflyer): complete definition (#42158)
* feat(react-native-appsflyer): complete definition * enhance: add new function and more types * enhance: add test
This commit is contained in:
+96
@@ -0,0 +1,96 @@
|
||||
// Type definitions for react-native-appsflyer 5.1
|
||||
// Project: https://github.com/AppsFlyerSDK/react-native-appsflyer#readme
|
||||
// Definitions by: Fabian Lee <https://github.com/fabianlee1211>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export interface InitSdkOptions {
|
||||
devKey: string;
|
||||
isDebug: boolean;
|
||||
appId: string;
|
||||
}
|
||||
|
||||
export interface ConversionData {
|
||||
status: 'success' | 'failure';
|
||||
type: string;
|
||||
data: {
|
||||
is_first_launch: boolean;
|
||||
af_status: 'Organic' | 'Non-organic';
|
||||
af_referrer_uid?: string;
|
||||
af_referrer_customer_id?: string;
|
||||
media_source: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
export enum EmailCryptType {
|
||||
EmailCryptTypeNone = 0,
|
||||
EmailCryptTypeSHA1 = 1,
|
||||
EmailCryptTypeMD5 = 2,
|
||||
EmailCryptTypeSHA256 = 3,
|
||||
}
|
||||
|
||||
export interface EmailOptions {
|
||||
emailsCryptType: EmailCryptType;
|
||||
emails: string[];
|
||||
}
|
||||
|
||||
export interface InviteLinkOptions {
|
||||
channel?: string;
|
||||
customerID?: string;
|
||||
campaign?: string;
|
||||
referrerName?: string;
|
||||
referrerImageUrl?: string;
|
||||
deeplinkPath?: string;
|
||||
baseDeeplink?: string;
|
||||
userParams?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
type SuccessCallback = (success: any) => void;
|
||||
|
||||
type ErrorCallback = (error: any) => void;
|
||||
|
||||
interface AdditionalData {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface EventValues {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
declare namespace appsFlyer {
|
||||
function initSdk(options: InitSdkOptions, success?: SuccessCallback, error?: ErrorCallback): void | Promise<string>;
|
||||
function trackAppLaunch(): void;
|
||||
function onInstallConversionData(callback: (data: ConversionData) => void): () => void;
|
||||
function onAppOpenAttribution(callback: (response: any) => void): () => void;
|
||||
function sendDeepLinkData(url: string): void;
|
||||
function stopTracking(isStopTracking: boolean, callback?: SuccessCallback): void;
|
||||
function generateInviteLink(options: InviteLinkOptions, success?: SuccessCallback, error?: ErrorCallback): void;
|
||||
function updateServerUninstallToken(token: string, callback?: SuccessCallback): void;
|
||||
function trackLocation(
|
||||
longitude: number,
|
||||
latitude: number,
|
||||
callback?: (error: any, coordinates: number[]) => void,
|
||||
): void;
|
||||
function trackCrossPromotionImpression(appId: string, campaign: string): void;
|
||||
function trackAndOpenStore(appId: string, campaign: string, additionalData?: AdditionalData): void;
|
||||
function trackEvent(
|
||||
eventName: string,
|
||||
eventValues: EventValues,
|
||||
success?: SuccessCallback,
|
||||
error?: ErrorCallback,
|
||||
): void | Promise<string>;
|
||||
function getAppsFlyerUID(callback: (error: any, appsFlyerUID: string) => void): void;
|
||||
function setUserEmails(options: EmailOptions, success?: SuccessCallback, error?: ErrorCallback): void;
|
||||
function setAdditionalData(additionalData: AdditionalData, success?: SuccessCallback): void;
|
||||
function setCustomerUserId(userId: string, callback?: SuccessCallback): void;
|
||||
function setCollectIMEI(isCollect: boolean, callback?: SuccessCallback): void;
|
||||
function setCollectAndroidID(isCollect: boolean, callback?: SuccessCallback): void;
|
||||
function setAppInviteOneLinkID(oneLinkId: string, callback?: SuccessCallback): void;
|
||||
function setCurrencyCode(currencyCode: string, callback?: SuccessCallback): void;
|
||||
function setDeviceTrackingDisabled(isDeviceTrackingDisabled: boolean, success?: SuccessCallback): void;
|
||||
}
|
||||
|
||||
export default appsFlyer;
|
||||
@@ -0,0 +1,64 @@
|
||||
import appsFlyer, { EmailCryptType } from 'react-native-appsflyer';
|
||||
|
||||
// $ExpectType void | Promise<string>
|
||||
appsFlyer.initSdk({ devKey: '1A2b3C', appId: 'app_id', isDebug: true });
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.getAppsFlyerUID((error, appsFlyerId) => {});
|
||||
|
||||
// $ExpectType () => void
|
||||
appsFlyer.onAppOpenAttribution(res => {});
|
||||
|
||||
// $ExpectType () => void
|
||||
appsFlyer.onInstallConversionData(res => {});
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.sendDeepLinkData('https://reactjs.org');
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.setAdditionalData({});
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.setAppInviteOneLinkID('ABCD');
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.setCollectAndroidID(true);
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.setCollectIMEI(true);
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.setCurrencyCode('USD');
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.setCustomerUserId('my_user_id');
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.setUserEmails({ emails: [], emailsCryptType: EmailCryptType.EmailCryptTypeNone });
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.stopTracking(true);
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.trackAndOpenStore('app_id', 'testing');
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.trackAppLaunch();
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.trackCrossPromotionImpression('app_id', 'testing');
|
||||
|
||||
// $ExpectType void | Promise<string>
|
||||
appsFlyer.trackEvent('af_testing', {});
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.trackLocation(100.1, 120.3);
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.updateServerUninstallToken('token');
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.generateInviteLink({});
|
||||
|
||||
// $ExpectType void
|
||||
appsFlyer.setDeviceTrackingDisabled(true);
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-appsflyer-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user