Skip to content

Sense of Protection Experiemnt: Add new experiment names #6145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TrackersBlockingExperimentViewModel @Inject constructor(
viewModelScope.launch(dispatchers.io()) {
val enrollmentDateET = ZonedDateTime.now(ZoneId.of("America/New_York")).toString()
if (checked) {
senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().setRawStoredState(
senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -71,7 +71,7 @@ class TrackersBlockingExperimentViewModel @Inject constructor(
),
)
} else {
senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().setRawStoredState(
senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = false,
enable = false,
Expand All @@ -93,7 +93,7 @@ class TrackersBlockingExperimentViewModel @Inject constructor(
viewModelScope.launch(dispatchers.io()) {
val enrollmentDateET = ZonedDateTime.now(ZoneId.of("America/New_York")).toString()
if (checked) {
senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().setRawStoredState(
senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -106,7 +106,7 @@ class TrackersBlockingExperimentViewModel @Inject constructor(
),
)
} else {
senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().setRawStoredState(
senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = false,
enable = false,
Expand All @@ -128,7 +128,7 @@ class TrackersBlockingExperimentViewModel @Inject constructor(
viewModelScope.launch(dispatchers.io()) {
val enrollmentDateET = ZonedDateTime.now(ZoneId.of("America/New_York")).toString()
if (checked) {
senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().setRawStoredState(
senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -141,7 +141,7 @@ class TrackersBlockingExperimentViewModel @Inject constructor(
),
)
} else {
senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().setRawStoredState(
senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = false,
enable = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ class SenseOfProtectionExperimentImpl @Inject constructor(
}

private fun enrollInNewUserExperiment(cohortName: CohortName): Boolean {
return senseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().isEnabled(cohortName)
return senseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().isEnabled(cohortName)
}

private fun enrollInExistingUserExperiment(cohortName: CohortName): Boolean {
return senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().isEnabled(cohortName)
return senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().isEnabled(cohortName)
}

private fun isUserEnrolledInNewUserExperimentModifiedControlCohortAndExperimentEnabled(): Boolean =
Expand Down Expand Up @@ -183,22 +183,22 @@ class SenseOfProtectionExperimentImpl @Inject constructor(
}

private fun isNewUserExperimentEnabled(cohortName: CohortName): Boolean =
senseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().isEnrolledAndEnabled(cohortName)
senseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().isEnrolledAndEnabled(cohortName)

private fun isExistingUserExperimentEnabled(cohortName: CohortName): Boolean =
senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().isEnrolledAndEnabled(cohortName)
senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().isEnrolledAndEnabled(cohortName)

private fun getNewUserExperimentCohortName(): String? =
senseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().getCohort()?.name
senseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().getCohort()?.name

private fun getNewUserExperimentName(): String =
senseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().featureName().name
senseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().featureName().name

private fun getExistingUserExperimentCohortName(): String? =
senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().getCohort()?.name
senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().getCohort()?.name

private fun getExistingUserExperimentName(): String =
senseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().featureName().name
senseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().featureName().name

private fun MetricsPixel.fire() = getPixelDefinitions().forEach {
pixel.fire(it.pixelName, it.params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ interface SenseOfProtectionToggles {
fun self(): Toggle

@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun senseOfProtectionNewUserExperimentMay25(): Toggle
fun senseOfProtectionNewUserExperiment27May25(): Toggle

@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun senseOfProtectionExistingUserExperimentMay25(): Toggle
fun senseOfProtectionExistingUserExperiment27May25(): Toggle

enum class Cohorts(override val cohortName: String) : CohortName {
MODIFIED_CONTROL("modifiedControl"), // without grey tracker logos from original animation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class SenseOfProtectionCohortSurveyParameterPlugin @Inject constructor(
) : SurveyParameterPlugin {
override val surveyParamKey: String = "senseProtectionCohort"

override suspend fun evaluate(): String = senseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().getCohort()?.name.orEmpty()
override suspend fun evaluate(): String = senseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().getCohort()?.name.orEmpty()
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SenseOfProtectionExperimentImplTest {
fun `when user is new and and visual design updates not enabled then user can be enrolled`() {
whenever(mockExperimentDataStore.isExperimentEnabled).thenReturn(MutableStateFlow(false))
fakeUserBrowserProperties.setDaysSinceInstalled(28)
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -103,7 +103,7 @@ class SenseOfProtectionExperimentImplTest {
fun `when user is new and and visual design updates not enabled then user can't be enrolled`() {
whenever(mockExperimentDataStore.isExperimentEnabled).thenReturn(MutableStateFlow(true))
fakeUserBrowserProperties.setDaysSinceInstalled(28)
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -121,7 +121,7 @@ class SenseOfProtectionExperimentImplTest {
fun `when user is new and experiment is enabled but for different cohort then isEnabled returns false`() {
whenever(mockExperimentDataStore.isExperimentEnabled).thenReturn(MutableStateFlow(false))
fakeUserBrowserProperties.setDaysSinceInstalled(20)
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -137,7 +137,7 @@ class SenseOfProtectionExperimentImplTest {
fun `when user is new and experiment is disabled then isEnabled returns false`() {
whenever(mockExperimentDataStore.isExperimentEnabled).thenReturn(MutableStateFlow(false))
fakeUserBrowserProperties.setDaysSinceInstalled(10)
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = false,
enable = false,
Expand All @@ -151,7 +151,7 @@ class SenseOfProtectionExperimentImplTest {

@Test
fun `when user is enrolled in new user experiment then getTabManagerPixelParams returns new user experiment params`() {
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -163,12 +163,12 @@ class SenseOfProtectionExperimentImplTest {
val params = testee.getTabManagerPixelParams()

assertEquals(VARIANT_1.cohortName, params["cohort"])
assertEquals(fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().featureName().name, params["experiment"])
assertEquals(fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().featureName().name, params["experiment"])
}

@Test
fun `when user is enrolled in new user experiment but experiment is disabled then getTabManagerPixelParams returns empty map`() {
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = false,
enable = false,
Expand All @@ -184,7 +184,7 @@ class SenseOfProtectionExperimentImplTest {

@Test
fun `when user is enrolled in existing user experiment then getTabManagerPixelParams returns existing user experiment params`() {
fakeSenseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -196,12 +196,12 @@ class SenseOfProtectionExperimentImplTest {
val params = testee.getTabManagerPixelParams()

assertEquals(VARIANT_2.cohortName, params["cohort"])
assertEquals(fakeSenseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().featureName().name, params["experiment"])
assertEquals(fakeSenseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().featureName().name, params["experiment"])
}

@Test
fun `when user is enrolled in existing user experiment but experiment is disabled then getTabManagerPixelParams returns empty map`() {
fakeSenseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = false,
enable = false,
Expand All @@ -218,15 +218,15 @@ class SenseOfProtectionExperimentImplTest {
@Test
fun `when user is not enrolled in any experiment then getTabManagerPixelParams returns empty map`() {
fakeUserBrowserProperties.setDaysSinceInstalled(30)
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = false,
enable = false,
assignedCohort = null,
cohorts = emptyList(),
),
)
fakeSenseOfProtectionToggles.senseOfProtectionExistingUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionExistingUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = false,
enable = false,
Expand All @@ -242,7 +242,7 @@ class SenseOfProtectionExperimentImplTest {

@Test
fun `when user is enrolled in modified control variant then we can detect it`() {
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -260,7 +260,7 @@ class SenseOfProtectionExperimentImplTest {

@Test
fun `when user is enrolled in variant 1 then other variants are not enabled`() {
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -278,7 +278,7 @@ class SenseOfProtectionExperimentImplTest {

@Test
fun `when user is enrolled in variant 2 then other variants are not enabled`() {
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -297,7 +297,7 @@ class SenseOfProtectionExperimentImplTest {
@Test
fun `when user is enrolled in modified control then legacy privacy shield is shown`() {
fakeUserBrowserProperties.setDaysSinceInstalled(20)
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -312,7 +312,7 @@ class SenseOfProtectionExperimentImplTest {
@Test
fun `when user is not enrolled in any variant`() {
fakeUserBrowserProperties.setDaysSinceInstalled(20)
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -326,7 +326,7 @@ class SenseOfProtectionExperimentImplTest {
@Test
fun `when user is enrolled in variant 1 then new privacy shield is shown`() {
fakeUserBrowserProperties.setDaysSinceInstalled(20)
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand All @@ -341,7 +341,7 @@ class SenseOfProtectionExperimentImplTest {
@Test
fun `when user is enrolled in variant 2 then new privacy shield is shown`() {
fakeUserBrowserProperties.setDaysSinceInstalled(20)
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25().setRawStoredState(
fakeSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25().setRawStoredState(
State(
remoteEnableState = true,
enable = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TemporaryDefaultSurveyParametersPluginTest {
on { it.isEnabled() } doReturn true
on { it.getCohort() } doReturn modifiedControlCohort
}
whenever(mockSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25()).thenReturn(mockToggle)
whenever(mockSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25()).thenReturn(mockToggle)

val plugin = SenseOfProtectionCohortSurveyParameterPlugin(mockSenseOfProtectionToggles)

Expand All @@ -36,7 +36,7 @@ class TemporaryDefaultSurveyParametersPluginTest {
on { it.isEnabled() } doReturn true
on { it.getCohort() } doReturn modifiedControlCohort
}
whenever(mockSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25()).thenReturn(mockToggle)
whenever(mockSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25()).thenReturn(mockToggle)

val plugin = SenseOfProtectionCohortSurveyParameterPlugin(mockSenseOfProtectionToggles)

Expand All @@ -50,7 +50,7 @@ class TemporaryDefaultSurveyParametersPluginTest {
on { it.isEnabled() } doReturn true
on { it.getCohort() } doReturn modifiedControlCohort
}
whenever(mockSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25()).thenReturn(mockToggle)
whenever(mockSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25()).thenReturn(mockToggle)

val plugin = SenseOfProtectionCohortSurveyParameterPlugin(mockSenseOfProtectionToggles)

Expand All @@ -63,7 +63,7 @@ class TemporaryDefaultSurveyParametersPluginTest {
on { it.isEnabled() } doReturn false
on { it.getCohort() } doReturn null
}
whenever(mockSenseOfProtectionToggles.senseOfProtectionNewUserExperimentMay25()).thenReturn(mockToggle)
whenever(mockSenseOfProtectionToggles.senseOfProtectionNewUserExperiment27May25()).thenReturn(mockToggle)

val plugin = SenseOfProtectionCohortSurveyParameterPlugin(mockSenseOfProtectionToggles)

Expand Down
Loading
Loading