From d5dafc8371615eb5d5196fc79e80c1f19193b200 Mon Sep 17 00:00:00 2001 From: Alexandre Ferris Date: Thu, 15 Aug 2024 17:59:24 +0200 Subject: [PATCH] feat: show analytics initialized for automation (WPB-10600) (#3330) Signed-off-by: alexandreferris (cherry picked from commit a404cdfadb443c3ccfd7cc896d4e7196f1d34a2e) Signed-off-by: alexandreferris --- .../com/wire/android/di/CoreLogicModule.kt | 8 +++++ .../ui/analytics/AnalyticsUsageViewModel.kt | 4 ++- .../wire/android/ui/debug/DebugDataOptions.kt | 17 +++++++++++ .../android/ui/debug/DebugDataOptionsState.kt | 1 + .../ui/debug/DebugDataOptionsViewModel.kt | 15 +++++++++- .../settings/privacy/PrivacySettingsScreen.kt | 2 +- .../settings/privacy/PrivacySettingsState.kt | 3 +- .../privacy/PrivacySettingsViewModel.kt | 24 +++++++++++++-- app/src/main/res/values/strings.xml | 4 +++ .../analytics/AnalyticsUsageViewModelTest.kt | 30 +++++++++---------- .../privacy/PrivacySettingsViewModelTest.kt | 18 ++++++++--- .../AnonymousAnalyticsManagerImpl.kt | 6 ++++ .../AnonymousAnalyticsRecorderImpl.kt | 2 ++ .../analytics/AnonymousAnalyticsManager.kt | 2 ++ .../AnonymousAnalyticsManagerStub.kt | 2 ++ .../analytics/AnonymousAnalyticsRecorder.kt | 2 ++ .../AnonymousAnalyticsRecorderStub.kt | 2 ++ default.json | 2 +- 18 files changed, 117 insertions(+), 27 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt b/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt index da4e9f5baf7..96a935276f4 100644 --- a/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt +++ b/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt @@ -29,6 +29,7 @@ import com.wire.kalium.logic.data.id.FederatedIdMapper import com.wire.kalium.logic.data.id.QualifiedIdMapper import com.wire.kalium.logic.data.id.QualifiedIdMapperImpl import com.wire.kalium.logic.data.user.UserId +import com.wire.kalium.logic.feature.analytics.GetCurrentAnalyticsTrackingIdentifierUseCase import com.wire.kalium.logic.feature.auth.AddAuthenticatedUserUseCase import com.wire.kalium.logic.feature.auth.LogoutUseCase import com.wire.kalium.logic.feature.connection.BlockUserUseCase @@ -473,4 +474,11 @@ class UseCaseModule { @KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId ): FetchConversationMLSVerificationStatusUseCase = coreLogic.getSessionScope(currentAccount).fetchConversationMLSVerificationStatus + + @ViewModelScoped + @Provides + fun provideGetCurrentAnalyticsTrackingIdentifierUseCase( + @KaliumCoreLogic coreLogic: CoreLogic, + @CurrentAccount currentAccount: UserId + ): GetCurrentAnalyticsTrackingIdentifierUseCase = coreLogic.getSessionScope(currentAccount).getCurrentAnalyticsTrackingIdentifier } diff --git a/app/src/main/kotlin/com/wire/android/ui/analytics/AnalyticsUsageViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/analytics/AnalyticsUsageViewModel.kt index db415d4a7ad..25d3dc17ff1 100644 --- a/app/src/main/kotlin/com/wire/android/ui/analytics/AnalyticsUsageViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/analytics/AnalyticsUsageViewModel.kt @@ -45,7 +45,9 @@ class AnalyticsUsageViewModel @Inject constructor( val isAnalyticsUsageEnabled = dataStore.isAnonymousUsageDataEnabled().first() val isAnalyticsConfigurationEnabled = analyticsEnabled is AnalyticsConfiguration.Enabled val isProdBackend = when (val serverConfig = selfServerConfig()) { - is SelfServerConfigUseCase.Result.Success -> serverConfig.serverLinks.links.api == ServerConfig.PRODUCTION.api + is SelfServerConfigUseCase.Result.Success -> + serverConfig.serverLinks.links.api == ServerConfig.PRODUCTION.api + || serverConfig.serverLinks.links.api == ServerConfig.STAGING.api is SelfServerConfigUseCase.Result.Failure -> false } diff --git a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt index 3145ce1fc62..b2cb4792faf 100644 --- a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt +++ b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt @@ -29,6 +29,7 @@ import androidx.compose.ui.res.stringResource import com.wire.android.BuildConfig import com.wire.android.R import com.wire.android.di.hiltViewModelScoped +import com.wire.android.feature.analytics.AnonymousAnalyticsManagerImpl import com.wire.android.model.Clickable import com.wire.android.ui.common.RowItemTemplate import com.wire.android.ui.common.WireDialog @@ -136,6 +137,22 @@ fun DebugDataOptionsContent( onClick = { onCopyText(state.debugId) } ) ) + + SettingsItem( + title = stringResource(id = R.string.debug_analytics_enabled_title), + text = AnonymousAnalyticsManagerImpl.isAnalyticsInitialized().toString() + ) + + SettingsItem( + title = stringResource(id = R.string.debug_analytics_tracking_identifier_title), + text = state.analyticsTrackingId, + trailingIcon = R.drawable.ic_copy, + onIconPressed = Clickable( + enabled = true, + onClick = { onCopyText(state.analyticsTrackingId) } + ) + ) + if (BuildConfig.DEBUG) { GetE2EICertificateSwitch( enrollE2EI = enrollE2EICertificate diff --git a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsState.kt b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsState.kt index 84951c69bca..acc93712f82 100644 --- a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsState.kt @@ -29,4 +29,5 @@ data class DebugDataOptionsState( val certificate: String = "null", val showCertificate: Boolean = false, val startGettingE2EICertificate: Boolean = false, + val analyticsTrackingId: String = "null" ) diff --git a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt index c813a7835c2..e6c4a667b01 100644 --- a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt @@ -33,6 +33,7 @@ import com.wire.android.util.getGitBuildId import com.wire.kalium.logic.CoreFailure import com.wire.kalium.logic.E2EIFailure import com.wire.kalium.logic.data.user.UserId +import com.wire.kalium.logic.feature.analytics.GetCurrentAnalyticsTrackingIdentifierUseCase import com.wire.kalium.logic.feature.e2ei.CheckCrlRevocationListUseCase import com.wire.kalium.logic.feature.e2ei.usecase.E2EIEnrollmentResult import com.wire.kalium.logic.feature.keypackage.MLSKeyPackageCountResult @@ -73,7 +74,8 @@ class DebugDataOptionsViewModelImpl private val updateApiVersions: UpdateApiVersionsScheduler, private val mlsKeyPackageCount: MLSKeyPackageCountUseCase, private val restartSlowSyncProcessForRecovery: RestartSlowSyncProcessForRecoveryUseCase, - private val checkCrlRevocationList: CheckCrlRevocationListUseCase + private val checkCrlRevocationList: CheckCrlRevocationListUseCase, + private val getCurrentAnalyticsTrackingIdentifier: GetCurrentAnalyticsTrackingIdentifierUseCase ) : ViewModel(), DebugDataOptionsViewModel { var state by mutableStateOf( @@ -85,6 +87,17 @@ class DebugDataOptionsViewModelImpl observeMlsMetadata() checkIfCanTriggerManualMigration() setGitHashAndDeviceId() + setAnalyticsTrackingId() + } + + private fun setAnalyticsTrackingId() { + viewModelScope.launch { + getCurrentAnalyticsTrackingIdentifier()?.let { trackingId -> + state = state.copy( + analyticsTrackingId = trackingId + ) + } + } } private fun setGitHashAndDeviceId() { diff --git a/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsScreen.kt b/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsScreen.kt index b36d2d49f38..974812ddc5d 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsScreen.kt @@ -50,7 +50,7 @@ fun PrivacySettingsConfigScreen( ) { with(viewModel) { PrivacySettingsScreenContent( - isAnonymousUsageDataEnabled = state.isAnonymousUsageDataEnabled, + isAnonymousUsageDataEnabled = state.isAnalyticsUsageEnabled, areReadReceiptsEnabled = state.areReadReceiptsEnabled, setReadReceiptsState = ::setReadReceiptsState, isTypingIndicatorEnabled = state.isTypingIndicatorEnabled, diff --git a/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsState.kt b/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsState.kt index a82f62dc3ed..57d067e8b4b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsState.kt @@ -19,7 +19,8 @@ package com.wire.android.ui.home.settings.privacy data class PrivacySettingsState( - val isAnonymousUsageDataEnabled: Boolean = true, + val isAnalyticsUsageEnabled: Boolean = true, + val shouldShowAnalyticsUsage: Boolean = false, val areReadReceiptsEnabled: Boolean = true, val isTypingIndicatorEnabled: Boolean = true, val screenshotCensoringConfig: ScreenshotCensoringConfig = ScreenshotCensoringConfig.ENABLED_BY_USER, diff --git a/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsViewModel.kt index a0992672691..4c9b5abb94e 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsViewModel.kt @@ -25,7 +25,10 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wire.android.appLogger import com.wire.android.datastore.UserDataStore +import com.wire.android.ui.analytics.AnalyticsConfiguration import com.wire.android.util.dispatchers.DispatcherProvider +import com.wire.kalium.logic.configuration.server.ServerConfig +import com.wire.kalium.logic.feature.user.SelfServerConfigUseCase import com.wire.kalium.logic.feature.user.readReceipts.ObserveReadReceiptsEnabledUseCase import com.wire.kalium.logic.feature.user.readReceipts.PersistReadReceiptsStatusConfigUseCase import com.wire.kalium.logic.feature.user.readReceipts.ReadReceiptStatusConfigResult @@ -42,6 +45,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import javax.inject.Inject +@Suppress("LongParameterList") @HiltViewModel class PrivacySettingsViewModel @Inject constructor( private val dispatchers: DispatcherProvider, @@ -51,6 +55,8 @@ class PrivacySettingsViewModel @Inject constructor( private val observeScreenshotCensoringConfig: ObserveScreenshotCensoringConfigUseCase, private val persistTypingIndicatorStatusConfig: PersistTypingIndicatorStatusConfigUseCase, private val observeTypingIndicatorEnabled: ObserveTypingIndicatorEnabledUseCase, + private val analyticsEnabled: AnalyticsConfiguration, + private val selfServerConfig: SelfServerConfigUseCase, private val dataStore: UserDataStore ) : ViewModel() { @@ -66,7 +72,7 @@ class PrivacySettingsViewModel @Inject constructor( dataStore.isAnonymousUsageDataEnabled() ) { readReceiptsEnabled, typingIndicatorEnabled, screenshotCensoringConfig, anonymousUsageDataEnabled -> PrivacySettingsState( - isAnonymousUsageDataEnabled = anonymousUsageDataEnabled, + isAnalyticsUsageEnabled = anonymousUsageDataEnabled, areReadReceiptsEnabled = readReceiptsEnabled, isTypingIndicatorEnabled = typingIndicatorEnabled, screenshotCensoringConfig = when (screenshotCensoringConfig) { @@ -82,6 +88,20 @@ class PrivacySettingsViewModel @Inject constructor( ) }.collect { state = it } } + + viewModelScope.launch { + val isAnalyticsConfigurationEnabled = analyticsEnabled is AnalyticsConfiguration.Enabled + val isValidBackend = when (val serverConfig = selfServerConfig()) { + is SelfServerConfigUseCase.Result.Success -> + serverConfig.serverLinks.links.api == ServerConfig.PRODUCTION.api + || serverConfig.serverLinks.links.api == ServerConfig.STAGING.api + is SelfServerConfigUseCase.Result.Failure -> false + } + + state = state.copy( + shouldShowAnalyticsUsage = isAnalyticsConfigurationEnabled && isValidBackend + ) + } } fun setReadReceiptsState(isEnabled: Boolean) { @@ -137,7 +157,7 @@ class PrivacySettingsViewModel @Inject constructor( dataStore.setIsAnonymousAnalyticsEnabled(enabled) } state = state.copy( - isAnonymousUsageDataEnabled = enabled + isAnalyticsUsageEnabled = enabled ) } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f34768cfabd..551622bf17d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -20,6 +20,10 @@ App version Build variant Debug Identifier + Analytics Initialized + + Analytics Tracking Identifier + New Login OK diff --git a/app/src/test/kotlin/com/wire/android/ui/analytics/AnalyticsUsageViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/analytics/AnalyticsUsageViewModelTest.kt index 592d1973c04..7af6ee33894 100644 --- a/app/src/test/kotlin/com/wire/android/ui/analytics/AnalyticsUsageViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/analytics/AnalyticsUsageViewModelTest.kt @@ -43,7 +43,7 @@ class AnalyticsUsageViewModelTest { fun `should hide or show Analytics Usage dialog - handle accordingly`(params: TestParams) = runTest { // given val (_, viewModel) = Arrangement() - .withProdBackend(params.isProdBackend) + .withServerConfig(params.serverConfig) .withAnalyticsUsageEnabled(params.isAnalyticsUsageEnabled) .withIsDialogSeen(params.isDialogSeen) .arrange(analyticsConfiguration = params.analyticsConfiguration) @@ -59,7 +59,7 @@ class AnalyticsUsageViewModelTest { fun `given dialog is shown, when user agrees to analytics usage, then setting analytics to enabled and dialog to seen`() = runTest { // given val (arrangement, viewModel) = Arrangement() - .withProdBackend(true) + .withServerConfig(STAGING_SERVER_CONFIG) .withAnalyticsUsageEnabled(false) .withIsDialogSeen(false) .arrange(analyticsConfiguration = AnalyticsConfiguration.Enabled) @@ -81,7 +81,7 @@ class AnalyticsUsageViewModelTest { fun `given dialog is shown, when user declines analytics usage, then setting analytics to disabled and dialog to seen`() = runTest { // given val (arrangement, viewModel) = Arrangement() - .withProdBackend(true) + .withServerConfig(PRODUCTION_SERVER_CONFIG) .withAnalyticsUsageEnabled(false) .withIsDialogSeen(false) .arrange(analyticsConfiguration = AnalyticsConfiguration.Enabled) @@ -110,9 +110,9 @@ class AnalyticsUsageViewModelTest { coEvery { dataStore.setIsAnalyticsDialogSeen() } returns Unit } - fun withProdBackend(isProd: Boolean) = apply { + fun withServerConfig(serverConfig: ServerConfig) = apply { coEvery { selfServerConfig() } returns SelfServerConfigUseCase.Result.Success( - serverLinks = if (isProd) PRODUCTION_SERVER_CONFIG else CUSTOM_SERVER_CONFIG + serverLinks = serverConfig ) } fun withAnalyticsUsageEnabled(enabled: Boolean) = apply { @@ -127,52 +127,50 @@ class AnalyticsUsageViewModelTest { dataStore = dataStore, selfServerConfig = selfServerConfig ) - - private companion object { - val PRODUCTION_SERVER_CONFIG = newServerConfig(1).copy(links = ServerConfig.PRODUCTION) - val CUSTOM_SERVER_CONFIG = newServerConfig(1).copy(links = ServerConfig.STAGING) - } } companion object { + val PRODUCTION_SERVER_CONFIG = newServerConfig(1).copy(links = ServerConfig.PRODUCTION) + val STAGING_SERVER_CONFIG = newServerConfig(1).copy(links = ServerConfig.STAGING) + val CUSTOM_SERVER_CONFIG = newServerConfig(1).copy(links = ServerConfig.DUMMY) enum class TestParams( - val isProdBackend: Boolean, + val serverConfig: ServerConfig, val isAnalyticsUsageEnabled: Boolean, val isDialogSeen: Boolean, val analyticsConfiguration: AnalyticsConfiguration, val expected: Boolean ) { SHOULD_SHOW_DIALOG( - true, + PRODUCTION_SERVER_CONFIG, false, false, AnalyticsConfiguration.Enabled, true ), SHOULD_HIDE_DIALOG( - true, + STAGING_SERVER_CONFIG, false, true, AnalyticsConfiguration.Enabled, false ), ANALYTICS_ALREADY_ENABLED( - true, + STAGING_SERVER_CONFIG, true, true, AnalyticsConfiguration.Enabled, false ), CUSTOM_BACKEND( - false, + CUSTOM_SERVER_CONFIG, false, false, AnalyticsConfiguration.Enabled, false ), ANALYTICS_CONFIGURATION_DISABLED( - true, + PRODUCTION_SERVER_CONFIG, false, false, AnalyticsConfiguration.Disabled, diff --git a/app/src/test/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsViewModelTest.kt index 623e24e49d5..a2a314db1db 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/settings/privacy/PrivacySettingsViewModelTest.kt @@ -20,6 +20,10 @@ package com.wire.android.ui.home.settings.privacy import com.wire.android.config.CoroutineTestExtension import com.wire.android.config.TestDispatcherProvider import com.wire.android.datastore.UserDataStore +import com.wire.android.ui.analytics.AnalyticsConfiguration +import com.wire.android.util.newServerConfig +import com.wire.kalium.logic.configuration.server.ServerConfig +import com.wire.kalium.logic.feature.user.SelfServerConfigUseCase import com.wire.kalium.logic.feature.user.readReceipts.ObserveReadReceiptsEnabledUseCase import com.wire.kalium.logic.feature.user.readReceipts.PersistReadReceiptsStatusConfigUseCase import com.wire.kalium.logic.feature.user.readReceipts.ReadReceiptStatusConfigResult @@ -54,7 +58,7 @@ class PrivacySettingsViewModelTest { // then assertEquals( true, - viewModel.state.isAnonymousUsageDataEnabled + viewModel.state.isAnalyticsUsageEnabled ) } @@ -69,7 +73,7 @@ class PrivacySettingsViewModelTest { // then assertEquals( false, - viewModel.state.isAnonymousUsageDataEnabled + viewModel.state.isAnalyticsUsageEnabled ) } @@ -86,7 +90,7 @@ class PrivacySettingsViewModelTest { // then assertEquals( false, - viewModel.state.isAnonymousUsageDataEnabled + viewModel.state.isAnalyticsUsageEnabled ) } @@ -103,7 +107,7 @@ class PrivacySettingsViewModelTest { // then assertEquals( true, - viewModel.state.isAnonymousUsageDataEnabled + viewModel.state.isAnalyticsUsageEnabled ) } @@ -114,6 +118,7 @@ class PrivacySettingsViewModelTest { val observeScreenshotCensoringConfig = mockk() val persistTypingIndicatorStatusConfig = mockk() val observeTypingIndicatorEnabled = mockk() + val selfServerConfig = mockk() val dataStore = mockk() val viewModel by lazy { @@ -125,6 +130,8 @@ class PrivacySettingsViewModelTest { observeScreenshotCensoringConfig = observeScreenshotCensoringConfig, persistTypingIndicatorStatusConfig = persistTypingIndicatorStatusConfig, observeTypingIndicatorEnabled = observeTypingIndicatorEnabled, + analyticsEnabled = AnalyticsConfiguration.Enabled, + selfServerConfig = selfServerConfig, dataStore = dataStore ) } @@ -140,6 +147,9 @@ class PrivacySettingsViewModelTest { coEvery { persistTypingIndicatorStatusConfig.invoke(true) } returns TypingIndicatorConfigResult.Success coEvery { observeTypingIndicatorEnabled() } returns flowOf(true) coEvery { dataStore.setIsAnonymousAnalyticsEnabled(any()) } returns Unit + coEvery { selfServerConfig.invoke() } returns SelfServerConfigUseCase.Result.Success( + serverLinks = newServerConfig(1).copy(links = ServerConfig.STAGING) + ) } fun withEnabledAnonymousUsageData() = apply { diff --git a/core/analytics-enabled/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManagerImpl.kt b/core/analytics-enabled/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManagerImpl.kt index 08a95836eba..bfa6151b0a3 100644 --- a/core/analytics-enabled/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManagerImpl.kt +++ b/core/analytics-enabled/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManagerImpl.kt @@ -167,4 +167,10 @@ object AnonymousAnalyticsManagerImpl : AnonymousAnalyticsManager { is AnalyticsIdentifierResult.Disabled -> {} } } + + override fun isAnalyticsInitialized(): Boolean = + anonymousAnalyticsRecorder?.isAnalyticsInitialized() ?: run { + Log.w(TAG, "Calling isAnalyticsInitialized with a null recorder.") + false + } } diff --git a/core/analytics-enabled/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorderImpl.kt b/core/analytics-enabled/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorderImpl.kt index 4252fb052aa..16e8d9e9590 100644 --- a/core/analytics-enabled/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorderImpl.kt +++ b/core/analytics-enabled/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorderImpl.kt @@ -105,4 +105,6 @@ class AnonymousAnalyticsRecorderImpl : AnonymousAnalyticsRecorder { ) Countly.sharedInstance().userProfile().save() } + + override fun isAnalyticsInitialized(): Boolean = Countly.sharedInstance().isInitialized } diff --git a/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManager.kt b/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManager.kt index 915511e0172..f58a956032e 100644 --- a/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManager.kt +++ b/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManager.kt @@ -47,4 +47,6 @@ interface AnonymousAnalyticsManager { fun onStart(activity: Activity) fun onStop(activity: Activity) + + fun isAnalyticsInitialized(): Boolean } diff --git a/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManagerStub.kt b/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManagerStub.kt index ee102d87a40..83734370994 100644 --- a/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManagerStub.kt +++ b/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsManagerStub.kt @@ -44,4 +44,6 @@ open class AnonymousAnalyticsManagerStub : AnonymousAnalyticsManager { override fun onStart(activity: Activity) = Unit override fun onStop(activity: Activity) = Unit + + override fun isAnalyticsInitialized(): Boolean = false } diff --git a/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorder.kt b/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorder.kt index ef96db149ac..80c226d3221 100644 --- a/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorder.kt +++ b/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorder.kt @@ -48,4 +48,6 @@ interface AnonymousAnalyticsRecorder { isTeamMember: Boolean, propagateIdentifier: suspend () -> Unit ) + + fun isAnalyticsInitialized(): Boolean } diff --git a/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorderStub.kt b/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorderStub.kt index 56bf3fe4d39..c4fae9fd2cf 100644 --- a/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorderStub.kt +++ b/core/analytics/src/main/kotlin/com/wire/android/feature/analytics/AnonymousAnalyticsRecorderStub.kt @@ -45,4 +45,6 @@ open class AnonymousAnalyticsRecorderStub : AnonymousAnalyticsRecorder { isTeamMember: Boolean, propagateIdentifier: suspend () -> Unit ) = Unit + + override fun isAnalyticsInitialized(): Boolean = false } diff --git a/default.json b/default.json index 19e8bba2422..bfb57910746 100644 --- a/default.json +++ b/default.json @@ -52,7 +52,7 @@ "default_backend_url_website": "https://wire.com", "default_backend_title": "wire-staging", "encrypt_proteus_storage": true, - "analytics_enabled": false, + "analytics_enabled": true, "analytics_app_key": "8ffae535f1836ed5f58fd5c8a11c00eca07c5438", "analytics_server_url": "https://countly.wire.com/" },