diff --git a/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt b/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt index 44e88c77b8bd..404db6118fc5 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt @@ -214,7 +214,6 @@ import com.duckduckgo.duckplayer.api.PrivatePlayerMode.Disabled import com.duckduckgo.duckplayer.api.PrivatePlayerMode.Enabled import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory import com.duckduckgo.feature.toggles.api.FakeToggleStore -import com.duckduckgo.feature.toggles.api.FeatureToggle import com.duckduckgo.feature.toggles.api.FeatureToggles import com.duckduckgo.feature.toggles.api.Toggle import com.duckduckgo.feature.toggles.api.Toggle.State diff --git a/app/src/androidTest/java/com/duckduckgo/app/cta/ui/CtaViewModelTest.kt b/app/src/androidTest/java/com/duckduckgo/app/cta/ui/CtaViewModelTest.kt index 0813d400d6ac..136960f59f12 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/cta/ui/CtaViewModelTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/cta/ui/CtaViewModelTest.kt @@ -34,6 +34,7 @@ import com.duckduckgo.app.onboarding.store.AppStage import com.duckduckgo.app.onboarding.store.OnboardingStore import com.duckduckgo.app.onboarding.store.UserStageStore import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.ExtendedOnboardingFeatureToggles +import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.ExtendedOnboardingFeatureToggles.Cohorts import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.ExtendedOnboardingPixelsPlugin import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.HighlightsOnboardingExperimentManager import com.duckduckgo.app.pixels.AppPixelName.* @@ -46,6 +47,7 @@ import com.duckduckgo.app.statistics.pixels.Pixel.PixelType.Count import com.duckduckgo.app.statistics.pixels.Pixel.PixelType.Unique import com.duckduckgo.app.tabs.model.TabEntity import com.duckduckgo.app.tabs.model.TabRepository +import com.duckduckgo.app.trackerdetection.blocklist.BlockList.Cohorts.CONTROL import com.duckduckgo.app.trackerdetection.model.Entity import com.duckduckgo.app.trackerdetection.model.TrackerStatus import com.duckduckgo.app.trackerdetection.model.TrackerType @@ -62,6 +64,7 @@ import com.duckduckgo.duckplayer.api.PrivatePlayerMode.AlwaysAsk import com.duckduckgo.feature.toggles.api.FakeToggleStore import com.duckduckgo.feature.toggles.api.FeatureToggles import com.duckduckgo.feature.toggles.api.Toggle +import com.duckduckgo.feature.toggles.api.Toggle.State.Cohort import com.duckduckgo.subscriptions.api.Subscriptions import java.util.concurrent.TimeUnit import kotlinx.coroutines.FlowPreview @@ -855,6 +858,19 @@ class CtaViewModelTest { assertTrue(value is OnboardingDaxDialogCta.DaxExperimentFireButtonCta) } + @Test + fun givenPrivacyProExperimentWhenControlCohortThenAppendItToOriginForPrivacyProSubscriptionURL() = runTest { + val controlCohort = Cohort(Cohorts.CONTROL.cohortName, 1) + whenever(mockExtendedOnboardingFeatureToggles.testPrivacyProOnboardingCopyNov24().getCohort()).thenReturn(controlCohort) + + assertEquals(testee.getCohortOrigin(), "_control") + } + + @Test + fun whenPrivacyProExperimentIsDisabledThenCohortIsNotAppendToPrivacyProSubscriptionURL() = runTest { + assertEquals(testee.getCohortOrigin(), "") + } + private suspend fun givenDaxOnboardingActive() { whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage.DAX_ONBOARDING) } diff --git a/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt b/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt index 32798364f8f8..d0a16555ea2d 100644 --- a/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt +++ b/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt @@ -603,11 +603,12 @@ class CtaViewModel @Inject constructor( fun isSuggestedSiteOption(query: String): Boolean = onboardingStore.getSitesOptions().map { it.link }.contains(query) fun getCohortOrigin(): String { - return when { - extendedOnboardingFeatureToggles.testPrivacyProOnboardingCopyNov24().isEnabled(Cohorts.PROTECTION) -> "_${Cohorts.PROTECTION.cohortName}" - extendedOnboardingFeatureToggles.testPrivacyProOnboardingCopyNov24().isEnabled(Cohorts.PIR) -> "_${Cohorts.PIR.cohortName}" - extendedOnboardingFeatureToggles.testPrivacyProOnboardingCopyNov24().isEnabled(Cohorts.VPN) -> "_${Cohorts.VPN.cohortName}" - extendedOnboardingFeatureToggles.testPrivacyProOnboardingCopyNov24().isEnabled(Cohorts.CONTROL) -> "_${Cohorts.CONTROL.cohortName}" + val cohort = extendedOnboardingFeatureToggles.testPrivacyProOnboardingCopyNov24().getCohort() + return when (cohort?.name) { + Cohorts.PROTECTION.cohortName -> "_${Cohorts.PROTECTION.cohortName}" + Cohorts.PIR.cohortName -> "_${Cohorts.PIR.cohortName}" + Cohorts.VPN.cohortName -> "_${Cohorts.VPN.cohortName}" + Cohorts.CONTROL.cohortName -> "_${Cohorts.CONTROL.cohortName}" else -> "" } } diff --git a/app/src/main/java/com/duckduckgo/app/onboarding/ui/page/extendedonboarding/ExtendedOnboardingFeatureToggles.kt b/app/src/main/java/com/duckduckgo/app/onboarding/ui/page/extendedonboarding/ExtendedOnboardingFeatureToggles.kt index 16ea6e08fd8b..4bed5a41a07b 100644 --- a/app/src/main/java/com/duckduckgo/app/onboarding/ui/page/extendedonboarding/ExtendedOnboardingFeatureToggles.kt +++ b/app/src/main/java/com/duckduckgo/app/onboarding/ui/page/extendedonboarding/ExtendedOnboardingFeatureToggles.kt @@ -78,19 +78,19 @@ class ExtendedOnboardingPixelsPlugin @Inject constructor(private val toggle: Ext metric = "dialogShown", value = "1", toggle = toggle.testPrivacyProOnboardingCopyNov24(), - conversionWindow = listOf(ConversionWindow(lowerWindow = 0, upperWindow = Int.MAX_VALUE)), + conversionWindow = listOf(ConversionWindow(lowerWindow = 0, upperWindow = 1)), ), MetricsPixel( metric = "primaryButtonSelected", value = "1", toggle = toggle.testPrivacyProOnboardingCopyNov24(), - conversionWindow = listOf(ConversionWindow(lowerWindow = 0, upperWindow = Int.MAX_VALUE)), + conversionWindow = listOf(ConversionWindow(lowerWindow = 0, upperWindow = 1)), ), MetricsPixel( metric = "secondaryButtonSelected", value = "1", toggle = toggle.testPrivacyProOnboardingCopyNov24(), - conversionWindow = listOf(ConversionWindow(lowerWindow = 0, upperWindow = Int.MAX_VALUE)), + conversionWindow = listOf(ConversionWindow(lowerWindow = 0, upperWindow = 1)), ), ) }