-
Notifications
You must be signed in to change notification settings - Fork 49
Stop capturing all feature flags on $feature_flag_called event.
#181
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
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.
PR Summary
This PR fixes an issue where the PostHog Python client was incorrectly enriching feature flag events with all cached flags, leading to potential data inconsistencies and unclear flag evaluation tracking.
- Modifies
client.get_feature_flagto prevent enriching$feature_flag_calledevents with all cached feature flags - Adds test case
test_capture_is_called_but_does_not_add_all_flagsto verify only specific flag data is included - Fixes inconsistency where enriched data didn't use original person properties from
get_feature_flag - Addresses hidden issue that wasn't caught by existing tests due to mocked capture calls
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
|
This change should probably be applied to all the other client libraries. |
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.
I think this is a reasonable change, and the implementation + test makes sense. Two follow-up questions from my perspective:
- does this behavior exist for all SDKs (at the very least, the most popular ones that aren't python (web, posthog-js-lite, and Android)?
- what's the documentation story behind this? My guess is we don't have this documented; if that's the case, I think it's worth adding docs around this. If we do have it documented, we'd need to update the docs. Overall, it feels like docs around how we emit posthog events seems like a smart thing to do
It may make sense to amend that to be more correct. Something like:
I can certainly follow-up with the documentation and the other libraries. But that probably shouldn't hold up this change. |
|
Awesome, your investigation makes sense, and agreed that it's not blocking for this, just wanted to get an idea of the scope. |
The
client.get_feature_flagmethod will by default callclient.capturewith the event named$feature_flag_called.Some time ago (in e60d52c), the
capturemethod was changed to enrich the event with all locally cached feature flags even ifsend_feature_flagsisFalse.What this leads to is
client.get_feature_flag->client.capture->client.get_all_flags. But the call toclient.get_all_flagsisn't passed the originalperson_propertiesthat were passed toclient.get_feature_flag. This leads to inconsistency in the enriched data. This can also cause confusion because it's unclear which feature flag is the one being called because the event adds "all" the locally cached feature flags.This PR takes the simplest path by not enriching the captured event with all feature flags for the
$feature_flag_calledevent.Note that this didn't show up in the tests because most of the tests of
get_feature_flagapply@mock.patch.object(Client, "capture")to the test, which hides this unexpected behavior.