feat(hogql): Add feature flag for opting queries into v3 persons-on-events #21150
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.
Problem
See #20460 and PostHog/product-internal#557 for context.
Changes
This adds a feature flag for opting teams/organizations into PoE v3.
Rather than being part of the
posthog.utils.PersonOnEventsMode
enum which applies to all (or at least most) queries, v3 only is available in HogQL viaposthog.schema.PersonsOnEventsMode
, so this is handled when determining the HogQL modifiers for a team, rather than as part ofTeam.person_on_events_mode
which might be expected.This also means that until all queries are run via HogQL, there is the potential for queries for the same team to be run with different PoE versions depending on that team's flag and settings configuration! The differences between non-PoE results and v3 results should be relatively minor (the only known discrepancies should be due to deletions) but the differences between v3 when compared to v1 or v2 will be more significant as they either do not have any overrides (v1) or the overrides were never fully backfilled (v2), so care should be taken when opting teams into this mode.
Does this work well for both Cloud and self-hosted?
This currently shouldn't enabled in self-hosted, and will fall back to the current behavior, though it can be enabled through settings or the right configuration to enable local evaluation of flags at your own risk.
How did you test this code?
Added test, also enabled setting in local environment and clicked around a bit though it's challenging to make too many assertions from that due to caching.