:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(taxonomic-filter): stop offering "not seen yet" for an excluded event (#91412)
Phil Haack1db814e5705d
diff --git a/.agents/skills/modifying-taxonomic-filter/SKILL.md b/.agents/skills/modifying-taxonomic-filter/SKILL.mdindex 99c0372f3b66..8de7c65ef564 100644--- a/.agents/skills/modifying-taxonomic-filter/SKILL.md+++ b/.agents/skills/modifying-taxonomic-filter/SKILL.md@@ -140,9 +140,15 @@ The rebuild is opt-in in exactly **two consumer wrappers**:`TaxonomicPopover.tsx` and`PropertyFilters/components/TaxonomicPropertyFilter.tsx`. Both check`TAXONOMIC_FILTER_MENU_REBUILD` and render `<TaxonomicFilterMenu>` or the-legacy `<TaxonomicFilter>`. Call sites that build their own popover (e.g.-`ActionFilterRow`) never see the rebuild — so "does this reach the-rebuild?" depends on the call site, not a single global switch.+legacy `<TaxonomicFilter>`. A call site reaching one of those wrappers can+still land on the legacy path: `TaxonomicPopover` renders the rebuild only+when `newMenuSupportsCallSite` holds (`!allowClear && closeOnChange && ref+== null`), because the rebuilt menu cannot honour those three capabilities.+So "does this reach the rebuild?" depends on the wrapper _and_ the props+that call site passes, not a single global switch — `ActionFilterRow` goes+through `TaxonomicPopover` and passes none of the three, so it does reach+the rebuild. Only a call site that hand-rolls its own popover around+`<TaxonomicFilter>` bypasses the wrappers entirely.**Touching tab/group rendering means testing all three surfaces.**diff --git a/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx b/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsxindex b4c6ddae8317..491af766261f 100644--- a/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx@@ -1839,7 +1839,7 @@ export function useTaxonomicAutocompleteShortcutItems(): {pinned: TaxonomicAutocompleteEntry[]suggested: TaxonomicAutocompleteEntry[]} {- const { groups } = useTaxonomicFilterContext()+ const { groups, excludedProperties } = useTaxonomicFilterContext()const { pinnedFilterItems } = useValues(taxonomicFilterPinnedPropertiesLogic)return useMemo<{ pinned: TaxonomicAutocompleteEntry[]; suggested: TaxonomicAutocompleteEntry[] }>(() => {@@ -1860,10 +1860,29 @@ export function useTaxonomicAutocompleteShortcutItems(): {const pinned: TaxonomicAutocompleteEntry[] = (pinnedFilterItems as Array<- TaxonomicDefinitionTypes & { _pinnedContext?: { sourceGroupType?: TaxonomicFilterGroupType } }+ TaxonomicDefinitionTypes & {+ _pinnedContext?: { sourceGroupType?: TaxonomicFilterGroupType; value?: TaxonomicFilterValue }+ }>)- .map((item) => buildEntry(item, item._pinnedContext?.sourceGroupType))+ .map((item) => {+ const sourceGroupType = item._pinnedContext?.sourceGroupType+ const pinnedValue = item._pinnedContext?.value+ const entry = buildEntry(item, sourceGroupType)+ // A value the source group excludes must not be offered as a shortcut, the same way+ // `filterPinnedForContext` drops it from the Pinned tab. Groups like Logs, Issues, and+ // Revenue analytics filter their own options from the root `excludedProperties` map and+ // never set `group.excludedProperties`, so read that root map keyed by the source group too.+ const rootExcluded = sourceGroupType ? excludedProperties?.[sourceGroupType] : undefined+ const isExcluded =+ pinnedValue != null &&+ (entry?.group.excludedProperties?.includes(pinnedValue as string) ||+ rootExcluded?.includes(pinnedValue))+ if (isExcluded) {+ return null+ }+ return entry+ }).filter((e): e is TaxonomicAutocompleteEntry => e != null)const suggestedGroup = findGroup(TaxonomicFilterGroupType.SuggestedFilters)@@ -1875,7 +1894,7 @@ export function useTaxonomicAutocompleteShortcutItems(): {.filter((e): e is TaxonomicAutocompleteEntry => e != null)return { pinned, suggested }- }, [groups, pinnedFilterItems])+ }, [groups, pinnedFilterItems, excludedProperties])}const DEFAULT_MENU_SHORTCUT_GROUPS: readonly TaxonomicFilterGroupType[] = [diff --git a/frontend/src/lib/components/TaxonomicFilter/headless/headless.test.tsx b/frontend/src/lib/components/TaxonomicFilter/headless/headless.test.tsxindex 867df89e26a9..fa50eabe50e3 100644--- a/frontend/src/lib/components/TaxonomicFilter/headless/headless.test.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/headless/headless.test.tsx@@ -1,6 +1,6 @@import '@testing-library/jest-dom'-import { cleanup, render, screen, waitFor } from '@testing-library/react'+import { cleanup, render, renderHook, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { Provider } from 'kea'@@ -14,8 +14,9 @@ import { PropertyFilterType, PropertyOperator } from '~/types'import { __clearTaxonomicResourceCache } from '../hooks/useTaxonomicResource'import { recentTaxonomicFiltersLogic } from '../recentTaxonomicFiltersLogic'+import { taxonomicFilterPinnedPropertiesLogic } from '../taxonomicFilterPinnedPropertiesLogic'import { TaxonomicFilterGroupType } from '../types'-import { TaxonomicFilterHeadless } from './index'+import { TaxonomicFilterHeadless, useTaxonomicAutocompleteShortcutItems } from './index'jest.mock('~/queries/query', () => ({performQuery: jest.fn(),@@ -247,4 +248,32 @@ describe('TaxonomicFilterHeadless integration', () => {recents.unmount()})++ // A pin outlives the picker it was made in, so without this the shortcut row is another door+ // to selecting a value the exclusion forbids.+ it.each([+ ['$exception', false],+ ['checkout_started', true],+ ])('offers the pinned shortcut %p: %p', (pinnedName, expected) => {+ const pinnedLogic = taxonomicFilterPinnedPropertiesLogic.build()+ pinnedLogic.mount()+ pinnedLogic.actions.togglePin(TaxonomicFilterGroupType.Events, 'Events', pinnedName, { name: pinnedName })++ const { result } = renderHook(() => useTaxonomicAutocompleteShortcutItems(), {+ wrapper: ({ children }) => (+ <Provider>+ <TaxonomicFilterHeadless.Root+ taxonomicGroupTypes={[TaxonomicFilterGroupType.Events]}+ onChange={onChangeMock}+ excludedProperties={{ [TaxonomicFilterGroupType.Events]: ['$exception'] }}+ >+ {children}+ </TaxonomicFilterHeadless.Root>+ </Provider>+ ),+ })++ expect(result.current.pinned.some((e) => e.name === pinnedName)).toBe(expected)+ pinnedLogic.unmount()+ })})diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsxindex 7c0008af6b5b..54a874f70430 100644--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx@@ -348,17 +348,25 @@ describe('useGroupList', () => {await waitFor(() => expect(result.current.isLoading).toBe(false))})- it('allowNonCapturedEvents surfaces the option for empty Events search', async () => {+ // Transformation filters exclude `$exception` while allowing uncaptured events, so an excluded+ // name must never be offered as "not seen yet".+ it.each([+ ['unseen', true],+ ['$exception', false],+ ])('allowNonCapturedEvents offers %p when nothing matches: %p', async (query, expected) => {apiGet.mockResolvedValueOnce({ results: [], count: 0 })const group = makeGroup({type: TaxonomicFilterGroupType.Events,endpoint: 'api/projects/1/event_definitions',+ excludedProperties: ['$exception'],})const { result } = renderHook(() =>- useGroupList({ group, searchQuery: 'unseen', allowNonCapturedEvents: true })+ useGroupList({ group, searchQuery: query, allowNonCapturedEvents: true }))await waitFor(() => expect(result.current.isLoading).toBe(false))- expect(result.current.showNonCapturedEventOption).toBe(true)+ expect(result.current.showNonCapturedEventOption).toBe(expected)+ // No rebuild renderer draws the offer row yet, so the empty state is what a person sees.+ expect(result.current.showEmptyState).toBe(!expected)})})})diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.tsindex 91776b3a8809..312fdb313dfb 100644--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts@@ -438,9 +438,14 @@ export function useGroupList(input: UseGroupListInput): UseGroupListResult {if (!trimmedSearch || isLoading) {return false}+ // Offering an excluded name would let it be selected as a non-captured event, committing the+ // value the exclusion forbids. Mirrors legacy infiniteListLogic's `showNonCapturedEventOption`.+ if (group.excludedProperties?.includes(trimmedSearch)) {+ return false+ }const realResults = items.filter((item) => !isQuickFilterItem(item))return realResults.length === 0- }, [allowNonCapturedEvents, group.type, trimmedSearch, isLoading, items])+ }, [allowNonCapturedEvents, group.type, group.excludedProperties, trimmedSearch, isLoading, items])// Empty / loading state checks read array length, not the API-reported// total — a remote tab can have count > 0 while still loading its firstdiff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicLocalOverrides.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicLocalOverrides.tsindex 68511bc62fcc..62b03eef1c92 100644--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicLocalOverrides.ts+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicLocalOverrides.ts@@ -65,8 +65,8 @@ export function useTaxonomicLocalOverrides(context: {[recentFilterItems, taxonomicGroupTypes, excludedOperators, selectingKeyOnly, excludedProperties])const contextFilteredPinnedItems = useMemo(- () => filterPinnedForContext(pinnedFilterItems, taxonomicGroupTypes),- [pinnedFilterItems, taxonomicGroupTypes]+ () => filterPinnedForContext(pinnedFilterItems, taxonomicGroupTypes, excludedProperties),+ [pinnedFilterItems, taxonomicGroupTypes, excludedProperties])return useCallback(diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.tsindex 3140112d9da5..2ebce5d73c01 100644--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts@@ -916,6 +916,33 @@ describe('infiniteListLogic', () => {})})+ // Transformation filters exclude `$exception` while allowing uncaptured events, so an excluded+ // name must never be offered as "not seen yet".+ describe('the "not seen yet" option and excluded names', () => {+ const EXCLUDED_EVENT = '$exception'++ it.each([+ [EXCLUDED_EVENT, false],+ ['checkout_started', true],+ ])('searching %p offers the option: %p', async (query, expected) => {+ const listLogic = infiniteListLogic({+ taxonomicFilterLogicKey: `excluded-events-${query}`,+ listGroupType: TaxonomicFilterGroupType.Events,+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events],+ showNumericalPropsOnly: false,+ allowNonCapturedEvents: true,+ excludedProperties: { [TaxonomicFilterGroupType.Events]: [EXCLUDED_EVENT] },+ })+ listLogic.mount()++ await expectLogic(listLogic, () => {+ listLogic.actions.setSearchQuery(query)+ })+ .toFinishAllListeners()+ .toMatchValues({ showNonCapturedEventOption: expected })+ })+ })+describe('data warehouse pin lifecycle', () => {beforeEach(() => {const databaseLogic = databaseTableListLogic()@@ -1791,6 +1818,34 @@ describe('infiniteListLogic', () => {expect(names).toContain('level')})+ it('hides a pinned value that is excluded for its source group', () => {+ // A pin outlives the picker it was made in, so without this the Pinned tab is a second+ // door to selecting a value the exclusion forbids.+ const pinnedLogic = taxonomicFilterPinnedPropertiesLogic.build()+ pinnedLogic.mount()+ pinnedLogic.actions.togglePin(TaxonomicFilterGroupType.Events, 'Events', '$exception', {+ name: '$exception',+ })+ pinnedLogic.actions.togglePin(TaxonomicFilterGroupType.Events, 'Events', 'checkout_started', {+ name: 'checkout_started',+ })++ const listLogic = infiniteListLogic({+ taxonomicFilterLogicKey: 'pinned-excluded-test',+ listGroupType: TaxonomicFilterGroupType.PinnedFilters,+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.PinnedFilters],+ showNumericalPropsOnly: false,+ excludedProperties: { [TaxonomicFilterGroupType.Events]: ['$exception'] },+ })+ listLogic.mount()++ const names = listLogic.values.contextFilteredPinnedItems+ .filter((i) => 'name' in i)+ .map((i) => (i as { name: string }).name)+ expect(names).not.toContain('$exception')+ expect(names).toContain('checkout_started')+ })+it('preserves sourceValue on recent Persons items so the row resolves the correct distinct_id', () => {// Persons items are stored stripped ({name, id?}) — distinct_ids is not persisted.// The fix in InfiniteListRow falls back to _recentContext.sourceValue instead ofdiff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.tsindex 24e652f5b5da..fd848bffd090 100644--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts@@ -519,7 +519,8 @@ export interface infiniteListLogicMeta {) => TaxonomicDefinitionTypes[]contextFilteredPinnedItems: (pinnedFilterItems: TaxonomicDefinitionTypes[],- taxonomicGroupTypes: TaxonomicFilterGroupType[]+ taxonomicGroupTypes: TaxonomicFilterGroupType[],+ arg: import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap | undefined) => TaxonomicDefinitionTypes[]isSoleSubstantiveGroup: (listGroupType: TaxonomicFilterGroupType,@@ -562,7 +563,8 @@ export interface infiniteListLogicMeta {listGroupType: TaxonomicFilterGroupType,searchQuery: string,isLoading: boolean,- results: QuickFilterItem[] | (SkeletonItem | TaxonomicDefinitionTypes)[]+ results: QuickFilterItem[] | (SkeletonItem | TaxonomicDefinitionTypes)[],+ excludedProperties: string[] | undefined) => booleansuggestedFiltersSettling: (isSuggestedFilters: boolean,@@ -1134,11 +1136,17 @@ export const infiniteListLogic = kea<infiniteListLogicType>([),],contextFilteredPinnedItems: [- (s) => [s.pinnedFilterItems, s.taxonomicGroupTypes],+ (s) => [+ s.pinnedFilterItems,+ s.taxonomicGroupTypes,+ (_, props: InfiniteListLogicProps) => props.excludedProperties,+ ],(pinnedFilterItems: TaxonomicDefinitionTypes[],- taxonomicGroupTypes: TaxonomicFilterGroupType[]- ): TaxonomicDefinitionTypes[] => filterPinnedForContext(pinnedFilterItems, taxonomicGroupTypes),+ taxonomicGroupTypes: TaxonomicFilterGroupType[],+ excludedProperties: ExcludedProperties | undefined+ ): TaxonomicDefinitionTypes[] =>+ filterPinnedForContext(pinnedFilterItems, taxonomicGroupTypes, excludedProperties),],// This list is the filter's only substantive (non-meta) group. There are no separate// Recent/Pinned tabs leading the filter, so this list floats recent/pinned items to@@ -1255,13 +1263,21 @@ export const infiniteListLogic = kea<infiniteListLogicType>([},],showNonCapturedEventOption: [- (s) => [s.allowNonCapturedEvents, s.listGroupType, s.searchQuery, s.isLoading, s.results],+ (s) => [+ s.allowNonCapturedEvents,+ s.listGroupType,+ s.searchQuery,+ s.isLoading,+ s.results,+ s.excludedProperties,+ ],(allowNonCapturedEvents: boolean,listGroupType: TaxonomicFilterGroupType,searchQuery: string,isLoading: boolean,- results: TaxonomicDefinitionTypes[]+ results: TaxonomicDefinitionTypes[],+ excludedProperties: string[] | undefined): boolean => {if (!allowNonCapturedEvents) {return false@@ -1272,7 +1288,13 @@ export const infiniteListLogic = kea<infiniteListLogicType>([) {return false}- if (searchQuery.trim().length === 0 || isLoading) {+ const trimmedSearch = searchQuery.trim()+ if (trimmedSearch.length === 0 || isLoading) {+ return false+ }+ // Offering an excluded name would let it be selected as a non-captured event,+ // committing the value the exclusion forbids.+ if (excludedProperties?.includes(trimmedSearch)) {return false}// Keyword-shortcut QuickFilterItems don't represent captured events — ignore themdiff --git a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsxindex aba045b31b66..147a2befbe63 100644--- a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx@@ -377,11 +377,12 @@ export function TaxonomicFilterMenu({mapShortcutItems(filterPinnedForContext(pinnedFilterItems as TaxonomicDefinitionTypes[],- taxonomicGroupTypes+ taxonomicGroupTypes,+ excludedProperties) as ShortcutItem[],groups),- [pinnedFilterItems, taxonomicGroupTypes, groups]+ [pinnedFilterItems, taxonomicGroupTypes, groups, excludedProperties])const hasDwh = groups.some((g) => g.type === TaxonomicFilterGroupType.DataWarehouse)diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.test.ts b/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.test.tsindex 358a9ed3994f..91ea42e8d507 100644--- a/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.test.ts+++ b/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.test.ts@@ -136,12 +136,28 @@ describe('suggestedContextFilters', () => {})describe.each([- ['only in-scope kept', [pinned(Events, 'a'), pinned(Cohorts, 'c')], [Events], ['a']],- ['all out-of-scope dropped', [pinned(Cohorts, 'c')], [Events], []],- ['empty input', [], [Events], []],- ])('filterPinnedForContext — %s', (_label, items, types, expected) => {+ ['only in-scope kept', [pinned(Events, 'a'), pinned(Cohorts, 'c')], [Events], undefined, ['a']],+ ['all out-of-scope dropped', [pinned(Cohorts, 'c')], [Events], undefined, []],+ ['empty input', [], [Events], undefined, []],+ // A pin outlives the picker it was made in, so without this the Pinned tab is a second door+ // to selecting a value the exclusion forbids.+ [+ 'excluded value dropped',+ [pinned(Events, '$exception'), pinned(Events, 'checkout_started')],+ [Events],+ { [Events]: ['$exception'] },+ ['checkout_started'],+ ],+ [+ 'exclusion applies only to its own group',+ [pinned(Events, '$exception'), pinned(Cohorts, '$exception')],+ [Events, Cohorts],+ { [Events]: ['$exception'] },+ ['$exception'],+ ],+ ])('filterPinnedForContext — %s', (_label, items, types, excludedProperties, expected) => {it('matches the expected in-scope set', () => {- expect(names(filterPinnedForContext(items, types))).toEqual(expected)+ expect(names(filterPinnedForContext(items, types, excludedProperties))).toEqual(expected)})})})diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.ts b/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.tsindex 00ccc81563ae..4ad9eb19cb90 100644--- a/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.ts+++ b/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.ts@@ -52,16 +52,24 @@ export function filterRecentsForContext(return expandRecentsForDisplay(inScope, selectingKeyOnly)}-/** Pinned items whose source group is one of the picker's groups. */+/** Pinned items whose source group is one of the picker's groups, with the group's+ * excluded values dropped. */export function filterPinnedForContext(pinnedFilterItems: TaxonomicDefinitionTypes[],- taxonomicGroupTypes: TaxonomicFilterGroupType[]+ taxonomicGroupTypes: TaxonomicFilterGroupType[],+ excludedProperties?: ExcludedProperties): TaxonomicDefinitionTypes[] {if (!pinnedFilterItems?.length) {return []}const availableTypes = new Set(taxonomicGroupTypes)- return pinnedFilterItems.filter(- (item) => hasPinnedContext(item) && availableTypes.has(item._pinnedContext.sourceGroupType)- )+ return pinnedFilterItems.filter((item) => {+ if (!hasPinnedContext(item) || !availableTypes.has(item._pinnedContext.sourceGroupType)) {+ return false+ }+ // A pin outlives the picker it was made in, so a value pinned elsewhere reaches a picker+ // that forbids it. Recents drop excluded values for the same reason.+ const excludedValues = excludedProperties?.[item._pinnedContext.sourceGroupType]+ return !(excludedValues?.length && excludedValues.includes(item._pinnedContext.value))+ })}