File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { AppsFlyer } from '../types/appsflyer.js' ;
2- import { addCommand } from '../utils/index.js' ;
2+ import { addCommandCallback } from '../utils/index.js' ;
33import { createListener } from '../utils/listener.js' ;
44
55/**
@@ -13,8 +13,8 @@ const appsflyer = {
1313 * @param eventName - The name of the event to be tracked.
1414 * @param eventValues - Key-value pairs containing event metadata.
1515 */
16- logEvent : function ( eventName : string , eventValues : any ) {
17- addCommand ( 'median://appsflyer/logEvent' , { eventName, eventValues } ) ;
16+ logEvent : function ( eventName : string , eventValues ?: Record < string , any > ) {
17+ return addCommandCallback < AppsFlyer . LogEventResponse > ( 'median://appsflyer/logEvent' , { eventName, eventValues } ) ;
1818 } ,
1919
2020 /**
@@ -24,7 +24,7 @@ const appsflyer = {
2424 * @param userId - Unique identifier for the current user.
2525 */
2626 setCustomerUserId : function ( userId : string ) {
27- addCommand ( 'median://appsflyer/setCustomerUserId' , { userId } ) ;
27+ return addCommandCallback < AppsFlyer . SetCustomerUserIdResponse > ( 'median://appsflyer/setCustomerUserId' , { userId } ) ;
2828 } ,
2929
3030 /**
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ export namespace AppsFlyer {
22 export type ConversionData = Record < string , any > & {
33 af_message ?: string ;
44 af_status ?: string ;
5- error ?: string ;
5+ error ?: { code ?: string ; description ?: string } ;
66 install_time ?: string ;
77 is_first_launch ?: boolean ;
88 } ;
@@ -18,13 +18,24 @@ export namespace AppsFlyer {
1818 clickEvent ?: string ;
1919 clickHTTPReferrer ?: string ;
2020 deeplinkValue ?: string ;
21+ error ?: { code ?: string ; description ?: string } ;
2122 isDeferred : boolean ;
2223 matchType ?: string ;
2324 mediaSource ?: string ;
2425 } ;
2526
2627 export type SdkStartResponse = {
27- error ?: string ;
28+ error ?: { code ?: string ; description ?: string } ;
29+ success : boolean ;
30+ } ;
31+
32+ export type LogEventResponse = {
33+ error ?: { code ?: string ; description ?: string } ;
34+ success : boolean ;
35+ } ;
36+
37+ export type SetCustomerUserIdResponse = {
38+ error ?: { code ?: string ; description ?: string } ;
2839 success : boolean ;
2940 } ;
3041}
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ export function addCommandCallback<T = AnyData>(
8282 params . callback = tempFunctionName ;
8383 return new Promise ( function ( resolve , reject ) {
8484 ( window [ tempFunctionName as AnyData ] as AnyData ) = function ( data : T ) {
85- if ( data && typeof data === 'object' && 'error' in data && typeof data . error === 'string' ) {
85+ if ( data && typeof data === 'object' && 'error' in data ) {
8686 reject ( data ) ;
8787 } else {
8888 resolve ( data ) ;
You can’t perform that action at this time.
0 commit comments