diff --git a/dependencies.gradle b/dependencies.gradle index da6eb9f433..0731291992 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -115,7 +115,7 @@ ext { gid = "1.3.4" shortcut = "1.0.2" - sentry = "6.9.2" + sentry = "6.20.0" autoServiceVersion = "1.0-rc7" arouterVersion = "1.5.1" diff --git a/feature/sentry/build.gradle b/feature/sentry/build.gradle index 8bfbcaac5f..c3f8316743 100644 --- a/feature/sentry/build.gradle +++ b/feature/sentry/build.gradle @@ -37,6 +37,7 @@ dependencies { kapt "com.alibaba:arouter-compiler:$arouterVersion" implementation "io.sentry:sentry-android:${sentry}" + implementation "io.sentry:sentry-android-fragment:${sentry}" implementation project(':libraries:LGLibrary') implementation(project(path: ":module_common")) { exclude group: 'androidx.swiperefreshlayout' diff --git a/feature/sentry/src/main/java/com/lg/SentryProviderImpl.kt b/feature/sentry/src/main/java/com/lg/SentryProviderImpl.kt index d97bd84161..69ab6a6c4b 100644 --- a/feature/sentry/src/main/java/com/lg/SentryProviderImpl.kt +++ b/feature/sentry/src/main/java/com/lg/SentryProviderImpl.kt @@ -6,6 +6,7 @@ import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.launcher.ARouter import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.constant.RouteConsts +import com.gh.gamecenter.core.HaloApp import com.gh.gamecenter.core.provider.IAppProvider import com.gh.gamecenter.core.provider.ISentryProvider import com.lightgame.utils.Utils @@ -20,6 +21,7 @@ import io.sentry.Scope import io.sentry.ScopeCallback import io.sentry.SentryOptions import io.sentry.android.core.SentryAndroid +import io.sentry.android.fragment.FragmentLifecycleIntegration @Route(path = RouteConsts.provider.sentry, name = "Sentry 暴露服务") class SentryProviderImpl : ISentryProvider { @@ -42,8 +44,17 @@ class SentryProviderImpl : ISentryProvider { options.setDebug(BuildConfig.DEBUG) options.setEnableAutoSessionTracking(true) options.setEnvironment(flavor) + options.setEnableRootCheck(false) options.setEnableSystemEventBreadcrumbs(false) options.setDsn("https://6b1caf0d17c1408e8680f3f73ff80bd0@sentry.shanqu.cc/22") + // 禁止Sentry上报Fragment和View生命周期相关的信息,因为目前Sentry上报的这些内容相关的类名仍然是混淆后的类名,没有什么参考价值 + options.addIntegration( + FragmentLifecycleIntegration( + HaloApp.getInstance(), + enableFragmentLifecycleBreadcrumbs = false, // enabled by default + enableAutoFragmentLifecycleTracing = false // disabled by default + ) + ) options.beforeSend = object : SentryOptions.BeforeSendCallback { override fun execute(event: SentryEvent, hint: Hint): SentryEvent? { @@ -67,7 +78,7 @@ class SentryProviderImpl : ISentryProvider { } } - Sentry.configureScope( object : ScopeCallback { + Sentry.configureScope(object : ScopeCallback { override fun run(scope: Scope) { if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) { scope.setTag("alias", "内测版$versionName") diff --git a/scripts/build_with_simple_backup.sh b/scripts/build_with_simple_backup.sh index 17d2085705..555ae3e016 100755 --- a/scripts/build_with_simple_backup.sh +++ b/scripts/build_with_simple_backup.sh @@ -16,9 +16,9 @@ git checkout module_sensors_data/build.gradle # 开启 mapping 上传 if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' '1 a plugins { id "io.sentry.android.gradle" version "2.1.5" } ' app/build.gradle + sed -i '' '1 a plugins { id "io.sentry.android.gradle" version "3.7.0" } ' app/build.gradle else - sed -i '1 a plugins { id "io.sentry.android.gradle" version "2.1.5" }' app/build.gradle + sed -i '1 a plugins { id "io.sentry.android.gradle" version "3.7.0" }' app/build.gradle fi ./gradlew --stop diff --git a/scripts/meta_build.sh b/scripts/meta_build.sh index 50df99689e..0299d46645 100755 --- a/scripts/meta_build.sh +++ b/scripts/meta_build.sh @@ -30,10 +30,10 @@ git checkout module_sensors_data/build.gradle # 开启 mapping 上传 if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' '1 a plugins { id "io.sentry.android.gradle" version "2.1.5" }' app/build.gradle + sed -i '' '1 a plugins { id "io.sentry.android.gradle" version "3.7.0" }' app/build.gradle sed -i '' 's/var isTestBuild = true/var isTestBuild = false/g' module_sensors_data/build.gradle else - sed -i '1 a plugins { id "io.sentry.android.gradle" version "2.1.5" }' app/build.gradle + sed -i '1 a plugins { id "io.sentry.android.gradle" version "3.7.0" }' app/build.gradle sed -i 's/var isTestBuild = true/var isTestBuild = false/g' module_sensors_data/build.gradle fi