Updated on 2026-08-14
This commit is contained in:
parent
bfd2daa0b8
commit
0308841aa0
5 changed files with 28 additions and 29 deletions
|
|
@ -2,7 +2,7 @@ package com.tangem.feature.learn2earn.analytics
|
|||
|
||||
import com.tangem.core.analytics.AnalyticsEvent
|
||||
|
||||
sealed class Learn2earnEvents(
|
||||
internal sealed class Learn2earnEvents(
|
||||
category: String,
|
||||
event: String,
|
||||
params: Map<String, String> = mapOf(),
|
||||
|
|
@ -58,10 +58,10 @@ sealed class Learn2earnEvents(
|
|||
}
|
||||
}
|
||||
|
||||
sealed class AnalyticsParam {
|
||||
internal sealed class AnalyticsParam {
|
||||
sealed class ClientType(val value: String) {
|
||||
object New : ClientType("New")
|
||||
object Old : ClientType("Old")
|
||||
class New : ClientType("New")
|
||||
class Old : ClientType("Old")
|
||||
}
|
||||
|
||||
companion object Key {
|
||||
|
|
|
|||
|
|
@ -205,10 +205,10 @@ internal class DefaultLearn2earnInteractor(
|
|||
WebViewResult.ReadyForAward -> {
|
||||
updateUserData { it.copy(isRegisteredInPromotion = true) }
|
||||
}
|
||||
is WebViewResult.AnalyticsEvent -> {
|
||||
is WebViewResult.Learn2earnAnalyticsEvent -> {
|
||||
analyticsEventHandler.send(result.event)
|
||||
}
|
||||
else -> Unit
|
||||
WebViewResult.Empty -> Unit
|
||||
}
|
||||
webViewResultHandler?.handleResult(result)
|
||||
|
||||
|
|
@ -286,21 +286,21 @@ internal class DefaultLearn2earnInteractor(
|
|||
repository.updateUserData(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Promotion.PromotionInfo.getData(promoCode: String?): PromotionInfoResponse.Data {
|
||||
return if (promoCode == null) {
|
||||
newCard
|
||||
} else {
|
||||
oldCard
|
||||
private fun Promotion.PromotionInfo.getData(promoCode: String?): PromotionInfoResponse.Data {
|
||||
return if (promoCode == null) {
|
||||
newCard
|
||||
} else {
|
||||
oldCard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun WebViewResult.toWebViewAction(): WebViewAction {
|
||||
return when (this) {
|
||||
WebViewResult.Empty -> WebViewAction.PROCEED
|
||||
WebViewResult.ReadyForAward -> WebViewAction.FINISH_SESSION
|
||||
is WebViewResult.AnalyticsEvent -> WebViewAction.NOTHING
|
||||
is WebViewResult.PromoCode -> WebViewAction.NOTHING
|
||||
private fun WebViewResult.toWebViewAction(): WebViewAction {
|
||||
return when (this) {
|
||||
WebViewResult.Empty -> WebViewAction.PROCEED
|
||||
WebViewResult.ReadyForAward -> WebViewAction.FINISH_SESSION
|
||||
is WebViewResult.Learn2earnAnalyticsEvent -> WebViewAction.NOTHING
|
||||
is WebViewResult.PromoCode -> WebViewAction.NOTHING
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ internal class WebViewUriParser(
|
|||
if (event == null) {
|
||||
WebViewResult.Empty
|
||||
} else {
|
||||
WebViewResult.AnalyticsEvent(event)
|
||||
WebViewResult.Learn2earnAnalyticsEvent(event)
|
||||
}
|
||||
}
|
||||
isPromoCodeRedirect(uri) -> {
|
||||
|
|
@ -68,8 +68,8 @@ internal class WebViewUriParser(
|
|||
|
||||
val analyticsEvent = when (event) {
|
||||
EVENT_PROMO_BUY -> PromoScreen.ButtonBuy()
|
||||
EVENT_PROMO_SUCCESS_NEW_USER -> PromoScreen.SuccessScreenOpened(AnalyticsParam.ClientType.New)
|
||||
EVENT_PROMO_SUCCESS_OLD_USER -> PromoScreen.SuccessScreenOpened(AnalyticsParam.ClientType.Old)
|
||||
EVENT_PROMO_SUCCESS_NEW_USER -> PromoScreen.SuccessScreenOpened(AnalyticsParam.ClientType.New())
|
||||
EVENT_PROMO_SUCCESS_OLD_USER -> PromoScreen.SuccessScreenOpened(AnalyticsParam.ClientType.Old())
|
||||
else -> null
|
||||
}
|
||||
return analyticsEvent
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.feature.learn2earn.domain.api
|
||||
|
||||
import com.tangem.feature.learn2earn.analytics.Learn2earnEvents
|
||||
import com.tangem.core.analytics.AnalyticsEvent
|
||||
|
||||
/**
|
||||
* Handler that helps determine a result of the Learn2earnWebViewActivity webView actions.
|
||||
|
|
@ -15,5 +15,5 @@ sealed class WebViewResult {
|
|||
object Empty : WebViewResult()
|
||||
data class PromoCode(val promoCode: String) : WebViewResult()
|
||||
object ReadyForAward : WebViewResult()
|
||||
data class AnalyticsEvent(val event: Learn2earnEvents) : WebViewResult()
|
||||
data class Learn2earnAnalyticsEvent(val event: AnalyticsEvent) : WebViewResult()
|
||||
}
|
||||
|
|
@ -73,13 +73,13 @@ class Learn2earnViewModel @Inject constructor(
|
|||
|
||||
private fun onButtonMainClick() {
|
||||
if (!interactor.isUserHadPromoCode() && !interactor.isUserRegisteredInPromotion()) {
|
||||
analytics.send(Learn2earnEvents.MainScreen.NoticeLear2earn(AnalyticsParam.ClientType.New))
|
||||
analytics.send(Learn2earnEvents.MainScreen.NoticeLear2earn(AnalyticsParam.ClientType.New()))
|
||||
subscribeToWebViewResultEvents()
|
||||
router.openWebView(interactor.buildUriForOldUser(), interactor.getBasicAuthHeaders())
|
||||
return
|
||||
}
|
||||
|
||||
analytics.send(Learn2earnEvents.MainScreen.NoticeLear2earn(AnalyticsParam.ClientType.Old))
|
||||
analytics.send(Learn2earnEvents.MainScreen.NoticeLear2earn(AnalyticsParam.ClientType.Old()))
|
||||
viewModelScope.launch(dispatchers.io) {
|
||||
updateUi { uiState.updateProgress(showProgress = true) }
|
||||
|
||||
|
|
@ -172,9 +172,8 @@ class Learn2earnViewModel @Inject constructor(
|
|||
interactor.webViewResultHandler = object : WebViewResultHandler {
|
||||
override fun handleResult(result: WebViewResult) {
|
||||
interactor.webViewResultHandler = null
|
||||
when (result) {
|
||||
WebViewResult.ReadyForAward -> updateMainScreenViews()
|
||||
else -> Unit
|
||||
if (result is WebViewResult.ReadyForAward) {
|
||||
updateMainScreenViews()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue