Skip to content

Commit

Permalink
fix(assistant): omit feature flags (PostHog#28057)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
skoob13 and github-actions[bot] authored Jan 30, 2025
1 parent 97c3f54 commit ed29226
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions posthog/hogql_queries/ai/event_taxonomy_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def _get_omit_filter(self):
r"\$sent_at",
# privacy-related
r"\$ip",
# feature flags and experiments
r"\$feature\/",
# flatten-properties-plugin
"__",
# other metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
LIMIT 100) ARRAY
JOIN (kv).1 AS key,
(kv).2 AS value
WHERE not(match(key, '(\\$set|\\$time|\\$set_once|\\$sent_at|\\$ip|__|phjs|survey_dismissed|survey_responded|partial_filter_chosen|changed_action|window-id|changed_event|partial_filter)'))
WHERE not(match(key, '(\\$set|\\$time|\\$set_once|\\$sent_at|\\$ip|\\$feature\\/|__|phjs|survey_dismissed|survey_responded|partial_filter_chosen|changed_action|window-id|changed_event|partial_filter)'))
GROUP BY key
ORDER BY total_count DESC
LIMIT 500 SETTINGS readonly=2,
Expand Down
30 changes: 30 additions & 0 deletions posthog/hogql_queries/ai/test/test_event_taxonomy_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,33 @@ def test_query_count(self):
self.assertEqual(response.results[0].property, "prop")
self.assertEqual(response.results[0].sample_count, 3)
self.assertEqual(len(response.results[0].sample_values), 1)

def test_feature_flags_properties_are_omitted(self):
_create_person(
distinct_ids=["person1"],
properties={"email": "[email protected]"},
team=self.team,
)
_create_event(
event="event1",
distinct_id="person1",
properties={"$feature/ai": "1"},
team=self.team,
)
_create_event(
event="event1",
distinct_id="person2",
properties={"prop": "2"},
team=self.team,
)
_create_event(
event="event1",
distinct_id="person2",
properties={"prop": "3", "$feature/dashboard": "0"},
team=self.team,
)

response = EventTaxonomyQueryRunner(team=self.team, query=EventTaxonomyQuery(event="event1")).calculate()
self.assertEqual(len(response.results), 1)
self.assertEqual(response.results[0].property, "prop")
self.assertEqual(response.results[0].sample_count, 2)

0 comments on commit ed29226

Please sign in to comment.