0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-21 21:49:51 +01:00

fix(web-analytics): Fix empty channel types (#24087)

This commit is contained in:
Robbie 2024-07-31 11:23:11 +01:00 committed by GitHub
parent 5e837f4385
commit f0268a1a3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 1 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2020-2023 PostHog Inc.
Copyright (c) 2020-2024 PostHog Inc.
Portions of this software are licensed as follows:

View File

@ -515,6 +515,10 @@ ORDER BY "context.columns.visitors" DESC,
return parse_expr("TRUE") # actually show null values
case WebStatsBreakdown.INITIAL_UTM_CONTENT:
return parse_expr("TRUE") # actually show null values
case WebStatsBreakdown.INITIAL_CHANNEL_TYPE:
return parse_expr(
"breakdown_value IS NOT NULL AND breakdown_value != ''"
) # we need to check for empty strings as well due to how the left join works
case _:
return parse_expr("breakdown_value IS NOT NULL")

View File

@ -951,3 +951,42 @@ class TestWebStatsTableQueryRunner(ClickhouseTestMixin, APIBaseTest):
include_scroll_depth=True,
).results
assert [["/path", 1, 2, None, None, None]] == results_event
def test_no_session_id(self):
d1 = "d1"
_create_person(
team_id=self.team.pk,
distinct_ids=[d1],
properties={
"name": d1,
},
)
_create_event(
team=self.team,
event="$pageview",
distinct_id=d1,
timestamp="2024-07-30",
properties={"utm_source": "google", "$pathname": "/path"},
)
# Don't show session property breakdowns type of sessions with no session id
results = self._run_web_stats_table_query(
"all",
"2024-07-31",
breakdown_by=WebStatsBreakdown.INITIAL_CHANNEL_TYPE,
).results
assert [] == results
results = self._run_web_stats_table_query(
"all",
"2024-07-31",
breakdown_by=WebStatsBreakdown.INITIAL_PAGE,
).results
assert [] == results
# Do show event property breakdowns of events of events with no session id
results = self._run_web_stats_table_query(
"all",
"2024-07-31",
breakdown_by=WebStatsBreakdown.PAGE,
).results
assert [["/path", 1, 1]] == results