Change in clear cache behavior:

- Do not reset the analytics store, so that we do not ask the user consent again => Parity with iOS.
- Do not reset the permission store, because it contains information that's related to the system permission, which cannot be retrieved otherwise => Should help with #3195.
This commit is contained in:
Benoit Marty 2025-09-22 10:30:04 +02:00 committed by Benoit Marty
parent c646d6d5c1
commit 290298ce01
15 changed files with 1 additions and 114 deletions

View file

@ -47,9 +47,4 @@ interface AnalyticsService : AnalyticsTracker, ErrorTracker {
* Update analyticsId from the AccountData.
*/
suspend fun setAnalyticsId(analyticsId: String)
/**
* Reset the analytics service (will ask for user consent again).
*/
suspend fun reset()
}

View file

@ -70,10 +70,6 @@ class DefaultAnalyticsService(
analyticsStore.setDidAskUserConsent()
}
override suspend fun reset() {
analyticsStore.setDidAskUserConsent(false)
}
override suspend fun setAnalyticsId(analyticsId: String) {
Timber.tag(analyticsTag.value).d("setAnalyticsId($analyticsId)")
analyticsStore.setAnalyticsId(analyticsId)

View file

@ -180,20 +180,6 @@ class DefaultAnalyticsServiceTest {
resetLambda.assertions().isCalledOnce()
}
@Test
fun `when reset is invoked, the user consent is reset`() = runTest {
val store = FakeAnalyticsStore(
defaultDidAskUserConsent = true,
)
val sut = createDefaultAnalyticsService(
coroutineScope = backgroundScope,
analyticsStore = store,
)
assertThat(store.didAskUserConsentFlow.first()).isTrue()
sut.reset()
assertThat(store.didAskUserConsentFlow.first()).isFalse()
}
@Test
fun `when a session is added, nothing happen`() = runTest {
val sut = createDefaultAnalyticsService(

View file

@ -31,7 +31,6 @@ class NoopAnalyticsService : AnalyticsService {
override suspend fun setDidAskUserConsent() = Unit
override val analyticsIdFlow: Flow<String> = flowOf("")
override suspend fun setAnalyticsId(analyticsId: String) = Unit
override suspend fun reset() = Unit
override fun capture(event: VectorAnalyticsEvent) = Unit
override fun screen(screen: VectorAnalyticsScreen) = Unit
override fun updateUserProperties(userProperties: UserProperties) = Unit

View file

@ -20,7 +20,6 @@ import kotlinx.coroutines.flow.asStateFlow
class FakeAnalyticsService(
isEnabled: Boolean = false,
didAskUserConsent: Boolean = false,
private val resetLambda: () -> Unit = {},
) : AnalyticsService {
private val isEnabledFlow = MutableStateFlow(isEnabled)
override val didAskUserConsentFlow = MutableStateFlow(didAskUserConsent)
@ -65,9 +64,4 @@ class FakeAnalyticsService(
override fun updateSuperProperties(updatedProperties: SuperProperties) {
// No op
}
override suspend fun reset() {
didAskUserConsentFlow.value = false
resetLambda()
}
}