From 861ca58a58675e5f063072b7f31e8cefeaaeaed5 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sun, 13 Mar 2022 17:41:01 +0530 Subject: Configure Sentry with more information (#1782) * build-logic: remove error path in Sentry plugin * gradle: fix UnstableApiUsage warning * build-logic: configure Sentry Gradle Plugin * app: set traces sample-rate to 1.0 * sentry-stub: init * app: populate Sentry user field with feature flags --- app/src/main/java/dev/msfjarvis/aps/Application.kt | 13 +++++++++++++ .../main/java/dev/msfjarvis/aps/util/features/Feature.kt | 5 +++++ 2 files changed, 18 insertions(+) (limited to 'app/src/main') diff --git a/app/src/main/java/dev/msfjarvis/aps/Application.kt b/app/src/main/java/dev/msfjarvis/aps/Application.kt index 1a72655b..0c7def1c 100644 --- a/app/src/main/java/dev/msfjarvis/aps/Application.kt +++ b/app/src/main/java/dev/msfjarvis/aps/Application.kt @@ -15,11 +15,15 @@ import dagger.hilt.android.HiltAndroidApp import dev.msfjarvis.aps.injection.context.FilesDirPath import dev.msfjarvis.aps.injection.prefs.SettingsPreferences import dev.msfjarvis.aps.util.extensions.getString +import dev.msfjarvis.aps.util.features.Feature +import dev.msfjarvis.aps.util.features.Features import dev.msfjarvis.aps.util.git.sshj.setUpBouncyCastleForSshj import dev.msfjarvis.aps.util.proxy.ProxyUtils import dev.msfjarvis.aps.util.settings.GitSettings import dev.msfjarvis.aps.util.settings.PreferenceKeys import dev.msfjarvis.aps.util.settings.runMigrations +import io.sentry.Sentry +import io.sentry.protocol.User import javax.inject.Inject import logcat.AndroidLogcatLogger import logcat.LogPriority.DEBUG @@ -33,6 +37,7 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere @Inject @FilesDirPath lateinit var filesDirPath: String @Inject lateinit var proxyUtils: ProxyUtils @Inject lateinit var gitSettings: GitSettings + @Inject lateinit var features: Features override fun onCreate() { super.onCreate() @@ -48,6 +53,14 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere runMigrations(filesDirPath, prefs, gitSettings) proxyUtils.setDefaultProxy() DynamicColors.applyToActivitiesIfAvailable(this) + Sentry.configureScope { scope -> + val user = User() + user.others = + Feature.VALUES.associate { feature -> + "features.${feature.configKey}" to features.isEnabled(feature).toString() + } + scope.user = user + } } override fun onTerminate() { diff --git a/app/src/main/java/dev/msfjarvis/aps/util/features/Feature.kt b/app/src/main/java/dev/msfjarvis/aps/util/features/Feature.kt index 7ae2e642..4eef003d 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/features/Feature.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/features/Feature.kt @@ -15,4 +15,9 @@ enum class Feature( /** Opt into the new PGP backend powered by the PGPainless library. */ EnablePGPainlessBackend(false, "enable_pgp_v2_backend"), + ; + + companion object { + @JvmField val VALUES = values() + } } -- cgit v1.2.3