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(mcp-analytics): unify shared filter controls (#103010)

Lucas Fariaf43974fd7c7b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index e7452e04c252..28b228fdc158 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6288,6 +6288,18 @@ snapshots:
hash: v1.k794b7964.769a69526cf676447319f587f24ed0d2670a137098867f8d3ee87ebda3415a70.3FGS0pbxxcrZUSto8SNCNHEkxaFXH6T8shqpdg5zzlQ
products-mcp-analytics-routingbar--all-variants--light:
hash: v1.k794b7964.7f57dacddb48fbad29a8614127d42d54425501b1f7755423d84316e1e937720e.thYPF2z3eMW5QvSe5SnvYtn35l6UCvUtsyx9EBLeqxk
+ products-mcp-analytics-shared-filters--active--dark:
+ hash: v1.k794b7964.9fac3ce8938d3678ab3d97b845e64aeb92ccb8b87e080ccabc07f10986396a41.jlEx_maqLc3PUvhAj627g8pQYZkXpTRQF4VMM8THMWo
+ products-mcp-analytics-shared-filters--active--light:
+ hash: v1.k794b7964.c02e82b97260bb0dc1df469edf64ae1c675220504415b8886f1ef69f1d5f0d9b.Nk0VyaP_pmTX49r6-DKzWG6m_AHOiQ_wTOTCEdUGOak
+ products-mcp-analytics-shared-filters--empty--dark:
+ hash: v1.k794b7964.4995952717b5240124024c0a79c72774b93930c779d6dba4ac1041359c86aded.E6lV2SZcED2ZkN8LTCMirNQb3yQ11HWUu6OGFUfja5I
+ products-mcp-analytics-shared-filters--empty--light:
+ hash: v1.k794b7964.6e21fbf234451ed0fcad4fc3c6b6920f146af36224fe66d93ea987b4f6baaee6.s7unVRI8opLLZuupdrGMNRIt0XCbpcJ-O0kX7BJHLEA
+ products-mcp-analytics-shared-filters--narrow--dark:
+ hash: v1.k794b7964.0c4ff880090d289792e07ce7cb7359a1b6ebc7f22018412f5e69b76d39b06c1c.5jO-D_nxXdrKXxqLu2eyHsS3a_h_Szw2YhyhYhVl4j4
+ products-mcp-analytics-shared-filters--narrow--light:
+ hash: v1.k794b7964.562db8df12c68befe57f8919f809de1df19a1ce38ac4df71182b1ef4dd992e60.gfWAYEniMvycz6kgaG9x41uOeVArlCV8Kr0Qoe09bfk
products-notebooks-notebook-widget-trust-controls--gate--dark:
hash: v1.k794b7964.97a5e7b5f92071f677d09773a3dea88ead3c9a71e85dbd6f6de8875ffc7a3036.9u2VOZ-O_aSU002VK8iAydGcjIYBXzRIacAelaDLJ6Y
products-notebooks-notebook-widget-trust-controls--gate--light:
@@ -8477,9 +8489,9 @@ snapshots:
scenes-app-experiments--experiment-results-row-recording-links-unselectable-metric--light:
hash: v1.k794b7964.e5c8c2db2f07793a503706854aeecedf60ac676c72aefc358a06d8233452b175.qqR2YNEpUBy2pyRr8WRoXOV74cJiOjNsHjJ0AzSRPKA
scenes-app-experiments--experiment-stopped-with-conclusion--dark:
- hash: v1.k794b7964.3ac8e414429f924fc3def7d2208ac0beed9216521f2ffd06ca76ce75c2e57183.LwPKIQIMSb8WaQ5fDINLCxUtNV2z7WqIR0NcAp0Htw0
+ hash: v1.k794b7964.bc6f02541890cd042457146425c1ec8529129ac18663ae74ccbe1ace4524050e.z-UJ5zy4-tG0CdZODBXs-ARg7-ZF8DmjTQlstpuRyVY
scenes-app-experiments--experiment-stopped-with-conclusion--light:
- hash: v1.k794b7964.69fc0dfee79900b9fac203354b723622fa5799fc558b51472469e1c6a41ed7c5.k5g3uAXB81S1THaQCr-WvL40EL2eF86yLXwRbmLORno
+ hash: v1.k794b7964.f178a16f637f9daf424c1b19f6b90a3c7892e54e9f7d5387d308adacd6524a32.2WpaRsAkUyyyhc5xwcGgFBTQem_1B-ZQ-bj88_hGBDA
scenes-app-experiments--experiment-stopped-with-long-conclusion--dark:
hash: v1.k794b7964.d9f67f619d391610a3730ebcc5ceefa8d8fdffde043f7eae9e8f56e1011bddfd.8YTbc5VRYqwQF1eEYApQPjB_7gdfUw2R8ERdQ6YQigc
scenes-app-experiments--experiment-stopped-with-long-conclusion--light:
@@ -9857,21 +9869,21 @@ snapshots:
scenes-app-mcp-analytics--activity--light:
hash: v1.k794b7964.b5b79d2bd502d8bc4c96fa698d4ff42687da96f6ad1db3b751a4ffdbeed7c7a9.1NKRmJQ6fzE1AWKFq632SoapJensy4UrDKiL20KiuxQ
scenes-app-mcp-analytics--dashboard--medium--dark:
- hash: v1.k794b7964.d720f243a9d94d614c00a31063df879f070eac53b3fce76c9d42931304941769.nsNkPSEGWTyU5u1XdmhHnveET4Lvu2hC4egcz9pV12M
+ hash: v1.k794b7964.4012c740b0deef7f5d9bee37aa55af37a799c71cfd5586bca7fb920fe4d09071.p4WeL3GF1jQ-_uD_OQoDyX-i-IBF87IHqZyG3rffRb0
scenes-app-mcp-analytics--dashboard--medium--light:
- hash: v1.k794b7964.c5dde84ed01a52e28ff57f057b2d0993b16a7065379f56cb488cb3ebce808cd1.ks9koqUwkuRomk18V2XOYYr7lzCtOpd_okVyNWEC4uk
+ hash: v1.k794b7964.faf5836b7f56c27ac5c09b182c64608bdd737d0d7749619638c75d5045fdfe23.v7NaCb4pkqINS8f4lod31ELlLEnpZLAAo6KdwkepmA8
scenes-app-mcp-analytics--dashboard--wide--dark:
- hash: v1.k794b7964.d3b1c5113067612f9728a8c5c70be035835fb88bb59f41504d540a3082e10cf3.YMt083wjL8ONNKACcE2MfklxNqoCaswcpPIlqfu7dWA
+ hash: v1.k794b7964.ed5619bb305a70012afd12dcaa2a87a30752a35b2931cb24e670558c3cf75c2b._aaytv4LHfWCQ5HtyDWSc2E6UZPKvaLLXcl5vRSUrPM
scenes-app-mcp-analytics--dashboard--wide--light:
- hash: v1.k794b7964.a14a0ccf927f4e04bbc5c583f1d196f0d6393575c5d598a7be93c9653cf0ac26.KpVtmJD_IqnqceAJH0BPqnPwOV7G5xeZ8LLA6fgcaSg
+ hash: v1.k794b7964.02827a94381ec568fd4c02343e5b1d3e2c33a3c4a284f18e73327b11eb242d34.q1a03mIvcmqZDrKF6WJ21rjfBEA16xoh4aHGhYvyTjA
scenes-app-mcp-analytics--dashboard-narrow--dark:
- hash: v1.k794b7964.5ef51629653e5bdf8c6d171ed5995cb83e8c1769d6805fbf4bc44a0bbbd21561.VTO1aGPaafx0iDWOzORTXl_RU9_IY06QCDfRFI290VQ
+ hash: v1.k794b7964.b0c18c7c48e6e5e91ba14e5d40edf1ee460f25e61172b0765919e6357534fb14.W10pNqhRrIYTGvy7sgnQo1Pcu_f-z_o-UfE3W9sZgQo
scenes-app-mcp-analytics--dashboard-narrow--light:
- hash: v1.k794b7964.1b0f034d65b83b016c1b956f6fd26ceeea9b3eec2b911fd914abdba311d3bcdf.u4FmLXfh5WKo8bYdFk1OcMlYEt7RDMn3Gs2hjTOiCPw
+ hash: v1.k794b7964.a2292e32d64d4577690e3dd9870b3a09db72ac92e9a59a6618a894ff32cd98d3.1ZKWf2yhLizLSn5nzUvgVxNcTbYp9gMlmznHB0cnzQs
scenes-app-mcp-analytics--dashboard-with-menu-bar--dark:
- hash: v1.k794b7964.8a64effc30dcb139ee46eb38eab71c5f7ee39b5fdd8df865f9ebd82b15e9e752.lF2iXnflVWCXsmZXOukWLUQTKgKM5Ijb9OGMO1jUwUc
+ hash: v1.k794b7964.701efa62a33cf461b8a895f3439734e069fefe22218409d7fe830358442a5c32.4cK-IvrHQruumka3Rnb_trr7S7-7pQoY2kNezZC1YQQ
scenes-app-mcp-analytics--dashboard-with-menu-bar--light:
- hash: v1.k794b7964.5950f14c1cba87ea5610ce1ae7f67791bf2320688e3bd04ffbd1154e465a163f.dyk-zwl99Fj0Dg39JnvwPOnx-zbxUeoxq1nT9FHqGfM
+ hash: v1.k794b7964.c3b4f2022c66f7ecd24bdc461d2da468d52756b50588fd1950788a986108153e.MHDtkomYAPJMQw9OwmnM-VOLeIHxH7VAEXqqFJWIfD0
scenes-app-mcp-analytics--intent-clustering--dark:
hash: v1.k794b7964.9549b853f80d754b9d6ccf17ab144d24218143200c90df7af687e184e7de5329.Er1_HM8avmrqmulj2hCLnkp98-HeuRvF5ed3j-_jS2A
scenes-app-mcp-analytics--intent-clustering--light:
@@ -9881,9 +9893,9 @@ snapshots:
scenes-app-mcp-analytics--sessions--light:
hash: v1.k794b7964.17f5e27f60024ff6e083bc6b799427b40e475fddb3bf7900aaab5f935d509b23.cgze06ZKpLRtg_doPvcuWuj_yfLplR3PlkqRGeqxzfE
scenes-app-mcp-analytics--tool-quality--dark:
- hash: v1.k794b7964.a490856eb234e8d317eb752b283d3b66796e6206f9855c8ecb4223c0be740ba1.zvXGsy66NnJM8yiFuDhn9bu9dJvWTNeLfG-OWwgqph0
+ hash: v1.k794b7964.3ad8d8cd5279b4a71f6c5f92cae80fa1b23ab125c30a1ca04b1f3b7ee7a9c8f0.08GjLTK6WJtlxDfcmYZhOKAsud2lE7V4CakPEJ0hjjA
scenes-app-mcp-analytics--tool-quality--light:
- hash: v1.k794b7964.0db52b49904cb908663bc7f32ea53bdbfc37ea32718183e311b51d9edb84ddf6.Ydhkj6pemSOwpAcF4NZfNGif-jJuNXsB1aED5WkHz5U
+ hash: v1.k794b7964.4e8b2fca4956be4651ecd15ec8ad844b1826118d6f5d59a2863567635e78946d.NGRUE9aboCDK--rhOUUwTQdBBRPlimxuvYz34uOc54o
scenes-app-mcp-analytics-dashboard-cards--daily-calls-and-errors--dark:
hash: v1.k794b7964.7302f068e1b6a63086ac35ffb7e7e1b9d10b8608cb7c6bb7033d341638e2d695.51PNQHMCZinl1fgHrAFmryj0im81JG1jIjU-DQc0oPY
scenes-app-mcp-analytics-dashboard-cards--daily-calls-and-errors--light:
@@ -9913,9 +9925,9 @@ snapshots:
scenes-app-mcp-analytics-dashboard-cards--key-metrics-in-progress-bucket--light:
hash: v1.k794b7964.987a4b9f762bab3f88f39ea33fb0eca000d0e5f6aeb2c0a89e2979399f4d5797.ziZ_6D2TpdPk2pVJqrCMfEcmRufZDVVVqN51I5vIHgM
scenes-app-mcp-analytics-dashboard-cards--overview-unknown-models--dark:
- hash: v1.k794b7964.4c40cc6779bd26466fc6daf6f82971827f145612adae1a28bf238e341d262962.ob9TvsNiXCUfk7O4CymtRroNcRzXSGsbPULAieP2JzQ
+ hash: v1.k794b7964.42627bcb672d30fc8743cc51d12ebb3c6afa706c34b823142fe046dfabf7da14.qgWmPYfrlGq2nC0pUkRH7gBufEAaZwylWaiJ7pQvDss
scenes-app-mcp-analytics-dashboard-cards--overview-unknown-models--light:
- hash: v1.k794b7964.5e4192071ebd122aa925a7186a25b50b94d23fc1a5d45b91e1b200d7341626b8.-A4DoyQrFq5Hfj1H7i4FhJfBfPQXEQokksPNGBmFL_A
+ hash: v1.k794b7964.14c81038ec52ea73ced39268d1074e90bca406ce789ea38bcccd392e04391e33.hsUugUYunh71q6Wl1qMxXT3nFMKlMp22LblYQ8ENSS4
scenes-app-mcp-analytics-dashboard-cards--share-by-harness--dark:
hash: v1.k794b7964.fde18be0efabaa2cf352bb9fb0a666d8093559da70e0aae8c810eacc1e729eb4.ZVHWg1s6g2RxLBy2o-N7DQE84oHBJ6a0krFomsu7Vlw
scenes-app-mcp-analytics-dashboard-cards--share-by-harness--light:
diff --git a/frontend/src/lib/components/PropertyFilters/PropertyFilters.test.tsx b/frontend/src/lib/components/PropertyFilters/PropertyFilters.test.tsx
index a80ead0382e4..cb06abe89938 100644
--- a/frontend/src/lib/components/PropertyFilters/PropertyFilters.test.tsx
+++ b/frontend/src/lib/components/PropertyFilters/PropertyFilters.test.tsx
@@ -13,7 +13,7 @@ import { mockActionDefinition, mockGetEventDefinitions, mockGetPropertyDefinitio
import { PropertyFilterType, PropertyOperator } from '~/types'
import { TaxonomicFilterGroupType } from '../TaxonomicFilter/types'
-import { PropertyFilters } from './PropertyFilters'
+import { PropertyFilters, PropertyFiltersProps } from './PropertyFilters'
jest.mock('lib/components/AutoSizer', () => ({
AutoSizer: ({ renderProp }: { renderProp: (size: { height: number; width: number }) => React.ReactNode }) =>
@@ -84,8 +84,15 @@ describe('PropertyFilters', () => {
operator: PropertyOperator.Exact,
} as const
- it('add filter: click add, search, select property, verify onChange shape', async () => {
- const { onChange } = renderPropertyFilters({ sendAllKeyUpdates: true })
+ const splitControls: PropertyFiltersProps['renderControls'] = ({ addFilter, activeFilters }) => (
+ <div>
+ <div>{addFilter}</div>
+ <div>{activeFilters}</div>
+ </div>
+ )
+
+ it.each([undefined, splitControls])('adds a filter with layout %p', async (renderControls) => {
+ const { onChange } = renderPropertyFilters({ sendAllKeyUpdates: true, renderControls })
await userEvent.click(screen.getByTestId('new-prop-filter-test-page'))
@@ -113,9 +120,10 @@ describe('PropertyFilters', () => {
expect(filters[0].type).toBe('event')
})
- it('remove first of two filters: onChange has only the remaining filter', async () => {
+ it.each([undefined, splitControls])('removes the first filter with layout %p', async (renderControls) => {
const { onChange } = renderPropertyFilters({
propertyFilters: [BROWSER_FILTER, OS_FILTER],
+ renderControls,
})
expect(screen.getByText(/Chrome/)).toBeInTheDocument()
@@ -237,7 +245,7 @@ describe('PropertyFilters', () => {
expect(screen.getByTestId('property-filter-0')).toBeInTheDocument()
})
- it('keeps an in-progress filter when re-rendered with a new same-content array', async () => {
+ it.each([undefined, splitControls])('keeps an in-progress filter with layout %p', async (renderControls) => {
// Regression: a parent that re-renders frequently (e.g. a live-streaming
// dashboard) passes a freshly `.filter()`-ed array each render. A property
// picked but not yet given a value is never committed via onChange, so it is
@@ -246,6 +254,7 @@ describe('PropertyFilters', () => {
const { rerender } = render(
<Provider>
<PropertyFilters
+ renderControls={renderControls}
pageKey="in-progress"
onChange={onChange}
propertyFilters={[]}
@@ -272,6 +281,7 @@ describe('PropertyFilters', () => {
rerender(
<Provider>
<PropertyFilters
+ renderControls={renderControls}
pageKey="in-progress"
onChange={onChange}
propertyFilters={[]}
diff --git a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
index 3013c34b527a..6d8192ed7bec 100644
--- a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
+++ b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
@@ -19,6 +19,7 @@ import {
} from 'lib/components/TaxonomicFilter/types'
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
+import { isOperatorFlag } from 'lib/utils/operators'
import { LogicalRowDivider } from 'scenes/cohorts/CohortFilters/CohortCriteriaRowBuilder'
import { AnyDataNode, DatabaseSchemaField } from '~/queries/schema/schema-general'
@@ -87,6 +88,11 @@ export interface PropertyFiltersProps {
addFilterSuffix?: ((addFilter: (property: AnyPropertyFilter) => void) => JSX.Element) | null
addFilterDivider?: boolean
framedRows?: boolean
+ renderControls?: (controls: {
+ addFilter: React.ReactNode
+ activeFilters: JSX.Element[]
+ clearFilters: () => void
+ }) => JSX.Element
}
export function PropertyFilters({
@@ -136,10 +142,11 @@ export function PropertyFilters({
addFilterSuffix,
addFilterDivider = false,
framedRows = false,
+ renderControls,
}: PropertyFiltersProps): JSX.Element {
const logicProps = { propertyFilters, onChange, pageKey, sendAllKeyUpdates }
const { filters, filtersWithNew, filterIds, filterIdsWithNew } = useValues(propertyFilterLogic(logicProps))
- const { remove, setFilter } = useActions(propertyFilterLogic(logicProps))
+ const { remove, setFilter, setFilters, update } = useActions(propertyFilterLogic(logicProps))
const [allowOpenOnInsert, setAllowOpenOnInsert] = useState<boolean>(false)
const showNewFilterRow = allowNew && editable
@@ -149,6 +156,117 @@ export function PropertyFilters({
// do not open on initial render, only open if newly inserted
useOnMountEffect(() => setAllowOpenOnInsert(true))
+ const rows = displayedFilters.map((item: AnyPropertyFilter, index: number) => {
+ // Moving a new property into a separate chip row remounts its value editor.
+ const openValueEditor =
+ !!renderControls &&
+ !!item.key &&
+ 'operator' in item &&
+ (!item.operator || !isOperatorFlag(item.operator)) &&
+ (item.value === undefined || item.value === null || item.value === '')
+ return (
+ <React.Fragment key={displayedFilterIds[index]}>
+ {logicalRowDivider && index > 0 && index !== displayedFilters.length - 1 && (
+ <LogicalRowDivider logicalOperator={propertyGroupType ?? FilterLogicalOperator.And} />
+ )}
+ {addFilterDivider &&
+ showNewFilterRow &&
+ index === displayedFilters.length - 1 &&
+ filters.length > 0 && <LemonDivider className="my-1 w-full" />}
+ <FilterRow
+ item={item}
+ index={index}
+ totalCount={displayedFilters.length - 1} // empty state
+ filters={displayedFilters}
+ pageKey={pageKey}
+ showConditionBadge={showConditionBadge}
+ disablePopover={disablePopover || orFiltering}
+ label={buttonText}
+ labelClassName={buttonClassName}
+ size={buttonSize}
+ onRemove={remove}
+ showRemoveButton={showRemoveButton}
+ orFiltering={orFiltering}
+ editable={editable}
+ filterComponent={(onComplete) =>
+ isBehavioralPropertyFilter(item) ? (
+ <div className="TaxonomicPropertyFilter__row w-full min-w-0">
+ {hasRowOperator && (
+ <PropertyFilterRowOperator
+ index={index}
+ orFiltering={orFiltering}
+ propertyGroupType={propertyGroupType}
+ hasKey={!!item.key}
+ />
+ )}
+ <div
+ className={clsx(
+ 'TaxonomicPropertyFilter__row-items',
+ framedRows && FILTER_ROW_FRAME_CLASSES
+ )}
+ >
+ <BehavioralPropertyFilterRow
+ filter={item}
+ onChange={(filter) => setFilter(index, filter)}
+ editable={editable}
+ pageKey={`${pageKey}-behavioral-${displayedFilterIds[index]}`}
+ size={buttonSize}
+ />
+ </div>
+ </div>
+ ) : (
+ <TaxonomicPropertyFilter
+ pageKey={pageKey}
+ index={index}
+ filters={filters}
+ setFilter={setFilter}
+ onComplete={onComplete}
+ orFiltering={orFiltering}
+ taxonomicGroupTypes={taxonomicGroupTypes}
+ metadataSource={metadataSource}
+ eventNames={eventNames}
+ schemaColumns={schemaColumns}
+ dataWarehouseTableName={dataWarehouseTableName}
+ propertyGroupType={propertyGroupType}
+ disablePopover={disablePopover || orFiltering}
+ addText={addText}
+ hasRowOperator={hasRowOperator}
+ propertyAllowList={propertyAllowList}
+ excludedProperties={excludedProperties}
+ taxonomicFilterOptionsFromProp={taxonomicFilterOptionsFromProp}
+ allowRelativeDateOptions={allowRelativeDateOptions}
+ excludedOperators={excludedOperators}
+ selectingKeyOnly={selectingKeyOnly}
+ hideBehavioralCohorts={hideBehavioralCohorts}
+ showCohortFlagTargeting={showCohortFlagTargeting}
+ size={buttonSize}
+ addFilterDocLink={addFilterDocLink}
+ editable={editable}
+ operatorAllowlist={operatorAllowlist}
+ hogQLGlobals={hogQLGlobals}
+ triggerVariant={triggerVariant}
+ staticValueOptions={staticValueOptions}
+ renderOperatorValueSelect={renderOperatorValueSelect}
+ propertyDefinitionsOverride={propertyDefinitionsOverride}
+ propertyKeyEditable={propertyKeyEditable}
+ singleLine={singleLine}
+ framedRows={framedRows}
+ />
+ )
+ }
+ errorMessage={errorMessages && errorMessages[index]}
+ openOnInsert={allowOpenOnInsert && (openOnInsert || openValueEditor)}
+ disabledReason={disabledReason}
+ suffix={
+ showNewFilterRow && index === displayedFilters.length - 1 && addFilterSuffix
+ ? addFilterSuffix((property) => setFilter(filters.length, property))
+ : null
+ }
+ />
+ </React.Fragment>
+ )
+ })
+
return (
<div className="PropertyFilters">
{showNestedArrow && !disablePopover && (
@@ -158,111 +276,16 @@ export function PropertyFilters({
)}
<div className="PropertyFilters__content max-w-full">
<BindLogic logic={propertyFilterLogic} props={logicProps}>
- {displayedFilters.map((item: AnyPropertyFilter, index: number) => {
- return (
- <React.Fragment key={displayedFilterIds[index]}>
- {logicalRowDivider && index > 0 && index !== displayedFilters.length - 1 && (
- <LogicalRowDivider
- logicalOperator={propertyGroupType ?? FilterLogicalOperator.And}
- />
- )}
- {addFilterDivider &&
- showNewFilterRow &&
- index === displayedFilters.length - 1 &&
- filters.length > 0 && <LemonDivider className="my-1 w-full" />}
- <FilterRow
- item={item}
- index={index}
- totalCount={displayedFilters.length - 1} // empty state
- filters={displayedFilters}
- pageKey={pageKey}
- showConditionBadge={showConditionBadge}
- disablePopover={disablePopover || orFiltering}
- label={buttonText}
- labelClassName={buttonClassName}
- size={buttonSize}
- onRemove={remove}
- showRemoveButton={showRemoveButton}
- orFiltering={orFiltering}
- editable={editable}
- filterComponent={(onComplete) =>
- isBehavioralPropertyFilter(item) ? (
- <div className="TaxonomicPropertyFilter__row w-full min-w-0">
- {hasRowOperator && (
- <PropertyFilterRowOperator
- index={index}
- orFiltering={orFiltering}
- propertyGroupType={propertyGroupType}
- hasKey={!!item.key}
- />
- )}
- <div
- className={clsx(
- 'TaxonomicPropertyFilter__row-items',
- framedRows && FILTER_ROW_FRAME_CLASSES
- )}
- >
- <BehavioralPropertyFilterRow
- filter={item}
- onChange={(filter) => setFilter(index, filter)}
- editable={editable}
- pageKey={`${pageKey}-behavioral-${displayedFilterIds[index]}`}
- size={buttonSize}
- />
- </div>
- </div>
- ) : (
- <TaxonomicPropertyFilter
- pageKey={pageKey}
- index={index}
- filters={filters}
- setFilter={setFilter}
- onComplete={onComplete}
- orFiltering={orFiltering}
- taxonomicGroupTypes={taxonomicGroupTypes}
- metadataSource={metadataSource}
- eventNames={eventNames}
- schemaColumns={schemaColumns}
- dataWarehouseTableName={dataWarehouseTableName}
- propertyGroupType={propertyGroupType}
- disablePopover={disablePopover || orFiltering}
- addText={addText}
- hasRowOperator={hasRowOperator}
- propertyAllowList={propertyAllowList}
- excludedProperties={excludedProperties}
- taxonomicFilterOptionsFromProp={taxonomicFilterOptionsFromProp}
- allowRelativeDateOptions={allowRelativeDateOptions}
- excludedOperators={excludedOperators}
- selectingKeyOnly={selectingKeyOnly}
- hideBehavioralCohorts={hideBehavioralCohorts}
- showCohortFlagTargeting={showCohortFlagTargeting}
- size={buttonSize}
- addFilterDocLink={addFilterDocLink}
- editable={editable}
- operatorAllowlist={operatorAllowlist}
- hogQLGlobals={hogQLGlobals}
- triggerVariant={triggerVariant}
- staticValueOptions={staticValueOptions}
- renderOperatorValueSelect={renderOperatorValueSelect}
- propertyDefinitionsOverride={propertyDefinitionsOverride}
- propertyKeyEditable={propertyKeyEditable}
- singleLine={singleLine}
- framedRows={framedRows}
- />
- )
- }
- errorMessage={errorMessages && errorMessages[index]}
- openOnInsert={allowOpenOnInsert && openOnInsert}
- disabledReason={disabledReason}
- suffix={
- showNewFilterRow && index === displayedFilters.length - 1 && addFilterSuffix
- ? addFilterSuffix((property) => setFilter(filters.length, property))
- : null
- }
- />
- </React.Fragment>
- )
- })}
+ {renderControls
+ ? renderControls({
+ addFilter: showNewFilterRow ? rows[rows.length - 1] : null,
+ activeFilters: showNewFilterRow ? rows.slice(0, -1) : rows,
+ clearFilters: () => {
+ setFilters([])
+ update()
+ },
+ })
+ : rows}
</BindLogic>
</div>
</div>
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
index f556ce83383b..31144a556069 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboard.stories.tsx
@@ -663,8 +663,8 @@ const meta: Meta = {
get: {
'/api/projects/:team_id/mcp_analytics/intent_clusters/': CLUSTER_SNAPSHOT,
'/api/projects/:team_id/mcp_analytics/sessions/activity_overview/': ACTIVITY_OVERVIEW,
- '/api/environments/:team_id/mcp_analytics/sessions/': SESSION_LIST,
- '/api/environments/:team_id/mcp_analytics/sessions/:session_id/tool_calls/': TOOL_CALL_LIST,
+ '/api/projects/:team_id/mcp_analytics/sessions/': SESSION_LIST,
+ '/api/projects/:team_id/mcp_analytics/sessions/:session_id/tool_calls/': TOOL_CALL_LIST,
'/api/projects/:team_id/property_definitions': ({ request }) => {
const isFeatureFlag = new URL(request.url).searchParams.get('is_feature_flag') === 'true'
return [200, isFeatureFlag ? MCP_FEATURE_FLAG_DEFINITIONS : MCP_PROPERTY_DEFINITIONS]
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
index 956e2a4f9d2a..aa33b091ccbb 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsDashboardOverview.tsx
@@ -1,16 +1,13 @@
import { useActions, useValues } from 'kea'
import { useChartTheme } from 'lib/charts/hooks'
-import { FilterBar } from 'lib/components/FilterBar'
-import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
-import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
-import { TestAccountFilterSwitch } from 'lib/components/TestAccountFiltersSwitch'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { cn } from 'lib/utils/css-classes'
import { teamLogic } from 'scenes/teamLogic'
import { McpDateFilter } from './components/McpDateFilter'
+import { McpSharedFilters } from './components/McpSharedFilters'
import { ActivityChart } from './dashboard/ActivityChart'
import { HarnessBarChart } from './dashboard/HarnessBarChart'
import { KpiTiles } from './dashboard/KpiTiles'
@@ -22,7 +19,6 @@ import { ToolUsageChart } from './dashboard/ToolUsageChart'
import { MCP_ANALYTICS_DASHBOARD_FEEDBACK_PROMPT } from './feedback/constants'
import { MCPAnalyticsFeedbackPrompt } from './feedback/MCPAnalyticsFeedbackPrompt'
import { MCPAnalyticsFirstLook } from './firstLook/MCPAnalyticsFirstLook'
-import { mcpAnalyticsFiltersLogic } from './mcpAnalyticsFiltersLogic'
import { mcpDashboardOverviewLogic } from './mcpDashboardOverviewLogic'
export function MCPAnalyticsDashboardOverview(): JSX.Element {
@@ -37,6 +33,7 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
harnessRows,
harnessRowsLoading,
modelRows,
+ modelRowsLoading,
hasModelData,
dailyActivity,
activityRowsLoading,
@@ -52,9 +49,7 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
canShowFeedback,
feedbackContextKey,
} = useValues(mcpDashboardOverviewLogic)
- const { setDateFilter, markFilterInteraction } = useActions(mcpDashboardOverviewLogic)
- const { filterTestAccounts, propertyFilters } = useValues(mcpAnalyticsFiltersLogic)
- const { setFilterTestAccounts, setPropertyFilters } = useActions(mcpAnalyticsFiltersLogic)
+ const { setDateFilter, reloadAll, markFilterInteraction } = useActions(mcpDashboardOverviewLogic)
const { timezone } = useValues(teamLogic)
const { featureFlags } = useValues(featureFlagLogic)
@@ -62,48 +57,31 @@ export function MCPAnalyticsDashboardOverview(): JSX.Element {
return (
<div className="@container/mcp-overview flex min-w-0 flex-col gap-6">
- <FilterBar
- left={
- <>
- <McpDateFilter
- dateFrom={dateFilter.dateFrom}
- dateTo={dateFilter.dateTo}
- onChange={(dateFrom, dateTo) => {
- setDateFilter(dateFrom, dateTo)
- markFilterInteraction()
- }}
- dataAttr="mcp-dashboard-date-filter"
- />
- <div data-attr="mcp-dashboard-property-filter">
- <PropertyFilters
- pageKey="mcp-dashboard-overview"
- propertyFilters={propertyFilters}
- onChange={(filters) => {
- setPropertyFilters(filters)
- markFilterInteraction()
- }}
- taxonomicGroupTypes={[
- TaxonomicFilterGroupType.MCPProperties,
- TaxonomicFilterGroupType.EventProperties,
- TaxonomicFilterGroupType.EventFeatureFlags,
- ]}
- eventNames={['$mcp_tool_call']}
- buttonText="Add filter"
- />
- </div>
- </>
- }
- right={
- <TestAccountFilterSwitch
- checked={filterTestAccounts}
- onChange={(enabled) => {
- setFilterTestAccounts(enabled)
- markFilterInteraction()
- }}
- data-attr="mcp-dashboard-test-account-filter"
- />
+ <McpSharedFilters
+ pageKey="mcp-dashboard-overview"
+ dataAttrPrefix="mcp-dashboard"
+ onRefresh={reloadAll}
+ refreshing={
+ kpisLoading ||
+ usersLoading ||
+ sessionRowsLoading ||
+ harnessRowsLoading ||
+ modelRowsLoading ||
+ activityRowsLoading ||
+ toolDailyRowsLoading ||
+ toolRowsLoading
}
- />
+ >
+ <McpDateFilter
+ dateFrom={dateFilter.dateFrom}
+ dateTo={dateFilter.dateTo}
+ onChange={(dateFrom, dateTo) => {
+ setDateFilter(dateFrom, dateTo)
+ markFilterInteraction()
+ }}
+ dataAttr="mcp-dashboard-date-filter"
+ />
+ </McpSharedFilters>
<MCPAnalyticsFeedbackPrompt
contextKey={feedbackContextKey}
eligible={canShowFeedback}
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
index 12d98401ea29..5db3f06d098e 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
@@ -42,6 +42,7 @@ import { SceneExport } from '~/scenes/sceneTypes'
import { PersonDisplay } from 'products/persons/frontend/components/PersonDisplay'
import { ToolDetailIntentsSection } from './clustering/ToolDetailIntentsSection'
+import { McpDateFilter } from './components/McpDateFilter'
import { McpSharedFilters } from './components/McpSharedFilters'
import { formatMs, formatMsAsSeconds, formatNumber } from './dashboard/formatters'
import { HarnessLogo, HarnessPill } from './dashboard/harness'
@@ -508,7 +509,7 @@ function MCPAnalyticsToolDetailContent({ toolName }: { toolName: string }): JSX.
pinnedInterval,
incompleteTail,
} = useValues(mcpAnalyticsToolDetailLogic({ toolName }))
- const { selectFailure } = useActions(mcpAnalyticsToolDetailLogic({ toolName }))
+ const { selectFailure, setDateFilter, loadAllSections } = useActions(mcpAnalyticsToolDetailLogic({ toolName }))
const { timezone } = useValues(teamLogic)
const { featureFlags } = useValues(featureFlagLogic)
const intentRoutingEnabled = !!featureFlags[FEATURE_FLAGS.MCP_ANALYTICS_INTENT_ROUTING]
@@ -542,7 +543,30 @@ function MCPAnalyticsToolDetailContent({ toolName }: { toolName: string }): JSX.
/>
<div className="flex flex-wrap items-center gap-3 px-4 pb-2">
- <McpSharedFilters pageKey="mcp-tool-detail" dataAttrPrefix="mcp-tool-detail" />
+ <McpSharedFilters
+ pageKey="mcp-tool-detail"
+ dataAttrPrefix="mcp-tool-detail"
+ onRefresh={loadAllSections}
+ refreshing={
+ summaryLoading ||
+ descriptionsLoading ||
+ dailyStatsLoading ||
+ failureBucketsLoading ||
+ sampleIntentRowsLoading ||
+ intentCoverageLoading ||
+ neighborsBeforeRowsLoading ||
+ neighborsAfterRowsLoading ||
+ byHarnessRowsLoading ||
+ topUserRowsLoading
+ }
+ >
+ <McpDateFilter
+ dateFrom={dateFilter.dateFrom}
+ dateTo={dateFilter.dateTo}
+ onChange={setDateFilter}
+ dataAttr="mcp-tool-detail-date-filter"
+ />
+ </McpSharedFilters>
</div>
<div className="flex flex-col gap-3 px-4 pb-4">
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsToolQuality.tsx b/products/mcp_analytics/frontend/MCPAnalyticsToolQuality.tsx
index 6d0640d3587b..1bf5775065da 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsToolQuality.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsToolQuality.tsx
@@ -17,16 +17,9 @@ import { ToolQualityCharts } from './tool-quality/ToolQualityCharts'
import { ToolQualityTable } from './tool-quality/ToolQualityTable'
function FilterBar(): JSX.Element {
- const {
- availableCategories,
- selectedCategories,
- scopeShare,
- dateFilter,
- dateRangeLabel,
- interval,
- intervalOptions,
- } = useValues(mcpAnalyticsToolQualityLogic)
- const { setSelectedCategories, setDateFilter, setPinnedInterval } = useActions(mcpAnalyticsToolQualityLogic)
+ const { availableCategories, selectedCategories, scopeShare, dateRangeLabel, interval, intervalOptions } =
+ useValues(mcpAnalyticsToolQualityLogic)
+ const { setSelectedCategories, setPinnedInterval } = useActions(mcpAnalyticsToolQualityLogic)
const hasScope = selectedCategories.length > 0
const sharePct = scopeShare.pct === null ? null : Math.round(scopeShare.pct * 10) / 10
@@ -43,12 +36,6 @@ function FilterBar(): JSX.Element {
dataAttr="mcp-tool-quality-category-scope"
/>
</div>
- <McpDateFilter
- dateFrom={dateFilter.dateFrom}
- dateTo={dateFilter.dateTo}
- onChange={(dateFrom, dateTo) => setDateFilter(dateFrom, dateTo)}
- dataAttr="mcp-tool-quality-date-filter"
- />
<McpIntervalFilter
interval={interval}
options={intervalOptions}
@@ -108,19 +95,41 @@ function ChartsScopeHeader(): JSX.Element {
}
export function MCPAnalyticsToolQuality(): JSX.Element {
- const { dailyChartData, dailyStatsLoading, interval, incompleteTail } = useValues(mcpAnalyticsToolQualityLogic)
+ const {
+ dailyChartData,
+ dailyStatsLoading,
+ interval,
+ incompleteTail,
+ dateFilter,
+ availableCategoriesLoading,
+ categoryCountsLoading,
+ toolRowsPageLoading,
+ } = useValues(mcpAnalyticsToolQualityLogic)
+ const { setDateFilter, reloadAll } = useActions(mcpAnalyticsToolQualityLogic)
const { timezone } = useValues(teamLogic)
const theme = useChartTheme()
return (
<div className="flex flex-col gap-4">
+ <McpSharedFilters
+ pageKey="mcp-tool-quality"
+ dataAttrPrefix="mcp-tool-quality"
+ onRefresh={reloadAll}
+ refreshing={
+ dailyStatsLoading || availableCategoriesLoading || categoryCountsLoading || toolRowsPageLoading
+ }
+ >
+ <McpDateFilter
+ dateFrom={dateFilter.dateFrom}
+ dateTo={dateFilter.dateTo}
+ onChange={(dateFrom, dateTo) => setDateFilter(dateFrom, dateTo)}
+ dataAttr="mcp-tool-quality-date-filter"
+ />
+ </McpSharedFilters>
<div data-quill>
<FilterBar />
</div>
- {/* Stays outside the quill scope: `[data-quill]` redefines the `--color-*` tokens, which
- paints the checked test-account switch as unchecked. */}
- <McpSharedFilters pageKey="mcp-tool-quality" dataAttrPrefix="mcp-tool-quality" />
<div className="flex flex-col gap-4" data-quill>
<ChartsScopeHeader />
<ToolQualityCharts
diff --git a/products/mcp_analytics/frontend/components/McpDateFilter.tsx b/products/mcp_analytics/frontend/components/McpDateFilter.tsx
index a40fe7271fe8..b73009c79feb 100644
--- a/products/mcp_analytics/frontend/components/McpDateFilter.tsx
+++ b/products/mcp_analytics/frontend/components/McpDateFilter.tsx
@@ -81,7 +81,7 @@ export function McpDateFilter({ dateFrom, dateTo, onChange, dataAttr }: McpDateF
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger
render={
- <Button variant="outline" data-attr={dataAttr} data-quill>
+ <Button variant="outline" size="sm" data-attr={dataAttr} data-quill>
<IconCalendar />
{formatTriggerLabel(value)}
</Button>
diff --git a/products/mcp_analytics/frontend/components/McpInternalUsersFilter.tsx b/products/mcp_analytics/frontend/components/McpInternalUsersFilter.tsx
new file mode 100644
index 000000000000..90cfd395ea0e
--- /dev/null
+++ b/products/mcp_analytics/frontend/components/McpInternalUsersFilter.tsx
@@ -0,0 +1,53 @@
+import { useActions, useValues } from 'kea'
+
+import { IconCheck, IconChevronDown, IconGear } from '@posthog/icons'
+import { LemonButton, LemonMenu } from '@posthog/lemon-ui'
+
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import { mcpAnalyticsFiltersLogic } from '../mcpAnalyticsFiltersLogic'
+
+export function McpInternalUsersFilter({ dataAttr }: { dataAttr: string }): JSX.Element {
+ const { currentTeam } = useValues(teamLogic)
+ const { filterTestAccounts } = useValues(mcpAnalyticsFiltersLogic)
+ const { setFilterTestAccounts } = useActions(mcpAnalyticsFiltersLogic)
+ const hasFilters = (currentTeam?.test_account_filters || []).length > 0
+ const excluded = hasFilters && filterTestAccounts
+
+ return (
+ <LemonMenu
+ items={[
+ {
+ items: [
+ {
+ label: 'Include internal and test users',
+ icon: !excluded ? <IconCheck /> : undefined,
+ onClick: () => setFilterTestAccounts(false),
+ },
+ {
+ label: 'Exclude internal and test users',
+ icon: excluded ? <IconCheck /> : undefined,
+ disabledReason: hasFilters ? undefined : 'Configure internal and test users first.',
+ onClick: () => setFilterTestAccounts(true),
+ },
+ ],
+ },
+ {
+ items: [
+ {
+ label: 'Configure internal and test users',
+ icon: <IconGear />,
+ to: urls.settings('environment-customization', 'internal-user-filtering'),
+ targetBlank: true,
+ },
+ ],
+ },
+ ]}
+ >
+ <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />} data-attr={dataAttr}>
+ {excluded ? 'Internal users excluded' : 'Internal users included'}
+ </LemonButton>
+ </LemonMenu>
+ )
+}
diff --git a/products/mcp_analytics/frontend/components/McpSharedFilters.stories.tsx b/products/mcp_analytics/frontend/components/McpSharedFilters.stories.tsx
new file mode 100644
index 000000000000..468a5cc408e3
--- /dev/null
+++ b/products/mcp_analytics/frontend/components/McpSharedFilters.stories.tsx
@@ -0,0 +1,74 @@
+import type { Meta, StoryObj } from '@storybook/react'
+
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import { AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
+
+import { mcpAnalyticsFiltersLogic } from '../mcpAnalyticsFiltersLogic'
+import { McpDateFilter } from './McpDateFilter'
+import { McpSharedFilters } from './McpSharedFilters'
+
+const FILTERS: AnyPropertyFilter[] = [
+ { key: '$mcp_client_name', type: PropertyFilterType.Event, operator: PropertyOperator.Exact, value: 'Claude' },
+ { key: '$mcp_tool_name', type: PropertyFilterType.Event, operator: PropertyOperator.Exact, value: 'search' },
+]
+
+const meta: Meta<typeof McpSharedFilters> = {
+ title: 'Products/MCP Analytics/Shared filters',
+ component: McpSharedFilters,
+ args: {
+ pageKey: 'mcp-shared-filters-story',
+ dataAttrPrefix: 'mcp-shared-filters-story',
+ refreshing: false,
+ onRefresh: () => {},
+ children: <McpDateFilter dateFrom="-7d" dateTo={null} onChange={() => {}} dataAttr="mcp-story-date-filter" />,
+ },
+ parameters: {
+ pageUrl: urls.mcpAnalyticsDashboard(),
+ mockDate: '2026-09-15T12:00:00Z',
+ },
+}
+export default meta
+
+type Story = StoryObj<typeof McpSharedFilters>
+
+export const Empty: Story = {}
+
+const applyActiveFilters: NonNullable<Story['play']> = async ({ canvas }) => {
+ await canvas.findByRole('button', { name: 'Refresh' })
+ if (!mcpAnalyticsFiltersLogic.isMounted()) {
+ throw new Error('Shared filter logic is not mounted')
+ }
+ const team = teamLogic.values.currentTeam
+ if (team) {
+ teamLogic.actions.loadCurrentTeamSuccess({
+ ...team,
+ test_account_filters: [
+ {
+ key: 'email',
+ type: PropertyFilterType.Person,
+ operator: PropertyOperator.IContains,
+ value: '@example.com',
+ },
+ ],
+ })
+ }
+ mcpAnalyticsFiltersLogic.actions.setPropertyFilters(FILTERS)
+ mcpAnalyticsFiltersLogic.actions.setFilterTestAccounts(true)
+}
+
+export const Active: Story = {
+ play: applyActiveFilters,
+}
+
+export const Narrow: Story = {
+ play: applyActiveFilters,
+ decorators: [
+ (Story) => (
+ <div className="w-[520px] max-w-full">
+ <Story />
+ </div>
+ ),
+ ],
+}
diff --git a/products/mcp_analytics/frontend/components/McpSharedFilters.tsx b/products/mcp_analytics/frontend/components/McpSharedFilters.tsx
index 2dbaac1c3cc8..0507afd512eb 100644
--- a/products/mcp_analytics/frontend/components/McpSharedFilters.tsx
+++ b/products/mcp_analytics/frontend/components/McpSharedFilters.tsx
@@ -1,41 +1,87 @@
import { useActions, useValues } from 'kea'
+import type { ReactNode } from 'react'
+
+import { IconRefresh, IconX } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
-import { TestAccountFilterSwitch } from 'lib/components/TestAccountFiltersSwitch'
+import { MCP_TOOL_CALL_EVENT } from 'lib/components/TaxonomicFilter/utils/mcpProperties'
+import { cn } from 'lib/utils/css-classes'
import { mcpAnalyticsFiltersLogic } from '../mcpAnalyticsFiltersLogic'
+import { McpInternalUsersFilter } from './McpInternalUsersFilter'
+
+const TAXONOMIC_GROUP_TYPES = [
+ TaxonomicFilterGroupType.MCPProperties,
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.EventFeatureFlags,
+]
-export interface McpSharedFiltersProps {
+interface McpSharedFiltersProps {
pageKey: string
dataAttrPrefix: string
+ className?: string
+ children?: ReactNode
+ onRefresh: () => void
+ refreshing: boolean
}
-export function McpSharedFilters({ pageKey, dataAttrPrefix }: McpSharedFiltersProps): JSX.Element {
- const { filterTestAccounts, propertyFilters } = useValues(mcpAnalyticsFiltersLogic)
- const { setFilterTestAccounts, setPropertyFilters } = useActions(mcpAnalyticsFiltersLogic)
+export function McpSharedFilters({
+ pageKey,
+ dataAttrPrefix,
+ className,
+ children,
+ onRefresh,
+ refreshing,
+}: McpSharedFiltersProps): JSX.Element {
+ const { propertyFilters } = useValues(mcpAnalyticsFiltersLogic)
+ const { setPropertyFilters } = useActions(mcpAnalyticsFiltersLogic)
return (
- <>
- <div data-attr={`${dataAttrPrefix}-property-filter`}>
- <PropertyFilters
- pageKey={pageKey}
- propertyFilters={propertyFilters}
- onChange={setPropertyFilters}
- taxonomicGroupTypes={[
- TaxonomicFilterGroupType.MCPProperties,
- TaxonomicFilterGroupType.EventProperties,
- TaxonomicFilterGroupType.EventFeatureFlags,
- ]}
- eventNames={['$mcp_tool_call']}
- buttonText="Add filter"
- />
- </div>
- <TestAccountFilterSwitch
- checked={filterTestAccounts}
- onChange={setFilterTestAccounts}
- data-attr={`${dataAttrPrefix}-test-account-filter`}
+ <div className={cn('w-full min-w-0', className)} data-attr={`${dataAttrPrefix}-property-filter`}>
+ <PropertyFilters
+ pageKey={pageKey}
+ propertyFilters={propertyFilters}
+ onChange={setPropertyFilters}
+ taxonomicGroupTypes={TAXONOMIC_GROUP_TYPES}
+ eventNames={[MCP_TOOL_CALL_EVENT]}
+ buttonText="Add filter"
+ buttonSize="small"
+ renderControls={({ addFilter, activeFilters, clearFilters }) => (
+ <div className="flex w-full min-w-0 flex-col gap-2">
+ <div className="flex flex-wrap items-center gap-2">
+ {children}
+ {addFilter}
+ {activeFilters.length > 0 && (
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconX />}
+ aria-label="Clear property filters"
+ tooltip="Clear property filters"
+ onClick={clearFilters}
+ data-attr={`${dataAttrPrefix}-clear-filters`}
+ />
+ )}
+ <McpInternalUsersFilter dataAttr={`${dataAttrPrefix}-test-account-filter`} />
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconRefresh />}
+ aria-label="Refresh"
+ tooltip="Refresh data"
+ onClick={onRefresh}
+ loading={refreshing}
+ data-attr={`${dataAttrPrefix}-refresh`}
+ />
+ </div>
+ {activeFilters.length > 0 && (
+ <div className="flex min-w-0 flex-wrap items-center gap-2">{activeFilters}</div>
+ )}
+ </div>
+ )}
/>
- </>
+ </div>
)
}
diff --git a/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.test.ts b/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.test.ts
index a2430a535f36..cdbcd81748ee 100644
--- a/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.test.ts
+++ b/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.test.ts
@@ -367,6 +367,24 @@ describe('mcpAnalyticsToolQualityLogic', () => {
)
})
+ it('refreshes every tool quality data source', async () => {
+ const logic = mcpAnalyticsToolQualityLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ const callsBefore = mockApi.query.mock.calls.length
+
+ await expectLogic(logic, () => logic.actions.reloadAll()).toFinishAllListeners()
+
+ expect(queryCallsSince(callsBefore).map((call) => call.kind)).toEqual(
+ expect.arrayContaining([
+ NodeKind.MCPToolQualityRowsQuery,
+ NodeKind.MCPToolQualityDailyStatsQuery,
+ NodeKind.MCPToolCategoryCountsQuery,
+ NodeKind.MCPToolCategoriesQuery,
+ ])
+ )
+ })
+
it('discards a superseded available-categories response so a slow earlier request cannot overwrite it', async () => {
const logic = mcpAnalyticsToolQualityLogic()
logic.mount()
diff --git a/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.ts b/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.ts
index 2dc82748d7cb..07bb0e91200c 100644
--- a/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.ts
+++ b/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.ts
@@ -583,6 +583,8 @@ export const mcpAnalyticsToolQualityLogic = kea<mcpAnalyticsToolQualityLogicType
reloadAll: () => {
actions.loadToolRowsPage()
actions.loadDailyStats()
+ actions.loadCategoryCounts()
+ actions.loadAvailableCategories()
},
setSelectedTool: () => {
actions.loadDailyStats()
diff --git a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
index 97afc9a3c678..b5b67e6e2a45 100644
--- a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
+++ b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
@@ -620,12 +620,12 @@ describe('mcpDashboardOverviewLogic', () => {
if (filter === 'date') {
logic.actions.setDateFilter('-30d', null)
+ logic.actions.markFilterInteraction()
} else if (filter === 'property') {
logic.actions.setPropertyFilters([EVENT_FILTER])
} else {
logic.actions.setFilterTestAccounts(true)
}
- logic.actions.markFilterInteraction()
expect(logic.values.canShowFeedback).toBe(false)
await expectLogic(logic).toFinishAllListeners()
expect(logic.values.canShowFeedback).toBe(true)
diff --git a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts
index 836742bf2a39..b9f2a8653b83 100644
--- a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts
+++ b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts
@@ -962,9 +962,11 @@ export const mcpDashboardOverviewLogic = kea<mcpDashboardOverviewLogicType>([
actions.reloadAll()
},
setFilterTestAccounts: () => {
+ actions.markFilterInteraction()
actions.reloadAll()
},
setPropertyFilters: () => {
+ actions.markFilterInteraction()
actions.reloadAll()
},
hydrateFilters: () => {