Skip to content

: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.

feat(dashboards): add test-account filter override (#68612)

Thomas Obermüller973918f28ec4
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 3ec1ad53942a..c3bebaa39c08 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5555,9 +5555,9 @@ snapshots:
scenes-app-dashboards--show-with-post-hog-ai-button-label--superwide--light:
hash: v1.k794b7964.9bd4d2714f9900c45b8687fc72431aab13e800fe1b776727aafa46cb18b726e9.tuNp6_rpbRUE_K4SJjfuxDmGAqEhEs2coFmRKgIJUU0
scenes-app-dashboards--show-with-post-hog-ai-button-label--wide--dark:
- hash: v1.k794b7964.124619da7d409d7b932970ca6cf582fc0d19d29dfc6cbb48675a9fe447c60892.BmxOeG12uGLWXhlL_qzUgtq-blyQRG1RVxDq22rJKqU
+ hash: v1.k794b7964.8eda456a1e6977f86853707a6bb59082480b6840481df879ef62bb11a5e1266d.wL10o_JQFvla9RXRSTqd-8WJPwJKx_5CL2OozSe-EI0
scenes-app-dashboards--show-with-post-hog-ai-button-label--wide--light:
- hash: v1.k794b7964.de9199dae71356e9180e03b49457c499980fce0748123f2e30aebc761be65b32.qIuiMZLH79AWKTwDrvkk7w8BqYC-VjGifh3e0lQVP4s
+ hash: v1.k794b7964.2a748a776b2f744013e450da34ffe4916fe9b4219e2eb1a285527d38bab66ae6.cGnuQ1Z0JZJtV9s1VtuOT2cEWcs2w663-KbDkTgPt08
scenes-app-dashboards--show-without-post-hog-ai-button-label--medium--dark:
hash: v1.k794b7964.8e451e072f54f7e2a4bf649e2af129a1624a9ce5939d023a10cef4dbe200d00a.35hPLpid_TQpN7vdWwVb9IwsPn0qt_aoDmzGmhvA0nA
scenes-app-dashboards--show-without-post-hog-ai-button-label--medium--light:
@@ -5571,9 +5571,9 @@ snapshots:
scenes-app-dashboards--show-without-post-hog-ai-button-label--superwide--light:
hash: v1.k794b7964.d0bef90d18f987e2544aa611b9341dd92177201242030b3d30352b308604675e.CWWmG6lSkFT83glxSckbnPhQTIUZiwkaGiqD3V0JVtY
scenes-app-dashboards--show-without-post-hog-ai-button-label--wide--dark:
- hash: v1.k794b7964.d0252e5613e6bcf9202e82ae3cfa5846cec3195c72e6d4332cc55461b4378dd3.L6IVBe6Y9cpQ6M1XHL46HlYwPkWQmz_R-0_JXx7pwWw
+ hash: v1.k794b7964.026fee89538e727c2b99d94b032a4ae18ef0debc1a48c31d318c915743e8302f.-7hg_I_jrJLDHpBveow50Cuf-zlQIfhNkOUIL9YTz0g
scenes-app-dashboards--show-without-post-hog-ai-button-label--wide--light:
- hash: v1.k794b7964.f9c443be46dd64532ac7c1f1e6efcd7f85a51232f815919fe5f53ce0d220184c.Dt2jIfjTWjeFAZNzMRlpM6vCbaatiKB5t5KmWoaAyQk
+ hash: v1.k794b7964.bdf731e7da5ee6a208a690c18c0d5e38bd06011b383c57f526196da0f91f829c.1hMJmP7uN1mi3H6iqZFeDmGORCs42h4JJm5-VWxN9Rs
scenes-app-dashboards--view-only-dashboard--dark:
hash: v1.k794b7964.a65acee97de57aeef30368365580e0e2c962193d6215acf55dac639823cb0ca8.zkO7nnEw6JoWOSq1KJ1DQrXzCI1FSmD0yzRsrMwcfA0
scenes-app-dashboards--view-only-dashboard--light:
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.test.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.test.tsx
index 6107e1ac1b30..c86e6cc62205 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.test.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.test.tsx
@@ -175,5 +175,57 @@ describe('InsightDetails', () => {
{ properties: [browserChrome], source: 'tile' },
])
})
+
+ it.each([
+ {
+ label: 'dashboard-only test account override',
+ filtersOverride: { filterTestAccounts: true },
+ tileFiltersOverride: undefined,
+ expected: { filterTestAccounts: { value: true, source: 'dashboard' }, interval: null },
+ },
+ {
+ label: 'force-off (false) still counts as a test account override',
+ filtersOverride: { filterTestAccounts: false },
+ tileFiltersOverride: undefined,
+ expected: { filterTestAccounts: { value: false, source: 'dashboard' }, interval: null },
+ },
+ {
+ label: 'dashboard-only interval override',
+ filtersOverride: { interval: 'month' },
+ tileFiltersOverride: undefined,
+ expected: { filterTestAccounts: null, interval: { value: 'month', source: 'dashboard' } },
+ },
+ {
+ label: 'tile scalar overrides beat dashboard ones',
+ filtersOverride: { filterTestAccounts: true, interval: 'week' },
+ tileFiltersOverride: { filterTestAccounts: false, interval: 'day' },
+ expected: {
+ filterTestAccounts: { value: false, source: 'tile' },
+ interval: { value: 'day', source: 'tile' },
+ },
+ },
+ {
+ label: 'no scalar overrides set',
+ filtersOverride: { properties: [countryUS] },
+ tileFiltersOverride: undefined,
+ expected: { filterTestAccounts: null, interval: null },
+ },
+ ])('$label', ({ filtersOverride, tileFiltersOverride, expected }) => {
+ const result = getEffectiveFilterOverrides(undefined, filtersOverride as any, tileFiltersOverride as any)
+
+ expect(result.filterTestAccounts).toEqual(expected.filterTestAccounts)
+ expect(result.interval).toEqual(expected.interval)
+ })
+
+ it('resolves scalar overrides from the backend context layers, ignoring raw props', () => {
+ const result = getEffectiveFilterOverrides(
+ { dashboard: { filterTestAccounts: true, interval: 'week' }, tile: null } as any,
+ { filterTestAccounts: false } as any,
+ undefined
+ )
+
+ expect(result.filterTestAccounts).toEqual({ value: true, source: 'dashboard' })
+ expect(result.interval).toEqual({ value: 'week', source: 'dashboard' })
+ })
})
})
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.tsx
index b6753cfda758..7525a3caaa20 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.tsx
@@ -6,9 +6,11 @@ import React from 'react'
import {
IconCalculator,
IconCalendar,
+ IconClock,
IconCode2,
IconFilter,
IconPencil,
+ IconPeople,
IconSort,
IconUser,
IconWarning,
@@ -52,6 +54,7 @@ import {
TileFilters,
} from '~/queries/schema/schema-general'
import {
+ getInterval,
isActionsNode,
isAnyDataWarehouseNode,
isDataTableNodeWithHogQLQuery,
@@ -73,6 +76,7 @@ import {
BaseMathType,
FilterLogicalOperator,
InsightFilterOverrideContext,
+ IntervalType,
UserBasicType,
} from '~/types'
@@ -612,6 +616,68 @@ export function DateRangeSummary({
)
}
+export function IntervalSummary({
+ interval,
+ override,
+ insightInterval,
+}: {
+ interval: IntervalType
+ override: { source: OverrideSource }
+ insightInterval?: IntervalType | null
+}): JSX.Element {
+ const replaced = insightInterval != null && insightInterval !== interval ? insightInterval : null
+ return (
+ <InsightDetailSectionDisplay icon={<IconClock />} label="Grouped by">
+ <div className="flex items-center gap-1">
+ <span className="font-medium">{capitalizeFirstLetter(interval)}</span>
+ <LayerTag source={override.source} />
+ </div>
+ {replaced && (
+ <div className="text-muted-alt text-xs mt-0.5 flex items-center gap-1">
+ <span>
+ was <span className="line-through">{capitalizeFirstLetter(replaced)}</span> from
+ </span>
+ <LayerTag source="insight" />
+ </div>
+ )}
+ </InsightDetailSectionDisplay>
+ )
+}
+
+const testAccountsLabel = (excluded: boolean): string => (excluded ? 'Excluded' : 'Included')
+
+export function TestAccountFilterSummary({
+ filterTestAccounts,
+ override,
+ insightFilterTestAccounts,
+}: {
+ filterTestAccounts: boolean
+ override: { source: OverrideSource }
+ insightFilterTestAccounts?: boolean | null
+}): JSX.Element {
+ // Show what the insight itself had only when it explicitly set the toggle to the other state.
+ const replaced =
+ insightFilterTestAccounts != null && insightFilterTestAccounts !== filterTestAccounts
+ ? insightFilterTestAccounts
+ : null
+ return (
+ <InsightDetailSectionDisplay icon={<IconPeople />} label="Internal and test users">
+ <div className="flex items-center gap-1">
+ <span className="font-medium">{testAccountsLabel(filterTestAccounts)}</span>
+ <LayerTag source={override.source} />
+ </div>
+ {replaced != null && (
+ <div className="text-muted-alt text-xs mt-0.5 flex items-center gap-1">
+ <span>
+ was <span className="line-through">{testAccountsLabel(replaced)}</span> from
+ </span>
+ <LayerTag source="insight" />
+ </div>
+ )}
+ </InsightDetailSectionDisplay>
+ )
+}
+
interface InsightDetailsProps {
query: Node | null
footerInfo?: {
@@ -645,6 +711,8 @@ export const InsightDetails = React.memo(
propertyGroups,
overriddenByTile,
breakdown: overrideBreakdown,
+ interval: overrideInterval,
+ filterTestAccounts: overrideFilterTestAccounts,
} = getEffectiveFilterOverrides(filterOverrideContext, filtersOverride, tileFiltersOverride)
const insightDateRange = isInsightVizNode(query) ? query.source.dateRange : undefined
const dateOverride = getDateRangeOverrideDisplay(
@@ -703,6 +771,24 @@ export const InsightDetails = React.memo(
) : (
<InsightBreakdownSummary query={query.source} />
)}
+ {overrideInterval && (
+ <IntervalSummary
+ interval={overrideInterval.value}
+ override={{ source: overrideInterval.source }}
+ insightInterval={isInsightVizNode(query) ? getInterval(query.source) : null}
+ />
+ )}
+ {overrideFilterTestAccounts && (
+ <TestAccountFilterSummary
+ filterTestAccounts={overrideFilterTestAccounts.value}
+ override={{ source: overrideFilterTestAccounts.source }}
+ insightFilterTestAccounts={
+ isHogQLQuery(query.source)
+ ? query.source.filters?.filterTestAccounts
+ : query.source.filterTestAccounts
+ }
+ />
+ )}
</>
)}
{footerInfo && (
diff --git a/frontend/src/lib/components/Cards/InsightCard/insightDetailsFilterOverrides.ts b/frontend/src/lib/components/Cards/InsightCard/insightDetailsFilterOverrides.ts
index 5df8b90a16b1..f9419323d1a2 100644
--- a/frontend/src/lib/components/Cards/InsightCard/insightDetailsFilterOverrides.ts
+++ b/frontend/src/lib/components/Cards/InsightCard/insightDetailsFilterOverrides.ts
@@ -1,5 +1,5 @@
import { DashboardFilter, TileFilters } from '~/queries/schema/schema-general'
-import { AnyPropertyFilter, InsightFilterOverrideContext, PropertyGroupFilter } from '~/types'
+import { AnyPropertyFilter, InsightFilterOverrideContext, IntervalType, PropertyGroupFilter } from '~/types'
export type OverrideSource = 'dashboard' | 'tile'
@@ -7,6 +7,20 @@ export interface EffectiveFilterOverrides {
propertyGroups: { properties: AnyPropertyFilter[]; source: OverrideSource }[]
overriddenByTile: AnyPropertyFilter[]
breakdown: { breakdownFilter: NonNullable<DashboardFilter['breakdown_filter']>; source: OverrideSource } | null
+ interval: { value: IntervalType; source: OverrideSource } | null
+ filterTestAccounts: { value: boolean; source: OverrideSource } | null
+}
+
+// Tile beats dashboard; `!= null` (not truthiness) so a force-off `filterTestAccounts: false` still counts.
+function resolveScalarOverride<T>(
+ tileValue: T | null | undefined,
+ dashboardValue: T | null | undefined
+): { value: T; source: OverrideSource } | null {
+ return tileValue != null
+ ? { value: tileValue, source: 'tile' }
+ : dashboardValue != null
+ ? { value: dashboardValue, source: 'dashboard' }
+ : null
}
export function getEffectiveFilterOverrides(
@@ -35,7 +49,13 @@ export function getEffectiveFilterOverrides(
? { breakdownFilter: dashboardBreakdown, source: 'dashboard' as const }
: null
- return { propertyGroups, overriddenByTile, breakdown }
+ const interval = resolveScalarOverride(tileFilters?.interval, dashboardFilters?.interval)
+ const filterTestAccounts = resolveScalarOverride(
+ tileFilters?.filterTestAccounts,
+ dashboardFilters?.filterTestAccounts
+ )
+
+ return { propertyGroups, overriddenByTile, breakdown, interval, filterTestAccounts }
}
interface DateRangeSource {
diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.ts
index b2217e9b4620..00273a1b6fdc 100644
--- a/frontend/src/lib/utils/eventUsageLogic.ts
+++ b/frontend/src/lib/utils/eventUsageLogic.ts
@@ -100,7 +100,7 @@ export enum DashboardEventSource {
DashboardVariableOverride = 'dashboard_variable_override',
}
-export type DashboardFilterChangeType = 'date' | 'properties' | 'breakdown' | 'variable' | 'interval'
+export type DashboardFilterChangeType = 'date' | 'properties' | 'breakdown' | 'variable' | 'interval' | 'test_accounts'
export enum InsightEventSource {
LongPress = 'long_press',
diff --git a/frontend/src/scenes/dashboard/DashboardEditBar.tsx b/frontend/src/scenes/dashboard/DashboardEditBar.tsx
index 6233eb3ed6c6..395dda38c50f 100644
--- a/frontend/src/scenes/dashboard/DashboardEditBar.tsx
+++ b/frontend/src/scenes/dashboard/DashboardEditBar.tsx
@@ -11,6 +11,7 @@ import { keyBinds } from 'lib/components/Shortcuts/shortcuts'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { DashboardEventSource } from 'lib/utils/eventUsageLogic'
import { getProjectEventExistence } from 'lib/utils/getAppContext'
+import { DashboardEditBarAdvancedFilters } from 'scenes/dashboard/DashboardEditBarAdvancedFilters'
import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
import { TaxonomicBreakdownFilter } from 'scenes/insights/filters/BreakdownFilter/TaxonomicBreakdownFilter'
import { insightLogic } from 'scenes/insights/insightLogic'
@@ -152,7 +153,8 @@ export function DashboardEditBar({ showDateFilter = true, className }: Dashboard
]}
/>
</div>
- <div className={clsx('content-end', { 'h-[61px]': hasVariables })}>
+ {/* Single flex item so the "…" button always wraps together with the breakdown button */}
+ <div className={clsx('content-end flex items-end gap-2', { 'h-[61px]': hasVariables })}>
<BindLogic logic={insightLogic} props={insightProps}>
<TaxonomicBreakdownFilter
insightProps={insightProps}
@@ -176,6 +178,7 @@ export function DashboardEditBar({ showDateFilter = true, className }: Dashboard
size="small"
/>
</BindLogic>
+ <DashboardEditBarAdvancedFilters />
</div>
<VariablesForDashboard />
diff --git a/frontend/src/scenes/dashboard/DashboardEditBarAdvancedFilters.tsx b/frontend/src/scenes/dashboard/DashboardEditBarAdvancedFilters.tsx
new file mode 100644
index 000000000000..27474fd7cea3
--- /dev/null
+++ b/frontend/src/scenes/dashboard/DashboardEditBarAdvancedFilters.tsx
@@ -0,0 +1,120 @@
+import { useActions, useValues } from 'kea'
+import { useState } from 'react'
+
+import { IconEllipsis, IconGear } from '@posthog/icons'
+import { LemonBadge, LemonButton, LemonDivider, LemonLabel, LemonSegmentedButton } from '@posthog/lemon-ui'
+
+import { Popover } from 'lib/lemon-ui/Popover'
+import { DashboardEventSource } from 'lib/utils/eventUsageLogic'
+import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import { DashboardMode } from '~/types'
+
+type TestAccountFilterChoice = 'inherit' | 'filter-out' | 'include'
+
+const CHOICE_TO_FILTER: Record<TestAccountFilterChoice, boolean | null> = {
+ inherit: null,
+ 'filter-out': true,
+ include: false,
+}
+
+const CHOICE_HINTS: Record<TestAccountFilterChoice, string> = {
+ inherit: 'Each insight keeps its own "Filter out internal and test users" setting.',
+ 'filter-out': 'Internal and test users are filtered out of every insight on this dashboard.',
+ include: 'Internal and test users are included in every insight on this dashboard.',
+}
+
+/**
+ * "…" at the end of the dashboard edit bar, opening a panel for overrides that are too rarely
+ * used to earn a spot in the bar itself. Currently hosts the test account filter override.
+ */
+export function DashboardEditBarAdvancedFilters(): JSX.Element {
+ const { dashboardMode, effectiveEditBarFilters } = useValues(dashboardLogic)
+ const { setFilterTestAccounts, setDashboardMode } = useActions(dashboardLogic)
+ const { currentTeam } = useValues(teamLogic)
+ const [visible, setVisible] = useState(false)
+
+ const filterTestAccounts = effectiveEditBarFilters.filterTestAccounts ?? null
+ const choice: TestAccountFilterChoice =
+ filterTestAccounts === null ? 'inherit' : filterTestAccounts ? 'filter-out' : 'include'
+ const overrideCount = choice === 'inherit' ? 0 : 1
+ const hasTestAccountFilters = (currentTeam?.test_account_filters || []).length > 0
+
+ return (
+ <Popover
+ visible={visible}
+ onClickOutside={() => setVisible(false)}
+ placement="bottom-end"
+ overlay={
+ <div className="flex w-80 flex-col gap-2 p-2">
+ <div>
+ <h4 className="mb-0 font-semibold">Advanced filters</h4>
+ <p className="mb-0 text-xs text-secondary">
+ Overrides applied to every insight on this dashboard.
+ </p>
+ </div>
+ <LemonDivider className="my-0" />
+ <div className="flex items-center justify-between gap-2">
+ <LemonLabel info="Force test account filtering on or off for every insight, or let each insight keep its own setting.">
+ Test account filtering
+ </LemonLabel>
+ <LemonButton
+ icon={<IconGear />}
+ size="xsmall"
+ noPadding
+ to={urls.settings('project-product-analytics', 'internal-user-filtering')}
+ tooltip="Configure internal and test account filters"
+ />
+ </div>
+ <LemonSegmentedButton<TestAccountFilterChoice>
+ fullWidth
+ size="small"
+ value={choice}
+ onChange={(next) => {
+ if (dashboardMode !== DashboardMode.Edit) {
+ setDashboardMode(DashboardMode.Edit, DashboardEventSource.DashboardFilters)
+ }
+ setFilterTestAccounts(CHOICE_TO_FILTER[next])
+ }}
+ options={[
+ {
+ value: 'inherit',
+ label: 'Inherit',
+ tooltip: 'Each insight keeps its own setting',
+ 'data-attr': 'dashboard-test-account-filter-inherit',
+ },
+ {
+ value: 'filter-out',
+ label: 'Filter out',
+ tooltip: 'Force test account filtering on for every insight',
+ disabledReason: !hasTestAccountFilters
+ ? "You haven't set any internal test filters. Click the gear icon to configure."
+ : undefined,
+ 'data-attr': 'dashboard-test-account-filter-out',
+ },
+ {
+ value: 'include',
+ label: 'Include',
+ tooltip: 'Force test account filtering off for every insight',
+ 'data-attr': 'dashboard-test-account-filter-include',
+ },
+ ]}
+ />
+ <p className="mb-0 text-xs text-secondary">{CHOICE_HINTS[choice]}</p>
+ </div>
+ }
+ >
+ <LemonButton
+ size="small"
+ icon={<IconEllipsis />}
+ tooltip="Advanced filters"
+ active={visible}
+ onClick={() => setVisible(!visible)}
+ sideIcon={overrideCount ? <LemonBadge.Number count={overrideCount} size="small" /> : undefined}
+ data-attr="dashboard-advanced-filters"
+ />
+ </Popover>
+ )
+}
diff --git a/frontend/src/scenes/dashboard/dashboardFilterEmpty.test.ts b/frontend/src/scenes/dashboard/dashboardFilterEmpty.test.ts
index eba49ee484ea..68c09b981fd4 100644
--- a/frontend/src/scenes/dashboard/dashboardFilterEmpty.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardFilterEmpty.test.ts
@@ -11,6 +11,7 @@ describe('isDashboardFilterEmpty', () => {
['only explicitDate false', { explicitDate: false }],
['null date fields + explicitDate false', { date_from: null, date_to: null, explicitDate: false }],
['empty properties array', { properties: [] }],
+ ['filterTestAccounts null', { filterTestAccounts: null }],
]
test.each(emptyCases)('returns true for %s', (_, filter) => {
@@ -35,6 +36,8 @@ describe('isDashboardFilterEmpty', () => {
],
['breakdown_filter set', { breakdown_filter: { breakdown: 'browser' } }],
['interval set', { interval: 'week' }],
+ ['filterTestAccounts forced on', { filterTestAccounts: true }],
+ ['filterTestAccounts forced off', { filterTestAccounts: false }],
]
test.each(nonEmptyCases)('returns false for %s', (_, filter) => {
diff --git a/frontend/src/scenes/dashboard/dashboardFilterEmpty.ts b/frontend/src/scenes/dashboard/dashboardFilterEmpty.ts
index bdaa0ed3d1da..eed09cfc0c2e 100644
--- a/frontend/src/scenes/dashboard/dashboardFilterEmpty.ts
+++ b/frontend/src/scenes/dashboard/dashboardFilterEmpty.ts
@@ -8,6 +8,7 @@ export function isDashboardFilterEmpty(filter: DashboardFilter | TileFilters | n
filter.date_to == null &&
(filter.properties == null || (Array.isArray(filter.properties) && filter.properties.length === 0)) &&
filter.breakdown_filter == null &&
- filter.interval == null)
+ filter.interval == null &&
+ filter.filterTestAccounts == null)
)
}
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.tsx b/frontend/src/scenes/dashboard/dashboardLogic.tsx
index 758b31281aff..f2d6797234dd 100644
--- a/frontend/src/scenes/dashboard/dashboardLogic.tsx
+++ b/frontend/src/scenes/dashboard/dashboardLogic.tsx
@@ -716,6 +716,9 @@ export interface dashboardLogicActions {
setExternalFilters: (filters: DashboardFilter) => {
filters: DashboardFilter
}
+ setFilterTestAccounts: (filterTestAccounts: boolean | null) => {
+ filterTestAccounts: boolean | null
+ }
setInitialLoadResponseBytes: (responseBytes: number) => {
responseBytes: number
}
@@ -1208,6 +1211,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
setProperties: (properties: AnyPropertyFilter[] | null) => ({ properties }),
setBreakdownFilter: (breakdown_filter: BreakdownFilter | null) => ({ breakdown_filter }),
setInterval: (interval: IntervalType | null) => ({ interval }),
+ setFilterTestAccounts: (filterTestAccounts: boolean | null) => ({ filterTestAccounts }),
setExternalFilters: (filters: DashboardFilter) => ({ filters }),
saveEditModeChanges: () => true,
resetUrlFilters: () => true,
@@ -1675,6 +1679,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
setProperties: () => false,
setBreakdownFilter: () => false,
setInterval: () => false,
+ setFilterTestAccounts: () => false,
loadDashboardSuccess: () => false,
loadDashboardFailure: () => false,
applyFilters: () => true,
@@ -2155,6 +2160,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
breakdown_filter: undefined,
explicitDate: undefined,
interval: undefined,
+ filterTestAccounts: undefined,
} as DashboardFilter,
{
setDates: (state, { date_from, date_to, explicitDate }) => ({
@@ -2175,6 +2181,10 @@ export const dashboardLogic = kea<dashboardLogicType>([
...state,
interval,
}),
+ setFilterTestAccounts: (state, { filterTestAccounts }) => ({
+ ...state,
+ filterTestAccounts,
+ }),
resetIntermittentFilters: () => ({
date_from: undefined,
date_to: undefined,
@@ -2182,6 +2192,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
breakdown_filter: undefined,
explicitDate: undefined,
interval: undefined,
+ filterTestAccounts: undefined,
}),
},
],
@@ -4005,6 +4016,18 @@ export const dashboardLogic = kea<dashboardLogicType>([
})
}
},
+ setFilterTestAccounts: ({ filterTestAccounts }) => {
+ eventUsageLogic.actions.reportDashboardFiltersChanged(values.dashboard, 'test_accounts', {
+ filter_test_accounts: filterTestAccounts,
+ })
+
+ if (values.canAutoPreview) {
+ actions.refreshDashboardItems({
+ action: RefreshDashboardItemsAction.Preview,
+ forceRefresh: false,
+ })
+ }
+ },
setExternalFilters: () => {
if (values.tiles.length > 0) {
actions.refreshDashboardItems({
@@ -4216,6 +4239,25 @@ export const dashboardLogic = kea<dashboardLogicType>([
currentLocation.hashParams,
]
},
+ setFilterTestAccounts: ({ filterTestAccounts }) => {
+ if (!values.canAutoPreview) {
+ return
+ }
+
+ const { currentLocation } = router.values
+
+ const urlFilters = parseURLFilters(currentLocation.searchParams)
+ const newUrlFilters: DashboardFilter = {
+ ...urlFilters,
+ filterTestAccounts,
+ }
+
+ return [
+ currentLocation.pathname,
+ { ...currentLocation.searchParams, ...encodeURLFilters(newUrlFilters) },
+ currentLocation.hashParams,
+ ]
+ },
overrideVariableValue: ({ variableId, value }) => {
const { currentLocation } = router.values