Skip to content

Commit 26faea5

Browse files
committed
chore: track possible dead ends for cash link claims for metrics
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 238a5d9 commit 26faea5

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

apps/flipcash/core/src/main/kotlin/com/flipcash/app/core/navigation/DeeplinkType.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import kotlinx.parcelize.Parcelize
1515
sealed interface DeeplinkType: Parcelable {
1616
sealed interface Navigatable
1717
data class Login(val entropy: String) : DeeplinkType
18-
data class CashLink(val entropy: String) : DeeplinkType
18+
data class CashLink(val entropy: String = "") : DeeplinkType
1919

2020
data class TokenInfo(val mint: Mint): DeeplinkType, Navigatable
2121

apps/flipcash/features/scanner/src/main/kotlin/com/flipcash/app/scanner/internal/NavigationStateRestorer.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.flipcash.app.scanner.internal
22

33
import cafe.adriel.voyager.core.registry.ScreenRegistry
4+
import com.flipcash.app.analytics.FlipcashAnalyticsService
45
import com.flipcash.app.core.AppRoute
56
import com.flipcash.app.core.navigation.DeeplinkType
67
import com.flipcash.app.core.onramp.deeplinks.OnRampDeeplinkOrigin
@@ -13,6 +14,7 @@ import kotlinx.coroutines.delay
1314

1415
class NavigationStateRestorer(
1516
private val navigator: CodeNavigator,
17+
private val analytics: FlipcashAnalyticsService,
1618
) {
1719
suspend fun restoreState(deeplink: DeeplinkType.Navigatable, animationScale: Float) {
1820
when (deeplink) {
@@ -79,7 +81,10 @@ class NavigationStateRestorer(
7981
}
8082

8183
if (screens.isNotEmpty()) {
84+
analytics.deeplinkRouted(deeplink)
8285
navigator.show(screens)
86+
} else {
87+
analytics.deeplinkRouted(deeplink, IllegalStateException("Failed to route deeplink"))
8388
}
8489
}
8590
}

apps/flipcash/features/scanner/src/main/kotlin/com/flipcash/app/scanner/internal/ScannerDeepLinkHandler.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ internal fun ScannerDeepLinkHandler(
2929

3030
val animationScale by rememberAnimationScale()
3131

32-
val stateRestorer = remember(navigator) {
33-
NavigationStateRestorer(navigator)
32+
val stateRestorer = remember(navigator, analytics) {
33+
NavigationStateRestorer(navigator, analytics)
3434
}
3535

3636
LaunchedEffect(biometricsState, previewing) {
@@ -56,7 +56,6 @@ internal fun ScannerDeepLinkHandler(
5656
}
5757
is DeeplinkType.Login -> Unit
5858
is DeeplinkType.Navigatable -> {
59-
analytics.deeplinkRouted(link)
6059
stateRestorer.restoreState(link, animationScale)
6160
}
6261
}

apps/flipcash/shared/session/src/main/kotlin/com/flipcash/app/session/internal/RealSessionController.kt

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,21 +689,41 @@ class RealSessionController @Inject constructor(
689689
override fun openCashLink(cashLink: String?) {
690690
BottomBarManager.clear()
691691

692-
val entropy = cashLink?.trim()?.replace("\n", "") ?: return
693-
val owner = userManager.accountCluster ?: return
692+
val entropy = cashLink?.trim()?.replace("\n", "")
693+
if (entropy == null) {
694+
trace(
695+
tag = "Session",
696+
message = "Cash link not provided",
697+
type = TraceType.Silent
698+
)
699+
analytics.deeplinkRouted(DeeplinkType.CashLink(), error = IllegalArgumentException("Cash link not provided"))
700+
return
701+
}
702+
val owner = userManager.accountCluster
703+
704+
if (owner == null) {
705+
trace(
706+
tag = "Session",
707+
message = "No owner found",
708+
type = TraceType.Silent
709+
)
710+
analytics.deeplinkRouted(DeeplinkType.CashLink(), error = IllegalStateException("No owner found"))
711+
return
712+
}
694713

695714
if (entropy.isEmpty()) {
696715
trace(
697716
tag = "Session",
698717
message = "Cash link empty",
699718
type = TraceType.Silent
700719
)
720+
analytics.deeplinkRouted(DeeplinkType.CashLink(), error = IllegalArgumentException("Cash link empty"))
701721
return
702722
}
703723

704724
if (giftCardClaimInProgress.value == null) {
705725
giftCardClaimInProgress.value = entropy
706-
analytics.deeplinkRouted(DeeplinkType.CashLink(entropy))
726+
analytics.deeplinkRouted(DeeplinkType.CashLink()) // entropy omitted since not needed for analytics
707727
claimGiftCard(owner = owner, entropy = entropy, claimIfOwned = false)
708728
}
709729
}

0 commit comments

Comments
 (0)