: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
fix(insights): preserve disabled test account filter across insight type switch (#59340)
Thomas Obermüllerf4e0d4fa75ce
diff --git a/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts b/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.tsindex 12e9a31539aa..93bd378fdcfb 100644--- a/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts+++ b/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts@@ -350,6 +350,42 @@ describe('insightNavLogic', () => {})})+ it('keeps filterTestAccounts disabled when switching insight types after it was turned off', async () => {+ // Mirrors the DW-series flow: the trends query had filterTestAccounts auto-disabled+ // (set to explicit false). Switching to Funnels must not re-enable it from the team default.+ const trendsQueryWithFilterDisabled: InsightVizNode<TrendsQuery> = {+ kind: NodeKind.InsightVizNode,+ source: {+ kind: NodeKind.TrendsQuery,+ series: [+ {+ kind: NodeKind.EventsNode,+ name: '$pageview',+ event: '$pageview',+ },+ ],+ filterTestAccounts: false,+ },+ }++ await expectLogic(logic, () => {+ builtInsightDataLogic.actions.setQuery(trendsQueryWithFilterDisabled)+ }).toMatchValues({+ queryPropertyCache: expect.objectContaining({+ filterTestAccounts: false,+ }),+ })++ await expectLogic(builtInsightDataLogic, () => {+ logic.actions.setActiveView(InsightType.FUNNELS)+ }).toFinishAllListeners()++ expect((builtInsightDataLogic.values.query as InsightVizNode).source).toMatchObject({+ kind: NodeKind.FunnelsQuery,+ filterTestAccounts: false,+ })+ })+it('keeps trends-only filters when switching away and back', async () => {const trendsQueryWithTrendLine: InsightVizNode = {kind: NodeKind.InsightVizNode,diff --git a/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx b/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsxindex 54a538b86c06..cbb197d0c6b7 100644--- a/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx+++ b/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx@@ -678,6 +678,7 @@ const mergeCachedProperties = (query: InsightQueryNode, cache: QueryPropertyCach...(cache.dateRange ? { dateRange: cache.dateRange } : {}),...(cache.properties !== undefined ? { properties: cache.properties } : {}),...(cache.samplingFactor ? { samplingFactor: cache.samplingFactor } : {}),+ ...(cache.filterTestAccounts !== undefined ? { filterTestAccounts: cache.filterTestAccounts } : {}),}// Insight-specific filter merge (web analytics already returned above)diff --git a/frontend/src/scenes/insights/insightVizDataLogic.test.ts b/frontend/src/scenes/insights/insightVizDataLogic.test.tsindex f6042934b0e1..b4eeb69f9492 100644--- a/frontend/src/scenes/insights/insightVizDataLogic.test.ts+++ b/frontend/src/scenes/insights/insightVizDataLogic.test.ts@@ -220,7 +220,7 @@ describe('insightVizDataLogic', () => {source: {kind: NodeKind.LifecycleQuery,properties: undefined,- filterTestAccounts: undefined,+ filterTestAccounts: false,samplingFactor: undefined,series: [{@@ -284,7 +284,7 @@ describe('insightVizDataLogic', () => {kind: NodeKind.InsightVizNode,source: expect.objectContaining({kind: NodeKind.TrendsQuery,- filterTestAccounts: undefined,+ filterTestAccounts: false,properties: undefined,series: [expect.objectContaining({diff --git a/frontend/src/scenes/insights/insightVizDataLogic.ts b/frontend/src/scenes/insights/insightVizDataLogic.tsindex 24e9b6d7db8c..003797292701 100644--- a/frontend/src/scenes/insights/insightVizDataLogic.ts+++ b/frontend/src/scenes/insights/insightVizDataLogic.ts@@ -812,7 +812,7 @@ const handleQuerySourceUpdateSideEffects = (maybeChangedSeries.some((series) => isLifecycleDataWarehouseNode(series))) {;(mergedUpdate as LifecycleQuery).properties = undefined- ;(mergedUpdate as LifecycleQuery).filterTestAccounts = undefined+ ;(mergedUpdate as LifecycleQuery).filterTestAccounts = false;(mergedUpdate as LifecycleQuery).samplingFactor = undefined}@@ -828,7 +828,7 @@ const handleQuerySourceUpdateSideEffects = ();(mergedUpdate as TrendsQuery).properties = undefined- ;(mergedUpdate as TrendsQuery).filterTestAccounts = undefined+ ;(mergedUpdate as TrendsQuery).filterTestAccounts = false;(mergedUpdate as TrendsQuery).samplingFactor = undefined}