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): merge tile, dashboard and insight filters by priority (#70139)

Matt Puae89ad8a5a7c4
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index a5bc93b4cf17..b0c769274bd3 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -181,9 +181,9 @@ snapshots:
components-cards-insight-card--insight-card--light:
hash: v1.k794b7964.bbb3f9393068a2bfbe6e68235d521be001c99d791d3e580b91be9040c2806a97.7eFGp37eVD9-ZlHTtMIrzcxhQQzWnhpNrnxKZ2OQiYw
components-cards-insight-details--dashboard-filter-overrides--dark:
- hash: v1.k794b7964.b0ca7f0da6044f42818d498b51898a43f1a5e5ad6135e1dd7186190e1cc05260.PucbrIcObuFhvoS9iwimw53QL_vAdLbQbeAA5INGaFU
+ hash: v1.k794b7964.a329bf8c33e5ba0f777352aedd989c5c6cdc9a052c5ff20941331ee8ad004e93.sVMhyuYiG4BcFfCwwkJG9Vbr6QsQx5bOawB9bbVAQ44
components-cards-insight-details--dashboard-filter-overrides--light:
- hash: v1.k794b7964.e5304e6fbd0fa5825b4ba3652c06e49a54c372cc56e1c4430b80fe2e1bae68ff.4hLu9flYn5bhHZoBcLKMqCCgByX1yGwL8I3bVd6vnME
+ hash: v1.k794b7964.efa1ae000447ea8672c2c6cfbf25521d9911f27e1c1c86d35634ae542b2989b3.mv1CRmeOJ6E1uUHPZd-m8YGJsbAUvYzpnwQyWu6YXTU
components-cards-insight-details--data-table-events-query--dark:
hash: v1.k794b7964.1d1e392081a1d0172c6c83c85dff608566bbc732a344c39cd2e42b9b8645788a.TYe-zSsUz7oMf4OXb-Av0262xnh6sCA-bZE7izMKGNs
components-cards-insight-details--data-table-events-query--light:
@@ -204,10 +204,18 @@ snapshots:
hash: v1.k794b7964.fc98b38bad63f40b69426c443559f497d0003a48bd74b30ca42264b9fe6fa0c1.6CZdMsLKWiSvqBQYr9bgQdn9HoCg3IWzR3n66HnZPAw
components-cards-insight-details--lifecycle--light:
hash: v1.k794b7964.25c9fb1686cd27aaa580afa4aa852246f63f8be9be1fe0ff77cfca299ca54754.P2Y5s3jG03-Qj2cxAGDAHH2c4-rN2DDfNy6Qr8kkYhQ
+ components-cards-insight-details--merged-filter-overrides--dark:
+ hash: v1.k794b7964.214d3c52b4bd3f390c685354658b0e74ece45a278726b29ee0d2dffeac3886b5.nhGJlfwEEtLjApcQEZnvK5gTfyXazsesDE9tb-sNvg8
+ components-cards-insight-details--merged-filter-overrides--light:
+ hash: v1.k794b7964.384610521578173bb840fccf34585c170d33de0dd593dbde351a84f8aa15380d.TTAjdLM1oBDiCmrKx78MX7-wkb5LgRZzlFnVE5b1cx4
components-cards-insight-details--paths--dark:
hash: v1.k794b7964.49c8ef0980ce12d99a42de99fbda85fbf27b819d5138451dd6f92b26140b6ba1.iNfvCq5rMh4ZQWvkOBnwdQrPpjxQp7SB9VuHaIIxy28
components-cards-insight-details--paths--light:
hash: v1.k794b7964.d44877a659d6dde10b68e2a3eb074a66022c9acc3d26e489bcb4bedf021f7260._S25ekQGM8qp70cYNiHTzNTqyUhB8bu-dnqkwSTxyoU
+ components-cards-insight-details--property-filter-conflict-cases--dark:
+ hash: v1.k794b7964.04687a345799e57a54039b3e37af8a7cc7dae34d334ff37529c32f6fafc88055.pjn9pfEjQDLI4zvXU_es_G4jsUvskEtfzjb8ABf103Y
+ components-cards-insight-details--property-filter-conflict-cases--light:
+ hash: v1.k794b7964.b3cec2a1c0ef3b90bb6024c0c48910554fd98e46a9932292bcda285df9614fb4.1OmuB5uelw61cD7FVuOzzfrd_lzTCa46U85Yt6Yz4m0
components-cards-insight-details--retention--dark:
hash: v1.k794b7964.467d146288500caf1d0fa3d19e45194880989c1a5f86f35926644abb129d86a7.qRXItl2so2CEcqfz-FS17qJZZZMriH54FBflYwsRO9s
components-cards-insight-details--retention--light:
@@ -216,14 +224,22 @@ snapshots:
hash: v1.k794b7964.0750bf878b81d49801898a5bd1f20572f224db123eb76885bad0663f9c368e09.EYBhDBsAZvhEqxH1YR4-kC0xZrZzhah_Cqehgyq7DMc
components-cards-insight-details--stickiness--light:
hash: v1.k794b7964.b5c5de9623b28bd325c6e4277350ee84cf4d30d1006715d3c0dcd5120fc13aad.owN-4QmORQ-RdynxA9tMeQxrXRGHkcLgKfNJOt2LuLE
+ components-cards-insight-details--tile-date-overrides-dashboard--dark:
+ hash: v1.k794b7964.a14fb934658e5a9674d304fca63330c30ca0554c3e3f530851d36b83bdd87a09.yL1-OeFy3P-CjWYVuhb1js5_1F0MsS5ekW4qEP8yrTA
+ components-cards-insight-details--tile-date-overrides-dashboard--light:
+ hash: v1.k794b7964.10e83be59d383d61ee9a60b8149973627d9e7e36d6e7cb66173e4a4a589674a6.hAJevdnovZ41MRgcLHkSwl8zViKqm7JxKycZBNfkeew
components-cards-insight-details--tile-filter-overrides--dark:
- hash: v1.k794b7964.17f6952a2c7fcacfc743d43ef26dd48555e211d9992ea9d69df0c961703dda3a.2sEcr7_6AeUBehlHaTTBJ_OTVaxnz8GlSC6-HvM_N1Y
+ hash: v1.k794b7964.e970f7dc0a339890be51aee01c759d4477955ab669022407a4fa3dc0e83293a1.KmBi3ZXWvvtlMTa_pD4BCLVxqOxqH7jsbl2taLhcb2I
components-cards-insight-details--tile-filter-overrides--light:
- hash: v1.k794b7964.5f7fb7bc28bcf75bbaf9cebfebfb2e4a644ebc05053faf6c1a8987150d8fd52f.3N_2DHQiCXzrg8CgyO1XIFahRFn2YbCFHl1AzYWowe0
+ hash: v1.k794b7964.de3076c75382b62bce74eea46ef5ada623258551b4f63deda6e23bc5acd9249b.lGRSOZ0SLsNN0_SDZjGxM67qyXxHz9ZIKJypYzHigMI
+ components-cards-insight-details--tile-property-overrides-dashboard--dark:
+ hash: v1.k794b7964.86c5c1e0f93d2c10ca52b527a1862560d2f40e91e0e7498677742ea2d473ecc8.k2VzsZKPsXhtGkt6RoozXvxj3q6tjOdstmunyLRw_lo
+ components-cards-insight-details--tile-property-overrides-dashboard--light:
+ hash: v1.k794b7964.300d924ce09e64f733c59dc33fb9a740965145afbb29d4469bee9a887856d1ab.nyCmvEIRkudVbSimZkRvaw42eB9GMv1Api0qOvEXV5c
components-cards-insight-details--trends--dark:
- hash: v1.k794b7964.17f6952a2c7fcacfc743d43ef26dd48555e211d9992ea9d69df0c961703dda3a.zfRwYQ7XZwEqS8UWl3MqvLkCKsymj1bLf9p2S3se8TA
+ hash: v1.k794b7964.86c5c1e0f93d2c10ca52b527a1862560d2f40e91e0e7498677742ea2d473ecc8.7v2gGuTomMIZYMTdOxSohjG_5iobM_JshDem3J3Dj_4
components-cards-insight-details--trends--light:
- hash: v1.k794b7964.f076a461b8f2248592718febd54ec5dbc2925977fe6f56bd2c212ed5da6a642b.FAPjNEzy1QPg9nriC5TBTUQrnT0-0jACihz6u8RA6t8
+ hash: v1.k794b7964.300d924ce09e64f733c59dc33fb9a740965145afbb29d4469bee9a887856d1ab.ZnqhW4vJluknq_Z2eFxVWCVzsUfdW3x0ZcSnnr4Tctw
components-cards-insight-details--trends-formulas--dark:
hash: v1.k794b7964.c7a5596477995be8a1ac7b2dc16f70b72df809c608166f970bc61792f4f0fbef.CBCVIVNRhTwiVhzWv8GWdACIjOFmAYsQzJIWODbvE4M
components-cards-insight-details--trends-formulas--light:
@@ -249,17 +265,17 @@ snapshots:
components-cards-insight-details--trends-world-map--light:
hash: v1.k794b7964.4210d17a7eb634c14762fe72d81a3af5d56ea21f500f0e9def7ccd95b190107a.WKTCAuzZF3jvvCkihMTeKxuFDcnK6eu0M5QnUeOxXog
components-cards-recordings-universal-filters-display--all-filters-enabled--dark:
- hash: v1.k794b7964.7d84f53004e3c55eca98dfdd7c738170bfb236011f3f5aea2d9db50892894c06.EmfGGyJyxOMTDxHUMPQSU2TQW8liXooL3qMefp4e7Ug
+ hash: v1.k794b7964.818595232ffeb8607ac06e5a3dd5ddf3654cec48a9a7b43192b35ae872eb1daa.NmxtZloYHsg_JhJpX1WPncWB5xETTR5Km-6UQq2_HCw
components-cards-recordings-universal-filters-display--all-filters-enabled--light:
- hash: v1.k794b7964.7793e5ee4a3ed6fa24020c30b7547c3dd56f74f07f246b02cf38b301dad2839b.k_Gh-mUUQV5makMtbKOKUJM_nrLaSjll0DRTw36z5Ag
+ hash: v1.k794b7964.f2fdad3518c11b92b673921663d66b180c992a0923bbf5264b07aa89d0f1670e.fVUuXiyN9YHHHlgH3pE7RAG2tBBtj12QI3i61PwLckc
components-cards-recordings-universal-filters-display--basic-date-range--dark:
hash: v1.k794b7964.41c319c6a8890f3b4abeb6cd212ac5240671df379d27bf7d8a1263f3e2674da9.dQOsMytaydFHoCe_CqEedUVA5Y9JkFDCT3mG7I775TI
components-cards-recordings-universal-filters-display--basic-date-range--light:
hash: v1.k794b7964.12c7899d7404db33cb25d44198faacf034af9cba7f9b9ac9d6631a2d0f0d93f5.oXvCl_We1i785K4s5gWaKrRSuZNaiyiH-jugOAU4Er8
components-cards-recordings-universal-filters-display--complex-filters--dark:
- hash: v1.k794b7964.d85bdbd24ae9b6dbac4a8960d9b1579a6327849a7d100c3192b7122a9692076c.8Ep9_X3MR_wE330225zBUvnnGcIOTSbp4d2TIPxyLqI
+ hash: v1.k794b7964.348c32c68772438247b3e7722c1d49a2b270687f452900b55254b104021c406d.z-Za0ocFYWcRXe5ddGemfayP55zWRXUriMm-eV9atnY
components-cards-recordings-universal-filters-display--complex-filters--light:
- hash: v1.k794b7964.470a442fd36a54a6b84e62c0eeeeb9d025c6b5fdbe6d50cf511e4fd7276967dd.O6E29IIqfqhsEBxEev-q7t863eu-SzZraEpCJSCivVg
+ hash: v1.k794b7964.8b3d9880ed3c2c0b403252bab2745d0f901cee580fbedd61b03f059184ac1699.MzZWLl-4SdnJjDNpPP9uLWyzhtC_yuUGkYGUfOo724s
components-cards-recordings-universal-filters-display--custom-date-range--dark:
hash: v1.k794b7964.2a69c5fbba48e549f3fa59efc6a47215c053fe6dbf70eb12f485e5560a25c4c3.2Xj5h9QvSXD9qNzwHw8yzxrHYPoW150nDvSo8X_mDM0
components-cards-recordings-universal-filters-display--custom-date-range--light:
@@ -273,9 +289,9 @@ snapshots:
components-cards-recordings-universal-filters-display--minimal-filters--light:
hash: v1.k794b7964.9f219591bfeee79fa3d3b9e864f9e820b7251d5559652e27300ac673c9963623.3YasvjbRalVEfiRD8N4Vt-sWVKGTnlHSC7mBFsdRVPg
components-cards-recordings-universal-filters-display--nested-filter-groups--dark:
- hash: v1.k794b7964.33333a5f7d71f7a592e352687ef0950c71f77c448bb3267dad4c8eb7e7410bf8.HSUh8KA3DfQCSqsgpSUsvKJbXjrzbtLEg4XopEdtGZw
+ hash: v1.k794b7964.d83cbe0569101b429c13a9a6db233739cdcfcad2d574ef677e2a6bbd11039bc2.uy65QwwxyzBWz6IbgHnrxCci3t5bWSRtaXOv5oWS1tk
components-cards-recordings-universal-filters-display--nested-filter-groups--light:
- hash: v1.k794b7964.492801236f7e55586eb1692c94266b855b0aa7271f5ea8bd051e787daa756d07.2cdxRx7HuxfpEFmi6ZS0Tdb9wGfJ3XC_8fVfA2mR6ec
+ hash: v1.k794b7964.25b0148517ac2f50d15d37112f68c6630ef7a500d7e6a09c846e87f301a69753._8f5YviEBgYzy-DVBoqKaH_Ee_pPFfggA7MktgGjaY4
components-cards-recordings-universal-filters-display--with-activity-score-ordering--dark:
hash: v1.k794b7964.bd491a636b680678e78f24751f369d1de3344cbc33ee21342d908482a749f0a4.LbKaTY3DlLr-AudBJh6-71Skgmwci8Xa4PwCcbV3icQ
components-cards-recordings-universal-filters-display--with-activity-score-ordering--light:
@@ -293,9 +309,9 @@ snapshots:
components-cards-recordings-universal-filters-display--with-multiple-duration-filters--light:
hash: v1.k794b7964.93a5562749858e72c42060b8e1da6820b8cf361197b939219420bebdf51eebb2.XN48HMdDyUOowV_ruR4nXP-tQmRbrSAHIPwia5QWvO0
components-cards-recordings-universal-filters-display--with-or-filters--dark:
- hash: v1.k794b7964.7610eb031fea8e7160199c754041129461fc8ec5f75b077883cd54f362da231a.AQaraDzJMJi3DmDICBtBQTpbX2PzMexsWy6gzdH28w8
+ hash: v1.k794b7964.e0c4f4183fca8f2c0d812e9b99033a24a3fc4441c7042034ae745f89c093641d.E2OqjcJsCNS82-Ru2O2d5TPMQBdYxV7Px_ILARnc5Ro
components-cards-recordings-universal-filters-display--with-or-filters--light:
- hash: v1.k794b7964.2aa4b432dc8b9086b84201828cba6c91484f23d551340fc68425ed63775a4351.8SRjVmQUUmG9RU9JkVSGPOenTvcLpfkFZw9mNqHIzSo
+ hash: v1.k794b7964.a20f8e80d0a45d0e0e7dc21a75e9b51648533726f7bc8afa656cf57e110fe21d.ZDZwkCiojFD-cbDRM8NgXP87IiylISr0EVr-qC02sD0
components-cards-recordings-universal-filters-display--with-ordering-ascending--dark:
hash: v1.k794b7964.57a716aae2ffe15f00adac21f793b8586fcafc877b02b9b94a93e9f0e06f53fa.bS0Ki-U9RO8xsiIG-vB0n3GOHeShFHqkNsAxIqFJP1k
components-cards-recordings-universal-filters-display--with-ordering-ascending--light:
@@ -305,9 +321,9 @@ snapshots:
components-cards-recordings-universal-filters-display--with-ordering-descending--light:
hash: v1.k794b7964.297ce7c3f62e1da9cd6bbe4f6232b4ed8774acdbfd6115f6ac3fb46e22eaffbd.hDu9-GrorizUthDhPNjpDnTQof9AxZmms3P8Ja2bsto
components-cards-recordings-universal-filters-display--with-property-filters--dark:
- hash: v1.k794b7964.961c51084c6774c989f650548d400a96f73beeb92f3308cde69be1c8ce5f91e5.wwnbxOH3Pmmkzt3-wDQNz-jk3DFYRQND_dwuNFdGYdA
+ hash: v1.k794b7964.827597e2cb63e45a0b22b7a34fcdc34060ea2e51cea201199505207a318715ec.-iDouVqCmiWs6p8jghc4n55Fom8YD9TPlno6OyhbtFk
components-cards-recordings-universal-filters-display--with-property-filters--light:
- hash: v1.k794b7964.212c05070965a9a87630bfba250609704b5d01a08c266df8980b0b28d9062ad3.A5yDqrWdncnsYONi75P0s7WJPROIR9cBw6Di0ij-Jq4
+ hash: v1.k794b7964.3be9d3afb4dc83f1209eebe33fe3bd0708e0c2abc8388da4df2c6400ffccc5d4.Cuhpvy9IzG1QwPLypqZkL_AqUMzQtDs8WNKbhE3fYGU
components-cards-recordings-universal-filters-display--with-test-accounts-excluded--dark:
hash: v1.k794b7964.407381ff793630510388ef73c424be70fe4b7f4505214ebf03e74861d6b35af5.VXt6UhMyl3bRD_Zg19yN60BSOlElwCuVXkT7QjxqRKE
components-cards-recordings-universal-filters-display--with-test-accounts-excluded--light:
diff --git a/frontend/src/lib/components/Cards/InsightCard/CompactUniversalFiltersDisplay.tsx b/frontend/src/lib/components/Cards/InsightCard/CompactUniversalFiltersDisplay.tsx
index a109e849695f..9bee50daca1b 100644
--- a/frontend/src/lib/components/Cards/InsightCard/CompactUniversalFiltersDisplay.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/CompactUniversalFiltersDisplay.tsx
@@ -13,6 +13,7 @@ import {
import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { Link } from 'lib/lemon-ui/Link'
+import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { allOperatorsMapping } from 'lib/utils/operators'
import { capitalizeFirstLetter } from 'lib/utils/strings'
import { urls } from 'scenes/urls'
@@ -42,6 +43,16 @@ function isUniversalFiltersGroup(value: UniversalFiltersGroupValue): value is Un
return (value as UniversalFiltersGroup).type !== undefined && (value as UniversalFiltersGroup).values !== undefined
}
+// A filter value can be a number, boolean, etc.; render it as text with the full value on hover, since
+// long values (e.g. URLs) are truncated to one line.
+function PropertyValueDisplay({ value }: { value: PropertyFilterBaseValue }): JSX.Element {
+ return (
+ <Tooltip title={String(value)}>
+ <code className="SeriesDisplay__value">{String(value)}</code>
+ </Tooltip>
+ )
+}
+
export function CompactUniversalFiltersDisplay({
groupFilter,
embedded,
@@ -158,14 +169,14 @@ export function CompactUniversalFiltersDisplay({
(Array.isArray(propertyFilter.value) ? (
propertyFilter.value.map((subValue, index) => (
<React.Fragment key={index}>
- <code className="SeriesDisplay__value">{String(subValue)}</code>
+ <PropertyValueDisplay value={subValue} />
{index <
(propertyFilter.value as PropertyFilterBaseValue[]).length -
1 && ' or '}
</React.Fragment>
))
) : propertyFilter.value != undefined ? (
- <code className="SeriesDisplay__value">{String(propertyFilter.value)}</code>
+ <PropertyValueDisplay value={propertyFilter.value} />
) : null)}
</>
)}
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.scss b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.scss
index c9a58505e75b..cb169fce89b0 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.scss
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.scss
@@ -99,10 +99,18 @@
}
.SeriesDisplay__value {
- display: inline-flex;
- align-items: center;
+ // inline-block (not inline-flex) so text-overflow can truncate a long value to one line; line-height
+ // matches height to keep it vertically centered without flex. vertical-align: middle matches
+ // .SeriesDisplay__raw-name so both tag styles sit on the same line.
+ display: inline-block;
+ max-width: 100%;
height: 1.25rem;
padding: 0 0.125rem;
+ overflow: hidden;
+ line-height: 1.25rem;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ vertical-align: middle;
background: var(--color-bg-surface-secondary);
border-width: 1px;
border-radius: var(--radius-sm);
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.stories.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.stories.tsx
index 10b67215ca12..8ee4e22c6076 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.stories.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.stories.tsx
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react'
import { DashboardFilter, TileFilters } from '~/queries/schema/schema-general'
-import { PropertyFilterType, PropertyOperator, QueryBasedInsightModel } from '~/types'
+import { AnyPropertyFilter, PropertyFilterType, PropertyOperator, QueryBasedInsightModel } from '~/types'
import __dataTableEvents from '../../../../mocks/fixtures/api/projects/team_id/insights/dataTableEvents.json'
import __dataTableHogQL from '../../../../mocks/fixtures/api/projects/team_id/insights/dataTableHogQL.json'
@@ -26,6 +26,12 @@ interface StoryArgs {
tileFiltersOverride?: TileFilters | null
}
+function withOwnProperties(properties: AnyPropertyFilter[]): QueryBasedInsightModel {
+ const insight = structuredClone(__trendsLine) as any
+ insight.query.source.properties = properties
+ return insight
+}
+
type Story = StoryObj<StoryArgs>
const meta: Meta<StoryArgs> = {
title: 'Components/Cards/Insight Details',
@@ -166,3 +172,185 @@ export const TileFilterOverrides: Story = {
},
},
}
+
+export const MergedFilterOverrides: Story = {
+ args: {
+ insight: __trendsLine as any,
+ filtersOverride: {
+ date_from: '-30d',
+ breakdown_filter: { breakdown: '$os', breakdown_type: 'event' },
+ },
+ tileFiltersOverride: {
+ breakdown_filter: { breakdown: '$browser', breakdown_type: 'event' },
+ },
+ },
+}
+
+export const TileDateOverridesDashboard: Story = {
+ args: {
+ insight: __trendsLine as any,
+ filtersOverride: {
+ date_from: '-30d',
+ },
+ tileFiltersOverride: {
+ date_from: '-7d',
+ },
+ },
+}
+
+export const TilePropertyOverridesDashboard: Story = {
+ args: {
+ insight: __trendsLine as any,
+ filtersOverride: {
+ properties: [
+ {
+ type: PropertyFilterType.Event,
+ key: '$browser',
+ operator: PropertyOperator.Exact,
+ value: ['Safari'],
+ },
+ ],
+ },
+ tileFiltersOverride: {
+ properties: [
+ {
+ type: PropertyFilterType.Event,
+ key: '$browser',
+ operator: PropertyOperator.Exact,
+ value: ['Firefox'],
+ },
+ ],
+ },
+ },
+}
+
+const PROPERTY_FILTER_CONFLICT_CASES: {
+ title: string
+ insightProperties: AnyPropertyFilter[]
+ dashboardProperties: AnyPropertyFilter[]
+}[] = [
+ {
+ title: 'Same value on both layers — duplicate, not a conflict',
+ insightProperties: [
+ { type: PropertyFilterType.Event, key: '$browser', operator: PropertyOperator.Exact, value: ['Chrome'] },
+ ],
+ dashboardProperties: [
+ { type: PropertyFilterType.Event, key: '$browser', operator: PropertyOperator.Exact, value: ['Chrome'] },
+ ],
+ },
+ {
+ title: 'Overlapping exact sets — compatible, both apply',
+ insightProperties: [
+ {
+ type: PropertyFilterType.Event,
+ key: '$browser',
+ operator: PropertyOperator.Exact,
+ value: ['Chrome', 'Safari'],
+ },
+ ],
+ dashboardProperties: [
+ { type: PropertyFilterType.Event, key: '$browser', operator: PropertyOperator.Exact, value: ['Chrome'] },
+ ],
+ },
+ {
+ title: 'Disjoint exact sets — contradicts, dashboard wins',
+ insightProperties: [
+ { type: PropertyFilterType.Event, key: '$browser', operator: PropertyOperator.Exact, value: ['Firefox'] },
+ ],
+ dashboardProperties: [
+ { type: PropertyFilterType.Event, key: '$browser', operator: PropertyOperator.Exact, value: ['Chrome'] },
+ ],
+ },
+ {
+ title: "utm_source = google + is_set — stacks (Andy's original case from PR #70139)",
+ insightProperties: [
+ { type: PropertyFilterType.Event, key: 'utm_source', operator: PropertyOperator.Exact, value: ['google'] },
+ ],
+ dashboardProperties: [{ type: PropertyFilterType.Event, key: 'utm_source', operator: PropertyOperator.IsSet }],
+ },
+ {
+ title: 'is_not_set vs is_set — contradicts, no value can satisfy both',
+ insightProperties: [{ type: PropertyFilterType.Event, key: 'utm_source', operator: PropertyOperator.IsNotSet }],
+ dashboardProperties: [{ type: PropertyFilterType.Event, key: 'utm_source', operator: PropertyOperator.IsSet }],
+ },
+ {
+ title: 'is_not vs is_not_set — compatible (a negated filter also matches unset)',
+ insightProperties: [
+ { type: PropertyFilterType.Event, key: '$os', operator: PropertyOperator.IsNot, value: ['Windows'] },
+ ],
+ dashboardProperties: [{ type: PropertyFilterType.Event, key: '$os', operator: PropertyOperator.IsNotSet }],
+ },
+ {
+ title: 'Same key+value, different group_type_index — compatible (distinct group types)',
+ insightProperties: [
+ {
+ type: PropertyFilterType.Group,
+ key: 'name',
+ group_type_index: 1,
+ operator: PropertyOperator.Exact,
+ value: ['Acme'],
+ } as AnyPropertyFilter,
+ ],
+ dashboardProperties: [
+ {
+ type: PropertyFilterType.Group,
+ key: 'name',
+ group_type_index: 0,
+ operator: PropertyOperator.Exact,
+ value: ['Acme'],
+ } as AnyPropertyFilter,
+ ],
+ },
+ {
+ title: 'icontains needle containing the excluded not_icontains needle — contradicts',
+ insightProperties: [
+ {
+ type: PropertyFilterType.Event,
+ key: '$current_url',
+ operator: PropertyOperator.IContains,
+ value: ['my-example.com/page'],
+ },
+ ],
+ dashboardProperties: [
+ {
+ type: PropertyFilterType.Event,
+ key: '$current_url',
+ operator: PropertyOperator.NotIContains,
+ value: ['example.com'],
+ },
+ ],
+ },
+ {
+ title: 'Mixed: one filter contradicts (dropped), one is unrelated (kept)',
+ insightProperties: [
+ { type: PropertyFilterType.Event, key: '$browser', operator: PropertyOperator.Exact, value: ['Firefox'] },
+ {
+ type: PropertyFilterType.Event,
+ key: '$device_type',
+ operator: PropertyOperator.Exact,
+ value: ['Desktop'],
+ },
+ ],
+ dashboardProperties: [
+ { type: PropertyFilterType.Event, key: '$browser', operator: PropertyOperator.Exact, value: ['Chrome'] },
+ ],
+ },
+]
+
+// One snapshot for all cases so a `filters_contradict` regression shows as one diff, not nine.
+export const PropertyFilterConflictCases: Story = {
+ render: () => (
+ <div className="flex flex-col gap-4">
+ {PROPERTY_FILTER_CONFLICT_CASES.map(({ title, insightProperties, dashboardProperties }) => (
+ <div key={title} className="bg-surface-primary w-[24rem] p-4 rounded">
+ <div className="text-xs font-semibold text-muted-alt mb-2">{title}</div>
+ <InsightDetailsComponent
+ query={withOwnProperties(insightProperties).query}
+ footerInfo={withOwnProperties(insightProperties)}
+ filtersOverride={{ properties: dashboardProperties }}
+ />
+ </div>
+ ))}
+ </div>
+ ),
+}
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.test.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.test.tsx
new file mode 100644
index 000000000000..6107e1ac1b30
--- /dev/null
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.test.tsx
@@ -0,0 +1,179 @@
+import {
+ dropDuplicatesOfOverrides,
+ getDateRangeOverrideDisplay,
+ getEffectiveFilterOverrides,
+} from './insightDetailsFilterOverrides'
+
+const browserChrome = { key: '$browser', value: 'Chrome', type: 'event', operator: 'exact' }
+const browserSafari = { key: '$browser', value: 'Safari', type: 'event', operator: 'exact' }
+const countryUS = { key: '$country', value: 'US', type: 'event', operator: 'exact' }
+
+describe('InsightDetails', () => {
+ describe('getDateRangeOverrideDisplay', () => {
+ it.each([
+ {
+ label: 'backend-resolved tile date includes the replaced dashboard date',
+ insightDateRange: { date_from: '-14d' },
+ filterOverrideContext: {
+ dashboard: null,
+ tile: { date_from: '-7d' },
+ overridden_dashboard: { date_from: '-30d' },
+ },
+ filtersOverride: { date_from: '-30d' },
+ tileFiltersOverride: { date_from: '-3d' },
+ expected: {
+ source: 'tile',
+ dateFrom: '-7d',
+ dateTo: undefined,
+ replaced: { source: 'dashboard', dateFrom: '-30d', dateTo: undefined },
+ },
+ },
+ {
+ label: 'tile date beats the insight range when no dashboard date (replaced = insight)',
+ insightDateRange: { date_from: '-14d' },
+ filtersOverride: undefined,
+ tileFiltersOverride: { date_from: '-7d' },
+ expected: {
+ source: 'tile',
+ dateFrom: '-7d',
+ dateTo: undefined,
+ replaced: { source: 'insight', dateFrom: '-14d', dateTo: undefined },
+ },
+ },
+ {
+ label: 'dashboard date beats the insight range (replaced = insight)',
+ insightDateRange: { date_from: '-14d' },
+ filtersOverride: { date_from: '-30d' },
+ tileFiltersOverride: undefined,
+ expected: {
+ source: 'dashboard',
+ dateFrom: '-30d',
+ dateTo: undefined,
+ replaced: { source: 'insight', dateFrom: '-14d', dateTo: undefined },
+ },
+ },
+ {
+ label: 'no override when only the insight has a date',
+ insightDateRange: { date_from: '-14d' },
+ filtersOverride: undefined,
+ tileFiltersOverride: undefined,
+ expected: null,
+ },
+ {
+ label: 'no replaced value when the overridden layers have no date',
+ insightDateRange: undefined,
+ filtersOverride: undefined,
+ tileFiltersOverride: { date_from: '-7d' },
+ expected: { source: 'tile', dateFrom: '-7d', dateTo: undefined, replaced: undefined },
+ },
+ {
+ label: 'replaced dropped when identical to the winning range',
+ insightDateRange: { date_from: '-7d' },
+ filtersOverride: undefined,
+ tileFiltersOverride: { date_from: '-7d' },
+ expected: { source: 'tile', dateFrom: '-7d', dateTo: undefined, replaced: undefined },
+ },
+ ])('$label', ({ insightDateRange, filterOverrideContext, filtersOverride, tileFiltersOverride, expected }) => {
+ expect(
+ getDateRangeOverrideDisplay(
+ insightDateRange,
+ filterOverrideContext,
+ filtersOverride,
+ tileFiltersOverride
+ )
+ ).toEqual(expected)
+ })
+ })
+
+ describe('dropDuplicatesOfOverrides', () => {
+ it.each([
+ {
+ label: 'flat list: exact duplicate of an override is dropped',
+ base: [browserChrome, countryUS],
+ overrides: [browserChrome],
+ expected: [countryUS],
+ },
+ {
+ label: 'flat list: same key with a different value is kept (both genuinely AND)',
+ base: [browserChrome, countryUS],
+ overrides: [browserSafari],
+ expected: [browserChrome, countryUS],
+ },
+ {
+ label: 'flat list: same key+value but different operator is kept (identity includes operator)',
+ base: [browserChrome],
+ overrides: [{ ...browserChrome, operator: 'is_not' }],
+ expected: [browserChrome],
+ },
+ {
+ label: 'scalar and single-element-array values of the same filter are treated as duplicates',
+ base: [{ key: '$email', value: '[email protected]', type: 'person', operator: 'exact' }],
+ overrides: [{ key: '$email', value: ['[email protected]'], type: 'person', operator: 'exact' }],
+ expected: [],
+ },
+ {
+ label: 'multi-value filters in a different order are treated as duplicates (values are a set)',
+ base: [{ key: '$browser', value: ['Chrome', 'Safari'], type: 'event', operator: 'exact' }],
+ overrides: [{ key: '$browser', value: ['Safari', 'Chrome'], type: 'event', operator: 'exact' }],
+ expected: [],
+ },
+ {
+ label: 'no overrides: base returned unchanged',
+ base: [browserChrome],
+ overrides: [],
+ expected: [browserChrome],
+ },
+ ])('$label', ({ base, overrides, expected }) => {
+ expect(dropDuplicatesOfOverrides(base as any, overrides as any)).toEqual(expected)
+ })
+
+ it('nested group: dedupes the matching leaf and prunes a subgroup left empty', () => {
+ const base = {
+ type: 'AND',
+ values: [
+ { type: 'AND', values: [browserChrome, countryUS] },
+ { type: 'AND', values: [browserChrome] },
+ ],
+ }
+
+ const result = dropDuplicatesOfOverrides(base as any, [browserChrome] as any) as any
+
+ // The lone-duplicate subgroup is pruned; the mixed subgroup keeps its non-duplicate leaf.
+ expect(result.values).toEqual([{ type: 'AND', values: [countryUS] }])
+ })
+ })
+
+ describe('getEffectiveFilterOverrides', () => {
+ it('renders the backend-resolved filter layers without recalculating conflicts', () => {
+ const result = getEffectiveFilterOverrides(
+ {
+ dashboard: { properties: [countryUS] } as any,
+ tile: { properties: [browserChrome] } as any,
+ overridden_dashboard: { properties: [browserSafari] } as any,
+ },
+ { properties: [browserSafari, countryUS] } as any,
+ { properties: [browserChrome] } as any
+ )
+
+ expect(result.overriddenByTile).toEqual([browserSafari])
+ expect(result.propertyGroups).toEqual([
+ { properties: [countryUS], source: 'dashboard' },
+ { properties: [browserChrome], source: 'tile' },
+ ])
+ })
+
+ it('falls back to raw layers when no backend context exists', () => {
+ const result = getEffectiveFilterOverrides(
+ undefined,
+ { properties: [countryUS] } as any,
+ { properties: [browserChrome] } as any
+ )
+
+ expect(result.overriddenByTile).toEqual([])
+ expect(result.propertyGroups).toEqual([
+ { properties: [countryUS], source: 'dashboard' },
+ { properties: [browserChrome], source: 'tile' },
+ ])
+ })
+ })
+})
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.tsx
index cfbf6d33767d..b6753cfda758 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.tsx
@@ -68,11 +68,26 @@ import {
isTrendsQuery,
hasBreakdownFilter,
} from '~/queries/utils'
-import { AnyPropertyFilter, BaseMathType, FilterLogicalOperator, PropertyGroupFilter, UserBasicType } from '~/types'
+import {
+ AnyPropertyFilter,
+ BaseMathType,
+ FilterLogicalOperator,
+ InsightFilterOverrideContext,
+ UserBasicType,
+} from '~/types'
import { PropertyKeyInfo } from '../../PropertyKeyInfo'
import { TZLabel } from '../../TZLabel'
import { CompactUniversalFiltersDisplay } from './CompactUniversalFiltersDisplay'
+import {
+ dropDuplicatesOfOverrides,
+ EffectiveDateOverride,
+ getDateRangeOverrideDisplay,
+ getEffectiveFilterOverrides,
+ OverrideSource,
+ PropertiesInput,
+ splitOutOverrideProperties,
+} from './insightDetailsFilterOverrides'
export function InsightDetailSectionDisplay({
icon,
@@ -98,79 +113,44 @@ function assertNever(value: never): never {
throw new Error(`Unexpected entity node: ${(value as { kind?: string } | undefined)?.kind ?? 'unknown'}`)
}
-type OverrideSource = 'dashboard' | 'tile'
+const LAYER_LABELS: Record<OverrideSource | 'insight', string> = {
+ insight: 'Insight',
+ dashboard: 'Dashboard',
+ tile: 'Tile',
+}
-// A tile override replaces the dashboard override wholesale (matches backend `apply_dashboard_filters`) —
-// never both at once.
-function getEffectiveFilterOverride(
- filtersOverride: DashboardFilter | undefined,
- tileFiltersOverride: TileFilters | null | undefined
-): { override: DashboardFilter | TileFilters; source: OverrideSource } | null {
- if (tileFiltersOverride && Object.keys(tileFiltersOverride).length > 0) {
- return { override: tileFiltersOverride, source: 'tile' }
- }
- if (filtersOverride && Object.keys(filtersOverride).length > 0) {
- return { override: filtersOverride, source: 'dashboard' }
- }
- return null
+// Distinct colors per layer so the precedence stack reads at a glance: insight (base, grey) →
+// dashboard (purple) → tile (accent, highest priority). Not primary/highlight for two of them — those
+// share --color-accent and would look identical.
+const LAYER_TAG_TYPE: Record<OverrideSource | 'insight', 'muted' | 'completion' | 'primary'> = {
+ insight: 'muted',
+ dashboard: 'completion',
+ tile: 'primary',
}
-function OverrideNote({ source, children }: { source: OverrideSource; children: React.ReactNode }): JSX.Element {
+function LayerTag({ source }: { source: OverrideSource | 'insight' }): JSX.Element {
return (
- <div className="mt-1.5 flex items-center gap-1">
- <LemonTag type="highlight" size="small">
- {source === 'tile' ? 'Tile' : 'Dashboard'}
- </LemonTag>
- <span className="text-muted-alt">{children}</span>
- </div>
+ <LemonTag type={LAYER_TAG_TYPE[source]} size="small">
+ {LAYER_LABELS[source]}
+ </LemonTag>
)
}
-// The override round-trips through the backend into the merged query and picks up normalized fields
-// the raw override lacks, so a deep-equal fails — compare on the fields that actually identify a filter.
-function isSamePropertyFilter(a: AnyPropertyFilter, b: AnyPropertyFilter): boolean {
- const operatorOf = (f: AnyPropertyFilter): string | undefined => ('operator' in f ? f.operator : undefined)
+function OverrideNote({
+ source,
+ children,
+}: {
+ source: OverrideSource | 'insight'
+ children: React.ReactNode
+}): JSX.Element {
return (
- (a.type ?? 'event') === (b.type ?? 'event') &&
- a.key === b.key &&
- (operatorOf(a) ?? 'exact') === (operatorOf(b) ?? 'exact') &&
- JSON.stringify(a.value ?? null) === JSON.stringify(b.value ?? null)
+ <div className="mt-1.5 flex items-center gap-1">
+ <LayerTag source={source} />
+ <span className="text-muted-alt">{children}</span>
+ </div>
)
}
-function samePropertyFilters(a: AnyPropertyFilter[], b: AnyPropertyFilter[]): boolean {
- return a.length === b.length && a.every((f, i) => isSamePropertyFilter(f, b[i]))
-}
-
-// Matches the shape `convertPropertiesToPropertyGroup` accepts: a group, a flat list, or nothing.
-type PropertiesInput = PropertyGroupFilter | AnyPropertyFilter[] | null | undefined
-
-// The query returned for a dashboard tile already has the override's properties ANDed in (as the
-// trailing subgroup/tail), so pull that part out to attribute it rather than list it twice.
-function splitOutOverrideProperties(
- properties: PropertiesInput,
- overrideProperties: AnyPropertyFilter[]
-): { base: PropertiesInput; overrideFound: boolean } {
- if (!properties || overrideProperties.length === 0) {
- return { base: properties, overrideFound: false }
- }
- // Flat list: the backend concatenated the override onto the end.
- if (Array.isArray(properties)) {
- const tailStart = properties.length - overrideProperties.length
- if (tailStart >= 0 && samePropertyFilters(properties.slice(tailStart), overrideProperties)) {
- return { base: properties.slice(0, tailStart), overrideFound: true }
- }
- return { base: properties, overrideFound: false }
- }
- // Group: the backend AND-wrapped the insight's group with the override as the final subgroup.
- const subgroups = properties.values ?? []
- const last = subgroups[subgroups.length - 1]
- if (last && samePropertyFilters(last.values as AnyPropertyFilter[], overrideProperties)) {
- return { base: { ...properties, values: subgroups.slice(0, -1) }, overrideFound: true }
- }
- return { base: properties, overrideFound: false }
-}
-
function EntityDisplay({ entity }: { entity: AnyEntityNode<AnyDataWarehouseNode> }): JSX.Element {
let content: JSX.Element
@@ -440,22 +420,48 @@ export function FormulaSummary({ query }: { query: TrendsQuery }): JSX.Element |
export function PropertiesSummary({
properties,
- override,
+ overrides,
+ overriddenByTile,
}: {
properties: PropertiesInput
- override?: { properties: AnyPropertyFilter[]; source: OverrideSource } | null
+ overrides?: { properties: AnyPropertyFilter[]; source: OverrideSource }[] | null
+ overriddenByTile?: AnyPropertyFilter[] | null
}): JSX.Element {
- const { base, overrideFound } = splitOutOverrideProperties(properties, override?.properties ?? [])
+ const overrideGroups = overrides ?? []
+ const overriddenProperties = overriddenByTile ?? []
+ const allOverrideProperties = overrideGroups.flatMap((group) => group.properties)
+ const { base, overrideFound } = splitOutOverrideProperties(properties, allOverrideProperties)
+ const dedupedBase = overrideFound ? dropDuplicatesOfOverrides(base, allOverrideProperties) : base
+ const label = overrideFound ? 'Active filters' : 'Filters'
return (
- <InsightDetailSectionDisplay icon={<IconFilter />} label="Filters">
- <CompactUniversalFiltersDisplay groupFilter={convertPropertiesToPropertyGroup(base)} />
- {/* overrideFound means we removed the override from the list above, so show it once here. */}
- {override && overrideFound && (
+ <InsightDetailSectionDisplay icon={<IconFilter />} label={label}>
+ {overrideFound && <OverrideNote source="insight">base filters:</OverrideNote>}
+ <CompactUniversalFiltersDisplay groupFilter={convertPropertiesToPropertyGroup(dedupedBase)} />
+ {overrideFound &&
+ overrideGroups.map((group) => (
+ <React.Fragment key={group.source}>
+ <OverrideNote source={group.source}>filters added on top:</OverrideNote>
+ <CompactUniversalFiltersDisplay
+ groupFilter={convertPropertiesToPropertyGroup(group.properties)}
+ />
+ </React.Fragment>
+ ))}
+ {/* Dashboard filters the tile shadowed — shown struck-through so precedence is visible. */}
+ {overrideFound && overriddenProperties.length > 0 && (
<>
- <OverrideNote source={override.source}>filters added on top:</OverrideNote>
- <CompactUniversalFiltersDisplay
- groupFilter={convertPropertiesToPropertyGroup(override.properties)}
- />
+ <LemonDivider className="my-2" />
+ <div className="text-muted-alt">
+ <div className="mt-1.5 flex items-center gap-1">
+ <LayerTag source="dashboard" />
+ <span>filter replaced by</span>
+ <LayerTag source="tile" />
+ </div>
+ <div className="line-through opacity-60">
+ <CompactUniversalFiltersDisplay
+ groupFilter={convertPropertiesToPropertyGroup(overriddenProperties)}
+ />
+ </div>
+ </div>
</>
)}
</InsightDetailSectionDisplay>
@@ -575,17 +581,33 @@ export function BreakdownSummary({
export function DateRangeSummary({
dateFrom,
dateTo,
+ override,
}: {
dateFrom: string | null | undefined
dateTo: string | null | undefined
+ override?: EffectiveDateOverride | null
}): JSX.Element | null {
const dateFilterText = dateFilterToText(dateFrom, dateTo, null)
if (!dateFilterText) {
return null
}
+ const replaced = override?.replaced
+ const replacedText = replaced ? dateFilterToText(replaced.dateFrom, replaced.dateTo, null) : null
return (
<InsightDetailSectionDisplay icon={<IconCalendar />} label="Date range">
- <div className="font-medium">{dateFilterText}</div>
+ {/* Tag the value with its source layer rather than repeating "date range" in a note. */}
+ <div className="flex items-center gap-1">
+ <span className="font-medium">{dateFilterText}</span>
+ {override && <LayerTag source={override.source} />}
+ </div>
+ {replaced && replacedText && (
+ <div className="text-muted-alt text-xs mt-0.5 flex items-center gap-1">
+ <span>
+ was <span className="line-through">{replacedText}</span> from
+ </span>
+ <LayerTag source={replaced.source} />
+ </div>
+ )}
</InsightDetailSectionDisplay>
)
}
@@ -602,22 +624,43 @@ interface InsightDetailsProps {
variablesOverride?: Record<string, HogQLVariable>
filtersOverride?: DashboardFilter
tileFiltersOverride?: TileFilters | null
+ filterOverrideContext?: InsightFilterOverrideContext | null
hasDataWarehouseSeries?: boolean
}
export const InsightDetails = React.memo(
React.forwardRef<HTMLDivElement, InsightDetailsProps>(function InsightDetailsInternal(
- { query, footerInfo, variablesOverride, filtersOverride, tileFiltersOverride, hasDataWarehouseSeries },
+ {
+ query,
+ footerInfo,
+ variablesOverride,
+ filtersOverride,
+ tileFiltersOverride,
+ filterOverrideContext,
+ hasDataWarehouseSeries,
+ },
ref
): JSX.Element {
- const effectiveOverride = getEffectiveFilterOverride(filtersOverride, tileFiltersOverride)
- const overrideProperties = effectiveOverride?.override.properties ?? []
- const overrideBreakdownFilter = effectiveOverride?.override.breakdown_filter
- const hasPropertyOverrides = overrideProperties.length > 0
+ const {
+ propertyGroups,
+ overriddenByTile,
+ breakdown: overrideBreakdown,
+ } = getEffectiveFilterOverrides(filterOverrideContext, filtersOverride, tileFiltersOverride)
+ const insightDateRange = isInsightVizNode(query) ? query.source.dateRange : undefined
+ const dateOverride = getDateRangeOverrideDisplay(
+ insightDateRange,
+ filterOverrideContext,
+ filtersOverride,
+ tileFiltersOverride
+ )
+ const overrideBreakdownFilter = overrideBreakdown?.breakdownFilter
+ const hasPropertyOverrides = propertyGroups.length > 0
const hasIgnoredBreakdownOverrides =
isInsightVizNode(query) &&
isTrendsQuery(query.source) &&
- hasUnsupportedBreakdownForDataWarehouseTrends(effectiveOverride?.override)
+ hasUnsupportedBreakdownForDataWarehouseTrends(
+ overrideBreakdownFilter ? { breakdown_filter: overrideBreakdownFilter } : null
+ )
return (
<div className="InsightDetails space-y-2" ref={ref}>
@@ -630,6 +673,13 @@ export const InsightDetails = React.memo(
variables={isHogQLQuery(query.source) ? query.source.variables : undefined}
variablesOverride={variablesOverride}
/>
+ {dateOverride && (
+ <DateRangeSummary
+ dateFrom={dateOverride.dateFrom}
+ dateTo={dateOverride.dateTo}
+ override={dateOverride}
+ />
+ )}
{hasDataWarehouseSeries && hasPropertyOverrides ? (
<PropertiesIgnoredWarning />
) : (
@@ -639,19 +689,16 @@ export const InsightDetails = React.memo(
? query.source.filters?.properties
: query.source.properties
}
- override={
- effectiveOverride && hasPropertyOverrides
- ? { properties: overrideProperties, source: effectiveOverride.source }
- : null
- }
+ overrides={hasPropertyOverrides ? propertyGroups : null}
+ overriddenByTile={hasPropertyOverrides ? overriddenByTile : null}
/>
)}
{hasDataWarehouseSeries && hasIgnoredBreakdownOverrides ? (
<BreakdownIgnoredWarning />
- ) : effectiveOverride && hasBreakdownFilter(overrideBreakdownFilter) ? (
+ ) : overrideBreakdown && hasBreakdownFilter(overrideBreakdownFilter) ? (
<BreakdownSummary
breakdownFilter={overrideBreakdownFilter}
- override={{ source: effectiveOverride.source }}
+ override={{ source: overrideBreakdown.source }}
/>
) : (
<InsightBreakdownSummary query={query.source} />
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.test.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.test.tsx
index 5bfc911d89ae..1c8026cd59a5 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.test.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.test.tsx
@@ -8,16 +8,21 @@ describe('InsightMeta', () => {
describe('getEffectiveDateOverride', () => {
it.each([
{
- label: 'tile override with dates → uses tile dates, ignores dashboard',
+ label: 'backend-resolved tile dates override raw dashboard and tile inputs',
+ filterOverrideContext: {
+ dashboard: null,
+ tile: { date_from: '-7d' },
+ overridden_dashboard: { date_from: '-30d' },
+ },
filtersOverride: { date_from: '-30d' },
- tileFiltersOverride: { date_from: '-7d' },
+ tileFiltersOverride: { date_from: '-3d' },
expected: { dateFromOverride: '-7d', dateToOverride: undefined },
},
{
- label: 'tile override without dates (properties-only) → falls back to insight, not dashboard',
+ label: 'tile override without dates (properties-only) → keeps dashboard dates (merge)',
filtersOverride: { date_from: '-30d' },
tileFiltersOverride: { properties: [] },
- expected: { dateFromOverride: undefined, dateToOverride: undefined },
+ expected: { dateFromOverride: '-30d', dateToOverride: undefined },
},
{
label: 'no tile override → uses dashboard override dates',
@@ -31,8 +36,10 @@ describe('InsightMeta', () => {
tileFiltersOverride: undefined,
expected: { dateFromOverride: undefined, dateToOverride: undefined },
},
- ])('$label', ({ filtersOverride, tileFiltersOverride, expected }) => {
- expect(getEffectiveDateOverride(filtersOverride, tileFiltersOverride)).toEqual(expected)
+ ])('$label', ({ filterOverrideContext, filtersOverride, tileFiltersOverride, expected }) => {
+ expect(getEffectiveDateOverride(filterOverrideContext, filtersOverride, tileFiltersOverride)).toEqual(
+ expected
+ )
})
})
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
index 0a87e9c110d1..723a7d8df8bc 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
@@ -52,6 +52,7 @@ import {
InsightLogicProps,
InsightShortId,
QueryBasedInsightModel,
+ InsightFilterOverrideContext,
} from '~/types'
import {
@@ -105,13 +106,15 @@ interface InsightMetaProps extends Pick<
onCreateAnomalyAlert?: () => void
}
-// Any tile override wins wholesale over the dashboard's (backend `apply_dashboard_filters`), so a tile
-// override with no dates uses the insight's own range, never the dashboard's.
export function getEffectiveDateOverride(
+ filterOverrideContext: InsightFilterOverrideContext | null | undefined,
filtersOverride: DashboardFilter | undefined,
tileFiltersOverride: TileFilters | undefined
): { dateFromOverride: string | null | undefined; dateToOverride: string | null | undefined } {
- const source = Object.keys(tileFiltersOverride ?? {}).length > 0 ? tileFiltersOverride : filtersOverride
+ const dashboardFilters = filterOverrideContext ? filterOverrideContext.dashboard : filtersOverride
+ const tileFilters = filterOverrideContext ? filterOverrideContext.tile : tileFiltersOverride
+ const tileHasDate = tileFilters?.date_from != null || tileFilters?.date_to != null
+ const source = tileHasDate ? tileFilters : dashboardFilters
return { dateFromOverride: source?.date_from, dateToOverride: source?.date_to }
}
@@ -196,7 +199,7 @@ export function InsightMeta({
const showCompactHeading = !showCompactTile || !isSqlInsight
const hasTileOverrides = Object.keys(tileFiltersOverride ?? {}).length > 0
- const dateOverride = getEffectiveDateOverride(filtersOverride, tileFiltersOverride)
+ const dateOverride = getEffectiveDateOverride(insight.filter_override_context, filtersOverride, tileFiltersOverride)
const topHeadingProps = {
query: insight.query,
lastRefresh: insight.last_refresh,
@@ -361,6 +364,7 @@ export function InsightMeta({
variablesOverride={variablesOverride}
filtersOverride={filtersOverride}
tileFiltersOverride={tileFiltersOverride ?? null}
+ filterOverrideContext={insight.filter_override_context}
hasDataWarehouseSeries={hasDataWarehouseSeries}
/>
) : null
diff --git a/frontend/src/lib/components/Cards/InsightCard/TileOverridesWarning.tsx b/frontend/src/lib/components/Cards/InsightCard/TileOverridesWarning.tsx
index 6e8285adc133..41e962e07829 100644
--- a/frontend/src/lib/components/Cards/InsightCard/TileOverridesWarning.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/TileOverridesWarning.tsx
@@ -7,7 +7,7 @@ export function TileOverridesWarning(): JSX.Element | null {
<Tooltip
title={
<div className="flex items-center gap-1">
- <span>Tile filters override all other filters</span>
+ <span>Tile filters merge with the dashboard's, taking precedence where they overlap</span>
</div>
}
>
diff --git a/frontend/src/lib/components/Cards/InsightCard/insightDetailsFilterOverrides.ts b/frontend/src/lib/components/Cards/InsightCard/insightDetailsFilterOverrides.ts
new file mode 100644
index 000000000000..5df8b90a16b1
--- /dev/null
+++ b/frontend/src/lib/components/Cards/InsightCard/insightDetailsFilterOverrides.ts
@@ -0,0 +1,181 @@
+import { DashboardFilter, TileFilters } from '~/queries/schema/schema-general'
+import { AnyPropertyFilter, InsightFilterOverrideContext, PropertyGroupFilter } from '~/types'
+
+export type OverrideSource = 'dashboard' | 'tile'
+
+export interface EffectiveFilterOverrides {
+ propertyGroups: { properties: AnyPropertyFilter[]; source: OverrideSource }[]
+ overriddenByTile: AnyPropertyFilter[]
+ breakdown: { breakdownFilter: NonNullable<DashboardFilter['breakdown_filter']>; source: OverrideSource } | null
+}
+
+export function getEffectiveFilterOverrides(
+ filterOverrideContext: InsightFilterOverrideContext | null | undefined,
+ filtersOverride: DashboardFilter | undefined,
+ tileFiltersOverride: TileFilters | null | undefined
+): EffectiveFilterOverrides {
+ const dashboardFilters = filterOverrideContext ? filterOverrideContext.dashboard : filtersOverride
+ const tileFilters = filterOverrideContext ? filterOverrideContext.tile : tileFiltersOverride
+ const dashboardProperties = (dashboardFilters?.properties ?? []) as AnyPropertyFilter[]
+ const tileProperties = (tileFilters?.properties ?? []) as AnyPropertyFilter[]
+ const overriddenByTile = (filterOverrideContext?.overridden_dashboard?.properties ?? []) as AnyPropertyFilter[]
+ const propertyGroups: EffectiveFilterOverrides['propertyGroups'] = []
+ if (dashboardProperties.length > 0) {
+ propertyGroups.push({ properties: dashboardProperties, source: 'dashboard' })
+ }
+ if (tileProperties.length > 0) {
+ propertyGroups.push({ properties: tileProperties, source: 'tile' })
+ }
+
+ const tileBreakdown = tileFilters?.breakdown_filter as DashboardFilter['breakdown_filter']
+ const dashboardBreakdown = dashboardFilters?.breakdown_filter as DashboardFilter['breakdown_filter']
+ const breakdown = tileBreakdown
+ ? { breakdownFilter: tileBreakdown, source: 'tile' as const }
+ : dashboardBreakdown
+ ? { breakdownFilter: dashboardBreakdown, source: 'dashboard' as const }
+ : null
+
+ return { propertyGroups, overriddenByTile, breakdown }
+}
+
+interface DateRangeSource {
+ date_from?: string | null
+ date_to?: string | null
+}
+
+export interface EffectiveDateOverride {
+ source: OverrideSource
+ dateFrom: string | null | undefined
+ dateTo: string | null | undefined
+ // The lower-priority layer this replaced, shown struck-through so the precedence is visible.
+ replaced?: {
+ source: OverrideSource | 'insight'
+ dateFrom: string | null | undefined
+ dateTo: string | null | undefined
+ }
+}
+
+function hasDateBound(source: DateRangeSource | null | undefined): boolean {
+ // `!= null` (not truthiness) matches the backend's `is not None`, so an explicit empty-string bound counts.
+ return source?.date_from != null || source?.date_to != null
+}
+
+// Works out which layer's date range applies and what it replaced (tile beats dashboard beats the
+// insight's own range); returns null when the insight's own range wins.
+export function getDateRangeOverrideDisplay(
+ insightDateRange: DateRangeSource | undefined,
+ filterOverrideContext: InsightFilterOverrideContext | null | undefined,
+ filtersOverride: DashboardFilter | undefined,
+ tileFiltersOverride: TileFilters | null | undefined
+): EffectiveDateOverride | null {
+ const dashboardFilters = filterOverrideContext ? filterOverrideContext.dashboard : filtersOverride
+ const tileFilters = filterOverrideContext ? filterOverrideContext.tile : tileFiltersOverride
+ let winner: {
+ source: OverrideSource
+ dateFrom: string | null | undefined
+ dateTo: string | null | undefined
+ } | null = null
+ if (hasDateBound(tileFilters)) {
+ winner = { source: 'tile', dateFrom: tileFilters?.date_from, dateTo: tileFilters?.date_to }
+ } else if (hasDateBound(dashboardFilters)) {
+ winner = { source: 'dashboard', dateFrom: dashboardFilters?.date_from, dateTo: dashboardFilters?.date_to }
+ }
+ if (!winner) {
+ return null
+ }
+
+ let replaced: EffectiveDateOverride['replaced']
+ if (hasDateBound(filterOverrideContext?.overridden_dashboard)) {
+ replaced = {
+ source: 'dashboard',
+ dateFrom: filterOverrideContext?.overridden_dashboard?.date_from,
+ dateTo: filterOverrideContext?.overridden_dashboard?.date_to,
+ }
+ } else if (winner.source === 'tile' && hasDateBound(filtersOverride)) {
+ replaced = { source: 'dashboard', dateFrom: filtersOverride?.date_from, dateTo: filtersOverride?.date_to }
+ } else if (hasDateBound(insightDateRange)) {
+ replaced = { source: 'insight', dateFrom: insightDateRange?.date_from, dateTo: insightDateRange?.date_to }
+ }
+ if (replaced && replaced.dateFrom === winner.dateFrom && replaced.dateTo === winner.dateTo) {
+ replaced = undefined
+ }
+
+ return { ...winner, replaced }
+}
+
+// A scalar and its single-element array form mean the same filter, and the value list is a set, so
+// compare as a sorted set.
+function normalizeFilterValue(value: unknown): string {
+ const entries = value == null ? [] : Array.isArray(value) ? value : [value]
+ return JSON.stringify([...new Set(entries.map((entry) => JSON.stringify(entry)))].sort())
+}
+
+// The override round-trips through the backend and picks up normalized fields the raw override lacks, so a
+// deep-equal fails — compare on the fields that actually identify a filter.
+function isSamePropertyFilter(a: AnyPropertyFilter, b: AnyPropertyFilter): boolean {
+ const operatorOf = (f: AnyPropertyFilter): string | undefined => ('operator' in f ? f.operator : undefined)
+ return (
+ (a.type ?? 'event') === (b.type ?? 'event') &&
+ a.key === b.key &&
+ (operatorOf(a) ?? 'exact') === (operatorOf(b) ?? 'exact') &&
+ normalizeFilterValue(a.value) === normalizeFilterValue(b.value)
+ )
+}
+
+function samePropertyFilters(a: AnyPropertyFilter[], b: AnyPropertyFilter[]): boolean {
+ return a.length === b.length && a.every((f, i) => isSamePropertyFilter(f, b[i]))
+}
+
+// The shape `convertPropertiesToPropertyGroup` accepts: a group, a flat list, or nothing.
+export type PropertiesInput = PropertyGroupFilter | AnyPropertyFilter[] | null | undefined
+
+// Drop base leaves that are exact duplicates of a filter shown in a higher-priority override layer, so a
+// filter the insight and an override both set shows once, on the layer that took priority. A shared key
+// with a different value is left alone, since both genuinely AND together.
+export function dropDuplicatesOfOverrides(
+ base: PropertiesInput,
+ overrideProperties: AnyPropertyFilter[]
+): PropertiesInput {
+ if (!base || overrideProperties.length === 0) {
+ return base
+ }
+ const isDuplicate = (leaf: AnyPropertyFilter): boolean =>
+ overrideProperties.some((override) => isSamePropertyFilter(leaf, override))
+ if (Array.isArray(base)) {
+ return base.filter((leaf) => !isDuplicate(leaf))
+ }
+ const values = (base.values ?? [])
+ .map((subgroup) =>
+ 'values' in subgroup && Array.isArray(subgroup.values)
+ ? { ...subgroup, values: (subgroup.values as AnyPropertyFilter[]).filter((leaf) => !isDuplicate(leaf)) }
+ : subgroup
+ )
+ .filter((subgroup) => !('values' in subgroup && Array.isArray(subgroup.values) && subgroup.values.length === 0))
+ return { ...base, values }
+}
+
+// The query returned for a dashboard tile already has the override's properties ANDed in as the trailing
+// subgroup/tail, so pull that part out to attribute it rather than list it twice.
+export function splitOutOverrideProperties(
+ properties: PropertiesInput,
+ overrideProperties: AnyPropertyFilter[]
+): { base: PropertiesInput; overrideFound: boolean } {
+ if (!properties || overrideProperties.length === 0) {
+ return { base: properties, overrideFound: false }
+ }
+ // Flat list: the backend concatenated the override onto the end.
+ if (Array.isArray(properties)) {
+ const tailStart = properties.length - overrideProperties.length
+ if (tailStart >= 0 && samePropertyFilters(properties.slice(tailStart), overrideProperties)) {
+ return { base: properties.slice(0, tailStart), overrideFound: true }
+ }
+ return { base: properties, overrideFound: false }
+ }
+ // Group: the backend AND-wrapped the insight's group with the override as the final subgroup.
+ const subgroups = properties.values ?? []
+ const last = subgroups[subgroups.length - 1]
+ if (last && samePropertyFilters(last.values as AnyPropertyFilter[], overrideProperties)) {
+ return { base: { ...properties, values: subgroups.slice(0, -1) }, overrideFound: true }
+ }
+ return { base: properties, overrideFound: false }
+}
diff --git a/frontend/src/scenes/dashboard/TileFiltersOverride.tsx b/frontend/src/scenes/dashboard/TileFiltersOverride.tsx
index cda761929831..902b01e6b76c 100644
--- a/frontend/src/scenes/dashboard/TileFiltersOverride.tsx
+++ b/frontend/src/scenes/dashboard/TileFiltersOverride.tsx
@@ -27,7 +27,8 @@ export function TileFiltersOverride({ tile }: { tile: DashboardTile<QueryBasedIn
<div className="space-y-4 tile-filters-override">
<div>
<p className="text-sm text-muted mb-4">
- Set custom filters for this tile that will override all other filters.
+ Set custom filters for this tile. Property filters apply on top of the dashboard's, while the tile's
+ date range and breakdown replace the dashboard's.
</p>
</div>
diff --git a/frontend/src/scenes/saved-insights/activityDescriptions.tsx b/frontend/src/scenes/saved-insights/activityDescriptions.tsx
index fd374b97c541..dd2d4db26ff3 100644
--- a/frontend/src/scenes/saved-insights/activityDescriptions.tsx
+++ b/frontend/src/scenes/saved-insights/activityDescriptions.tsx
@@ -241,6 +241,7 @@ const insightActionsMapping: Record<
viewers: () => null,
view_count: () => null,
is_cached: () => null,
+ filter_override_context: () => null,
}
function summarizeChanges(filtersAfter: Partial<FilterType>): ChangeMapping | null {
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 30d8caf639a1..a39e2728de3f 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -80,6 +80,7 @@ import { QueryContext } from '~/queries/types'
import { AlertType } from 'products/alerts/frontend/types'
import type { ExperimentFeatureFlagInputApi } from 'products/experiments/frontend/generated/api.schemas'
+import type { InsightFilterOverrideContextApi } from 'products/product_analytics/frontend/generated/api.schemas'
import type { AIPromptConfigApi } from 'products/subscriptions/frontend/generated/api.schemas'
import { CyclotronInputType } from 'products/workflows/frontend/Workflows/hogflows/steps/types'
import type { HogFlow } from 'products/workflows/frontend/Workflows/hogflows/types'
@@ -2525,10 +2526,13 @@ export interface InsightModel extends Cacheable, WithAccessControl {
query?: Node | null
query_status?: QueryStatus
is_cached?: boolean
+ filter_override_context?: InsightFilterOverrideContextApi | null
/** Only used when creating objects */
_create_in_folder?: string | null
}
+export type InsightFilterOverrideContext = InsightFilterOverrideContextApi
+
export interface QueryBasedInsightModel<R extends Node<Record<string, any>> = Node<Record<string, any>>> extends Omit<
InsightModel,
'filters'
diff --git a/posthog/api/test/dashboards/test_dashboard.py b/posthog/api/test/dashboards/test_dashboard.py
index a4d8fa6a135c..6879599fc566 100644
--- a/posthog/api/test/dashboards/test_dashboard.py
+++ b/posthog/api/test/dashboards/test_dashboard.py
@@ -2804,6 +2804,7 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):
"effective_privilege_level": 37,
"effective_restriction_level": 21,
"favorited": False,
+ "filter_override_context": None,
"filters": {},
"filters_hash": ANY,
"hasMore": None,
diff --git a/posthog/caching/calculate_results.py b/posthog/caching/calculate_results.py
index 84eeeaf49267..b7ce0e0e95e3 100644
--- a/posthog/caching/calculate_results.py
+++ b/posthog/caching/calculate_results.py
@@ -10,6 +10,7 @@ from posthog.hogql.constants import LimitContext
from posthog.api.services.query import ExecutionMode, process_query_dict
from posthog.clickhouse.query_tagging import get_team_query_tags, tag_queries
from posthog.event_usage import AnalyticsProps
+from posthog.hogql_queries.apply_dashboard_filters import resolve_effective_dashboard_filters
from posthog.hogql_queries.query_runner import get_query_runner_or_none, response_results_contain_models
from posthog.models import Team, User
from posthog.schema_migrations.upgrade_manager import upgrade_query
@@ -102,14 +103,14 @@ def calculate_for_query_based_insight(
variables_override if variables_override is not None else dashboard.variables if dashboard is not None else None
)
- # Tile filters overrides all other filters
- if tile_filters_override is not None and tile_filters_override != {}:
- dashboard_filters_json = tile_filters_override
-
query_json: dict | None = query_override if query_override is not None else insight.query
if query_json is None:
raise ValueError("Insight has no query and no query_override was provided")
+ query_json, dashboard_filters_json = resolve_effective_dashboard_filters(
+ query_json, dashboard_filters_json, tile_filters_override
+ )
+
process_response = process_query_dict(
team,
query_json,
diff --git a/posthog/hogql_queries/apply_dashboard_filters.py b/posthog/hogql_queries/apply_dashboard_filters.py
index c2ebc2923f9e..1c0e67cdf3d9 100644
--- a/posthog/hogql_queries/apply_dashboard_filters.py
+++ b/posthog/hogql_queries/apply_dashboard_filters.py
@@ -1,12 +1,202 @@
-from typing import Any
+from typing import Any, TypedDict
from posthog.schema import DashboardFilter, HogQLVariable, NodeKind
from posthog.exceptions_capture import capture_exception
from posthog.hogql_queries.query_runner import get_query_runner
+from posthog.hogql_queries.utils.dashboard_filter_conflicts import filters_contradict
from posthog.models import Team
WRAPPER_NODE_KINDS = [NodeKind.DATA_TABLE_NODE, NodeKind.DATA_VISUALIZATION_NODE, NodeKind.INSIGHT_VIZ_NODE]
+_DATA_WAREHOUSE_NODE_KINDS = {"DataWarehouseNode", "FunnelsDataWarehouseNode", "LifecycleDataWarehouseNode"}
+
+# Fields where the higher-priority (override) layer replaces the lower-priority (base) value outright
+# when set. Property filters are handled separately (stacked unless they contradict).
+_SCALAR_OVERRIDE_FIELDS = ["breakdown_filter", "interval", "filterTestAccounts"]
+
+
+class FilterLayerResolution(TypedDict):
+ dashboard: dict
+ tile: dict
+ overridden_dashboard: dict
+
+
+def resolve_filter_layers_by_priority(
+ base_filters: dict | None, override_filters: dict | None
+) -> FilterLayerResolution:
+ base = base_filters or {}
+ override = override_filters or {}
+ effective_base = {**base}
+ overridden_base: dict = {}
+
+ for field in _SCALAR_OVERRIDE_FIELDS:
+ if override.get(field) is not None:
+ effective_base.pop(field, None)
+ if base.get(field) is not None:
+ overridden_base[field] = base[field]
+
+ if override.get("date_from") is not None or override.get("date_to") is not None:
+ if base.get("date_from") is not None or base.get("date_to") is not None:
+ overridden_base["date_from"] = base.get("date_from")
+ overridden_base["date_to"] = base.get("date_to")
+ if base.get("explicitDate") is not None:
+ overridden_base["explicitDate"] = base["explicitDate"]
+ effective_base.pop("date_from", None)
+ effective_base.pop("date_to", None)
+ effective_base.pop("explicitDate", None)
+
+ override_props = override.get("properties") or []
+ base_props = base.get("properties") or []
+ contradicted_base = []
+ surviving_base = []
+ for base_property in base_props:
+ if any(filters_contradict(base_property, override_property) for override_property in override_props):
+ contradicted_base.append(base_property)
+ else:
+ surviving_base.append(base_property)
+ if contradicted_base:
+ overridden_base["properties"] = contradicted_base
+ if base_props:
+ if surviving_base:
+ effective_base["properties"] = surviving_base
+ else:
+ effective_base.pop("properties", None)
+
+ return {
+ "dashboard": effective_base,
+ "tile": override,
+ "overridden_dashboard": overridden_base,
+ }
+
+
+def merge_filters_by_priority(base_filters: dict | None, override_filters: dict | None) -> dict:
+ """Merge two filter layers, with `override_filters` taking priority over `base_filters`.
+
+ The override wins per field. Scalars (breakdown, interval, test-account filtering) are replaced
+ outright when the override sets them. Property filters stack (AND-combine) by default, since two
+ filters on the same key can still describe a valid set (e.g. `utm_source = google` and
+ `utm_source is set`). A base property is dropped only when an override property provably contradicts
+ it — ANDing them could never match — in which case the override wins. The date range is treated as
+ one unit — an override that sets either bound supplies both bounds and explicitDate, so an override
+ date_from is never paired with a stale base date_to or a stale base explicitDate.
+
+ Callers today use this for the dashboard/tile layer pair (dashboard as base, tile as override), but
+ the algorithm itself is generic priority merging and isn't tied to that pairing.
+
+ Overriding the insight's own base filters (not just the lower-priority layer's) is handled separately
+ by `remove_query_properties_overridden_by`, which the override-aware call sites apply to the query.
+ """
+ if not override_filters:
+ return base_filters or {}
+ if not base_filters:
+ return override_filters or {}
+
+ resolved_layers = resolve_filter_layers_by_priority(base_filters, override_filters)
+ merged = {**resolved_layers["dashboard"]}
+
+ for field in _SCALAR_OVERRIDE_FIELDS:
+ if override_filters.get(field) is not None:
+ merged[field] = override_filters[field]
+
+ if override_filters.get("date_from") is not None or override_filters.get("date_to") is not None:
+ merged["date_from"] = override_filters.get("date_from")
+ merged["date_to"] = override_filters.get("date_to")
+ # The date range is one unit — drop the base's explicitDate before adopting the override's.
+ merged.pop("explicitDate", None)
+ if override_filters.get("explicitDate") is not None:
+ merged["explicitDate"] = override_filters["explicitDate"]
+
+ override_props = override_filters.get("properties") or []
+ combined_properties = (resolved_layers["dashboard"].get("properties") or []) + override_props
+ if combined_properties:
+ merged["properties"] = combined_properties
+
+ return merged
+
+
+def _without_contradicted(properties: Any, overriding_props: list[dict]) -> Any:
+ """Drop leaf property filters that any `overriding_props` filter provably contradicts from a query's
+ `properties`, which is either a flat list of leaves or a `PropertyGroupFilter` dict (a group of
+ `PropertyGroupFilterValue` subgroups, themselves arbitrarily nested — AND of ORs of ANDs, etc).
+ Recurses into every nested subgroup rather than stopping at one level, since leaves can sit at any
+ depth. Emptied subgroups are pruned."""
+
+ def is_contradicted(leaf: Any) -> bool:
+ return isinstance(leaf, dict) and any(filters_contradict(leaf, o) for o in overriding_props)
+
+ if isinstance(properties, list):
+ return [p for p in properties if not is_contradicted(p)]
+ if isinstance(properties, dict) and isinstance(properties.get("values"), list):
+ new_values = []
+ for value in properties["values"]:
+ if isinstance(value, dict) and isinstance(value.get("values"), list):
+ pruned = _without_contradicted(value, overriding_props)
+ if pruned["values"]:
+ new_values.append(pruned)
+ elif not is_contradicted(value):
+ new_values.append(value)
+ return {**properties, "values": new_values}
+ return properties
+
+
+def _strip_query_properties(query: dict, overriding_props: list[dict]) -> dict:
+ if query.get("kind") in WRAPPER_NODE_KINDS:
+ return {**query, "source": _strip_query_properties(query["source"], overriding_props)}
+ if query.get("properties") is not None:
+ query = {**query, "properties": _without_contradicted(query["properties"], overriding_props)}
+ series = query.get("series")
+ if isinstance(series, list):
+ query = {
+ **query,
+ "series": [
+ (
+ {**node, "properties": _without_contradicted(node["properties"], overriding_props)}
+ if isinstance(node, dict) and node.get("properties") is not None
+ else node
+ )
+ for node in series
+ ],
+ }
+ filters = query.get("filters")
+ if isinstance(filters, dict) and filters.get("properties") is not None:
+ query = {
+ **query,
+ "filters": {**filters, "properties": _without_contradicted(filters["properties"], overriding_props)},
+ }
+ return query
+
+
+def remove_query_properties_overridden_by(query: dict, overriding_filters: dict | None) -> dict:
+ """Drop the insight's own property filters that an `overriding_filters` property provably contradicts,
+ so the higher-priority layers take precedence over the insight's base filter instead of AND-ing a
+ contradiction into an empty result. Compatible filters on the same key are left in place to stack.
+ Callers pass the effective dashboard + tile filter set, so both layers can override the insight's own
+ filter."""
+ overriding_props = (overriding_filters or {}).get("properties") or []
+ if not overriding_props:
+ return query
+ return _strip_query_properties(query, overriding_props)
+
+
+def _has_data_warehouse_series(query: dict) -> bool:
+ if query.get("kind") in WRAPPER_NODE_KINDS:
+ return _has_data_warehouse_series(query["source"])
+ series = query.get("series")
+ return isinstance(series, list) and any(
+ isinstance(node, dict) and node.get("kind") in _DATA_WAREHOUSE_NODE_KINDS for node in series
+ )
+
+
+def resolve_effective_dashboard_filters(
+ query: dict, base_filters: dict | None, tile_filters_override: dict | None
+) -> tuple[dict, dict]:
+ """Combine dashboard and tile filters for query execution and display reconstruction."""
+ effective_filters = (
+ merge_filters_by_priority(base_filters, tile_filters_override) if tile_filters_override else base_filters or {}
+ )
+ if effective_filters and not _has_data_warehouse_series(query):
+ query = remove_query_properties_overridden_by(query, effective_filters)
+ return query, effective_filters
# Apply the filters from the django-style Dashboard object
diff --git a/posthog/hogql_queries/test/test_dashboard_filters_overrides.py b/posthog/hogql_queries/test/test_dashboard_filters_overrides.py
index ceec90d314f7..ce8ce439dd40 100644
--- a/posthog/hogql_queries/test/test_dashboard_filters_overrides.py
+++ b/posthog/hogql_queries/test/test_dashboard_filters_overrides.py
@@ -6,6 +6,7 @@ from parameterized import parameterized
from posthog.schema import (
DashboardFilter,
+ DataWarehouseNode,
EventsNode,
FunnelsQuery,
IntervalType,
@@ -18,6 +19,10 @@ from posthog.schema import (
TrendsQuery,
)
+from posthog.hogql_queries.apply_dashboard_filters import (
+ apply_dashboard_filters_to_dict,
+ resolve_effective_dashboard_filters,
+)
from posthog.hogql_queries.insights.funnels.funnels_query_runner import FunnelsQueryRunner
from posthog.hogql_queries.insights.lifecycle.lifecycle_query_runner import LifecycleQueryRunner
from posthog.hogql_queries.insights.retention.retention_query_runner import RetentionQueryRunner
@@ -129,3 +134,28 @@ class TestDashboardFiltersTestAccountsOverride(BaseTest):
runner.apply_dashboard_filters(DashboardFilter())
assert runner.query.filterTestAccounts is True
+
+
+class TestDashboardPropertyOverrides(BaseTest):
+ def test_warehouse_insight_property_is_kept_when_dashboard_properties_are_ignored(self) -> None:
+ insight_property = {"key": "region", "value": "US", "operator": "exact", "type": "data_warehouse"}
+ dashboard_property = {"key": "region", "value": "EU", "operator": "exact", "type": "data_warehouse"}
+ query = TrendsQuery(
+ series=[
+ DataWarehouseNode(
+ id="warehouse_table",
+ id_field="id",
+ distinct_id_field="distinct_id",
+ table_name="warehouse_table",
+ timestamp_field="timestamp",
+ properties=[insight_property],
+ )
+ ]
+ ).model_dump()
+
+ query, effective_filters = resolve_effective_dashboard_filters(
+ query, {"properties": [dashboard_property]}, None
+ )
+ result = apply_dashboard_filters_to_dict(query, effective_filters, self.team)
+
+ assert [prop["value"] for prop in result["series"][0]["properties"]] == ["US"]
diff --git a/posthog/hogql_queries/test/test_merge_filters_by_priority.py b/posthog/hogql_queries/test/test_merge_filters_by_priority.py
new file mode 100644
index 000000000000..077846a228f5
--- /dev/null
+++ b/posthog/hogql_queries/test/test_merge_filters_by_priority.py
@@ -0,0 +1,248 @@
+from django.test import SimpleTestCase
+
+from parameterized import parameterized
+
+from posthog.hogql_queries.apply_dashboard_filters import (
+ merge_filters_by_priority,
+ remove_query_properties_overridden_by,
+ resolve_filter_layers_by_priority,
+)
+
+
+class TestMergeFiltersByPriority(SimpleTestCase):
+ @parameterized.expand(
+ [
+ ("both empty", None, None, {}),
+ ("only dashboard", {"date_from": "-30d"}, None, {"date_from": "-30d"}),
+ ("only tile", None, {"date_from": "-7d"}, {"date_from": "-7d"}),
+ ("empty tile keeps dashboard", {"date_from": "-30d"}, {}, {"date_from": "-30d"}),
+ ]
+ )
+ def test_returns_single_layer_when_other_absent(self, _name, dashboard, tile, expected):
+ assert merge_filters_by_priority(dashboard, tile) == expected
+
+ def test_tile_scalar_fields_win_over_dashboard(self):
+ merged = merge_filters_by_priority(
+ {"interval": "day", "filterTestAccounts": False},
+ {"interval": "week", "filterTestAccounts": True},
+ )
+ assert merged == {"interval": "week", "filterTestAccounts": True}
+
+ def test_dashboard_scalar_kept_when_tile_leaves_it_unset(self):
+ merged = merge_filters_by_priority(
+ {"interval": "day", "filterTestAccounts": True},
+ {"breakdown_filter": {"breakdown": "$browser", "breakdown_type": "event"}},
+ )
+ assert merged["interval"] == "day"
+ assert merged["filterTestAccounts"] is True
+ assert merged["breakdown_filter"] == {"breakdown": "$browser", "breakdown_type": "event"}
+
+ def test_properties_on_different_keys_are_and_combined_dashboard_first(self):
+ dashboard_prop = {"key": "$country", "value": "US", "type": "event"}
+ tile_prop = {"key": "$browser", "value": "Chrome", "type": "event"}
+
+ merged = merge_filters_by_priority(
+ {"properties": [dashboard_prop]},
+ {"properties": [tile_prop]},
+ )
+
+ assert merged["properties"] == [dashboard_prop, tile_prop]
+
+ def test_tile_property_replaces_dashboard_property_when_they_contradict(self):
+ # Disjoint exact sets on the same key can never both match, so the tile wins outright rather than
+ # AND-ing (which would zero out results).
+ dashboard_prop = {"key": "$browser", "value": ["Chrome", "Safari"], "type": "event", "operator": "exact"}
+ tile_prop = {"key": "$browser", "value": ["Firefox"], "type": "event", "operator": "exact"}
+
+ merged = merge_filters_by_priority(
+ {"properties": [dashboard_prop]},
+ {"properties": [tile_prop]},
+ )
+ resolved_layers = resolve_filter_layers_by_priority(
+ {"properties": [dashboard_prop]},
+ {"properties": [tile_prop]},
+ )
+
+ assert merged["properties"] == [tile_prop]
+ assert resolved_layers == {
+ "dashboard": {},
+ "tile": {"properties": [tile_prop]},
+ "overridden_dashboard": {"properties": [dashboard_prop]},
+ }
+
+ def test_compatible_properties_on_same_key_stack_instead_of_replacing(self):
+ # `utm_source = google` and `utm_source is set` describe a valid combined set, so both apply
+ # rather than the tile dropping the dashboard's filter.
+ dashboard_prop = {"key": "utm_source", "value": ["google"], "type": "event", "operator": "exact"}
+ tile_prop = {"key": "utm_source", "type": "event", "operator": "is_set"}
+
+ merged = merge_filters_by_priority(
+ {"properties": [dashboard_prop]},
+ {"properties": [tile_prop]},
+ )
+
+ assert merged["properties"] == [dashboard_prop, tile_prop]
+
+ def test_date_range_treated_as_a_unit_when_tile_sets_a_bound(self):
+ # Tile sets only date_from, so the dashboard's date_to must not leak through.
+ merged = merge_filters_by_priority(
+ {"date_from": "-30d", "date_to": "-1d"},
+ {"date_from": "-7d"},
+ )
+ assert merged["date_from"] == "-7d"
+ assert merged["date_to"] is None
+
+ @parameterized.expand(
+ [
+ (
+ "dashboard explicitDate dropped when tile range omits it",
+ {"date_from": "2026-01-01", "date_to": "2026-01-31", "explicitDate": True},
+ {"date_from": "-7d"},
+ None,
+ ),
+ (
+ "tile explicitDate applied with tile range",
+ {"date_from": "-30d"},
+ {"date_from": "-7d", "explicitDate": True},
+ True,
+ ),
+ ]
+ )
+ def test_explicit_date_follows_the_tile_range_not_the_dashboards(self, _name, dashboard, tile, expected):
+ merged = merge_filters_by_priority(dashboard, tile)
+ assert merged["date_from"] == "-7d"
+ assert merged.get("explicitDate") is expected
+
+ def test_dashboard_date_range_kept_when_tile_has_no_dates(self):
+ merged = merge_filters_by_priority(
+ {"date_from": "-30d", "date_to": "-1d"},
+ {"properties": [{"key": "$browser", "value": "Chrome", "type": "event"}]},
+ )
+ assert merged["date_from"] == "-30d"
+ assert merged["date_to"] == "-1d"
+
+ def test_same_key_on_different_group_types_are_not_treated_as_the_same_filter(self):
+ dashboard_prop = {"key": "name", "value": "Acme", "type": "group", "group_type_index": 0}
+ tile_prop = {"key": "name", "value": "Beta", "type": "group", "group_type_index": 1}
+
+ merged = merge_filters_by_priority(
+ {"properties": [dashboard_prop]},
+ {"properties": [tile_prop]},
+ )
+
+ assert merged["properties"] == [dashboard_prop, tile_prop]
+
+ def test_tile_property_with_non_string_key_does_not_raise(self):
+ # `key` comes from unvalidated client JSON and can be a list; contradiction detection must not crash.
+ merged = merge_filters_by_priority(
+ {"properties": [{"key": "browser", "type": "event", "value": "x"}]},
+ {"properties": [{"key": ["a", "b"], "type": "event", "value": "y"}]},
+ )
+ assert len(merged["properties"]) == 2
+
+
+class TestRemoveQueryPropertiesOverriddenBy(SimpleTestCase):
+ def _query(self, properties):
+ return {"kind": "InsightVizNode", "source": {"kind": "TrendsQuery", "properties": properties}}
+
+ def test_strips_insight_property_the_tile_contradicts(self):
+ query = self._query(
+ [
+ {"key": "$browser", "value": "Chrome", "type": "event"},
+ {"key": "$country", "value": "US", "type": "event"},
+ ]
+ )
+ tile = {"properties": [{"key": "$browser", "value": "Firefox", "type": "event"}]}
+
+ stripped = remove_query_properties_overridden_by(query, tile)
+
+ assert stripped["source"]["properties"] == [{"key": "$country", "value": "US", "type": "event"}]
+
+ @parameterized.expand([("TrendsQuery",), ("FunnelsQuery",), ("LifecycleQuery",)])
+ def test_strips_contradicted_series_property(self, query_kind):
+ query = {
+ "kind": "InsightVizNode",
+ "source": {
+ "kind": query_kind,
+ "series": [
+ {
+ "kind": "EventsNode",
+ "event": "$pageview",
+ "properties": [
+ {"key": "$browser", "value": "Chrome", "type": "event"},
+ {"key": "$country", "value": "US", "type": "event"},
+ ],
+ }
+ ],
+ },
+ }
+ overriding = {"properties": [{"key": "$browser", "value": "Firefox", "type": "event"}]}
+
+ stripped = remove_query_properties_overridden_by(query, overriding)
+
+ assert stripped["source"]["series"][0]["properties"] == [{"key": "$country", "value": "US", "type": "event"}]
+
+ def test_keeps_insight_property_compatible_with_the_override(self):
+ # Insight `utm_source = google` and dashboard `utm_source is set` combine into a valid set, so the
+ # insight's own filter is kept to stack rather than dropped.
+ query = self._query([{"key": "utm_source", "value": "google", "type": "event", "operator": "exact"}])
+ overriding = {"properties": [{"key": "utm_source", "type": "event", "operator": "is_set"}]}
+
+ assert remove_query_properties_overridden_by(query, overriding) == query
+
+ def test_no_op_when_tile_has_no_properties(self):
+ query = self._query([{"key": "$browser", "value": "Chrome", "type": "event"}])
+
+ assert remove_query_properties_overridden_by(query, {"date_from": "-7d"}) == query
+
+ def test_prunes_matching_leaf_from_property_group(self):
+ query = self._query(
+ {
+ "type": "AND",
+ "values": [
+ {
+ "type": "AND",
+ "values": [
+ {"key": "$browser", "value": "Chrome", "type": "event"},
+ {"key": "$country", "value": "US", "type": "event"},
+ ],
+ }
+ ],
+ }
+ )
+ tile = {"properties": [{"key": "$browser", "value": "Firefox", "type": "event"}]}
+
+ stripped = remove_query_properties_overridden_by(query, tile)
+
+ assert stripped["source"]["properties"]["values"][0]["values"] == [
+ {"key": "$country", "value": "US", "type": "event"}
+ ]
+
+ def test_prunes_matching_leaf_nested_three_levels_deep(self):
+ # AND[OR[AND[leaf]]] — a plain PropertyGroupFilter nesting shape. A shallow, one-level-only
+ # traversal would leave the innermost leaf in place despite the tile overriding it.
+ query = self._query(
+ {
+ "type": "AND",
+ "values": [
+ {
+ "type": "OR",
+ "values": [
+ {
+ "type": "AND",
+ "values": [
+ {"key": "$browser", "value": "Chrome", "type": "event"},
+ {"key": "$country", "value": "US", "type": "event"},
+ ],
+ }
+ ],
+ }
+ ],
+ }
+ )
+ tile = {"properties": [{"key": "$browser", "value": "Firefox", "type": "event"}]}
+
+ stripped = remove_query_properties_overridden_by(query, tile)
+
+ innermost = stripped["source"]["properties"]["values"][0]["values"][0]["values"]
+ assert innermost == [{"key": "$country", "value": "US", "type": "event"}]
diff --git a/posthog/hogql_queries/utils/dashboard_filter_conflicts.py b/posthog/hogql_queries/utils/dashboard_filter_conflicts.py
new file mode 100644
index 000000000000..edbf1aab3c14
--- /dev/null
+++ b/posthog/hogql_queries/utils/dashboard_filter_conflicts.py
@@ -0,0 +1,91 @@
+from typing import Any
+
+from posthog.schema import PropertyOperator
+
+_POSITIVE_EXACT_OPERATORS = {PropertyOperator.EXACT, PropertyOperator.IN_}
+_NEGATIVE_EXACT_OPERATORS = {PropertyOperator.IS_NOT, PropertyOperator.NOT_IN}
+# Operators that can never match an unset (NULL) property value, per _expr_to_compare_op in
+# posthog/hogql/property.py. Negated operators (is_not, not_icontains, not_regex) DO match unset
+# values there, so they are compatible with is_not_set and must not be listed here.
+_MATCHES_ONLY_SET_VALUES = _POSITIVE_EXACT_OPERATORS | {
+ PropertyOperator.ICONTAINS,
+ PropertyOperator.REGEX,
+ PropertyOperator.IS_SET,
+}
+_INCOMPARABLE_FILTER_TYPES = ("cohort", "hogql")
+
+
+def filters_contradict(filter_a: dict, filter_b: dict) -> bool:
+ """Whether two property filters on the same property provably contradict — ANDing them could never
+ match any value (e.g. `utm_medium = abc` vs `utm_medium != abc`, or `= google` vs `= facebook`).
+
+ Compatible pairs like `= google` and `is set` return False so they stack (AND-combine) rather than one
+ replacing the other. Anything not provably contradictory is treated as compatible.
+
+ """
+ if not _same_property(filter_a, filter_b):
+ return False
+ op_a, values_a = _operator_and_values(filter_a)
+ op_b, values_b = _operator_and_values(filter_b)
+ return _contradicts_one_way(op_a, values_a, op_b, values_b) or _contradicts_one_way(op_b, values_b, op_a, values_a)
+
+
+def _same_property(filter_a: dict, filter_b: dict) -> bool:
+ for f in (filter_a, filter_b):
+ if f.get("key") is None:
+ return False
+ if f.get("type") in _INCOMPARABLE_FILTER_TYPES:
+ return False
+ return (
+ filter_a.get("key") == filter_b.get("key")
+ and filter_a.get("type") == filter_b.get("type")
+ and filter_a.get("group_type_index") == filter_b.get("group_type_index")
+ )
+
+
+def _contradicts_one_way(
+ op_a: PropertyOperator, values_a: list[str] | None, op_b: PropertyOperator, values_b: list[str] | None
+) -> bool:
+ """Is `a` a positively-matching filter that `b` negates entirely?"""
+ if op_b == PropertyOperator.IS_NOT_SET and op_a in _MATCHES_ONLY_SET_VALUES:
+ # A valueless exact/in/icontains/regex filter is a no-op, so only is_set conflicts unconditionally
+ return op_a == PropertyOperator.IS_SET or values_a is not None
+ if values_a is None or values_b is None:
+ return False
+ if op_a in _POSITIVE_EXACT_OPERATORS:
+ if op_b in _NEGATIVE_EXACT_OPERATORS:
+ return set(values_a) <= set(values_b)
+ if op_b in _POSITIVE_EXACT_OPERATORS:
+ return not set(values_a) & set(values_b)
+ if op_a == PropertyOperator.ICONTAINS and op_b == PropertyOperator.NOT_ICONTAINS:
+ # icontains matches values containing ANY needle; not_icontains requires containing NONE.
+ # Unsatisfiable when every icontains needle itself contains an excluded needle.
+ positive_needles = [v.casefold() for v in values_a]
+ negative_needles = [v.casefold() for v in values_b]
+ return all(any(negative in positive for negative in negative_needles) for positive in positive_needles)
+ if op_a == PropertyOperator.REGEX and op_b == PropertyOperator.NOT_REGEX:
+ return len(values_a) == 1 and len(values_b) == 1 and values_a[0] == values_b[0]
+ return False
+
+
+def _operator_and_values(property_filter: dict) -> tuple[PropertyOperator, list[str] | None]:
+ operator = property_filter.get("operator") or PropertyOperator.EXACT
+ return PropertyOperator(operator), _normalized_values(property_filter.get("value"))
+
+
+def _normalized_values(value: Any) -> list[str] | None:
+ """None for valueless/empty filters (no-ops per posthog/hogql/property.py), else stringified values."""
+ if value is None:
+ return None
+ values = value if isinstance(value, list) else [value]
+ if not values:
+ return None
+ return [_canonicalize_value(v) for v in values]
+
+
+def _canonicalize_value(value: Any) -> str:
+ # JSON booleans and the lowercase strings the UI offers for boolean properties are interchangeable;
+ # mixed-case strings like "True" stay untouched since string comparison in ClickHouse is case-sensitive
+ if isinstance(value, bool):
+ return "true" if value else "false"
+ return str(value)
diff --git a/posthog/hogql_queries/utils/test/test_dashboard_filter_conflicts.py b/posthog/hogql_queries/utils/test/test_dashboard_filter_conflicts.py
new file mode 100644
index 000000000000..f427ec0e3a5a
--- /dev/null
+++ b/posthog/hogql_queries/utils/test/test_dashboard_filter_conflicts.py
@@ -0,0 +1,101 @@
+from django.test import SimpleTestCase
+
+from parameterized import parameterized
+
+from posthog.hogql_queries.utils.dashboard_filter_conflicts import filters_contradict
+
+
+class TestFiltersContradict(SimpleTestCase):
+ @parameterized.expand(
+ [
+ # (name, filter_a, filter_b, expected)
+ (
+ "same exact value is compatible",
+ {"key": "k", "type": "event", "operator": "exact", "value": ["a"]},
+ {"key": "k", "type": "event", "operator": "exact", "value": ["a"]},
+ False,
+ ),
+ (
+ "disjoint exact values contradict",
+ {"key": "k", "type": "event", "operator": "exact", "value": ["a"]},
+ {"key": "k", "type": "event", "operator": "exact", "value": ["b"]},
+ True,
+ ),
+ (
+ "overlapping exact values are compatible",
+ {"key": "k", "type": "event", "operator": "exact", "value": ["a", "b"]},
+ {"key": "k", "type": "event", "operator": "exact", "value": ["b", "c"]},
+ False,
+ ),
+ (
+ "exact contradicts is_not on the same value",
+ {"key": "k", "type": "event", "operator": "exact", "value": ["a"]},
+ {"key": "k", "type": "event", "operator": "is_not", "value": ["a"]},
+ True,
+ ),
+ (
+ "exact and is_not on different values are compatible",
+ {"key": "k", "type": "event", "operator": "exact", "value": ["a"]},
+ {"key": "k", "type": "event", "operator": "is_not", "value": ["b"]},
+ False,
+ ),
+ (
+ "exact and is_set stack",
+ {"key": "k", "type": "event", "operator": "exact", "value": ["a"]},
+ {"key": "k", "type": "event", "operator": "is_set"},
+ False,
+ ),
+ (
+ "exact contradicts is_not_set",
+ {"key": "k", "type": "event", "operator": "exact", "value": ["a"]},
+ {"key": "k", "type": "event", "operator": "is_not_set"},
+ True,
+ ),
+ (
+ "is_not and is_not_set are compatible (negation matches unset)",
+ {"key": "k", "type": "event", "operator": "is_not", "value": ["a"]},
+ {"key": "k", "type": "event", "operator": "is_not_set"},
+ False,
+ ),
+ (
+ "different keys never contradict",
+ {"key": "a", "type": "event", "operator": "exact", "value": ["x"]},
+ {"key": "b", "type": "event", "operator": "exact", "value": ["y"]},
+ False,
+ ),
+ (
+ "same key on different group types does not contradict",
+ {"key": "name", "type": "group", "group_type_index": 0, "operator": "exact", "value": ["x"]},
+ {"key": "name", "type": "group", "group_type_index": 1, "operator": "exact", "value": ["y"]},
+ False,
+ ),
+ (
+ "cohort filters are never compared",
+ {"key": "id", "type": "cohort", "operator": "exact", "value": [1]},
+ {"key": "id", "type": "cohort", "operator": "exact", "value": [2]},
+ False,
+ ),
+ (
+ "icontains contradicts not_icontains that excludes the needle",
+ {"key": "k", "type": "event", "operator": "icontains", "value": ["Goog"]},
+ {"key": "k", "type": "event", "operator": "not_icontains", "value": ["goog"]},
+ True,
+ ),
+ (
+ "regex contradicts not_regex with the identical pattern",
+ {"key": "k", "type": "event", "operator": "regex", "value": ["^a$"]},
+ {"key": "k", "type": "event", "operator": "not_regex", "value": ["^a$"]},
+ True,
+ ),
+ (
+ "boolean and its lowercase string form are the same value",
+ {"key": "k", "type": "event", "operator": "exact", "value": [True]},
+ {"key": "k", "type": "event", "operator": "is_not", "value": ["true"]},
+ True,
+ ),
+ ]
+ )
+ def test_filters_contradict(self, _name, filter_a, filter_b, expected):
+ assert filters_contradict(filter_a, filter_b) is expected
+ # Contradiction is symmetric.
+ assert filters_contradict(filter_b, filter_a) is expected
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 66276935002e..98326f8b583a 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -8106,6 +8106,52 @@ export interface DashboardTileBasicApi {
deleted?: boolean | null
}
+export interface DashboardFilterApi {
+ breakdown_filter?: BreakdownFilterApi | null
+ date_from?: string | null
+ date_to?: string | null
+ explicitDate?: boolean | null
+ /** Tri-state test-account override. Null/absent = inherit; true = force on; false = force off. */
+ filterTestAccounts?: boolean | null
+ /** Time granularity forced onto every insight that supports one. Absent/null = inherit. */
+ interval?: IntervalTypeApi | null
+ properties?:
+ | (
+ | EventPropertyFilterApi
+ | PersonPropertyFilterApi
+ | PersonMetadataPropertyFilterApi
+ | ElementPropertyFilterApi
+ | EventMetadataPropertyFilterApi
+ | SessionPropertyFilterApi
+ | CohortPropertyFilterApi
+ | RecordingPropertyFilterApi
+ | LogEntryPropertyFilterApi
+ | GroupPropertyFilterApi
+ | FeaturePropertyFilterApi
+ | FlagPropertyFilterApi
+ | HogQLPropertyFilterApi
+ | EmptyPropertyFilterApi
+ | DataWarehousePropertyFilterApi
+ | DataWarehousePersonPropertyFilterApi
+ | ErrorTrackingIssueFilterApi
+ | LogPropertyFilterApi
+ | MetricPropertyFilterApi
+ | SpanPropertyFilterApi
+ | RevenueAnalyticsPropertyFilterApi
+ | WorkflowVariablePropertyFilterApi
+ )[]
+ | null
+}
+
+export interface InsightFilterOverrideContextApi {
+ /** Dashboard filters that remain active after applying tile precedence. */
+ dashboard?: DashboardFilterApi | null
+ /** Tile filters applied above the dashboard filters. */
+ tile?: DashboardFilterApi | null
+ /** Dashboard filters replaced by the tile filters. */
+ overridden_dashboard?: DashboardFilterApi | null
+}
+
/**
* @nullable
*/
@@ -8211,6 +8257,8 @@ export interface InsightApi {
readonly resolved_date_range: InsightApiResolvedDateRange
_create_in_folder?: string
readonly alerts: readonly unknown[]
+ /** Resolved dashboard and tile filter layers used to explain filter precedence in the UI. */
+ readonly filter_override_context: InsightFilterOverrideContextApi | null
/** @nullable */
readonly last_viewed_at: string | null
/** How this row matched the `search` query parameter: `exact` (the term is a case-insensitive substring of a searched field) or `similar` (a fuzzy trigram match, returned only when no exact match exists). Null when the list is not filtered by `search`. */
diff --git a/products/product_analytics/backend/api/insight.py b/products/product_analytics/backend/api/insight.py
index 1355a91b59a7..696492988acb 100644
--- a/products/product_analytics/backend/api/insight.py
+++ b/products/product_analytics/backend/api/insight.py
@@ -75,6 +75,8 @@ from posthog.hogql_queries.apply_dashboard_filters import (
WRAPPER_NODE_KINDS,
apply_dashboard_filters_to_dict,
apply_dashboard_variables_to_dict,
+ resolve_effective_dashboard_filters,
+ resolve_filter_layers_by_priority,
)
from posthog.hogql_queries.legacy_compatibility.feature_flag import get_query_method
from posthog.hogql_queries.legacy_compatibility.filter_to_query import filter_to_query
@@ -451,6 +453,18 @@ class QueryFieldSerializer(serializers.Serializer):
return data
+class InsightFilterOverrideContext(BaseModel):
+ dashboard: schema.DashboardFilter | None = PydanticField(
+ default=None, description="Dashboard filters that remain active after applying tile precedence."
+ )
+ tile: schema.DashboardFilter | None = PydanticField(
+ default=None, description="Tile filters applied above the dashboard filters."
+ )
+ overridden_dashboard: schema.DashboardFilter | None = PydanticField(
+ default=None, description="Dashboard filters replaced by the tile filters."
+ )
+
+
class InsightSerializer(InsightBasicSerializer):
result = serializers.SerializerMethodField()
hasMore = serializers.SerializerMethodField()
@@ -505,6 +519,11 @@ class InsightSerializer(InsightBasicSerializer):
resolved_date_range = serializers.SerializerMethodField(read_only=True)
_create_in_folder = serializers.CharField(required=False, allow_blank=True, write_only=True)
alerts = serializers.SerializerMethodField(read_only=True)
+ filter_override_context = serializers.SerializerMethodField(
+ read_only=True,
+ allow_null=True,
+ help_text="Resolved dashboard and tile filter layers used to explain filter precedence in the UI.",
+ )
class Meta:
model = Insight
@@ -546,6 +565,7 @@ class InsightSerializer(InsightBasicSerializer):
"resolved_date_range",
"_create_in_folder",
"alerts",
+ "filter_override_context",
"last_viewed_at",
"search_match_type",
]
@@ -941,6 +961,30 @@ class InsightSerializer(InsightBasicSerializer):
return AlertSerializer(alerts, many=True, context=self.context).data
+ @extend_schema_field(InsightFilterOverrideContext) # type: ignore[arg-type]
+ def get_filter_override_context(self, insight: Insight) -> dict[str, object] | None:
+ dashboard: Dashboard | None = self.context.get("dashboard")
+ request: Request | None = self.context.get("request")
+ if request is None:
+ return None
+
+ is_shared = self.context.get("is_shared", False)
+ dashboard_filters_override = filters_override_requested_by_client(request, dashboard, is_shared=is_shared)
+ dashboard_tile = self.dashboard_tile_from_context(insight, dashboard)
+ tile_filters_override = tile_filters_override_requested_by_client(request, dashboard_tile, is_shared=is_shared)
+ dashboard_filters = (
+ dashboard_filters_override
+ if dashboard_filters_override is not None
+ else dashboard.filters
+ if dashboard
+ else {}
+ )
+ if not dashboard_filters and not tile_filters_override:
+ return None
+
+ resolved_layers = resolve_filter_layers_by_priority(dashboard_filters, tile_filters_override)
+ return {key: value or None for key, value in resolved_layers.items()}
+
def get_effective_restriction_level(self, insight: Insight) -> Dashboard.RestrictionLevel:
if self.context.get("is_shared"):
return Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT
@@ -984,10 +1028,10 @@ class InsightSerializer(InsightBasicSerializer):
request, dashboard, list(self.context["insight_variables"]), is_shared=is_shared
)
- # Tile filters completely replace dashboard filters (same semantics as the compute path in
- # calculate_results.py). Without this, the returned `query` field would reflect dashboard
- # filters while the cached result was computed with tile filters — causing the persons modal
- # to use a different filter set than the chart.
+ # Tile filters merge on top of dashboard filters (same semantics as the compute path in
+ # calculate_results.py). Keeping this in sync ensures the returned `query` field matches the
+ # filter set the cached result was computed with — otherwise the persons modal would use a
+ # different filter set than the chart.
dashboard_tile = self.dashboard_tile_from_context(instance, dashboard)
tile_filters_override = (
tile_filters_override_requested_by_client(request, dashboard_tile, is_shared=is_shared) if request else {}
@@ -1001,17 +1045,19 @@ class InsightSerializer(InsightBasicSerializer):
dashboard is not None
or dashboard_filters_override is not None
or dashboard_variables_override is not None
+ or tile_filters_override
):
- effective_filters = (
- tile_filters_override
- if tile_filters_override
- else (
- dashboard_filters_override
- if dashboard_filters_override is not None
- else dashboard.filters
- if dashboard
- else {}
- )
+ base_filters = (
+ dashboard_filters_override
+ if dashboard_filters_override is not None
+ else dashboard.filters
+ if dashboard
+ else {}
+ )
+ # Same dashboard+tile+insight precedence the compute path applies in calculate_results.py,
+ # so the returned query matches what the cached result was actually computed with.
+ query, effective_filters = resolve_effective_dashboard_filters(
+ query, base_filters, tile_filters_override
)
query = apply_dashboard_filters_to_dict(
query,
@@ -1914,6 +1960,21 @@ When set, the specified dashboard's filters and date range override will be appl
.first()
)
+ if dashboard_tile is not None:
+ authenticator = request.successful_authenticator
+ if isinstance(
+ authenticator,
+ SharingAccessTokenAuthentication | SharingPasswordProtectedAuthentication,
+ ):
+ can_view_dashboard = authenticator.sharing_configuration.dashboard_id == dashboard_tile.dashboard_id
+ else:
+ can_view_dashboard = self.user_access_control.check_access_level_for_object(
+ dashboard_tile.dashboard, "viewer"
+ )
+
+ if not can_view_dashboard:
+ dashboard_tile = None
+
if dashboard_tile is not None:
# context is used in the to_representation method to report filters used
serializer_context.update({"dashboard": dashboard_tile.dashboard})
diff --git a/products/product_analytics/backend/api/test/test_insight.py b/products/product_analytics/backend/api/test/test_insight.py
index 59379caf3b3d..1a232b6f5a05 100644
--- a/products/product_analytics/backend/api/test/test_insight.py
+++ b/products/product_analytics/backend/api/test/test_insight.py
@@ -4248,7 +4248,7 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):
assert isinstance(response["query"]["source"], dict)
assert response["query"]["source"]["dateRange"]["date_from"] == "-7d"
- def test_tile_filters_override_replaces_dashboard_filters_in_returned_query(self) -> None:
+ def test_tile_filters_merge_with_dashboard_filters_in_returned_query(self) -> None:
insight = Insight.objects.create(
filters={},
query={
@@ -4262,18 +4262,14 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):
team=self.team,
)
dashboard = Dashboard.objects.create(team=self.team, name="dashboard 1", created_by=self.user)
- # Tile has its own date-range filter (no person properties). The compute path treats
- # this as a complete replacement for all dashboard filters.
DashboardTile.objects.create(
dashboard=dashboard,
insight=insight,
filters_overrides={"date_from": "-7d"},
)
- # Dashboard-level filter includes a person property filter (e.g. $initial_host = readdy.ai).
- dashboard_filters = {
- "properties": [{"key": "$initial_host", "type": "person", "operator": "exact", "value": ["readdy.ai"]}]
- }
+ person_filter = {"key": "$initial_host", "type": "person", "operator": "exact", "value": ["readdy.ai"]}
+ dashboard_filters = {"properties": [person_filter]}
response = self.client.get(
f"/api/projects/{self.team.id}/insights/{insight.pk}",
@@ -4284,14 +4280,156 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):
).json()
source = response["query"]["source"]
- # The tile's filter (date_from = -7d, no person properties) must win over the
- # dashboard filter. If the dashboard person properties appeared here the persons
- # modal would use a different filter set than the chart — the bug this test guards.
assert source["dateRange"]["date_from"] == "-7d"
- # properties must be absent or empty — the dashboard's person filter must not appear.
- assert not source.get("properties"), (
- f"Tile filters should replace dashboard filters; persons modal would diverge. Got: {source.get('properties')}"
+ merged_properties = source.get("properties") or []
+ assert any(p.get("key") == "$initial_host" and p.get("value") == ["readdy.ai"] for p in merged_properties), (
+ f"Dashboard person filter should be merged into the tile query. Got: {merged_properties}"
+ )
+
+ def test_tile_property_override_replaces_insight_and_dashboard_on_same_key(self) -> None:
+ # Insight, dashboard, and tile all filter $browser. The tile must win outright on that key —
+ # over both the insight's own filter and the dashboard's — instead of AND-ing all three (which
+ # would be an impossible intersection and return nothing).
+ insight = Insight.objects.create(
+ query={
+ "kind": "InsightVizNode",
+ "source": {
+ "kind": "TrendsQuery",
+ "series": [{"event": "$pageview", "kind": "EventsNode"}],
+ "properties": [{"key": "$browser", "type": "event", "operator": "exact", "value": ["Chrome"]}],
+ },
+ },
+ team=self.team,
+ )
+ dashboard = Dashboard.objects.create(team=self.team, name="dashboard 1", created_by=self.user)
+ DashboardTile.objects.create(
+ dashboard=dashboard,
+ insight=insight,
+ filters_overrides={
+ "properties": [{"key": "$browser", "type": "event", "operator": "exact", "value": ["Firefox"]}]
+ },
+ )
+ dashboard_filters = {
+ "properties": [{"key": "$browser", "type": "event", "operator": "exact", "value": ["Chrome", "Safari"]}]
+ }
+
+ response = self.client.get(
+ f"/api/projects/{self.team.id}/insights/{insight.pk}",
+ data={"from_dashboard": str(dashboard.pk), "filters_override": json.dumps(dashboard_filters)},
+ ).json()
+
+ browser_values = self._collect_property_values(response["query"]["source"].get("properties"), "$browser")
+ assert browser_values == [["Firefox"]], f"Tile $browser should replace all others. Got: {browser_values}"
+ assert response["filter_override_context"] == {
+ "dashboard": None,
+ "tile": {"properties": [{"key": "$browser", "type": "event", "operator": "exact", "value": ["Firefox"]}]},
+ "overridden_dashboard": {
+ "properties": [
+ {
+ "key": "$browser",
+ "type": "event",
+ "operator": "exact",
+ "value": ["Chrome", "Safari"],
+ }
+ ]
+ },
+ }
+
+ def test_dashboard_property_override_replaces_insight_on_same_key(self) -> None:
+ # Insight and dashboard both filter $browser, no tile. The dashboard must win on that key —
+ # over the insight's own filter — instead of AND-ing (Chrome AND Safari would return nothing).
+ insight = Insight.objects.create(
+ query={
+ "kind": "InsightVizNode",
+ "source": {
+ "kind": "TrendsQuery",
+ "series": [{"event": "$pageview", "kind": "EventsNode"}],
+ "properties": [{"key": "$browser", "type": "event", "operator": "exact", "value": ["Chrome"]}],
+ },
+ },
+ team=self.team,
+ )
+ dashboard = Dashboard.objects.create(team=self.team, name="dashboard 1", created_by=self.user)
+ DashboardTile.objects.create(dashboard=dashboard, insight=insight)
+ dashboard_filters = {
+ "properties": [{"key": "$browser", "type": "event", "operator": "exact", "value": ["Safari"]}]
+ }
+
+ response = self.client.get(
+ f"/api/projects/{self.team.id}/insights/{insight.pk}",
+ data={"from_dashboard": str(dashboard.pk), "filters_override": json.dumps(dashboard_filters)},
+ ).json()
+
+ browser_values = self._collect_property_values(response["query"]["source"].get("properties"), "$browser")
+ assert browser_values == [["Safari"]], f"Dashboard $browser should replace the insight's. Got: {browser_values}"
+
+ def test_from_dashboard_ignores_dashboard_context_without_view_access(self) -> None:
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},
+ ]
+ self.organization.save()
+ viewer = self._create_user("[email protected]", level=OrganizationMembership.Level.MEMBER)
+ insight = Insight.objects.create(
+ query={
+ "kind": "InsightVizNode",
+ "source": {
+ "kind": "TrendsQuery",
+ "series": [{"event": "$pageview", "kind": "EventsNode"}],
+ },
+ },
+ team=self.team,
+ created_by=self.user,
)
+ dashboard = Dashboard.objects.create(
+ team=self.team,
+ name="restricted dashboard",
+ created_by=self.user,
+ filters={
+ "properties": [
+ {"key": "email", "type": "person", "operator": "exact", "value": ["[email protected]"]}
+ ]
+ },
+ )
+ DashboardTile.objects.create(
+ dashboard=dashboard,
+ insight=insight,
+ filters_overrides={
+ "properties": [{"key": "$browser", "type": "event", "operator": "exact", "value": ["Chrome"]}]
+ },
+ )
+ AccessControl.objects.create(
+ resource="dashboard",
+ resource_id=dashboard.id,
+ team=self.team,
+ access_level="none",
+ )
+ self.client.force_login(viewer)
+
+ response = self.client.get(
+ f"/api/projects/{self.team.id}/insights/{insight.pk}",
+ data={"from_dashboard": str(dashboard.pk)},
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ response_data = response.json()
+ assert response_data["filter_override_context"] is None
+ properties = response_data["query"]["source"].get("properties")
+ assert self._collect_property_values(properties, "email") == []
+ assert self._collect_property_values(properties, "$browser") == []
+
+ @staticmethod
+ def _collect_property_values(properties: object, key: str) -> list:
+ """Flatten a query's properties (flat list or nested PropertyGroupFilter) to the values set for one key."""
+ found: list = []
+ if isinstance(properties, list):
+ for prop in properties:
+ found.extend(TestInsight._collect_property_values(prop, key))
+ elif isinstance(properties, dict):
+ if isinstance(properties.get("values"), list):
+ found.extend(TestInsight._collect_property_values(properties["values"], key))
+ elif properties.get("key") == key:
+ found.append(properties.get("value"))
+ return found
def test_insight_cache_key_changes_with_variable_override_when_tile_filters_are_set(self) -> None:
dashboard = Dashboard.objects.create(
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 1648cba3d11d..73b7845293f5 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -7522,6 +7522,52 @@ export const EffectivePrivilegeLevelEnumApi = {
Number37: 37,
} as const
+export interface DashboardFilterApi {
+ breakdown_filter?: BreakdownFilterApi | null
+ date_from?: string | null
+ date_to?: string | null
+ explicitDate?: boolean | null
+ /** Tri-state test-account override. Null/absent = inherit; true = force on; false = force off. */
+ filterTestAccounts?: boolean | null
+ /** Time granularity forced onto every insight that supports one. Absent/null = inherit. */
+ interval?: IntervalTypeApi | null
+ properties?:
+ | (
+ | EventPropertyFilterApi
+ | PersonPropertyFilterApi
+ | PersonMetadataPropertyFilterApi
+ | ElementPropertyFilterApi
+ | EventMetadataPropertyFilterApi
+ | SessionPropertyFilterApi
+ | CohortPropertyFilterApi
+ | RecordingPropertyFilterApi
+ | LogEntryPropertyFilterApi
+ | GroupPropertyFilterApi
+ | FeaturePropertyFilterApi
+ | FlagPropertyFilterApi
+ | HogQLPropertyFilterApi
+ | EmptyPropertyFilterApi
+ | DataWarehousePropertyFilterApi
+ | DataWarehousePersonPropertyFilterApi
+ | ErrorTrackingIssueFilterApi
+ | LogPropertyFilterApi
+ | MetricPropertyFilterApi
+ | SpanPropertyFilterApi
+ | RevenueAnalyticsPropertyFilterApi
+ | WorkflowVariablePropertyFilterApi
+ )[]
+ | null
+}
+
+export interface InsightFilterOverrideContextApi {
+ /** Dashboard filters that remain active after applying tile precedence. */
+ dashboard?: DashboardFilterApi | null
+ /** Tile filters applied above the dashboard filters. */
+ tile?: DashboardFilterApi | null
+ /** Dashboard filters replaced by the tile filters. */
+ overridden_dashboard?: DashboardFilterApi | null
+}
+
export type SearchMatchTypeEnumApi = (typeof SearchMatchTypeEnumApi)[keyof typeof SearchMatchTypeEnumApi]
export const SearchMatchTypeEnumApi = {
@@ -7634,6 +7680,8 @@ export interface InsightApi {
readonly resolved_date_range: InsightApiResolvedDateRange
_create_in_folder?: string
readonly alerts: readonly unknown[]
+ /** Resolved dashboard and tile filter layers used to explain filter precedence in the UI. */
+ readonly filter_override_context: InsightFilterOverrideContextApi | null
/** @nullable */
readonly last_viewed_at: string | null
/** How this row matched the `search` query parameter: `exact` (the term is a case-insensitive substring of a searched field) or `similar` (a fuzzy trigram match, returned only when no exact match exists). Null when the list is not filtered by `search`. */
@@ -7754,6 +7802,8 @@ export interface PatchedInsightApi {
readonly resolved_date_range?: PatchedInsightApiResolvedDateRange
_create_in_folder?: string
readonly alerts?: readonly unknown[]
+ /** Resolved dashboard and tile filter layers used to explain filter precedence in the UI. */
+ readonly filter_override_context?: InsightFilterOverrideContextApi | null
/** @nullable */
readonly last_viewed_at?: string | null
/** How this row matched the `search` query parameter: `exact` (the term is a case-insensitive substring of a searched field) or `similar` (a fuzzy trigram match, returned only when no exact match exists). Null when the list is not filtered by `search`. */
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 787d1bab8c47..3ca62c76f2cd 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -7721,6 +7721,27 @@ export namespace Schemas {
Number37: 37,
} as const;
+ export interface DashboardFilter {
+ breakdown_filter?: BreakdownFilter | null;
+ date_from?: string | null;
+ date_to?: string | null;
+ explicitDate?: boolean | null;
+ /** Tri-state test-account override. Null/absent = inherit; true = force on; false = force off. */
+ filterTestAccounts?: boolean | null;
+ /** Time granularity forced onto every insight that supports one. Absent/null = inherit. */
+ interval?: IntervalType | null;
+ properties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
+ }
+
+ export interface InsightFilterOverrideContext {
+ /** Dashboard filters that remain active after applying tile precedence. */
+ dashboard?: DashboardFilter | null;
+ /** Tile filters applied above the dashboard filters. */
+ tile?: DashboardFilter | null;
+ /** Dashboard filters replaced by the tile filters. */
+ overridden_dashboard?: DashboardFilter | null;
+ }
+
export type SearchMatchTypeEnum = typeof SearchMatchTypeEnum[keyof typeof SearchMatchTypeEnum];
@@ -7834,6 +7855,8 @@ export namespace Schemas {
readonly resolved_date_range: InsightResolvedDateRange;
_create_in_folder?: string;
readonly alerts: readonly unknown[];
+ /** Resolved dashboard and tile filter layers used to explain filter precedence in the UI. */
+ readonly filter_override_context: InsightFilterOverrideContext | null;
/** @nullable */
readonly last_viewed_at: string | null;
/** How this row matched the `search` query parameter: `exact` (the term is a case-insensitive substring of a searched field) or `similar` (a fuzzy trigram match, returned only when no exact match exists). Null when the list is not filtered by `search`. */
@@ -15747,18 +15770,6 @@ export namespace Schemas {
user_uuid: string;
}
- export interface DashboardFilter {
- breakdown_filter?: BreakdownFilter | null;
- date_from?: string | null;
- date_to?: string | null;
- explicitDate?: boolean | null;
- /** Tri-state test-account override. Null/absent = inherit; true = force on; false = force off. */
- filterTestAccounts?: boolean | null;
- /** Time granularity forced onto every insight that supports one. Absent/null = inherit. */
- interval?: IntervalType | null;
- properties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
- }
-
/**
* OpenAPI-only shape for a dashboard's filters object (agents/MCP).
*
@@ -43865,6 +43876,8 @@ export namespace Schemas {
readonly resolved_date_range?: PatchedInsightResolvedDateRange;
_create_in_folder?: string;
readonly alerts?: readonly unknown[];
+ /** Resolved dashboard and tile filter layers used to explain filter precedence in the UI. */
+ readonly filter_override_context?: InsightFilterOverrideContext | null;
/** @nullable */
readonly last_viewed_at?: string | null;
/** How this row matched the `search` query parameter: `exact` (the term is a case-insensitive substring of a searched field) or `similar` (a fuzzy trigram match, returned only when no exact match exists). Null when the list is not filtered by `search`. */