Skip to content

Commit

Permalink
Changed conversionWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
nalcalag committed Nov 19, 2024
1 parent a6ef1a5 commit 4687e7c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> ""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
),
)
}
Expand Down

0 comments on commit 4687e7c

Please sign in to comment.