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(taxonomic-filter): stop offering value shortcut groups as categories (#119110)

Paul D'Ambra7c18e8a59eb4
diff --git a/frontend/src/lib/components/PropertyFilters/PropertyFilters.component.test.tsx b/frontend/src/lib/components/PropertyFilters/PropertyFilters.component.test.tsx
index aaeb0d139bb0..7b4170dc6b25 100644
--- a/frontend/src/lib/components/PropertyFilters/PropertyFilters.component.test.tsx
+++ b/frontend/src/lib/components/PropertyFilters/PropertyFilters.component.test.tsx
@@ -127,13 +127,16 @@ describe('PropertyFilters recent selections', () => {
itemTestId,
onChange,
}: {
- tabTestId: string
+ tabTestId: string | null
searchQuery: string
itemTestId: string
onChange: jest.Mock
}): Promise<void> {
await openNewFilter()
- await switchToTab(tabTestId)
+ // Search-only groups have no tab. Their list still renders its rows, which is all the commit path needs.
+ if (tabTestId) {
+ await switchToTab(tabTestId)
+ }
await searchFor(searchQuery)
await waitFor(() => {
expect(screen.getByTestId(itemTestId)).toBeInTheDocument()
@@ -222,7 +225,7 @@ describe('PropertyFilters recent selections', () => {
mockOverrides: {
'/api/environments/:team/persons/values': [{ name: '[email protected]' }, { name: '[email protected]' }],
},
- tabTestId: 'taxonomic-tab-email_addresses',
+ tabTestId: null,
searchQuery: 'alice',
itemTestId: 'prop-filter-email_addresses-0',
expectedRecentPattern: /email.*=.*alice@example\.com/i,
diff --git a/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx b/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx
index c83614f601a2..4bf523a1a8dc 100644
--- a/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/headless/AutocompleteInput.tsx
@@ -79,10 +79,12 @@ import { PropertyDefinitionType } from '~/types'
import { useGroupList } from '../hooks/useGroupList'
import { hasPinnedContext, taxonomicFilterPinnedPropertiesLogic } from '../taxonomicFilterPinnedPropertiesLogic'
import {
+ META_GROUP_TYPES,
TaxonomicDefinitionTypes,
TaxonomicFilterGroup,
TaxonomicFilterGroupType,
TaxonomicFilterValue,
+ withoutSearchOnlyGroups,
} from '../types'
import { useTaxonomicFilterContext } from './context'
@@ -1260,7 +1262,13 @@ export function useTaxonomicAutocompleteCategories(): TaxonomicAutocompleteCateg
isActive: ctx.category === 'all',
onSelect: () => ctx.setCategory('all'),
}
- const groupCats = ctx.visibleGroups.map<TaxonomicAutocompleteCategory>((group) => ({
+ // Search-only groups still feed "all", but are not offered as categories.
+ const categoryGroups = withoutSearchOnlyGroups(
+ ctx.visibleGroups,
+ (group) => group.type,
+ (type) => META_GROUP_TYPES.has(type)
+ )
+ const groupCats = categoryGroups.map<TaxonomicAutocompleteCategory>((group) => ({
id: group.type,
name: group.name,
group,
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
index 2d9a7ced8acf..bad89783d026 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
@@ -747,16 +747,26 @@ describe('MenuFilterCombobox', () => {
expect(screen.queryByText(/URL contains/)).not.toBeInTheDocument()
})
- it('does not offer Pageview URLs as a navigable category', async () => {
+ it.each([
+ { groupType: TaxonomicFilterGroupType.PageviewUrls, name: 'Pageview URLs' },
+ { groupType: TaxonomicFilterGroupType.EmailAddresses, name: 'Email addresses' },
+ { groupType: TaxonomicFilterGroupType.AutocaptureEvents, name: 'Autocapture events' },
+ ])('does not offer $name as a navigable category', async ({ groupType, name }) => {
const user = userEvent.setup()
mockUrlValues(['https://app.posthog.com/checkout'])
renderAll({
- groupTypes: [TaxonomicFilterGroupType.EventProperties, TaxonomicFilterGroupType.PageviewUrls],
+ groupTypes: [
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.PersonProperties,
+ groupType,
+ ],
})
await user.click(screen.getByLabelText('Filter category'))
- expect(within(await openedCategoryPopup()).queryByText('Pageview URLs')).not.toBeInTheDocument()
+ const popup = within(await openedCategoryPopup())
+ expect(popup.getByText('Person properties')).toBeInTheDocument()
+ expect(popup.queryByText(name)).not.toBeInTheDocument()
})
it('commits the typed query as the value so it becomes $current_url contains <query>', async () => {
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
index f7b4e30f15b2..6073a44c6562 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
@@ -47,9 +47,11 @@ import { HiddenEventExplanation } from '../HiddenEventExplanation'
import { useGroupList } from '../hooks/useGroupList'
import {
OPEN_AS_SELF_ON_REOPEN,
+ META_GROUP_TYPES,
TaxonomicDefinitionTypes,
TaxonomicFilterGroup,
TaxonomicFilterGroupType,
+ withoutSearchOnlyGroups,
} from '../types'
import {
COLLAPSED_TO_CONTAINS_ROW,
@@ -329,7 +331,12 @@ export function MenuFilterCombobox({
// exposes them, not only via the outer dropdown menu.
const categoryOptions = useMemo<{ value: DrillCategory; label: string }[]>(() => {
const opts: { value: DrillCategory; label: string }[] = [{ value: 'all', label: 'All' }]
- for (const g of visibleChipGroups) {
+ const categoryGroups = withoutSearchOnlyGroups(
+ visibleChipGroups,
+ (g) => g.type,
+ (type) => META_GROUP_TYPES.has(type)
+ )
+ for (const g of categoryGroups) {
// Collapsed groups feed the "all" rows but aren't navigable categories.
if (COLLAPSED_TO_CONTAINS_ROW.has(g.type)) {
continue
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
index 75ee3388cde0..d806403d208b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
@@ -1138,6 +1138,69 @@ describe('taxonomicFilterLogic', () => {
})
})
+ describe('search-only groups', () => {
+ it.each([
+ {
+ picker: 'property picker',
+ groupTypes: [
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.PersonProperties,
+ TaxonomicFilterGroupType.PageviewUrls,
+ TaxonomicFilterGroupType.EmailAddresses,
+ ],
+ hidden: [TaxonomicFilterGroupType.EmailAddresses],
+ shown: [TaxonomicFilterGroupType.PersonProperties, TaxonomicFilterGroupType.PageviewUrls],
+ },
+ {
+ picker: 'series picker',
+ groupTypes: [
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.Actions,
+ TaxonomicFilterGroupType.PageviewEvents,
+ TaxonomicFilterGroupType.ScreenEvents,
+ TaxonomicFilterGroupType.AutocaptureEvents,
+ ],
+ hidden: [
+ TaxonomicFilterGroupType.PageviewEvents,
+ TaxonomicFilterGroupType.ScreenEvents,
+ TaxonomicFilterGroupType.AutocaptureEvents,
+ ],
+ shown: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions],
+ },
+ {
+ picker: 'picker of a search-only group and a meta group',
+ groupTypes: [TaxonomicFilterGroupType.EmailAddresses, TaxonomicFilterGroupType.HogQLExpression],
+ hidden: [],
+ shown: [TaxonomicFilterGroupType.EmailAddresses],
+ },
+ {
+ picker: 'picker of only a search-only group',
+ groupTypes: [TaxonomicFilterGroupType.EmailAddresses],
+ hidden: [],
+ shown: [TaxonomicFilterGroupType.EmailAddresses],
+ },
+ ])(
+ 'keeps search-only groups searched but out of the categories in a $picker',
+ ({ picker, groupTypes, hidden, shown }) => {
+ const testLogic = taxonomicFilterLogic({
+ taxonomicFilterLogicKey: `testSearchOnly-${picker}`,
+ taxonomicGroupTypes: groupTypes,
+ })
+ testLogic.mount()
+
+ for (const groupType of hidden) {
+ expect(testLogic.values.categoryGroupTypes).not.toContain(groupType)
+ expect(testLogic.values.taxonomicGroupTypes).toContain(groupType)
+ }
+ for (const groupType of shown) {
+ expect(testLogic.values.categoryGroupTypes).toContain(groupType)
+ }
+
+ testLogic.unmount()
+ }
+ )
+ })
+
describe('searchPlaceholder', () => {
it.each([
{ groupTypes: [TaxonomicFilterGroupType.Events], expected: 'events' },
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index d867e73fe2b1..456d537a0944 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -40,6 +40,7 @@ import {
ListStorage,
QuickFilterItem,
META_GROUP_TYPES,
+ withoutSearchOnlyGroups,
OPEN_AS_SELF_ON_REOPEN,
SelectedProperties,
SimpleOption,
@@ -780,7 +781,10 @@ export interface taxonomicFilterLogicMeta {
taxonomicGroups: TaxonomicFilterGroup[],
eventNames: any
) => TaxonomicFilterGroupType[]
- categoryGroupTypes: (taxonomicGroupTypes: TaxonomicFilterGroupType[]) => TaxonomicFilterGroupType[]
+ categoryGroupTypes: (
+ taxonomicGroupTypes: TaxonomicFilterGroupType[],
+ metaGroupTypes: Set<string>
+ ) => TaxonomicFilterGroupType[]
groupAnalyticsTaxonomicGroupNames: (
groupTypes: Map<GroupTypeIndex, GroupType>,
currentTeamId: number | null,
@@ -2309,13 +2313,19 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
{ resultEqualityCheck: objectsEqual },
],
categoryGroupTypes: [
- (s) => [s.taxonomicGroupTypes],
- (groupTypes: TaxonomicFilterGroupType[]): TaxonomicFilterGroupType[] =>
- groupTypes.filter(
+ (s) => [s.taxonomicGroupTypes, s.metaGroupTypes],
+ (groupTypes: TaxonomicFilterGroupType[], metaGroupTypes: Set<string>): TaxonomicFilterGroupType[] => {
+ const categories = groupTypes.filter(
(type) =>
type !== TaxonomicFilterGroupType.RecentFilters &&
type !== TaxonomicFilterGroupType.PinnedFilters
- ),
+ )
+ return withoutSearchOnlyGroups(
+ categories,
+ (type) => type,
+ (type) => metaGroupTypes.has(type) || META_GROUP_TYPES.has(type)
+ )
+ },
{ resultEqualityCheck: objectsEqual },
],
groupAnalyticsTaxonomicGroupNames: [
diff --git a/frontend/src/lib/components/TaxonomicFilter/types.ts b/frontend/src/lib/components/TaxonomicFilter/types.ts
index f2e8dc6f1f7d..038b63e2f9fd 100644
--- a/frontend/src/lib/components/TaxonomicFilter/types.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/types.ts
@@ -381,6 +381,27 @@ export enum TaxonomicFilterGroupType {
Empty = 'empty',
}
+/**
+ * Value shortcut groups that stay searched and keep feeding the All list, but are not offered as categories.
+ * Their items are found through All and search, so a separate category only adds a place to come up empty.
+ */
+export const SEARCH_ONLY_GROUP_TYPES: ReadonlySet<TaxonomicFilterGroupType> = new Set([
+ TaxonomicFilterGroupType.EmailAddresses,
+ TaxonomicFilterGroupType.AutocaptureEvents,
+ TaxonomicFilterGroupType.PageviewEvents,
+ TaxonomicFilterGroupType.ScreenEvents,
+])
+
+/** The categories to offer: everything except search-only groups, unless that leaves no real category. */
+export function withoutSearchOnlyGroups<T>(
+ items: T[],
+ groupTypeOf: (item: T) => TaxonomicFilterGroupType,
+ isMetaGroupType: (groupType: TaxonomicFilterGroupType) => boolean
+): T[] {
+ const kept = items.filter((item) => !SEARCH_ONLY_GROUP_TYPES.has(groupTypeOf(item)))
+ return kept.some((item) => !isMetaGroupType(groupTypeOf(item))) ? kept : items
+}
+
export const META_GROUP_TYPES = new Set<TaxonomicFilterGroupType>([
TaxonomicFilterGroupType.HogQLExpression,
TaxonomicFilterGroupType.SuggestedFilters,
diff --git a/frontend/src/lib/components/UniversalFilters/UniversalFilters.component.test.tsx b/frontend/src/lib/components/UniversalFilters/UniversalFilters.component.test.tsx
index 1e0623bcbb64..dd8a04f5d6b4 100644
--- a/frontend/src/lib/components/UniversalFilters/UniversalFilters.component.test.tsx
+++ b/frontend/src/lib/components/UniversalFilters/UniversalFilters.component.test.tsx
@@ -13,7 +13,7 @@ import { mockActionDefinition, mockGetEventDefinitions, mockGetPropertyDefinitio
import { FilterLogicalOperator, UniversalFiltersGroup } from '~/types'
import { recentTaxonomicFiltersLogic } from '../TaxonomicFilter/recentTaxonomicFiltersLogic'
-import { TaxonomicFilterGroupType } from '../TaxonomicFilter/types'
+import { SEARCH_ONLY_GROUP_TYPES, TaxonomicFilterGroupType } from '../TaxonomicFilter/types'
import UniversalFilters from './UniversalFilters'
jest.mock('lib/components/AutoSizer', () => ({
@@ -99,7 +99,10 @@ describe('UniversalFilters recent selections', () => {
itemTestId: string
): Promise<void> {
await openAddFilter()
- await switchToCategory(groupType)
+ // Search-only groups have no category. Their list still renders its rows, which is all the commit path needs.
+ if (!SEARCH_ONLY_GROUP_TYPES.has(groupType)) {
+ await switchToCategory(groupType)
+ }
await searchFor(searchQuery)
await waitFor(() => {
expect(screen.getByTestId(itemTestId)).toBeInTheDocument()