How to create flag dependencies on PostHog
Flag dependencies in PostHog allow you to control when feature flags are evaluated based on the state of other flags. You can create dependencies by accessing the flag settings and configuring prerequisite conditions that must be met before the dependent flag becomes active.
Prerequisites
- PostHog account with feature flags enabled
- At least two existing feature flags in your project
- Admin or write permissions for feature flags
- Basic understanding of feature flag logic
Step-by-Step Instructions
Navigate to Feature Flags
Select the Dependent Flag
Access Advanced Settings
Select Prerequisite Flag
Configure Dependency Conditions
- Flag is enabled - prerequisite flag must be on
- Flag is disabled - prerequisite flag must be off
- Flag matches variant - prerequisite flag must return a specific variant value
Set Fallback Behavior
- Return false - dependent flag will be disabled
- Return specific variant - dependent flag returns a predetermined value
- Skip evaluation - dependent flag won't be evaluated at all
Test the Dependency
Save and Deploy
Common Issues & Troubleshooting
Dependent flag not respecting prerequisites
Check that the prerequisite flag is properly enabled and targeting the same user segments. Verify the dependency condition logic matches your intended behavior.
Circular dependency error
Review your flag dependency chain to ensure no flags depend on each other in a loop. Use the Dependencies visualization to identify circular references and restructure accordingly.
Flag dependency not visible in dashboard
Ensure you have the latest PostHog version and refresh your browser. Check that you have sufficient permissions to view and modify flag dependencies in your project settings.
Performance issues with complex dependencies
Limit dependency chains to 2-3 levels deep and consider consolidating related flags. Use Flag insights to monitor evaluation times and optimize dependency structures.