fix: Respect send_feature_flags=false and local eval when populating flags event properties#93
Merged
dustinbyrne merged 2 commits intomasterfrom Dec 17, 2025
Merged
Conversation
1. If `send_feature_flags` is not explicitly set to true, calls to `capture` will no longer add feature flag properties to an event, even when local evaluation is enabled. 2. Local evaluation is used to populate feature flag properties when local evaluation is enabled and `send_feature_flags` is true 3. As an indirect result, `$feature_flag_called` will no longer include other feature flag properties
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the handling of the send_feature_flags parameter in the capture method to properly respect when it's set to false (or not set at all), and to prioritize local evaluation when it's set to true. The changes ensure that:
- Feature flag properties are only added to events when
send_feature_flagsis explicitlytrue(not when omitted orfalse) - When
send_feature_flags=true, local evaluation is used first if available, falling back to API calls only if local flags aren't loaded - The
$feature_flag_calledevents no longer include other feature flag properties ($active_feature_flags,$feature/*)
Key changes:
- Modified the capture method logic to wrap all flag-fetching code within a strict check for
send_feature_flags === true - Reorganized the priority to prefer local evaluation over API calls when both are available
- Updated test expectations to reflect the new behavior where flag properties are not automatically added
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/Client.php | Refactored capture method to only add feature flag properties when send_feature_flags is explicitly true, and prioritize local evaluation over API calls |
| test/PostHogTest.php | Updated test expectations and added new test for send_feature_flags=false scenario |
| test/FeatureFlagTest.php | Updated expected payloads to remove $active_feature_flags from $feature_flag_called events |
| test/FeatureFlagLocalEvaluationTest.php | Updated expected payloads to remove flag properties from $feature_flag_called events |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If
send_feature_flagsis not explicitly set to true, calls tocapturewill no longer add feature flag properties to an event, even when local evaluation is enabled. In other words,send_feature_flags=falseis the default, and is respected.Local evaluation is used to populate feature flag properties when enabled and
send_feature_flagsis true. Previously, it'd make an API call, unlesssend_feature_flags=false.As an indirect result,
$feature_flag_calledwill no longer include other feature flag properties (i.e.,$active_feature_flags,$feature/*).Related to PostHog/posthog#31425