Skip to content

Conversation

@dustinbyrne
Copy link
Contributor

@dustinbyrne dustinbyrne commented Dec 16, 2025

Summary

  • Fix capture() to respect send_feature_flags=False when local evaluation is enabled
  • Deprecate send_feature_flag_events parameter in get_feature_flag_payload() and default it to False

Problem

  1. When local evaluation was enabled (personal_api_key set and flags loaded), capture() automatically attached all locally-evaluated feature flags to events, ignoring the send_feature_flags parameter entirely.

  2. get_feature_flag_payload() was sending $feature_flag_called events by default, which is unexpected by current SDK standards.

Solution

  1. Removed the automatic flag evaluation block in capture() that ran unconditionally when self.feature_flags was populated. Flags are now only attached when send_feature_flags=True is explicitly passed.

  2. Changed send_feature_flag_events default to False in get_feature_flag_payload() and added a deprecation warning directing users to use get_feature_flag() if they need events, and remove the deprecated option.

Related to PostHog/posthog#31425

@dustinbyrne dustinbyrne requested a review from Copilot December 16, 2025 22:21
@dustinbyrne dustinbyrne marked this pull request as ready for review December 16, 2025 22:21
Copy link

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 a bug where the send_feature_flags parameter was ignored when local evaluation was enabled, and deprecates the send_feature_flag_events parameter in get_feature_flag_payload().

  • Removed automatic feature flag evaluation in capture() that ran unconditionally when local flags were loaded
  • Changed send_feature_flag_events default to False in get_feature_flag_payload() and added deprecation warning
  • Updated tests to explicitly pass send_feature_flag_events=True where event sending is expected

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
posthog/client.py Removed automatic local flag evaluation block in capture() method; changed default of send_feature_flag_events to False and added deprecation warning in get_feature_flag_payload()
posthog/test/test_client.py Added new test to verify send_feature_flags=False with local evaluation doesn't send flags; updated existing tests to pass send_feature_flags=True explicitly
posthog/test/test_feature_flags.py Renamed test to reflect new behavior of not sending events by default; updated tests to explicitly pass send_feature_flag_events=True where event capture is expected

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Collaborator

@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.

: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 80e6e43 into master Dec 17, 2025
24 checks passed
@dustinbyrne dustinbyrne deleted the fix/send-feature-flags-ff-called branch December 17, 2025 18:04
@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