Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/flipcash/features/onramp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {

implementation(project(":apps:flipcash:shared:onramp:coinbase"))
implementation(project(":apps:flipcash:shared:onramp:deeplinks"))
implementation(project(":apps:flipcash:shared:analytics"))
implementation(project(":apps:flipcash:shared:router"))

implementation(project(":libs:crypto:solana"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.flipcash.app.onramp.internal

import androidx.lifecycle.viewModelScope
import com.flipcash.app.analytics.Analytics
import com.flipcash.app.analytics.FlipcashAnalyticsService
import com.flipcash.app.core.extensions.mapResult
import com.flipcash.app.core.extensions.onResult
import com.flipcash.app.core.ui.CurrencyHolder
Expand Down Expand Up @@ -81,6 +83,7 @@ internal class OnRampViewModel @Inject constructor(
tokenController: TokenController,
transactionController: TransactionOperations,
dispatchers: DispatcherProvider,
analytics: FlipcashAnalyticsService,
) : BaseViewModel2<OnRampViewModel.State, OnRampViewModel.Event>(
initialState = State(),
updateStateForEvent = updateStateForEvent,
Expand Down Expand Up @@ -344,8 +347,15 @@ internal class OnRampViewModel @Inject constructor(
amount = selectedAmount.localFiat.underlyingTokenAmount,
token = token,
verifiedFiat = selectedAmount,
).onFailure { error ->
).onSuccess {
analytics.buy(
method = Analytics.PurchaseMethod.Coinbase,
amount = selectedAmount.localFiat.nativeAmount,
mint = token.address,
)
}.onFailure { error ->
dispatchEvent(Event.UpdateConfirmingAmountState())

when (error) {
is OnRampAuthError.CoinbasePhoneVerificationRequired -> {
dispatchEvent(Event.OnVerificationNeeded(phone = true))
Expand Down Expand Up @@ -375,6 +385,13 @@ internal class OnRampViewModel @Inject constructor(
}

else -> {
analytics.buy(
method = Analytics.PurchaseMethod.Coinbase,
amount = selectedAmount.localFiat.nativeAmount,
mint = token.address,
error = error
)

BottomBarManager.showError(
title = "Something Went Wrong",
message = error.message ?: "Please try again",
Expand Down
Loading