-
Notifications
You must be signed in to change notification settings - Fork 25
fix: Respect send_feature_flags=false and local eval when populating flags event properties
#93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
haacked
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing the lord's work. ![]()
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