Skip to content

Conversation

@dustinbyrne
Copy link
Contributor

@dustinbyrne dustinbyrne commented Dec 16, 2025

  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. In other words, send_feature_flags=false is the default, and is respected.

  2. Local evaluation is used to populate feature flag properties when enabled and send_feature_flags is true. Previously, it'd make an API call, unless send_feature_flags=false.

  3. As an indirect result, $feature_flag_called will no longer include other feature flag properties (i.e., $active_feature_flags, $feature/*).

Related to PostHog/posthog#31425

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
Copy link
Contributor

Copilot AI left a 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:

  1. Feature flag properties are only added to events when send_feature_flags is explicitly true (not when omitted or false)
  2. When send_feature_flags=true, local evaluation is used first if available, falling back to API calls only if local flags aren't loaded
  3. The $feature_flag_called events 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.

Copy link
Contributor

Copilot AI left a 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.

Copy link
Contributor

@haacked haacked left a 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. :shipit:

@github-project-automation github-project-automation bot moved this from In Review to Approved in Feature Flags Dec 17, 2025
@dustinbyrne dustinbyrne merged commit 1725145 into master Dec 17, 2025
21 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in Feature Flags Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants