From e6444fe9c07cc211c09b1d0e4cccf73b652a6876 Mon Sep 17 00:00:00 2001 From: valere Date: Fri, 2 Dec 2022 12:39:13 +0100 Subject: [PATCH] enable analytics by default on nightly --- .../src/main/java/im/vector/app/VectorApplication.kt | 9 +++++++++ .../src/main/java/im/vector/app/config/Config.kt | 2 ++ .../im/vector/app/core/di/ConfigurationModule.kt | 12 ++++++++++-- .../app/features/settings/VectorPreferences.kt | 6 ++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/vector-app/src/main/java/im/vector/app/VectorApplication.kt b/vector-app/src/main/java/im/vector/app/VectorApplication.kt index 2fafdc033b..1dbbc17403 100644 --- a/vector-app/src/main/java/im/vector/app/VectorApplication.kt +++ b/vector-app/src/main/java/im/vector/app/VectorApplication.kt @@ -32,6 +32,7 @@ import androidx.core.provider.FontsContractCompat import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ProcessLifecycleOwner +import androidx.lifecycle.coroutineScope import androidx.multidex.MultiDex import androidx.recyclerview.widget.SnapHelper import com.airbnb.epoxy.Carousel @@ -68,6 +69,7 @@ import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.themes.ThemeUtils import im.vector.app.features.version.VersionProvider import im.vector.application.R +import kotlinx.coroutines.launch import org.jitsi.meet.sdk.log.JitsiMeetDefaultLogHandler import org.matrix.android.sdk.api.Matrix import org.matrix.android.sdk.api.auth.AuthenticationService @@ -135,6 +137,13 @@ class VectorApplication : autoRageShaker.initialize() vectorUncaughtExceptionHandler.activate() + if (BuildConfig.FLAVOR == "rustCrypto") { + ProcessLifecycleOwner.get().lifecycle.coroutineScope.launch { + vectorAnalytics.setUserConsent(true) + } + vectorPreferences.setLabsAutoReportUISI(true) + } + // Remove Log handler statically added by Jitsi Timber.forest() .filterIsInstance(JitsiMeetDefaultLogHandler::class.java) diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index c91987dbfd..a9bae626a4 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -93,4 +93,6 @@ object Config { * Can be disabled by providing Analytics.Disabled */ val NIGHTLY_ANALYTICS_CONFIG = RELEASE_ANALYTICS_CONFIG.copy(sentryEnvironment = "NIGHTLY") + val ER_NIGHTLY_ANALYTICS_CONFIG = RELEASE_ANALYTICS_CONFIG.copy(sentryEnvironment = "element-r") + val ER_DEBUG_ANALYTICS_CONFIG = DEBUG_ANALYTICS_CONFIG.copy(sentryEnvironment = "element-r") } diff --git a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt index caa38d20d9..ce7da7fe68 100644 --- a/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ConfigurationModule.kt @@ -38,8 +38,16 @@ object ConfigurationModule { @Provides fun providesAnalyticsConfig(): AnalyticsConfig { val config: Analytics = when (BuildConfig.BUILD_TYPE) { - "debug" -> Config.DEBUG_ANALYTICS_CONFIG - "nightly" -> Config.NIGHTLY_ANALYTICS_CONFIG + "debug" -> if (BuildConfig.FLAVOR == "rustCrypto") { + Config.ER_DEBUG_ANALYTICS_CONFIG + } else { + Config.DEBUG_ANALYTICS_CONFIG + } + "nightly" -> if (BuildConfig.FLAVOR == "rustCrypto") { + Config.ER_NIGHTLY_ANALYTICS_CONFIG + } else { + Config.NIGHTLY_ANALYTICS_CONFIG + } "release" -> Config.RELEASE_ANALYTICS_CONFIG else -> throw IllegalStateException("Unhandled build type: ${BuildConfig.BUILD_TYPE}") } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 1a452e0426..f8f78332c0 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -1092,6 +1092,12 @@ class VectorPreferences @Inject constructor( return defaultPrefs.getBoolean(SETTINGS_LABS_AUTO_REPORT_UISI, false) } + fun setLabsAutoReportUISI(enabled: Boolean) { + return defaultPrefs.edit { + putBoolean(SETTINGS_LABS_AUTO_REPORT_UISI, enabled) + } + } + fun prefSpacesShowAllRoomInHome(): Boolean { return defaultPrefs.getBoolean(SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME, false) }