| package com.secondworld.sdk; | 
|   | 
| import com.appsflyer.AppsFlyerConversionListener; | 
| import com.appsflyer.AppsFlyerLib; | 
| import com.secondworld.sdk.utils.LogUtil; | 
|   | 
| import java.util.HashMap; | 
| import java.util.Map; | 
|   | 
| public class AppsFlyerUtil { | 
|   | 
|     private static final String AF_DEV_KEY = "muBUcmQaNv9hbArNpvSm6V"; | 
|   | 
|     public static void init() { | 
|         AppsFlyerConversionListener conversionListener = new AppsFlyerConversionListener() { | 
|             @Override | 
|             public void onConversionDataSuccess(Map<String, Object> conversionData) { | 
|   | 
|                 for (String attrName : conversionData.keySet()) { | 
|                     LogUtil.debug("AppsFlyerMgr", "attribute: " + attrName + " = " + conversionData.get(attrName)); | 
|                 } | 
|             } | 
|   | 
|             @Override | 
|             public void onConversionDataFail(String errorMessage) { | 
|                 LogUtil.debug("AppsFlyerMgr", "error getting conversion data: " + errorMessage); | 
|             } | 
|   | 
|             @Override | 
|             public void onAppOpenAttribution(Map<String, String> conversionData) { | 
|   | 
|                 for (String attrName : conversionData.keySet()) { | 
|                     LogUtil.debug("AppsFlyerMgr", "attribute: " + attrName + " = " + conversionData.get(attrName)); | 
|                 } | 
|   | 
|             } | 
|   | 
|             @Override | 
|             public void onAttributionFailure(String errorMessage) { | 
|                 LogUtil.debug("AppsFlyerMgr", "error onAttributionFailure : " + errorMessage); | 
|             } | 
|         }; | 
|   | 
|         AppsFlyerLib.getInstance().init(AF_DEV_KEY, conversionListener, GameAppProxy.app); | 
|         AppsFlyerLib.getInstance().startTracking(GameAppProxy.app); | 
|     } | 
|   | 
|     //统计事件 | 
|     public static void trackEvent(String eventName, Map<String, Object> eventValues) { | 
|         if (eventValues == null) | 
|             eventValues = new HashMap<>(); | 
|         AppsFlyerLib.getInstance().trackEvent(GameAppProxy.app, eventName, eventValues); | 
|     } | 
|   | 
| } |