:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(insights): retire the hide weekends display option (#78752)
Sam Penningtonc5963966c608
diff --git a/frontend/src/queries/nodes/InsightViz/DisplayOptions.tsx b/frontend/src/queries/nodes/InsightViz/DisplayOptions.tsxindex bcad99b8639a..55c598f15911 100644--- a/frontend/src/queries/nodes/InsightViz/DisplayOptions.tsx+++ b/frontend/src/queries/nodes/InsightViz/DisplayOptions.tsx@@ -12,7 +12,6 @@ import { LemonMenuItem } from 'lib/lemon-ui/LemonMenu'import { DEFAULT_DECIMAL_PLACES } from 'lib/utils/numbers'import { AxisLabelsFilter } from 'scenes/insights/EditorFilters/AxisLabelsFilter'import { HideIncompleteConversionWindowPeriodsFilter } from 'scenes/insights/EditorFilters/HideIncompleteConversionWindowPeriodsFilter'-import { HideWeekendsFilter } from 'scenes/insights/EditorFilters/HideWeekendsFilter'import { LegendOptionsFilter } from 'scenes/insights/EditorFilters/LegendOptionsFilter'import { LifecyclePercentagesFilter } from 'scenes/insights/EditorFilters/LifecyclePercentagesFilter'import { LifecycleStackingFilter } from 'scenes/insights/EditorFilters/LifecycleStackingFilter'@@ -272,7 +271,6 @@ export const DisplayOptions = {MultipleYAxes: { label: () => <ShowMultipleYAxesFilter /> },TrendLines: { label: () => <ShowTrendLinesFilter /> },HideIncompleteFunnelPeriods: { label: () => <HideIncompleteConversionWindowPeriodsFilter /> },- HideWeekends: { label: () => <HideWeekendsFilter /> },Annotations: { label: () => <ShowAnnotationsFilter /> },ResultCustomizationBy: { label: () => <ResultCustomizationByPicker /> },Unit: { label: () => <UnitPicker /> },diff --git a/frontend/src/queries/nodes/InsightViz/InsightResultMetadata.tsx b/frontend/src/queries/nodes/InsightViz/InsightResultMetadata.tsxindex 7bfe6b8cedd0..bd0b24be31d0 100644--- a/frontend/src/queries/nodes/InsightViz/InsightResultMetadata.tsx+++ b/frontend/src/queries/nodes/InsightViz/InsightResultMetadata.tsx@@ -20,7 +20,7 @@ export const InsightResultMetadata = ({disableLastComputationRefresh,}: InsightResultMetadataProps): JSX.Element => {const { insightProps } = useValues(insightLogic)- const { samplingFactor, trendsFilter, dateRange, querySource } = useValues(insightVizDataLogic(insightProps))+ const { samplingFactor, dateRange, querySource } = useValues(insightVizDataLogic(insightProps))// Only insights that apply daysOfWeek server-side get the noteconst excludedDays = querySupportsDaysOfWeek(querySource) ? getExcludedDaysOfWeek(dateRange) : []@@ -42,12 +42,6 @@ export const InsightResultMetadata = ({Excluding {excludedText}</span>) : null}- {trendsFilter?.hideWeekends ? (- <span className="text-secondary">- <span className="mx-1">•</span>- Weekends hidden- </span>- ) : null}{dateRange?.excludeIncompletePeriods ? (<span className="text-secondary"><span className="mx-1">•</span>diff --git a/frontend/src/queries/nodes/InsightViz/insightDisplayOptions.tsx b/frontend/src/queries/nodes/InsightViz/insightDisplayOptions.tsxindex 1882e992dae9..6195e7bd7ba9 100644--- a/frontend/src/queries/nodes/InsightViz/insightDisplayOptions.tsx+++ b/frontend/src/queries/nodes/InsightViz/insightDisplayOptions.tsx@@ -59,10 +59,6 @@ export function useInsightDisplayOptions(): { items: LemonMenuItems; count: numbshowConfidenceIntervals,showMovingAverage,} = useValues(trendsDataLogic(insightProps))- // Hide weekends is superseded by the days-of-week date filter and is being sunset: the option- // only renders on insights that already have it on, so it can be turned off but not on. Gating- // on the value rather than the key matters — the key is persisted as false on most insights.- const hasHideWeekends = !!trendsFilter?.hideWeekends// The slope graph shows the first vs last interval, so it drops the options that need the points// between them (smoothing, multiple axes, alert/annotation overlays, statistical analysis).@@ -162,9 +158,6 @@ export function useInsightDisplayOptions(): { items: LemonMenuItems; count: numbif (isTrendsFunnel && !hideContinuousChartOptions) {displayItems.push(DisplayOptions.HideIncompleteFunnelPeriods)}- if (isTrends && !hideContinuousChartOptions && hasHideWeekends) {- displayItems.push(DisplayOptions.HideWeekends)- }if (showAnnotationsConfig) {displayItems.push(DisplayOptions.Annotations)}@@ -262,7 +255,6 @@ export function useInsightDisplayOptions(): { items: LemonMenuItems; count: numb(showAxisLabelsConfig && normalizeAxisLabel(trendsFilter?.xAxisLabel) ? 1 : 0) +(showAxisLabelsConfig && normalizeAxisLabel(trendsFilter?.yAxisLabel) ? 1 : 0) +(showMultipleYAxes ? 1 : 0) +- (hasHideWeekends ? 1 : 0) +(showAnnotationsConfig && showAnnotations === false ? 1 : 0) +(isMetric && trendsFilter?.metricShowChange === false ? 1 : 0) +(isMetric && trendsFilter?.metricColorByDirection ? 1 : 0) +diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex e8a92a51c3b7..9f3a91d68a87 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -52190,6 +52190,8 @@},"hideWeekends": {"default": false,+ "deprecated": "Use dateRange.daysOfWeek instead.",+ "description": "Ignored. Superseded by `dateRange.daysOfWeek`, which excludes the days from the query instead of only hiding their buckets. Still accepted so existing API clients keep working.","type": "boolean"},"legendPosition": {diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 4cd5754e4d1b..7870a12601d3 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -1595,7 +1595,10 @@ export type TrendsFilter = {detailedResultsAggregationType?: 'total' | 'average' | 'median'/** @default true */excludeBoxPlotOutliers?: boolean- /** @default false */+ /** Ignored. Superseded by `dateRange.daysOfWeek`, which excludes the days from the query+ * instead of only hiding their buckets. Still accepted so existing API clients keep working.+ * @deprecated Use dateRange.daysOfWeek instead.+ * @default false */hideWeekends?: boolean/** @default true */showAnnotations?: booleandiff --git a/frontend/src/scenes/insights/EditorFilters/HideWeekendsFilter.tsx b/frontend/src/scenes/insights/EditorFilters/HideWeekendsFilter.tsxdeleted file mode 100644index c585641d6cc6..000000000000--- a/frontend/src/scenes/insights/EditorFilters/HideWeekendsFilter.tsx+++ /dev/null@@ -1,27 +0,0 @@-import { useActions, useValues } from 'kea'--import { LemonCheckbox } from '@posthog/lemon-ui'--import { insightLogic } from 'scenes/insights/insightLogic'--import { insightVizDataLogic } from '../insightVizDataLogic'--export function HideWeekendsFilter(): JSX.Element | null {- const { insightProps } = useValues(insightLogic)- const { trendsFilter } = useValues(insightVizDataLogic(insightProps))- const { updateInsightFilter } = useActions(insightVizDataLogic(insightProps))-- const toggleHideWeekends = (): void => {- updateInsightFilter({ hideWeekends: !trendsFilter?.hideWeekends })- }-- return (- <LemonCheckbox- className="p-1 px-2"- onChange={toggleHideWeekends}- checked={!!trendsFilter?.hideWeekends}- label={<span className="font-normal">Hide weekend data</span>}- size="small"- />- )-}diff --git a/frontend/src/scenes/insights/filters/InsightDateFilter/daysOfWeekFilterUtils.ts b/frontend/src/scenes/insights/filters/InsightDateFilter/daysOfWeekFilterUtils.tsindex 9d1a4d8eedc0..f18f917b0826 100644--- a/frontend/src/scenes/insights/filters/InsightDateFilter/daysOfWeekFilterUtils.ts+++ b/frontend/src/scenes/insights/filters/InsightDateFilter/daysOfWeekFilterUtils.ts@@ -69,9 +69,7 @@ export function daysOfWeekLabel(days: IsoDayOfWeek[]): string {return days.map((day) => DAY_LABELS[day]).join(', ')}-/** 0 or 7 excluded days normalise to daysOfWeek: null ("all days included"). Deliberately does- * not touch the legacy display-only trendsFilter.hideWeekends — its semantics differ (buckets- * hidden from the response, events kept in windowed aggregations), so it stays independent. */+/** 0 or 7 excluded days normalise to daysOfWeek: null ("all days included"). */export function computeDaysOfWeekUpdate(excludedDays: IsoDayOfWeek[],dateRange: DateRange | null | undefineddiff --git a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.pyindex 05546a5bb90d..1ac1ad8d7db5 100644--- a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py+++ b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py@@ -681,6 +681,95 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):with self.assertRaises(DRFValidationError):TrendsQueryRunner(team=self.team, query=query).calculate()+ def test_days_of_week_with_formula(self):+ # Formula results carry action=None, which the bucket filter has to tolerate while it+ # slices the day axis+ self._create_test_events()++ query = TrendsQuery(+ series=[EventsNode(event="$pageview"), EventsNode(event="$pageleave")],+ dateRange=DateRange(+ date_from=self.default_date_from, # 2020-01-09 (Thu)+ date_to=self.default_date_to, # 2020-01-19 (Sun)+ daysOfWeek=[1, 2, 3, 4, 5],+ ),+ interval=IntervalType.DAY,+ trendsFilter=TrendsFilter(formulaNodes=[TrendsFormulaNode(formula="A+B")]),+ )+ response = TrendsQueryRunner(team=self.team, query=query).calculate()++ # Formula queries return only the formula result+ assert len(response.results) == 1+ formula_result = response.results[0]+ assert formula_result["action"] is None+ # 11 days Thu-Sun, weekend buckets removed leaves 7 weekdays+ assert formula_result["days"] == [+ "2020-01-09", # Thu+ "2020-01-10", # Fri+ "2020-01-13", # Mon+ "2020-01-14", # Tue+ "2020-01-15", # Wed+ "2020-01-16", # Thu+ "2020-01-17", # Fri+ ]+ assert len(formula_result["data"]) == len(formula_result["days"])+ assert formula_result["count"] == sum(formula_result["data"])++ def test_days_of_week_with_compare_slices_each_period_on_its_own_axis(self):+ # Compare is the common case where two series carry different day axes, so it is what+ # exercises the per-axis index cache. The two periods drop weekends at different+ # positions, so reusing one series' kept indices would misalign the other.+ self._create_test_events()++ query = TrendsQuery(+ series=[EventsNode(event="$pageview")],+ dateRange=DateRange(+ date_from="2020-01-15", # Wed+ date_to="2020-01-19", # Sun+ daysOfWeek=[1, 2, 3, 4, 5],+ ),+ interval=IntervalType.DAY,+ compareFilter=CompareFilter(compare=True),+ )+ response = TrendsQueryRunner(team=self.team, query=query).calculate()++ assert len(response.results) == 2+ assert response.results[0]["compare_label"] == "current"+ assert response.results[1]["compare_label"] == "previous"+ assert response.results[0]["days"] == ["2020-01-15", "2020-01-16", "2020-01-17"]+ assert response.results[1]["days"] == ["2020-01-10", "2020-01-13", "2020-01-14"]++ def test_days_of_week_with_cumulative_display(self):+ # Cumulative recomputes count from the final bucket instead of summing the buckets, so+ # the bucket filter has to leave a coherent running total behind+ self._create_test_events()++ query = TrendsQuery(+ series=[EventsNode(event="$pageview")],+ dateRange=DateRange(+ date_from=self.default_date_from, # 2020-01-09 (Thu)+ date_to=self.default_date_to, # 2020-01-19 (Sun)+ daysOfWeek=[1, 2, 3, 4, 5],+ ),+ interval=IntervalType.DAY,+ trendsFilter=TrendsFilter(display=ChartDisplayType.ACTIONS_LINE_GRAPH_CUMULATIVE),+ )+ response = TrendsQueryRunner(team=self.team, query=query).calculate()++ # Weekend events leave the aggregation entirely, so the running total only accumulates+ # the weekday counts [1, 0, 1, 0, 2, 0, 1]+ assert response.results[0]["days"] == [+ "2020-01-09",+ "2020-01-10",+ "2020-01-13",+ "2020-01-14",+ "2020-01-15",+ "2020-01-16",+ "2020-01-17",+ ]+ assert response.results[0]["data"] == [1, 1, 2, 2, 4, 4, 5]+ assert response.results[0]["count"] == response.results[0]["data"][-1]+def test_exclude_incomplete_periods_drops_current_bucket(self):self._create_test_events()@@ -7765,155 +7854,6 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):self.assertEqual(11, len(result["data"]), "Should have 11 days of data")self.assertEqual(result["count"], sum(result["data"]), "Count should equal sum of data points")- def test_hide_weekends_day_interval(self):- self._create_test_events()-- response = self._run_trends_query(- self.default_date_from, # 2020-01-09 (Thu)- self.default_date_to, # 2020-01-19 (Sun)- IntervalType.DAY,- [EventsNode(event="$pageview")],- trends_filters=TrendsFilter(hideWeekends=True),- )-- # 11 days Thu-Sun, weekend days removed leaves 7 weekdays- assert response.results[0]["days"] == [- "2020-01-09", # Thu- "2020-01-10", # Fri- "2020-01-13", # Mon- "2020-01-14", # Tue- "2020-01-15", # Wed- "2020-01-16", # Thu- "2020-01-17", # Fri- ]- assert response.results[0]["data"] == [1, 0, 1, 0, 2, 0, 1]- assert response.results[0]["count"] == 5.0-- def test_hide_weekends_week_interval(self):- self._create_test_events()-- response_normal = self._run_trends_query(- self.default_date_from,- self.default_date_to,- IntervalType.WEEK,- [EventsNode(event="$pageview")],- )-- response_hidden = self._run_trends_query(- self.default_date_from,- self.default_date_to,- IntervalType.WEEK,- [EventsNode(event="$pageview")],- trends_filters=TrendsFilter(hideWeekends=True),- )-- # Week buckets span weekends, so hiding weekends is a no-op here — buckets and counts- # are identical to the normal response (we never drop weekend events from aggregation).- assert response_hidden.results[0]["days"] == response_normal.results[0]["days"]- assert response_hidden.results[0]["data"] == response_normal.results[0]["data"]- assert response_hidden.results[0]["count"] == response_normal.results[0]["count"] == 10.0-- def test_hide_weekends_with_compare(self):- self._create_test_events()-- response = self._run_trends_query(- "2020-01-15", # Wed- "2020-01-19", # Sun- IntervalType.DAY,- [EventsNode(event="$pageview")],- trends_filters=TrendsFilter(hideWeekends=True),- compare_filters=CompareFilter(compare=True),- )-- assert len(response.results) == 2- assert response.results[0]["compare_label"] == "current"- assert response.results[1]["compare_label"] == "previous"-- for result in response.results:- for day_str in result["days"]:- parsed = datetime.strptime(day_str[:10], "%Y-%m-%d")- assert parsed.weekday() < 5, f"{day_str} is a weekend day but should be filtered out"-- def test_hide_weekends_with_formula(self):- self._create_test_events()-- response = self._run_trends_query(- self.default_date_from, # 2020-01-09 (Thu)- self.default_date_to, # 2020-01-19 (Sun)- IntervalType.DAY,- [EventsNode(event="$pageview"), EventsNode(event="$pageleave")],- trends_filters=TrendsFilter(- hideWeekends=True,- formulaNodes=[TrendsFormulaNode(formula="A+B")],- ),- )-- # Formula queries return only the formula result- assert len(response.results) == 1-- formula_result = response.results[0]- for day_str in formula_result["days"]:- parsed = datetime.strptime(day_str[:10], "%Y-%m-%d")- assert parsed.weekday() < 5, f"{day_str} is a weekend day but should be filtered out"-- # 11 days Thu-Sun, weekend days removed leaves 7 weekdays- assert len(formula_result["days"]) == 7- # Formula result has action=None and should not crash- assert formula_result["action"] is None- assert len(formula_result["data"]) == len(formula_result["days"])- assert formula_result["count"] == sum(formula_result["data"])-- @parameterized.expand(- [- # Weekly active users: each weekday's sliding-window value must still count weekend- # events, so the weekday values match the non-hidden query (would drop under the bug).- (- "weekly_active",- "2020-01-09",- "2020-01-20",- [EventsNode(event="$pageview", math=BaseMathType.WEEKLY_ACTIVE)],- None,- [- "2020-01-09",- "2020-01-10",- "2020-01-13",- "2020-01-14",- "2020-01-15",- "2020-01-16",- "2020-01-17",- "2020-01-20",- ],- [1, 1, 3, 3, 4, 4, 4, 2],- ),- # Cumulative: the running total keeps weekend events folded in, so Monday 2020-01-13- # is already 6 (would be lower if weekend events were filtered out of the aggregation).- (- "cumulative",- "2020-01-09",- "2020-01-19",- [EventsNode(event="$pageview")],- ChartDisplayType.ACTIONS_LINE_GRAPH_CUMULATIVE,- ["2020-01-09", "2020-01-10", "2020-01-13", "2020-01-14", "2020-01-15", "2020-01-16", "2020-01-17"],- [1, 1, 6, 6, 8, 8, 9],- ),- ]- )- def test_hide_weekends_does_not_corrupt_windowed_math(- self, _name, date_from, date_to, series, display, expected_days, expected_data- ):- self._create_test_events()-- response = self._run_trends_query(- date_from,- date_to,- IntervalType.DAY,- series,- trends_filters=TrendsFilter(hideWeekends=True, display=display),- )-- assert response.results[0]["days"] == expected_days- assert response.results[0]["data"] == expected_data-@parameterized.expand([(diff --git a/posthog/hogql_queries/insights/trends/trends_query_runner.py b/posthog/hogql_queries/insights/trends/trends_query_runner.pyindex adcb73c8f38c..283a3bdab87c 100644--- a/posthog/hogql_queries/insights/trends/trends_query_runner.py+++ b/posthog/hogql_queries/insights/trends/trends_query_runner.py@@ -534,27 +534,12 @@ class TrendsQueryRunner(AnalyticsQueryRunner[TrendsQueryResponse]):final_result = [item for item in final_result if not self._is_other_breakdown(item["breakdown_value"])]has_more = True- # Hiding weekends is purely a display concern: we keep weekend events in the aggregation- # (so windowed math like WAU/MAU, cumulative, and smoothing stay correct) and only drop the- # weekend date buckets from the response so the chart x-axis shows weekdays.- # For week and longer intervals we keep all buckets since they span multiple days.- # For hour/minute intervals we skip bucket removal to avoid discarding all data on weekends.- allowed_days: Optional[set[int]] = None- if (- self.query.trendsFilter- and self.query.trendsFilter.hideWeekends- and self.query_date_range.interval_name not in ("hour", "minute", "week", "month", "quarter", "year")- ):- allowed_days = {1, 2, 3, 4, 5}-# daysOfWeek filters events at the query level; for day interval also drop the- # deselected day buckets so the chart doesn't show a row of zeros for them+ # deselected day buckets so the chart doesn't show a row of zeros for them.+ # Longer intervals span multiple days, so their buckets are kept.days_of_week = self.query_date_range.days_of_week()if days_of_week and self.query_date_range.interval_name == "day":- allowed_days = set(days_of_week) if allowed_days is None else allowed_days & set(days_of_week)-- if allowed_days is not None:- final_result = self._filter_buckets_to_days(final_result, allowed_days)+ final_result = self._filter_buckets_to_days(final_result, set(days_of_week))return final_result, has_morediff --git a/posthog/schema.py b/posthog/schema.pyindex affb0f2041bc..85212ccc9265 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -7955,7 +7955,14 @@ class TrendsFilter(BaseModel):formulas: list[str] | None = NonegoalLines: list[GoalLine] | None = Field(default=None, description="Goal Lines")hiddenLegendIndexes: list[int] | None = None- hideWeekends: bool | None = False+ hideWeekends: bool | None = Field(+ default=False,+ description=(+ "Ignored. Superseded by `dateRange.daysOfWeek`, which excludes the days"+ " from the query instead of only hiding their buckets. Still accepted so"+ " existing API clients keep working."+ ),+ )legendPosition: LegendPosition | None = Field(default=LegendPosition.BOTTOM,description=("Where the in-chart legend sits relative to the plot. Only applies to the in-chart legend."),diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 9f736d5df829..413e89a317d3 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -2407,6 +2407,7 @@ export interface TrendsFilterApi {/** Goal Lines */goalLines?: GoalLineApi[] | nullhiddenLegendIndexes?: number[] | null+ /** Ignored. Superseded by `dateRange.daysOfWeek`, which excludes the days from the query instead of only hiding their buckets. Still accepted so existing API clients keep working. */hideWeekends?: boolean | null/** Where the in-chart legend sits relative to the plot. Only applies to the in-chart legend. */legendPosition?: LegendPositionApi | nulldiff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 094811506c4f..86dad29191ae 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -1737,6 +1737,7 @@ export interface TrendsFilterApi {/** Goal Lines */goalLines?: GoalLineApi[] | nullhiddenLegendIndexes?: number[] | null+ /** Ignored. Superseded by `dateRange.daysOfWeek`, which excludes the days from the query instead of only hiding their buckets. Still accepted so existing API clients keep working. */hideWeekends?: boolean | null/** Where the in-chart legend sits relative to the plot. Only applies to the in-chart legend. */legendPosition?: LegendPositionApi | nulldiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex b617a50ba705..37e227340e09 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -3129,6 +3129,7 @@ export namespace Schemas {/** Goal Lines */goalLines?: GoalLine[] | null;hiddenLegendIndexes?: number[] | null;+ /** Ignored. Superseded by `dateRange.daysOfWeek`, which excludes the days from the query instead of only hiding their buckets. Still accepted so existing API clients keep working. */hideWeekends?: boolean | null;/** Where the in-chart legend sits relative to the plot. Only applies to the in-chart legend. */legendPosition?: LegendPosition | null;