1、takingdata升级,精简无用的组件,480kb->220kb

2、数据统计部分整理,切勿更改数据统计和错误上报任何顺序
3、依赖整理
This commit is contained in:
CsHeng
2017-09-08 11:58:56 +08:00
parent 4de5593802
commit f552a06bd7
27 changed files with 263 additions and 654 deletions

View File

@ -5,6 +5,7 @@ import android.app.Application;
import android.content.Context;
import com.gh.common.constant.Config;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.stat.MtaSDkException;
import com.tencent.stat.StatConfig;
import com.tencent.stat.StatCrashReporter;
@ -29,52 +30,67 @@ public class DataUtils {
* @param debug 是否debug模式
* @param channel
*/
public static void init(Application context, final boolean debug, String channel) {
public static void init(final Application context, final boolean debug, String channel) {
//TalkingData
TCAgent.LOG_ON = debug;
if (!debug) {
TCAgent.init(context, Config.TD_APPID, channel);
//TODO 去除为了测试MTA的问题这个版本不启用
TCAgent.setReportUncaughtExceptions(true);
try {
TCAgent.LOG_ON = debug;
TCAgent.init(context, Config.TALKINGDATA_APPID, channel);
/**
*
* 不要启用!!!!不要启用,全部由{@link com.gh.base.AppUncaughtHandler}处理
*/
TCAgent.setReportUncaughtExceptions(false);
} catch (Exception e) {
e.printStackTrace();
}
// 打开debug开关可查看mta上报日志或错误
// debug true release false
StatConfig.setDebugEnable(debug);
//MTA
if (!debug) {
try {
/**
*
* 不要启用!!!!全部由{@link com.gh.base.AppUncaughtHandler}处理
*/
StatConfig.setAutoExceptionCaught(false);
//TODO 加入账号之后设置用户
// StatConfig.setCustomUserId(context, "userid");
StatCrashReporter crashReporter = StatCrashReporter.getStatCrashReporter(context);
crashReporter.setJavaCrashHandlerStatus(false);
// crashReporter.setEnableInstantReporting(true);
// 收集未处理的异常
StatConfig.setAutoExceptionCaught(true);
StatConfig.setAntoActivityLifecycleStat(true);
StatConfig.setDebugEnable(debug);
// 设置数据上报策略
StatConfig.setStatSendStrategy(StatReportStrategy.PERIOD);
StatConfig.setSendPeriodMinutes(5);
if (debug) {
StatConfig.setStatSendStrategy(StatReportStrategy.INSTANT);
} else {
StatConfig.setStatSendStrategy(StatReportStrategy.PERIOD);
StatConfig.setSendPeriodMinutes(5);
}
StatConfig.init(context);
StatConfig.setInstallChannel(channel);
StatConfig.setAntoActivityLifecycleStat(true);
StatService.setContext(context);
StatService.registerActivityLifecycleCallbacks(context);
// 开启收集服务
StatService.startStatService(context, Config.MTA_APPKEY, com.tencent.stat.common.StatConstants.VERSION);
} catch (MtaSDkException e) {
e.printStackTrace();
}
StatCrashReporter crashReporter = StatCrashReporter.getStatCrashReporter(context);
// 开启异常时的实时上报
crashReporter.setEnableInstantReporting(true);
// 开启java异常捕获
crashReporter.setJavaCrashHandlerStatus(true);
// init bugly
try {
CrashReport.setIsDevelopmentDevice(context, debug);
try {
// 开启收集服务
StatService.startStatService(context, Config.MTA_APPKEY, com.tencent.stat.common.StatConstants.VERSION);
} catch (MtaSDkException e) {
e.printStackTrace();
}
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
strategy.setEnableANRCrashMonitor(false);
strategy.setEnableNativeCrashMonitor(false);
strategy.setAppChannel(channel);
CrashReport.initCrashReport(context, Config.BUGLY_APPID, debug, strategy);
} catch (Exception e) {
e.printStackTrace();
}
}
@ -85,12 +101,12 @@ public class DataUtils {
}
public static void onPause(Activity var0) {
TCAgent.onPause(var0);
TCAgent.onPageEnd(var0, var0.getClass().getSimpleName());
StatService.onPause(var0);
}
public static void onResume(Activity var0) {
TCAgent.onResume(var0);
TCAgent.onPageStart(var0, var0.getClass().getSimpleName());
StatService.onResume(var0);
}