1、移除MTA可视化埋点

2、增加TalkingData可视化埋点
This commit is contained in:
CsHeng
2017-12-27 19:20:31 +08:00
parent 719dbeef76
commit 1006bf25c1
18 changed files with 63 additions and 57 deletions

View File

@ -7,7 +7,6 @@ import android.content.Context;
import com.gh.common.constant.Config;
import com.gh.common.util.PackageUtils;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.mta.track.StatisticsDataAPI;
import com.tencent.stat.MtaSDkException;
import com.tencent.stat.StatConfig;
import com.tencent.stat.StatCrashReporter;
@ -25,7 +24,7 @@ import java.util.Properties;
*/
public class DataUtils {
public static final boolean DEBUG = false;
public static final boolean DEBUG = true;
/**
* 初始化各种统计工具仅在release build非debug模式启用统计
@ -76,18 +75,15 @@ public class DataUtils {
// 设置启用Tlink
StatConfig.setTLinkStatus(true);
// 设置启用可视化埋点
StatisticsDataAPI.instance(context);
StatConfig.init(context);
StatConfig.setInstallChannel(channel);
StatConfig.setAntoActivityLifecycleStat(true);
StatConfig.setAppVersion(PackageUtils.getPatchVersionName());
StatService.setContext(context);
StatService.registerActivityLifecycleCallbacks(context);
// 开启收集服务
StatService.startStatService(context, Config.MTA_APPKEY, com.tencent.stat.common.StatConstants.VERSION);
StatService.registerActivityLifecycleCallbacks(context);
} catch (MtaSDkException e) {
e.printStackTrace();
}
@ -189,4 +185,24 @@ public class DataUtils {
onEvent(context, "游戏更新", gameName, kv);
}
public static void onError(Context context, Throwable throwable) {
// MTA主动上传错误
try {
StatService.reportException(context, throwable);
} catch (Exception e) {
}
// //bugly 作为默认处理异常的类库,已经上报了,此处不重复上报
// try {
// CrashReport.postCatchedException(throwable);
// } catch (Exception e) {
// }
//talkingdata
try {
TCAgent.onError(context, throwable);
} catch (Exception e) {
}
}
}

View File

@ -3,11 +3,9 @@ package com.gh.gamecenter;
import android.app.Application;
import com.facebook.stetho.Stetho;
import com.facebook.stetho.okhttp3.StethoInterceptor;
import com.squareup.leakcanary.LeakCanary;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
/**
* @author CsHeng
@ -54,10 +52,10 @@ public class Injection {
// loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.addNetworkInterceptor(interceptor);
builder.addNetworkInterceptor(new StethoInterceptor());
// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
// interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
// builder.addNetworkInterceptor(interceptor);
// builder.addNetworkInterceptor(new StethoInterceptor());
// if (BuildConfig.DEBUG) {
// builder.addNetworkInterceptor(loggingInterceptor);
// }