Skip to content

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

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

feat(flags): support mixed targeting in local evaluation#134
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-php.

💚 How did you test it?

Updated FeatureFlag::matchFeatureFlagProperties to accept groups, groupProperties, and groupTypeMapping and 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 tests in FeatureFlagLocalEvaluationTest: 4 parameterized cases (person match, group match, no match, only-group-no-groups) plus a standalone rollout-bucketing case. All 254 existing tests continue to pass.

📝 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

  • Added the release label to the PR
  • Added exactly one version bump label: bump-patch, bump-minor, or bump-major

@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 a95b9de into main May 5, 2026
18 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