Skip to content

Commit 35c3122

Browse files
committed
chore: add withdrawal analytics
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 6916daf commit 35c3122

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

api/src/main/java/com/getcode/analytics/AnalyticsManager.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ class AnalyticsManager @Inject constructor(
246246
)
247247
}
248248

249+
override fun withdrawal(amount: KinAmount, successful: Boolean) {
250+
track(
251+
Name.Withdrawal,
252+
Property.State to if (successful) StringValue.Success.value else StringValue.Failure.value,
253+
Property.Amount to amount.kin.toKin().toInt().toString(),
254+
Property.Fiat to amount.fiat.toString(),
255+
Property.Fx to amount.rate.fx.toString(),
256+
Property.Currency to amount.rate.currency.name,
257+
)
258+
}
259+
249260
override fun onBillReceived() {
250261
Timber.i("Bill scanned. From start: " + (System.currentTimeMillis() - (timeAppInit ?: 0)))
251262
}
@@ -326,6 +337,7 @@ class AnalyticsManager @Inject constructor(
326337
ClaimGetFreeKin("Claim Get Free Kin"),
327338
PrivacyMigration("Privacy Migration"),
328339
BackgroundSwap("Background Swap Initiated"),
340+
Withdrawal("Withdrawal"),
329341

330342
// Errors
331343
ErrorRequest("Error Request"),

api/src/main/java/com/getcode/analytics/AnalyticsService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ interface AnalyticsService {
4242
fun migration(amount: Kin)
4343
fun upgradePrivacy(successful: Boolean, intentId: PublicKey, actionCount: Int)
4444
fun onBillReceived()
45+
fun withdrawal(amount: KinAmount, successful: Boolean)
4546

4647
fun tipCardShown(username: String)
4748

@@ -77,6 +78,7 @@ class AnalyticsServiceNull : AnalyticsService {
7778
override fun transfer(amount: KinAmount, successful: Boolean) = Unit
7879
override fun transferForRequest(amount: KinAmount, successful: Boolean) = Unit
7980
override fun transferForTip(amount: KinAmount, successful: Boolean) = Unit
81+
override fun withdrawal(amount: KinAmount, successful: Boolean) = Unit
8082

8183
override fun remoteSendOutgoing(kin: Kin, currencyCode: CurrencyCode) = Unit
8284
override fun remoteSendIncoming(kin: Kin, currencyCode: CurrencyCode, isVoiding: Boolean) = Unit

app/src/main/java/com/getcode/view/main/account/withdraw/AccountWithdrawSummaryViewModel.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.getcode.view.main.account.withdraw
33
import android.annotation.SuppressLint
44
import androidx.lifecycle.viewModelScope
55
import com.getcode.R
6+
import com.getcode.analytics.AnalyticsService
67
import com.getcode.solana.keys.PublicKey
78
import com.getcode.manager.BottomBarManager
89
import com.getcode.manager.SessionManager
@@ -41,6 +42,7 @@ data class AccountWithdrawSummaryUiModel(
4142

4243
@HiltViewModel
4344
class AccountWithdrawSummaryViewModel @Inject constructor(
45+
private val analytics: AnalyticsService,
4446
private val client: Client,
4547
private val historyController: HistoryController,
4648
private val resources: ResourceHelper,
@@ -117,6 +119,8 @@ class AccountWithdrawSummaryViewModel @Inject constructor(
117119
)
118120
)
119121

122+
analytics.withdrawal(amount = amount, successful = true)
123+
120124
navigator.replaceAll(HomeScreen())
121125

122126
uiFlow.value = uiFlow.value.copy(isSuccess = true)
@@ -127,6 +131,7 @@ class AccountWithdrawSummaryViewModel @Inject constructor(
127131
getString(R.string.error_description_failedWithdrawal)
128132
)
129133
)
134+
analytics.withdrawal(amount = amount, successful = false)
130135
ErrorUtils.handleError(it)
131136
})
132137
}

0 commit comments

Comments
 (0)