Skip to content

Commit e96eba5

Browse files
committed
fix(analytics): resolve null screen and call site in release error modals
R8 strips Kotlin metadata and source file attributes from coroutine continuations, causing screenName() and showError() call site capture to produce null values. Switch screen resolution to Java reflection with a ProGuard keep rule for AppRoute names, and fall back to the outer class name when source file info is unavailable. Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 2275434 commit e96eba5

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

apps/flipcash/app/proguard-rules.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
# Keep screen names
1717
-keepnames class * implements cafe.adriel.voyager.core.screen.Screen
1818

19+
# Keep AppRoute class names for analytics screen tracking
20+
-keepnames class com.flipcash.app.core.AppRoute
21+
-keepnames class com.flipcash.app.core.AppRoute$**
22+
1923
# Protobuf — keep all generated message classes and their builders.
2024
# Using type-hierarchy rules so new packages / updated gRPC stubs are
2125
# caught automatically instead of listing every gen package.

apps/flipcash/app/src/main/kotlin/com/flipcash/app/internal/ui/navigation/decorators/NavMessagingEntryDecorator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fun rememberNavMessagingEntryDecorator(
6767
) = remember { NavMessagingEntryDecorator(backStack, barManager) }
6868

6969
private fun NavKey.screenName(): String? {
70-
val prefix = AppRoute::class.qualifiedName ?: return null
71-
val qualifiedName = this::class.qualifiedName ?: return null
72-
return qualifiedName.removePrefix("$prefix.").takeIf { it != qualifiedName }
70+
val prefix = AppRoute::class.java.name
71+
val name = this::class.java.name
72+
return name.removePrefix("$prefix$").replace('$', '.').takeIf { it != name }
7373
}

libs/messaging/src/main/kotlin/com/getcode/manager/BottomBarManager.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,11 @@ object BottomBarManager {
291291
) {
292292
val callSite = Throwable().stackTrace
293293
.firstOrNull { it.className != BottomBarManager::class.java.name }
294-
?.let { "${it.fileName}:${it.lineNumber}" }
294+
?.let {
295+
val file = it.fileName
296+
?: it.className.substringAfterLast('.').substringBefore('$')
297+
"$file:${it.lineNumber}"
298+
}
295299

296300
showMessage(
297301
BottomBarMessage(

0 commit comments

Comments
 (0)