diff --git a/LICENSE b/LICENSE index 244538035e8..67950460d43 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 PostHog Inc. +Copyright (c) 2020-2024 PostHog Inc. Portions of this software are licensed as follows: diff --git a/posthog/hogql_queries/web_analytics/stats_table.py b/posthog/hogql_queries/web_analytics/stats_table.py index 38a2a58706a..889cceab5e2 100644 --- a/posthog/hogql_queries/web_analytics/stats_table.py +++ b/posthog/hogql_queries/web_analytics/stats_table.py @@ -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") diff --git a/posthog/hogql_queries/web_analytics/test/test_web_stats_table.py b/posthog/hogql_queries/web_analytics/test/test_web_stats_table.py index 088942335c7..953e94319de 100644 --- a/posthog/hogql_queries/web_analytics/test/test_web_stats_table.py +++ b/posthog/hogql_queries/web_analytics/test/test_web_stats_table.py @@ -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