1、增加 自建APM统计 Countly
http://countly.zhidaozhixing.com/
用户名是拼音全拼,密码MoGo@123
This commit is contained in:
donghongyu-pc
2024-11-04 19:17:25 +08:00
parent 2d549caec6
commit 79e70718cd
3 changed files with 101 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: ly.count.android.plugins.UploadSymbolsPlugin
apply from: rootProject.file('gradle/bytex/bytex.gradle')
@@ -226,6 +227,9 @@ dependencies {
implementation project(':OCH:facade')
implementation 'com.mogo.cloud:countly-sdk:1.4.7.49.18-debug'
implementation 'com.mogo.cloud:countly-sdk-native:1.4.7.49.18-debug'
androidTestImplementation rootProject.ext.dependencies.androidx_test_core
androidTestImplementation rootProject.ext.dependencies.androidx_test_core_ktx
androidTestImplementation rootProject.ext.dependencies.androidx_unit_ext
@@ -359,3 +363,29 @@ def variantName() {
}
countly {
// required by both tasks
server "http://countly.zhidaozhixing.com"
// same app_key used for SDK integration
app_key "45cccb4a005ca14b79fca7d24b69e1a67730e325"
// location of mapping.txt file relative to project build directory
mappingFile "outputs/mapping/release/mapping.txt"
// note that will be saved with the upload and can be checked in the UI
noteJava "sdk-plugin automatic upload of mapping.txt"
// optional properties for uploadNativeSymbols. Shown are the default values.
// directory of .so files relative to project build directory.
// you can check the tar.gz file created under intermediates/countly
// BUILD_TYPE could be debug or release
nativeObjectFilesDir "intermediates/merged_native_libs/BUILD_TYPE"
// path for breakpad tool dump_syms executable
dumpSymsPath "/usr/bin"
// note that will be saved with the upload and can be checked in the UI
noteNative "sdk-plugin automatic upload of breakpad symbols"
}

View File

@@ -1,5 +1,6 @@
package com.mogo.launcher;
import android.text.TextUtils;
import android.util.Log;
import com.mogo.commons.debug.DebugConfig;
@@ -11,10 +12,15 @@ import com.mogo.eagle.core.function.main.MainMoGoApplication;
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.commons.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.util.DeviceUtils;
import com.mogo.launcher.crash.CrashSystem;
import com.mogo.launcher.startup.ARouterStartUp;
import com.mogo.launcher.startup.ConfigStartUp;
import ly.count.android.sdk.Countly;
import ly.count.android.sdk.CountlyConfig;
import ly.count.android.sdknative.CountlyNative;
/**
* @author congtaowang
* @since 2019-12-18
@@ -26,6 +32,10 @@ public class MogoApplication extends MainMoGoApplication {
private static final String TAG = "MogoApplication";
// 正式统计用的key
private String COUNTLY_APP_KEY = "657d18706e9a5acf79ea6a4bcb54605406548f71";
private String COUNTLY_SERVER_URL = "http://countly.zhidaozhixing.com";
@Override
public void onCreate() {
// TraceNodeCore.Companion.getTraceNodeCore().setDebugMode(false); //debuggable验证时打开
@@ -52,6 +62,66 @@ public class MogoApplication extends MainMoGoApplication {
crashSystem.init();
//设置debug模式日志不上传
crashSystem.setDebug(BuildConfig.DEBUG);
if (BuildConfig.DEBUG){
// debug测试用的key
COUNTLY_APP_KEY = "d8cfb7be4679f650a6dc806d289a0d8c1996ed05";
}
// 初始化自建APM统计 Countly
CountlyConfig countlyConfig =
// 创建配置对象
new CountlyConfig(
this,
COUNTLY_APP_KEY,
COUNTLY_SERVER_URL
);
// 优先获取设备在 蘑菇平台注册的SN
String devicesID = SharedPrefsMgr.getInstance().getSn();
// 如果拿不到 蘑菇SN则使用设备自己的序列号
if (TextUtils.isEmpty(devicesID)) {
devicesID = DeviceUtils.getDeviceSN();
}
// 设置设备唯一标志
countlyConfig.setDeviceId(devicesID)
// 获取您在 Countly 服务器中设置的一些配置
.enableServerConfiguration()
// 自动视图跟踪
.enableAutomaticViewTracking()
.enableAutomaticViewShortNames()
.enableTemporaryDeviceIdMode()
// 参数篡改保护salt
.setParameterTamperingProtectionSalt("mogo_auto")
// 如果发送到服务器的数据足够短SDK 将使用 HTTP GET 请求。要覆盖该行为,
// 以便在所有情况下都使用 HTTP POST 请求,您需要在 init 配置中将“setHttpPostForced”标志设置为 true。
.setHttpPostForced(true)
// 启用日志记录:
.setLoggingEnabled(true);
// 限制每个线程记录的堆栈跟踪行默认值30 行)
countlyConfig.sdkInternalLimits.setMaxStackTraceLinesPerThread(10000);
// 限制每个堆栈跟踪行允许的字符默认200 个字符)
countlyConfig.sdkInternalLimits.setMaxStackTraceLineLength(10000);
// 限制所有用户设置的字符串分段或其等效值值的大小默认值256 个字符)
countlyConfig.sdkInternalLimits.setMaxValueSize(10000);
// 限制用户设置的分段键值对的数量默认100 个条目)
countlyConfig.sdkInternalLimits.setMaxSegmentationValues(1000);
// 限制可以记录的用户设置痕迹导航的数量默认值100 个条目,超过此值将删除最早的条目)
countlyConfig.sdkInternalLimits.setMaxBreadcrumbCount(1000);
// 自动崩溃处理
countlyConfig.crashes.enableCrashReporting();
// 记录所有线程
countlyConfig.crashes.enableRecordAllThreadsWithCrash();
// 初始化Countly SDK配置
Countly.sharedInstance().init(countlyConfig);
// java崩溃报告
Countly.sharedInstance().crashes();
// C++ 崩溃报告
CountlyNative.initNative(this);
}
@Override

View File

@@ -38,6 +38,7 @@ buildscript {
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.4.0.2513'
classpath 'com.mogo.eagle.core.handler.proxy:plugin:10.0.10'
classpath 'com.gradle:gradle-enterprise-gradle-plugin:3.15.1'
classpath group: 'com.mogo.cloud', 'name': 'upload-plugin', 'version': '1.4.7.49.18-debug'
// classpath 'com.bytedance.btrace:rhea-gradle-plugin:2.0.0'
}
// 遇无法更新依赖情况针对Snapshot无法刷新然后sync project即可刷新完成注释该代码