mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Track NotificationTroubleshoot
This commit is contained in:
committed by
Benoit Marty
parent
ef48c2b5a3
commit
8da435b514
+13
@@ -16,11 +16,13 @@
|
|||||||
|
|
||||||
package io.element.android.features.preferences.impl.notifications.troubleshoot
|
package io.element.android.features.preferences.impl.notifications.troubleshoot
|
||||||
|
|
||||||
|
import im.vector.app.features.analytics.plan.NotificationTroubleshoot
|
||||||
import io.element.android.libraries.architecture.AsyncAction
|
import io.element.android.libraries.architecture.AsyncAction
|
||||||
import io.element.android.libraries.core.notifications.NotificationTroubleshootTest
|
import io.element.android.libraries.core.notifications.NotificationTroubleshootTest
|
||||||
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
|
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
|
||||||
import io.element.android.libraries.core.notifications.TestFilterData
|
import io.element.android.libraries.core.notifications.TestFilterData
|
||||||
import io.element.android.libraries.push.api.GetCurrentPushProvider
|
import io.element.android.libraries.push.api.GetCurrentPushProvider
|
||||||
|
import io.element.android.services.analytics.api.AnalyticsService
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
@@ -32,6 +34,7 @@ import javax.inject.Inject
|
|||||||
class TroubleshootTestSuite @Inject constructor(
|
class TroubleshootTestSuite @Inject constructor(
|
||||||
private val notificationTroubleshootTests: Set<@JvmSuppressWildcards NotificationTroubleshootTest>,
|
private val notificationTroubleshootTests: Set<@JvmSuppressWildcards NotificationTroubleshootTest>,
|
||||||
private val getCurrentPushProvider: GetCurrentPushProvider,
|
private val getCurrentPushProvider: GetCurrentPushProvider,
|
||||||
|
private val analyticsService: AnalyticsService,
|
||||||
) {
|
) {
|
||||||
lateinit var tests: List<NotificationTroubleshootTest>
|
lateinit var tests: List<NotificationTroubleshootTest>
|
||||||
|
|
||||||
@@ -77,6 +80,16 @@ class TroubleshootTestSuite @Inject constructor(
|
|||||||
|
|
||||||
private fun emitState() {
|
private fun emitState() {
|
||||||
val states = tests.map { it.state.value }
|
val states = tests.map { it.state.value }
|
||||||
|
val mainState = states.computeMainState()
|
||||||
|
when (mainState) {
|
||||||
|
is AsyncAction.Success -> {
|
||||||
|
analyticsService.capture(NotificationTroubleshoot(hasError = false))
|
||||||
|
}
|
||||||
|
is AsyncAction.Failure -> {
|
||||||
|
analyticsService.capture(NotificationTroubleshoot(hasError = true))
|
||||||
|
}
|
||||||
|
else -> Unit
|
||||||
|
}
|
||||||
_state.tryEmit(
|
_state.tryEmit(
|
||||||
TroubleshootTestSuiteState(
|
TroubleshootTestSuiteState(
|
||||||
mainState = states.computeMainState(),
|
mainState = states.computeMainState(),
|
||||||
|
|||||||
+2
@@ -24,6 +24,7 @@ import io.element.android.libraries.architecture.AsyncAction
|
|||||||
import io.element.android.libraries.core.notifications.NotificationTroubleshootTest
|
import io.element.android.libraries.core.notifications.NotificationTroubleshootTest
|
||||||
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
|
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
|
||||||
import io.element.android.libraries.push.test.FakeGetCurrentPushProvider
|
import io.element.android.libraries.push.test.FakeGetCurrentPushProvider
|
||||||
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
@@ -113,6 +114,7 @@ class TroubleshootNotificationsPresenterTests {
|
|||||||
return TroubleshootTestSuite(
|
return TroubleshootTestSuite(
|
||||||
notificationTroubleshootTests = tests,
|
notificationTroubleshootTests = tests,
|
||||||
getCurrentPushProvider = FakeGetCurrentPushProvider(currentPushProvider),
|
getCurrentPushProvider = FakeGetCurrentPushProvider(currentPushProvider),
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user