Skip to content

feat(flags): Add flag dependencies support for local feature flag evaluation#75

Merged
haacked merged 5 commits intomainfrom
haacked/flag-dependencies-local-eval
Aug 26, 2025
Merged

feat(flags): Add flag dependencies support for local feature flag evaluation#75
haacked merged 5 commits intomainfrom
haacked/flag-dependencies-local-eval

Conversation

@haacked
Copy link
Copy Markdown
Contributor

@haacked haacked commented Aug 26, 2025

Implement local evaluation of feature flag dependencies by adding support for flag properties with type="flag" and dependency_chain arrays.

@haacked haacked requested a review from Copilot August 26, 2025 00:43

This comment was marked as outdated.

@haacked haacked requested a review from a team August 26, 2025 00:59
@dmarticus dmarticus moved this to In Review in Feature Flags Aug 26, 2025
@haacked haacked force-pushed the haacked/flag-dependencies-local-eval branch from e0ca5dd to f3f1ce7 Compare August 26, 2025 04:48
@haacked haacked requested a review from Copilot August 26, 2025 04:54

This comment was marked as outdated.

@haacked haacked force-pushed the haacked/flag-dependencies-local-eval branch from f3f1ce7 to 8e19bf3 Compare August 26, 2025 15:46
Implement local evaluation of feature flag dependencies by adding support for flag properties with type="flag" and dependency_chain arrays.
Added two new examples demonstrating complex multivariate flag dependency
chains that were ported from the Python SDK:

1. Pineapple chain: pineapple@example.com -> blue -> breaking-bad
2. Mango chain: mango@example.com -> red -> the-wire

These examples showcase the multivariate flag dependencies feature that
was recently implemented and demonstrate local evaluation of complex
dependency chains without requiring HTTP requests.

Changes:
- Added examples to both main section (case 4) and "run all" section (case 6)
- Used proper Ruby syntax with named parameters for client methods
- Added success/failure validation with expected vs actual value reporting
@haacked haacked force-pushed the haacked/flag-dependencies-local-eval branch from 8e19bf3 to 267f998 Compare August 26, 2025 15:49
@haacked haacked requested a review from Copilot August 26, 2025 15:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements local evaluation of feature flag dependencies in the PostHog Ruby SDK by adding support for flag properties with type="flag" and dependency_chain arrays. The feature enables evaluating flags that depend on other flags without requiring remote API calls.

  • Adds comprehensive flag dependency evaluation logic with circular dependency detection
  • Implements matches_dependency_value method for comparing expected vs actual flag values
  • Adds extensive test coverage for various dependency scenarios including complex multivariate chains

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/posthog/feature_flags.rb Core implementation of flag dependency evaluation with new helper methods
spec/posthog/flags_spec.rb Comprehensive test suite for flag dependencies including edge cases
spec/posthog/feature_flag_spec.rb Removes old test that was replaced by new dependency implementation
example.rb Updates example script with flag dependency demonstrations and env var name changes
.env.example Updates environment variable name for consistency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread lib/posthog/feature_flags.rb Outdated
Comment thread lib/posthog/feature_flags.rb
Comment thread lib/posthog/feature_flags.rb
haacked and others added 2 commits August 26, 2025 08:56
And remove the TODO comment.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-project-automation github-project-automation Bot moved this from In Review to Approved in Feature Flags Aug 26, 2025
@haacked haacked merged commit 39a2770 into main Aug 26, 2025
7 checks passed
@haacked haacked deleted the haacked/flag-dependencies-local-eval branch August 26, 2025 21:57
@github-project-automation github-project-automation Bot moved this from Approved to Done in Feature Flags Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants