Skip to main content

Flag Targeting Depending On Other Flags

· 5 min read
Kenta Kozuka

This blog post will show you how to build flag settings depending on other flags. It will also clarify the difference between "prerequisite" and "targeting with other flags," which will provide you with a more flexible and complex feature flag rollout strategy.

Fine-Grained Control: Understanding Prerequisites and Flag Dependencies in Bucketeer

As a maintainer of Bucketeer, I'm always looking for ways to help you fine-tune your feature rollouts. Today, I'm going to clarify two powerful features that offer advanced targeting capabilities: prerequisites and targeting with other flags. While both involve using other feature flags to control how a target flag is evaluated, they function differently and serve distinct purposes.

Prerequisites: The Gatekeepers

Prerequisites act as gatekeepers for a target flag. When you set up a prerequisite, you're defining a condition that must be fully satisfied before the target flag is even considered for evaluation.

Here's a breakdown:

  • Conditional Evaluation: A target flag is only evaluated if the prerequisite flag's returned value matches the configured value.
  • Logical AND: If there are multiple prerequisite flags, they are evaluated using the logical AND operator. This means that all prerequisite conditions must be met.
  • Fallback to OFF: If any of the prerequisite conditions are not met, the user receives the OFF variation of the target flag, and no further targeting or rollout rules are evaluated.

In essence, prerequisites provide a binary decision - either all conditions are met, and the target flag is evaluated, or at least one prerequisite is not met, and the target flag is not evaluated, the user gets the OFF variation.

Targeting with other flags

Targeting with other flags, on the other hand, is one type of condition used within targeting rules. They are not gatekeepers, but rather, they are a way to define how a specific variation of the target flag is delivered depending on the variation of another feature flag.

Here's a breakdown:

  • Targeting Condition: Flag dependencies are used to determine which variation of a target flag a user will receive based on the evaluation of another flag.
  • Part of Targeting Logic: They are part of the targeting evaluation within a rollout rule that may also include user attributes, user segments, or date conditions.
  • Evaluated After Prerequisites: Flag dependency conditions are evaluated after the prerequisites are met and the switch is ON. If the prerequisites are not satisfied, the flag dependency condition will not be evaluated.
  • Part of complex rules: You can combine flag dependencies with other conditions, like user attributes, segments, or dates, to build very fine-grained control.

In short, targeting with other flags is used to create rules that target specific users based on other feature flag evaluations, and it is evaluated within a rule after the prerequisites are satisfied.

Key Differences Summarized

To clarify, let’s look at a table of key differences:

FeatureFunctionEvaluationFallback
PrerequisitesActs as a gatekeeper; determines if a target flag should be evaluated.Evaluated first before any targeting or rollout rules.OFF variation of the target flag.
Flag DependencyActs as a condition within a rule; determines which variation of a target flag to serve.Evaluated after prerequisites within targeting and rollout rules.Default or other variations based on the targeting and rollout rules

Practical Examples

So, in which case should we use prerequisite and targeting with other flags? We would recommend you to make a flag rollout strategy in the following.

#1: Think of using prerequisites

This is one example of using a prerequisite;

  1. You have a feature flag called "user-type" with variations "internal" and "external".
  2. You want to test a new feature called "new-admin-panel," and you want to use it only internally for internal users.
  3. You would set up "user-type" with the "internal" variation as a prerequisite for the "new-admin-panel" flag. Only if a user gets the "internal" variation on the "user-type" flag will the "new-admin-panel" be evaluated. If the user is "external", then the user will be served the OFF variation of "new-admin-panel" and there is no further evaluation for this flag.

#2: If the prerequisite cannot satisfy what you want, use targeting with other flags.

If you want to achieve a more complex targeting strategy, use targeting with other flags.

For example;

  • Using multiple flags in a condition
  • Combination other flags and additional conditions such as date, user attributes, or user segments

Important Considerations

  • Evaluation Order: Remember that prerequisites are evaluated before any targeting rules, including flag dependency conditions.
  • Complexity: While powerful, using too many prerequisites or flag dependencies can make your system difficult to manage.

Conclusion

Both prerequisites and Targeting with other flags provide robust capabilities for managing feature rollouts, but they address different needs. Prerequisites provide a way to gate the evaluation of a flag based on another flag, while targeting with other flags acts as conditions within targeting rules that determine the variation a user should receive. By understanding the nuances of these features, you can create highly tailored and effective feature rollouts in Bucketeer.