Пример #1
0
    /**
     * 上报监控接口,记得初始化monitor并对所有成员变量赋值!
     */
    public static void ReportAppMonitorStat(MtaAppMonitor monitor)
    {
        if (Application.platform != RuntimePlatform.OSXEditor)
        {
                        #if UNITY_IPHONE
            Dictionary <string, object> dict = new Dictionary <string, object> ();
            dict.Add("interfaceName", monitor.InterfaceName);
            dict.Add("requestPackageSize", monitor.RequestSize);
            dict.Add("responsePackageSize", monitor.ResponseSize);
            dict.Add("resultType", monitor.ResultType);
            dict.Add("millisecondsConsume", monitor.MillisecondsConsume);
            dict.Add("returnCode", monitor.ReturnCode);
            dict.Add("sampling", monitor.Sampling);

            _reportAppMonitorStat(JsonMapper.ToJson(dict));
                        #elif UNITY_ANDROID
            if (monitor == null || monitor.InterfaceName == null || monitor.InterfaceName.Equals(""))
            {
                return;
            }
            AndroidJavaObject obj = new AndroidJavaObject("com.tencent.stat.StatAppMonitor",
                                                          monitor.InterfaceName, monitor.ResultType, monitor.ReturnCode,
                                                          monitor.RequestSize, monitor.ResponseSize,
                                                          monitor.MillisecondsConsume, monitor.Sampling);
            MtaServiceImpl.CallStatic("reportAppMonitorStat", Context, obj);
                        #endif
        }
    }
Пример #2
0
 /**
  * 带时长统计的自定义K-V事件,event_id需要在前台注册
  * begin和end需匹配使用,event_id和prop要完全一致
  */
 public static void TrackCustomBeginKVEvent(string event_id, Dictionary <string, string> dict)
 {
     if (Application.platform != RuntimePlatform.OSXEditor)
     {
                     #if UNITY_IPHONE
         _trackCustomBeginKVEvent(event_id, JsonMapper.ToJson(dict));
                     #elif UNITY_ANDROID
         MtaServiceImpl.CallStatic("trackCustomBeginKVEvent", Context, event_id, DictToJavaProperties(dict));
                     #endif
     }
 }
Пример #3
0
 /**
  * 页面统计:结果
  */
 public static void TrackEndPage(string page_name)
 {
     if (Application.platform != RuntimePlatform.OSXEditor)
     {
                     #if UNITY_IPHONE
         _trackEndPage(page_name);
                     #elif UNITY_ANDROID
         MtaServiceImpl.CallStatic("trackEndPage", Context, page_name);
                     #endif
     }
 }
Пример #4
0
 /**
  * 结束当时Session,不建议APP主动调用!
  */
 public static void StopSession()
 {
     if (Application.platform != RuntimePlatform.OSXEditor)
     {
                     #if UNITY_IPHONE
         _stopSession();
                     #elif UNITY_ANDROID
         MtaServiceImpl.CallStatic("stopSession");
                     #endif
     }
 }
Пример #5
0
 /**
  * 上报本地事件,counts为上报的数量
  */
 public static void CommitEvents(int counts)
 {
     if (Application.platform != RuntimePlatform.OSXEditor)
     {
                     #if UNITY_IPHONE
         _commitEvents(counts);
                     #elif UNITY_ANDROID
         MtaServiceImpl.CallStatic("commitEvents", Context, counts);
                     #endif
     }
 }
Пример #6
0
 /**
  * 上报QQ号码,用于用户画像(机器人项目)等分析
  */
 public static void ReportQQ(string qq_account)
 {
     if (Application.platform != RuntimePlatform.OSXEditor)
     {
                     #if UNITY_IPHONE
         _reportQQ(qq_account);
                     #elif UNITY_ANDROID
         MtaServiceImpl.CallStatic("reportQQ", Context, qq_account);
                     #endif
     }
 }
Пример #7
0
    /******************** 统计接口开始  ********************************/

    /**
     * 启动MTA统计,设置APPKEY,APPKEY为MTA分配的key;如果是合作方SDK,则为按MTA规则生成的APPKEY
     */
    public static bool StartStatServiceWithAppKey(string appkey)
    {
        if (Application.platform != RuntimePlatform.OSXEditor)
        {
#if UNITY_IPHONE
            _startStatServiceWithAppKey(appkey);
            return(true);
#elif UNITY_ANDROID
            AndroidJavaClass consts_cls = new AndroidJavaClass("com.tencent.stat.common.StatConstants");
            string           ver        = consts_cls.GetStatic <string> ("VERSION");
            return(MtaServiceImpl.CallStatic <bool> ("startStatService", Context, appkey, ver));
#endif
        }
        return(false);
    }
Пример #8
0
 /**
  * 上报错误
  */
 public static void ReportError(string error_msg)
 {
     if (Application.platform != RuntimePlatform.OSXEditor)
     {
                     #if UNITY_IPHONE
         _reportError(error_msg);
                     #elif UNITY_ANDROID
         if (error_msg == null || error_msg.Length == 0)
         {
             return;
         }
         MtaServiceImpl.CallStatic("reportError", Context, error_msg);
                     #endif
     }
 }
Пример #9
0
    /**
     * 上报游戏用户
     */
    public static void ReportGameUser(MtaGameUser gameUser)
    {
        if (Application.platform != RuntimePlatform.OSXEditor)
        {
                        #if UNITY_IPHONE
            Dictionary <string, string> dict = new Dictionary <string, string> ();
            dict.Add("account", gameUser.Account);
            dict.Add("worldName", gameUser.WorldName);
            dict.Add("level", gameUser.Level);

            _reportGameUser(JsonMapper.ToJson(dict));
                        #elif UNITY_ANDROID
            if (gameUser == null)
            {
                return;
            }
            AndroidJavaObject obj = new AndroidJavaObject("com.tencent.stat.StatGameUser",
                                                          gameUser.Account, gameUser.WorldName, gameUser.Level);
            MtaServiceImpl.CallStatic("reportGameUser", Context, obj);
                        #endif
        }
    }
Пример #10
0
 /**
  * 测试MTA前台配置的固定域名的连接速度等情况,不建议主动调用
  */
 public static void TestSpeed()
 {
     MtaServiceImpl.CallStatic("testSpeed", Context);
 }
Пример #11
0
 /**
  * 测试domain_map列表里域名(ip)的连接速度、成功/失败等
  */
 public static void TestSpeed(Dictionary <string, int> domain_map)
 {
     MtaServiceImpl.CallStatic("testSpeed", Context, ToJavaHashMap(domain_map));
 }