Skip to content

Commit

Permalink
Merge pull request #1829 from HedvigInsurance/refactor/remove_payment…
Browse files Browse the repository at this point in the history
…_type_from_hanalytics

Remove payment  type and loging method from hanalytics
  • Loading branch information
StylianosGakis authored Oct 16, 2023
2 parents 6c5cbcb + 257e7e9 commit 8ea2250
Show file tree
Hide file tree
Showing 27 changed files with 37 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ internal fun HedvigNavHost(
context.startActivity(
connectPayinIntent(
context,
featureManager.getPaymentType(),
market,
false,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private val repositoriesModule = module {
}

private val notificationModule = module {
single { PaymentNotificationSender(get(), get(), get(), get()) } bind NotificationSender::class
single { PaymentNotificationSender(get(), get(), get()) } bind NotificationSender::class
single { CrossSellNotificationSender(get(), get()) } bind NotificationSender::class
single { ChatNotificationSender(get(), get<HedvigDeepLinkContainer>()) } bind NotificationSender::class
single { ReferralsNotificationSender(get()) } bind NotificationSender::class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ class LoggedInActivity : AppCompatActivity() {
this@LoggedInActivity.startActivity(
connectPayinIntent(
this@LoggedInActivity,
featureManager.getPaymentType(),
market,
false,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.hedvig.app.feature.offer.usecase.ObserveOfferStateUseCase
import com.hedvig.app.feature.offer.usecase.OfferState
import com.hedvig.app.feature.offer.usecase.StartCheckoutUseCase
import com.hedvig.app.feature.perils.PerilItem
import com.hedvig.hanalytics.PaymentType
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -63,7 +62,6 @@ abstract class OfferViewModel : ViewModel() {
val startDate: LocalDate?,
val postSignScreen: PostSignScreen,
val bundleDisplayName: String,
val payinType: PaymentType,
) : Event()

object StartSwedishBankIdSign : Event()
Expand Down Expand Up @@ -249,7 +247,6 @@ class OfferViewModelImpl(
startDate = (it.bundle.inception.startDate as? OfferStartDate.AtDate)?.date,
postSignScreen = it.bundle.viewConfiguration.postSignScreen,
bundleDisplayName = it.bundle.name,
payinType = featureManager.getPaymentType(),
)
_events.send(event)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ class OfferActivity : AppCompatActivity(R.layout.activity_offer) {
startActivity(
connectPayinIntent(
this,
event.payinType,
market,
true,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import com.hedvig.android.market.Market
import com.hedvig.app.feature.adyen.AdyenCurrency
import com.hedvig.app.feature.adyen.payin.AdyenConnectPayinActivity
import com.hedvig.app.feature.trustly.TrustlyConnectPayinActivity
import com.hedvig.hanalytics.PaymentType

fun connectPayinIntent(
context: Context,
paymentType: PaymentType,
market: Market,
isPostSign: Boolean,
) = when (paymentType) {
PaymentType.ADYEN -> {
AdyenConnectPayinActivity.newInstance(context, AdyenCurrency.fromMarket(market), isPostSign)
}
PaymentType.TRUSTLY -> {
) = when (market) {
Market.SE -> {
TrustlyConnectPayinActivity.newInstance(context, isPostSign)
}
Market.NO,
Market.DK,
-> {
AdyenConnectPayinActivity.newInstance(context, AdyenCurrency.fromMarket(market), isPostSign)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class SwedishBankIdSignDialog : DialogFragment() {
startActivity(
connectPayinIntent(
requireContext(),
state.payinType,
marketManager.market.value,
true,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.hedvig.android.core.common.android.QuoteCartId
import com.hedvig.android.hanalytics.featureflags.FeatureManager
import com.hedvig.app.feature.offer.model.Checkout
import com.hedvig.app.feature.offer.usecase.ObserveQuoteCartCheckoutUseCase
import com.hedvig.hanalytics.PaymentType
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
Expand Down Expand Up @@ -39,7 +38,7 @@ class SwedishBankIdSignViewModel(
}
viewState is BankIdSignViewState.BankIdSuccess -> {
featureManager.invalidateExperiments()
_viewState.value = BankIdSignViewState.StartDirectDebit(featureManager.getPaymentType())
_viewState.value = BankIdSignViewState.StartDirectDebit
}
}
}
Expand Down Expand Up @@ -74,7 +73,7 @@ sealed interface BankIdSignViewState {
object Cancelled : BankIdSignViewState
data class Error(val message: String? = null) : BankIdSignViewState
object BankIdSuccess : BankIdSignViewState
data class StartDirectDebit(val payinType: PaymentType) : BankIdSignViewState
object StartDirectDebit : BankIdSignViewState
object Success : BankIdSignViewState

val shouldQueryForSignStatus: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.core.app.TaskStackBuilder
import com.google.firebase.messaging.RemoteMessage
import com.hedvig.android.core.common.ApplicationScope
import com.hedvig.android.core.common.android.notification.setupNotificationChannel
import com.hedvig.android.hanalytics.featureflags.FeatureManager
import com.hedvig.android.logger.LogPriority
import com.hedvig.android.logger.logcat
import com.hedvig.android.market.MarketManager
Expand All @@ -24,7 +23,6 @@ import kotlinx.coroutines.launch
class PaymentNotificationSender(
private val context: Context,
private val marketManager: MarketManager,
private val featureManager: FeatureManager,
private val applicationScope: ApplicationScope,
) : NotificationSender {
override fun createChannel() {
Expand Down Expand Up @@ -66,16 +64,13 @@ class PaymentNotificationSender(
addNextIntentWithParentStack(
connectPayinIntent(
context,
featureManager.getPaymentType(),
market,
false,
),
)
} catch (error: IllegalArgumentException) {
val paymentType = featureManager.getPaymentType()
logcat(LogPriority.ERROR) {
"Illegal market and payment type, could not create payin intent. " +
"Market: $market, PaymentType: $paymentType"
"Illegal market and payment type, could not create payin intent. Market: $market"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import assertk.assertions.prop
import com.hedvig.android.core.common.android.QuoteCartId
import com.hedvig.android.core.common.test.MainCoroutineRule
import com.hedvig.android.hanalytics.featureflags.test.FakeFeatureManager
import com.hedvig.android.hanalytics.featureflags.test.FakeFeatureManager2
import com.hedvig.app.feature.offer.model.Checkout
import com.hedvig.app.feature.offer.usecase.FakeObserveQuoteCartCheckoutUseCase
import com.hedvig.hanalytics.PaymentType
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
Expand All @@ -27,7 +27,7 @@ class SwedishBankIdSignViewModelTest {
val viewModel = SwedishBankIdSignViewModel(
QuoteCartId(""),
fakeObserveQuoteCartCheckoutUseCase,
FakeFeatureManager(paymentType = { enumValues<PaymentType>().random() }),
FakeFeatureManager2(),
)

viewModel.viewState.test {
Expand Down Expand Up @@ -56,7 +56,7 @@ class SwedishBankIdSignViewModelTest {
val viewModel = SwedishBankIdSignViewModel(
QuoteCartId(""),
fakeObserveQuoteCartCheckoutUseCase,
FakeFeatureManager(paymentType = { enumValues<PaymentType>().random() }),
FakeFeatureManager2(),
)

viewModel.viewState.test {
Expand Down Expand Up @@ -86,7 +86,7 @@ class SwedishBankIdSignViewModelTest {
val viewModel = SwedishBankIdSignViewModel(
QuoteCartId(""),
fakeObserveQuoteCartCheckoutUseCase,
FakeFeatureManager(paymentType = { enumValues<PaymentType>().random() }),
FakeFeatureManager2(),
)

viewModel.viewState.test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ data class MoveQuote(
),
documents = persistentListOf(),
),
displayItems = persistentListOf()
displayItems = persistentListOf(),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/feature/feature-forever/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ dependencies {
implementation(projects.coreBuildConstants)
implementation(projects.coreCommonAndroidPublic)
implementation(projects.coreCommonPublic)
implementation(projects.coreDemoMode)
implementation(projects.coreDesignSystem)
implementation(projects.coreIcons)
implementation(projects.coreResources)
implementation(projects.coreUi)
implementation(projects.coreUiData)
implementation(projects.dataForever)
implementation(projects.languageCore)
implementation(projects.coreDemoMode)
implementation(projects.moleculeAndroid)
implementation(projects.moleculePublic)
implementation(projects.navigationComposeTyped)
Expand Down
2 changes: 1 addition & 1 deletion app/feature/feature-home/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
implementation(projects.authAndroid)
implementation(projects.coreCommonAndroidPublic)
implementation(projects.coreCommonPublic)
implementation(projects.coreDemoMode)
implementation(projects.coreDesignSystem)
implementation(projects.coreIcons)
implementation(projects.coreResources)
Expand All @@ -52,7 +53,6 @@ dependencies {
implementation(projects.hanalyticsCore)
implementation(projects.hanalyticsFeatureFlagsPublic)
implementation(projects.languageCore)
implementation(projects.coreDemoMode)
implementation(projects.marketCore)
implementation(projects.memberRemindersPublic)
implementation(projects.memberRemindersUi)
Expand Down
3 changes: 2 additions & 1 deletion app/feature/feature-insurances/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
implementation(projects.apolloOctopusPublic)
implementation(projects.coreCommonAndroidPublic)
implementation(projects.coreCommonPublic)
implementation(projects.coreDemoMode)
implementation(projects.coreDesignSystem)
implementation(projects.coreIcons)
implementation(projects.coreResources)
Expand All @@ -43,7 +44,7 @@ dependencies {
implementation(projects.navigationCore)
implementation(projects.notificationBadgeDataPublic)
implementation(projects.pullrefresh)
implementation(projects.coreDemoMode)

testImplementation(libs.assertK)
testImplementation(libs.coroutines.test)
testImplementation(libs.junit)
Expand Down
2 changes: 1 addition & 1 deletion app/feature/feature-profile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ dependencies {
implementation(projects.coreCommonAndroidPublic)
implementation(projects.coreCommonPublic)
implementation(projects.coreDatastorePublic)
implementation(projects.coreDemoMode)
implementation(projects.coreDesignSystem)
implementation(projects.coreIcons)
implementation(projects.coreResources)
implementation(projects.coreUi)
implementation(projects.dataForever)
implementation(projects.dataSettingsDatastorePublic)
implementation(projects.coreDemoMode)
implementation(projects.hanalyticsCore)
implementation(projects.hanalyticsFeatureFlagsPublic)
implementation(projects.languageCore)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.hedvig.android.hanalytics.featureflags

import com.hedvig.android.hanalytics.featureflags.flags.FeatureFlagProvider
import com.hedvig.android.hanalytics.featureflags.loginmethod.LoginMethodProvider
import com.hedvig.android.hanalytics.featureflags.paymenttype.PaymentTypeProvider
import com.hedvig.android.hanalytics.featureflags.flags.Feature

interface FeatureManager : FeatureFlagProvider, LoginMethodProvider, PaymentTypeProvider {
interface FeatureManager {
suspend fun isFeatureEnabled(feature: Feature): Boolean
suspend fun invalidateExperiments()
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package com.hedvig.android.hanalytics.featureflags

import com.hedvig.android.hanalytics.featureflags.flags.FeatureFlagProvider
import com.hedvig.android.hanalytics.featureflags.loginmethod.LoginMethodProvider
import com.hedvig.android.hanalytics.featureflags.paymenttype.PaymentTypeProvider

internal class FeatureManagerImpl(
private val featureFlagProvider: FeatureFlagProvider,
private val loginMethodProvider: LoginMethodProvider,
private val paymentTypeProvider: PaymentTypeProvider,
private val clearHAnalyticsExperimentsCacheUseCase: ClearHAnalyticsExperimentsCacheUseCase,
) : FeatureManager,
FeatureFlagProvider by featureFlagProvider,
LoginMethodProvider by loginMethodProvider,
PaymentTypeProvider by paymentTypeProvider {
) : FeatureManager, FeatureFlagProvider by featureFlagProvider {

override suspend fun invalidateExperiments() {
clearHAnalyticsExperimentsCacheUseCase.invoke()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,26 @@ import com.hedvig.android.hanalytics.featureflags.FeatureManager
import com.hedvig.android.hanalytics.featureflags.FeatureManagerImpl
import com.hedvig.android.hanalytics.featureflags.flags.DevFeatureFlagProvider
import com.hedvig.android.hanalytics.featureflags.flags.FeatureFlagAuthEventListener
import com.hedvig.android.hanalytics.featureflags.flags.FeatureFlagProvider
import com.hedvig.android.hanalytics.featureflags.flags.HAnalyticsFeatureFlagProvider
import com.hedvig.android.hanalytics.featureflags.loginmethod.DevLoginMethodProvider
import com.hedvig.android.hanalytics.featureflags.loginmethod.HAnalyticsLoginMethodProvider
import com.hedvig.android.hanalytics.featureflags.paymenttype.DevPaymentTypeProvider
import com.hedvig.android.hanalytics.featureflags.paymenttype.HAnalyticsPaymentTypeProvider
import com.hedvig.android.market.MarketManager
import com.hedvig.hanalytics.HAnalytics
import org.koin.dsl.bind
import org.koin.dsl.module

@Suppress("RemoveExplicitTypeArguments")
val featureManagerModule = module {
single<ClearHAnalyticsExperimentsCacheUseCase> { ClearHAnalyticsExperimentsCacheUseCase(get()) }
single<FeatureManager> {
if (get<HedvigBuildConstants>().isDebug) {
FeatureManagerImpl(
DevFeatureFlagProvider(get()),
DevLoginMethodProvider(get()),
DevPaymentTypeProvider(get()),
get<ClearHAnalyticsExperimentsCacheUseCase>(),
)
val featureFlagProvider: FeatureFlagProvider = if (get<HedvigBuildConstants>().isDebug) {
DevFeatureFlagProvider(get<MarketManager>())
} else {
FeatureManagerImpl(
HAnalyticsFeatureFlagProvider(get()),
HAnalyticsLoginMethodProvider(get()),
HAnalyticsPaymentTypeProvider(get()),
get<ClearHAnalyticsExperimentsCacheUseCase>(),
)
HAnalyticsFeatureFlagProvider(get<HAnalytics>())
}
FeatureManagerImpl(
featureFlagProvider,
get<ClearHAnalyticsExperimentsCacheUseCase>(),
)
}
single<FeatureFlagAuthEventListener> {
FeatureFlagAuthEventListener(get<ClearHAnalyticsExperimentsCacheUseCase>())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.hedvig.android.hanalytics.featureflags.flags

interface FeatureFlagProvider {
internal interface FeatureFlagProvider {
suspend fun isFeatureEnabled(feature: Feature): Boolean
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.hedvig.android.hanalytics.featureflags.flags

import com.hedvig.hanalytics.ClaimType
import com.hedvig.hanalytics.HAnalytics

internal class HAnalyticsFeatureFlagProvider(
Expand All @@ -20,11 +19,7 @@ internal class HAnalyticsFeatureFlagProvider(
Feature.SHOW_BUSINESS_MODEL -> hAnalytics.showCharity()
Feature.TERMINATION_FLOW -> hAnalytics.terminationFlow()
Feature.UPDATE_NECESSARY -> hAnalytics.updateNecessary()
Feature.USE_NATIVE_CLAIMS_FLOW -> {
val useOdyssey = hAnalytics.claimsFlow()
hAnalytics.claimFlowType(if (useOdyssey) ClaimType.AUTOMATION else ClaimType.MANUAL)
useOdyssey
}
Feature.USE_NATIVE_CLAIMS_FLOW -> hAnalytics.claimsFlow()
Feature.NEW_MOVING_FLOW -> false
Feature.CLAIMS_TRIAGING -> hAnalytics.claimsTriaging()
Feature.TRAVEL_CERTIFICATE -> hAnalytics.travelInsurance()
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8ea2250

Please sign in to comment.