Skip to content

Commit 76b129c

Browse files
committed
Merge branch 'develop'
2 parents acac5c9 + 814189c commit 76b129c

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class AnalyticsManager @Inject constructor(
6363
)
6464
}
6565

66+
override fun unintentionalLogout() {
67+
track(Name.UnintentionalLogout)
68+
}
69+
70+
6671
override fun billTimeoutReached(
6772
kin: Kin,
6873
currencyCode: CurrencyCode,
@@ -238,6 +243,10 @@ class AnalyticsManager @Inject constructor(
238243
)
239244
}
240245

246+
override fun backgroundSwapInitiated() {
247+
track(Name.BackgroundSwap)
248+
}
249+
241250
private fun track(event: Name, vararg properties: Pair<Property, String>) {
242251
if (BuildConfig.DEBUG) {
243252
Timber.d("debug track $event, ${properties.map { "${it.first.name}, ${it.second}" }}")
@@ -259,6 +268,7 @@ class AnalyticsManager @Inject constructor(
259268
Logout("Logout"),
260269
Login("Login"),
261270
CreateAccount("Create Account"),
271+
UnintentionalLogout("Unintentional Logout"),
262272

263273
//Bill
264274
Bill("Bill"),
@@ -276,6 +286,7 @@ class AnalyticsManager @Inject constructor(
276286
UpgradePrivacy("Upgrade Privacy"),
277287
ClaimGetFreeKin("Claim Get Free Kin"),
278288
PrivacyMigration("Privacy Migration"),
289+
BackgroundSwap("Background Swap Initiated"),
279290

280291
// Errors
281292
ErrorRequest("Error Request"),

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ interface AnalyticsService {
4444
fun onBillReceived()
4545

4646
fun tipCardShown(username: String)
47+
48+
fun backgroundSwapInitiated()
49+
fun unintentionalLogout()
4750
}
4851

4952
class AnalyticsServiceNull : AnalyticsService {
@@ -85,4 +88,6 @@ class AnalyticsServiceNull : AnalyticsService {
8588
override fun upgradePrivacy(successful: Boolean, intentId: PublicKey, actionCount: Int) = Unit
8689
override fun onBillReceived() = Unit
8790
override fun tipCardShown(username: String) = Unit
91+
override fun backgroundSwapInitiated() = Unit
92+
override fun unintentionalLogout() = Unit
8893
}

api/src/main/java/com/getcode/network/repository/BetaFlagsRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ data class BetaOptions(
3232
buyModuleEnabled = true,
3333
establishCodeRelationship = false,
3434
chatUnsubEnabled = false,
35-
tipsEnabled = false,
35+
tipsEnabled = true,
3636
tipsChatEnabled = false,
3737
tipsChatCashEnabled = false,
3838
balanceCurrencySelectionEnabled = true

app/src/main/java/com/getcode/notifications/CodePushMessagingService.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.os.Build
99
import androidx.core.app.NotificationCompat
1010
import androidx.core.app.Person
1111
import com.getcode.R
12+
import com.getcode.analytics.AnalyticsService
1213
import com.getcode.manager.AuthManager
1314
import com.getcode.manager.SessionManager
1415
import com.getcode.model.notifications.NotificationType
@@ -42,6 +43,9 @@ import javax.inject.Inject
4243
class CodePushMessagingService : FirebaseMessagingService(),
4344
CoroutineScope by CoroutineScope(Dispatchers.IO) {
4445

46+
@Inject
47+
lateinit var analyticsService: AnalyticsService
48+
4549
@Inject
4650
lateinit var pushRepository: PushRepository
4751

@@ -102,12 +106,16 @@ class CodePushMessagingService : FirebaseMessagingService(),
102106
launch { historyController.fetchChats() }
103107
launch { balanceController.fetchBalanceSuspend() }
104108
}
109+
105110
NotificationType.ExecuteSwap -> {
106-
updateOrganizerAndSwap()
111+
analyticsService.backgroundSwapInitiated()
112+
updateOrganizerAndSwap()
107113
}
114+
108115
NotificationType.Twitter -> {
109116
launch { tipController.checkForConnection() }
110117
}
118+
111119
NotificationType.Unknown -> Unit
112120
}
113121
} else {
@@ -164,7 +172,7 @@ class CodePushMessagingService : FirebaseMessagingService(),
164172
person
165173
)
166174

167-
val style = notificationManager.getActiveNotification(title.hashCode())?.let {
175+
val style = notificationManager.getActiveNotification(title.hashCode())?.let {
168176
NotificationCompat.MessagingStyle.extractMessagingStyleFromNotification(it)
169177
} ?: NotificationCompat.MessagingStyle(person)
170178

@@ -199,7 +207,6 @@ class CodePushMessagingService : FirebaseMessagingService(),
199207
}
200208

201209

202-
203210
private fun NotificationManager.getActiveNotification(notificationId: Int): Notification? {
204211
val barNotifications = getActiveNotifications()
205212
for (notification in barNotifications) {

app/src/main/java/com/getcode/view/login/SeedInputViewModel.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.lifecycle.viewModelScope
66
import dagger.hilt.android.lifecycle.HiltViewModel
77
import com.getcode.App
88
import com.getcode.R
9+
import com.getcode.analytics.AnalyticsService
910
import com.getcode.crypt.MnemonicPhrase
1011
import com.getcode.manager.AccountManager
1112
import com.getcode.manager.AuthManager
@@ -40,6 +41,7 @@ data class SeedInputUiModel(
4041

4142
@HiltViewModel
4243
class SeedInputViewModel @Inject constructor(
44+
private val analyticsService: AnalyticsService,
4345
private val authManager: AuthManager,
4446
private val resources: ResourceHelper,
4547
private val mnemonicManager: MnemonicManager,
@@ -52,6 +54,7 @@ class SeedInputViewModel @Inject constructor(
5254
viewModelScope.launch {
5355
val token = accountManager.getToken()
5456
if (token != null) {
57+
analyticsService.unintentionalLogout()
5558
ErrorUtils.handleError(
5659
Throwable("We shouldn't be here. Login screen visible with associated account in AccountManager.")
5760
)

app/src/main/java/com/getcode/view/main/giveKin/GiveKinSheetViewModel.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,11 @@ class GiveKinSheetViewModel @Inject constructor(
110110
if (checkBalanceLimit() || checkSendLimit()) return null
111111

112112
val amountFiat = uiModel.amountModel.amountDouble
113-
val amountKin = uiModel.amountModel.amountKin
114-
115-
val currencyCode = CurrencyCode
116-
.tryValueOf(uiModel.currencyModel.selectedCurrency?.code) ?: return null
117113

118114
exchange.fetchRatesIfNeeded()
119-
val rate = exchange.rateFor(currencyCode) ?: return null
115+
val rate = exchange.entryRate
120116

121-
return KinAmount.fromFiatAmount(amountKin, amountFiat, rate.fx, currencyCode)
117+
return KinAmount.fromFiatAmount(amountFiat, rate)
122118
}
123119

124120
override fun onAmountChanged(lastPressedBackspace: Boolean) {

0 commit comments

Comments
 (0)