From 79e70718cd84c5256c95e0693544f691c6111df7 Mon Sep 17 00:00:00 2001 From: donghongyu-pc Date: Mon, 4 Nov 2024 19:17:25 +0800 Subject: [PATCH] =?UTF-8?q?[6.7.3]=201=E3=80=81=E5=A2=9E=E5=8A=A0=20?= =?UTF-8?q?=E8=87=AA=E5=BB=BAAPM=E7=BB=9F=E8=AE=A1=20Countly=20http://coun?= =?UTF-8?q?tly.zhidaozhixing.com/=20=E7=94=A8=E6=88=B7=E5=90=8D=E6=98=AF?= =?UTF-8?q?=E6=8B=BC=E9=9F=B3=E5=85=A8=E6=8B=BC=EF=BC=8C=E5=AF=86=E7=A0=81?= =?UTF-8?q?MoGo@123?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 30 ++++++++ .../com/mogo/launcher/MogoApplication.java | 70 +++++++++++++++++++ build.gradle | 1 + 3 files changed, 101 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 6822f1dff2..dfc40af614 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" +} \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 34ec3e8a7e..33eefbdc85 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -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 diff --git a/build.gradle b/build.gradle index 4f65df0298..a181b4f700 100644 --- a/build.gradle +++ b/build.gradle @@ -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即可,刷新完成注释该代码