|
1 | 1 | package com.flipcash.app.onramp.internal |
2 | 2 |
|
3 | 3 | import androidx.lifecycle.viewModelScope |
| 4 | +import com.flipcash.app.analytics.Analytics |
| 5 | +import com.flipcash.app.analytics.FlipcashAnalyticsService |
4 | 6 | import com.flipcash.app.core.extensions.mapResult |
5 | 7 | import com.flipcash.app.core.extensions.onResult |
6 | 8 | import com.flipcash.app.core.ui.CurrencyHolder |
@@ -81,6 +83,7 @@ internal class OnRampViewModel @Inject constructor( |
81 | 83 | tokenController: TokenController, |
82 | 84 | transactionController: TransactionOperations, |
83 | 85 | dispatchers: DispatcherProvider, |
| 86 | + analytics: FlipcashAnalyticsService, |
84 | 87 | ) : BaseViewModel2<OnRampViewModel.State, OnRampViewModel.Event>( |
85 | 88 | initialState = State(), |
86 | 89 | updateStateForEvent = updateStateForEvent, |
@@ -344,8 +347,15 @@ internal class OnRampViewModel @Inject constructor( |
344 | 347 | amount = selectedAmount.localFiat.underlyingTokenAmount, |
345 | 348 | token = token, |
346 | 349 | verifiedFiat = selectedAmount, |
347 | | - ).onFailure { error -> |
| 350 | + ).onSuccess { |
| 351 | + analytics.buy( |
| 352 | + method = Analytics.PurchaseMethod.Coinbase, |
| 353 | + amount = selectedAmount.localFiat.nativeAmount, |
| 354 | + mint = token.address, |
| 355 | + ) |
| 356 | + }.onFailure { error -> |
348 | 357 | dispatchEvent(Event.UpdateConfirmingAmountState()) |
| 358 | + |
349 | 359 | when (error) { |
350 | 360 | is OnRampAuthError.CoinbasePhoneVerificationRequired -> { |
351 | 361 | dispatchEvent(Event.OnVerificationNeeded(phone = true)) |
@@ -375,6 +385,13 @@ internal class OnRampViewModel @Inject constructor( |
375 | 385 | } |
376 | 386 |
|
377 | 387 | else -> { |
| 388 | + analytics.buy( |
| 389 | + method = Analytics.PurchaseMethod.Coinbase, |
| 390 | + amount = selectedAmount.localFiat.nativeAmount, |
| 391 | + mint = token.address, |
| 392 | + error = error |
| 393 | + ) |
| 394 | + |
378 | 395 | BottomBarManager.showError( |
379 | 396 | title = "Something Went Wrong", |
380 | 397 | message = error.message ?: "Please try again", |
|
0 commit comments