Skip to content

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

Open
patricio-posthog wants to merge 1 commit intomainfrom
feat/mixed-targeting-local-eval
Open

feat(flags): support mixed targeting in local evaluation#138
patricio-posthog wants to merge 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant