Merge branch 'feat/GHZSCY-6583' into 'dev'

feat: 更新 Sentry SDK https://jira.shanqu.cc/browse/GHZSCY-6583

See merge request halo/android/assistant-android!1899
This commit is contained in:
曾祥俊
2024-09-20 17:22:19 +08:00
5 changed files with 18 additions and 6 deletions

View File

@ -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"

View File

@ -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'

View File

@ -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")

View File

@ -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

View File

@ -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