hch
4 天以前 e8d63e91d80cc59d7947ad026149c2b752ce9364
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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);
    }
 
}