0.2.45 - Advanced analytics, logout old versions

This commit is contained in:
ponzischeme89
2026-08-10 20:24:22 +12:00
parent 63f0768507
commit 56c1167382
32 changed files with 1125 additions and 452 deletions
@@ -0,0 +1,38 @@
package com.ponzischeme89.memby.data.analytics
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class JourneyAnalyticsTest {
@Test
fun `events stay ordered and contain no arbitrary characters`() {
val analytics = JourneyAnalytics(userId = "user-1", now = { 1_700_000_000_000L }, journeyId = "journey-1")
analytics.track(
category = "content", action = "open", screen = "home screen",
feature = "latest_movies", itemId = "item/unsafe", itemType = "Movie",
)
val events = analytics.drain()
assertEquals(listOf(0, 1), events.map { it.sequence })
assertEquals("user-1", events.last().userId)
assertEquals("homescreen", events.last().screen)
assertEquals("itemunsafe", events.last().itemId)
}
@Test
fun `ending records one terminal event and rejects later actions`() {
val analytics = JourneyAnalytics(userId = "user-1", journeyId = "journey-1")
analytics.drain()
analytics.end("details")
analytics.end("player")
analytics.track("navigation", "open", feature = "search")
val events = analytics.drain()
assertEquals(1, events.size)
assertEquals("journey_end", events.single().action)
assertTrue(events.single().screen == "details")
assertFalse(events.any { it.feature == "search" })
}
}
@@ -9,26 +9,6 @@ import org.junit.Test
class PlaybackRecoveryTest {
@Test
fun `libmpv takes codec failures only after Media3 recovery is exhausted`() {
val codecFailure = describePlaybackFailure(
PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED,
)
assertFalse(shouldUseLibmpvFallback(codecFailure, completedAttempts = 0))
assertFalse(shouldUseLibmpvFallback(codecFailure, completedAttempts = 1))
assertTrue(shouldUseLibmpvFallback(codecFailure, completedAttempts = 2))
}
@Test
fun `libmpv does not replace Media3 network recovery`() {
val networkFailure = describePlaybackFailure(
PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED,
)
assertFalse(shouldUseLibmpvFallback(networkFailure, completedAttempts = 2))
}
@Test
fun networkFailuresAreSafeToRetry() {
val failure = describePlaybackFailure(