Skip to content

feat(flags): support mixed targeting in local evaluation#138

Merged
patricio-posthog merged 1 commit intomainfrom
feat/mixed-targeting-local-eval
May 5, 2026
Merged

feat(flags): support mixed targeting in local evaluation#138
patricio-posthog merged 1 commit intomainfrom
feat/mixed-targeting-local-eval

Conversation

@patricio-posthog
Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Feature flags with "mixed targeting" (the feature-flag-mixed-targeting beta) allow different condition sets within a single flag to target different aggregation levels — some targeting users/persons, others targeting groups.

The SDK only reads aggregation_group_type_index at the flag level. For mixed flags this is null, so the SDK treats all conditions as person-targeted. Group conditions fail property matching and the SDK falls back to a server-side HTTP call. This breaks customers using flags in environments that cannot make HTTP calls (e.g., background workers).

Ports posthog-python#523 to posthog-ruby.

💚 How did you test it?

Updated match_feature_flag_properties to resolve aggregation per condition when a condition sets its own aggregation_group_type_index that differs from the flag level. Each condition uses the correct properties and bucketing value for its aggregation type. Backwards compatible with existing pure person and pure group flags.

Added 5 new RSpec examples covering: person condition match, group condition match, no match, only-group-condition-no-groups-passed, and rollout bucketing. All 359 existing specs continue to pass; rubocop clean.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file
  • Added the release label to the PR

@patricio-posthog patricio-posthog marked this pull request as ready for review April 29, 2026 13:44
@patricio-posthog patricio-posthog requested a review from a team as a code owner April 29, 2026 13:44
@posthog-project-board-bot posthog-project-board-bot Bot moved this to In Review in Feature Flags Apr 30, 2026
@github-project-automation github-project-automation Bot moved this from In Review to Approved in Feature Flags Apr 30, 2026
@patricio-posthog patricio-posthog merged commit fe7e453 into main May 5, 2026
17 checks passed
@patricio-posthog patricio-posthog deleted the feat/mixed-targeting-local-eval branch May 5, 2026 12:14
@github-project-automation github-project-automation Bot moved this from Approved to Done in Feature Flags May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants