Track NotificationTroubleshoot
This commit is contained in:
parent
12a1cf048e
commit
6aa3169496
2 changed files with 15 additions and 0 deletions
|
|
@ -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(),
|
||||||
|
|
|
||||||
|
|
@ -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(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue