Skip to content

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

Open
patricio-posthog wants to merge 2 commits intomainfrom
feat/mixed-targeting-local-eval
Open

feat(flags): support mixed targeting in local evaluation#192
patricio-posthog wants to merge 2 commits 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., Temporal workflows).

💚 How did you test it?

Updated matchFeatureFlagProperties 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 TestMixedTargetingLocalEvaluation (4 parameterized cases) and TestMixedTargetingRolloutBucketing. All existing feature-flag tests continue to pass.

Ports posthog-python#523 to posthog-go.

📝 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 a version bump label: bump-patch, bump-minor, or bump-major

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

posthog-go Compliance Report

Date: 2026-04-28 16:14:11 UTC
Duration: 105909ms

⚠️ Some Tests Failed

29/30 tests passed, 1 failed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 609ms
Format Validation.Event Has Uuid 607ms
Format Validation.Event Has Lib Properties 607ms
Format Validation.Distinct Id Is String 607ms
Format Validation.Token Is Present 608ms
Format Validation.Custom Properties Preserved 607ms
Format Validation.Event Has Timestamp 606ms
Retry Behavior.Retries On 503 5612ms
Retry Behavior.Does Not Retry On 400 2610ms
Retry Behavior.Does Not Retry On 401 2610ms
Retry Behavior.Respects Retry After Header 5613ms
Retry Behavior.Implements Backoff 15622ms
Retry Behavior.Retries On 500 5612ms
Retry Behavior.Retries On 502 5613ms
Retry Behavior.Retries On 504 5613ms
Retry Behavior.Max Retries Respected 15613ms
Deduplication.Generates Unique Uuids 617ms
Deduplication.Preserves Uuid On Retry 5612ms
Deduplication.Preserves Uuid And Timestamp On Retry 10619ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5614ms
Deduplication.No Duplicate Events In Batch 611ms
Deduplication.Different Events Have Different Uuids 620ms
Compression.Sends Gzip When Enabled 607ms
Batch Format.Uses Proper Batch Structure 607ms
Batch Format.Flush With No Events Sends Nothing 605ms
Batch Format.Multiple Events Batched Together 611ms
Error Handling.Does Not Retry On 403 2609ms
Error Handling.Does Not Retry On 413 2610ms
Error Handling.Retries On 408 5613ms

Feature_Flags Tests

⚠️ 0/1 tests passed, 1 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 7ms

Failures

request_payload.request_with_person_properties_device_id

Field 'distinct_id' not found in /flags request body at path 'person_properties.distinct_id'. Available keys: ['$device_id']

@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
@patricio-posthog patricio-posthog added the release Add this label to trigger a release from a PR label Apr 30, 2026
@github-project-automation github-project-automation Bot moved this from In Review to Approved in Feature Flags Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Add this label to trigger a release from a PR

Projects

Status: Approved

Development

Successfully merging this pull request may close these issues.

2 participants