Skip to content

Commit b442f91

Browse files
authored
Consider rollouts before assigning cohorts (#6138)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1198194956794324/task/1210380290910042?focus=true ### Description Before assigning any experiment cohort we need to make sure that the feature flag has entered rollout and targets do match, else cohort is not assigned. ### Steps to test this PR Code review and check end to end tests added. Alternatively or in addition, do the e2e tests using remote config (json blob etc)
1 parent b7d4535 commit b442f91

File tree

2 files changed

+610
-9
lines changed

2 files changed

+610
-9
lines changed

feature-toggles/feature-toggles-api/src/main/java/com/duckduckgo/feature/toggles/api/FeatureToggles.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,9 @@ internal class ToggleImpl constructor(
388388
val cohortDefaultValue = false
389389

390390
return store.get(key)?.let { state ->
391-
// appVersion should be above or equal to minSupportedVersion for the cohort to be assigned
392-
// we do not assign a cohort if the feature flag is not enabled remotely
393-
val updatedState = if (
394-
appVersionProvider.invoke() >= (state.minSupportedVersion ?: 0) &&
395-
state.remoteEnableState == true
396-
) {
391+
// the feature flag should be "rollout-enabled" before we assign cohorts
392+
// this means checking EVERYTHING we check when we call [isEnabled(ANY_COHORT)]
393+
val updatedState = if (isRolloutEnabled() == true) {
397394
// we assign cohorts if it hasn't been assigned before or if the cohort was removed from the remote config
398395
if (state.assignedCohort == null || !state.cohorts.map { it.name }.contains(state.assignedCohort.name)) {
399396
state.copy(assignedCohort = assignCohortRandomly(state.cohorts, state.targets)).also {

0 commit comments

Comments
 (0)