1、使用新的渠道打包方案,将渠道值写入到已经签名的apk上面,具体参考README.md

2、将各种第三方工具使用的appid、key和渠道值改成用gradle.properties的配置方式
This commit is contained in:
CsHeng
2017-05-12 15:46:46 +08:00
parent b280e1bf89
commit 5eb5f6807e
25 changed files with 462 additions and 297 deletions

View File

@ -1,8 +1,8 @@
package com.gh.common.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import com.gh.common.constant.Config;
import com.tencent.stat.*;
import com.tendcloud.tenddata.TCAgent;
@ -14,28 +14,40 @@ import java.util.*;
*/
public class DataUtils {
public static void init(Application application) {
/**
* 初始化各种统计工具仅在release build非debug模式启用统计
*
* @param context
* @param debug 是否debug模式
* @param channel
*/
public static void init(Context context, final boolean debug, String channel) {
//TalkingData
//dubug true release false
TCAgent.LOG_ON = true;
TCAgent.init(application);
TCAgent.setReportUncaughtExceptions(true);
if (!debug) {
TCAgent.setReportUncaughtExceptions(true);
TCAgent.init(context, Config.TD_APPID, channel);
} else {
TCAgent.LOG_ON = true;
}
//MTA
// 打开debug开关可查看mta上报日志或错误
// dubug true release false
StatConfig.setDebugEnable(true);
// 收集未处理的异常
StatConfig.setAutoExceptionCaught(true);
// 设置数据上报策略
StatConfig.setStatSendStrategy(StatReportStrategy.PERIOD);
StatConfig.setSendPeriodMinutes(5);
// 开启收集服务
String TA_APPKEY = (String) PackageUtils.getMetaData(application, application.getPackageName(), "TA_APPKEY");
try {
StatService.startStatService(application, TA_APPKEY, com.tencent.stat.common.StatConstants.VERSION);
} catch (MtaSDkException e) {
e.printStackTrace();
if (!debug) {
// 收集未处理的异常
StatConfig.setAutoExceptionCaught(true);
// 设置数据上报策略
StatConfig.setStatSendStrategy(StatReportStrategy.PERIOD);
StatConfig.setSendPeriodMinutes(5);
try {
// 开启收集服务
StatService.startStatService(context, Config.MTA_APPKEY, com.tencent.stat.common.StatConstants.VERSION);
} catch (MtaSDkException e) {
e.printStackTrace();
}
} else {
// 打开debug开关可查看mta上报日志或错误
// dubug true release false
StatConfig.setDebugEnable(true);
}
}