Skip to content

Commit 9726bc0

Browse files
authored
Merge pull request #468 from code-payments/chore/onboarding-funnel-metrics
chore: dont trigger login event unless a login (e.g not for create ac…
2 parents 66ee7a8 + b03338f commit 9726bc0

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

app/src/main/java/com/getcode/manager/AuthManager.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,36 @@ class AuthManager @Inject constructor(
8686
return login(entropyB64, isSoftLogin = true)
8787
}
8888

89+
fun createAccount(
90+
entropyB64: String,
91+
rollbackOnError: Boolean = false,
92+
): Completable {
93+
if (entropyB64.isEmpty()) {
94+
taggedTrace("provided entropy was empty", type = TraceType.Error)
95+
sessionManager.clear()
96+
return Completable.complete()
97+
}
98+
99+
return Single.create {
100+
softLoginDisabled = true
101+
102+
if (!Database.isOpen()) {
103+
Database.init(context, entropyB64)
104+
}
105+
106+
val originalSessionState = SessionManager.authState.value
107+
sessionManager.set(entropyB64)
108+
109+
it.onSuccess(originalSessionState)
110+
}.flatMapCompletable {
111+
fetchAdditionalAccountData(context, entropyB64,
112+
isSoftLogin = false,
113+
rollbackOnError = rollbackOnError,
114+
originalSessionState = it
115+
)
116+
}.doOnError { softLoginDisabled = false }
117+
}
118+
89119
fun login(
90120
entropyB64: String,
91121
isSoftLogin: Boolean = false,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class AccessKeyViewModel @Inject constructor(
3939
fun onSubmit(navigator: CodeNavigator, isSaveImage: Boolean, isDeepLink: Boolean = false) {
4040
val entropyB64 = uiFlow.value.entropyB64 ?: return
4141

42-
authManager.login(entropyB64, rollbackOnError = isDeepLink)
42+
authManager.createAccount(entropyB64, rollbackOnError = isDeepLink)
4343
.observeOn(AndroidSchedulers.mainThread())
4444
.subscribeOn(Schedulers.computation())
4545
.doOnSubscribe {

0 commit comments

Comments
 (0)