Skip to content

Commit

Permalink
fix(hogql): correctly parse event names with quotes for funnels
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr committed Mar 22, 2024
1 parent fea5780 commit 9827c97
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion posthog/hogql_queries/insights/funnels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def _build_step_query(
event_expr = ast.Constant(value=True)
else:
# event
event_expr = parse_expr(f"event = '{entity.event}'")
event_expr = parse_expr("event = {event}", {"event": ast.Constant(value=entity.event)})

if entity.properties is not None and entity.properties != []:
# add property filters
Expand Down
31 changes: 31 additions & 0 deletions posthog/hogql_queries/insights/funnels/test/test_funnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3618,6 +3618,37 @@ def test_funnel_parses_breakdowns_correctly(self):
self.assertEqual(results[0][1]["breakdown_value"], ["test'123"])
self.assertEqual(results[0][1]["count"], 1)

def test_funnel_parses_event_names_correctly(self):
_create_person(
distinct_ids=[f"user_1"],
team=self.team,
)

events_by_person = {
"user_1": [
{
"event": "test''1",
"timestamp": datetime(2024, 3, 22, 13, 46),
},
{
"event": "test''2",
"timestamp": datetime(2024, 3, 22, 13, 47),
},
],
}
journeys_for(events_by_person, self.team)

query = FunnelsQuery(
series=[EventsNode(event="test'1"), EventsNode()],
dateRange=DateRange(
date_from="2024-03-22",
date_to="2024-03-22",
),
)
results = FunnelsQueryRunner(query=query, team=self.team).calculate().results

self.assertEqual(results[0]["count"], 1)

return TestGetFunnel


Expand Down

0 comments on commit 9827c97

Please sign in to comment.