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): simplify categories and value searches (#118563)

Paul D'Ambra26a5eefb9465
diff --git a/docs/internal/taxonomic-filter-search.md b/docs/internal/taxonomic-filter-search.md
index a73b21da7f39..7780335b6693 100644
--- a/docs/internal/taxonomic-filter-search.md
+++ b/docs/internal/taxonomic-filter-search.md
@@ -1,11 +1,13 @@
# Taxonomic filter search loading
-The classic picker and the rebuilt menu hold aggregated search results until the contributing categories settle. This prevents late category results from moving a choice under the pointer. Only categories offered by the picker contribute to that wait; a category-specific list waits for its own results. Recent and Pinned scopes use pre-resolved entries and never enter this search loading barrier.
+The classic picker and the rebuilt menu hold aggregated search results until the contributing categories settle. This prevents late category results from moving a choice under the pointer. Only categories offered by the picker contribute to that wait; a category-specific list waits for its own results. Recent and Pinned lists use pre-resolved entries and never enter this search loading barrier. Their separate category controls are hidden in both pickers. Recent and pinned items remain in Suggested, and the pin control remains available.
The classic picker shows its active category in the search input. A person can dock the category rail from that menu. This preference persists for that person and project. A narrow picker hides the rail and shows the category control in the search input.
The rail starts undocked. `taxonomic filter category rail toggled` records whether it is docked. `taxonomic filter closed` records the final `categoryRailDocked` state so reports can show which people keep the rail docked.
+With `taxonomic-filter-value-search-gating` enabled, email value searches require `@` or domain-like text, such as `example.com`. Pageview URL and pageview event value searches require URL-like text: a path, an HTTP prefix, a `www.` prefix, or a domain. Existing minimum query lengths still apply. These rules affect remote value searches; property-name searches, cached recents, and pins remain available. A rejected query sends no request and clears earlier remote results.
+
A category shows results for the current query only. It clears its earlier rows when the current query cannot fetch, such as a query below the category minimum length or a request that failed.
A failed search with no usable matches shows an error in the classic picker and the rebuilt menu.
The rebuilt menu offers "Try again" to retry the failed result source.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f1d802429425..7534e68a3f96 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3593,9 +3593,9 @@ snapshots:
filters-taxonomic-filter--category-dropdown--light:
hash: v1.k794b7964.1bea71d84b0eb24126b991c7a545639f658d9ebd1194b9dc9bcb901e4543c143.2svfFUCdtdOtLNQW1pwyu6yzSUMjsLSSoYClBjQf-60
filters-taxonomic-filter--category-rail-pinned--dark:
- hash: v1.k794b7964.ec7737061d2ba8ef3a6ba408078ea5bf6114d18504091be17497634712ba8292.bhZAfMWI7xXawk6Xk8zcVxN_hPJUGQN3mtCpzteLOHY
+ hash: v1.k794b7964.53db2a3f4dd104a0eb93afd345f168169450902abedba41a488762110cde163a.fBdkgYF5DlUxBPtZhSO3h0XSl3HroW5HH464ofN_bUs
filters-taxonomic-filter--category-rail-pinned--light:
- hash: v1.k794b7964.216bb7b64a4d8292956a5399af50a729fc333a052f917b2a28725d8660d0bd19.17vZPcHxLysEZwE0vLdJr9jEGtxmr9ryku_mpPIjzoY
+ hash: v1.k794b7964.1d4ac211b2d75b8766bc9650443e119352eb0e3d9dfe66fb3fcf8c996a8fbfbf.F-WLCQPbI8Ex4hyKv6LgoSW5o72T77oXXDe8pcXscSk
filters-taxonomic-filter--cohorts-with-realtime-states--dark:
hash: v1.k794b7964.4ecf5ef9bc95151a6444f1b7247ced4f43ad62f12399783f180c8d82f2b05021.12FrJN6IzU1RbrsFSt_QSvWv4xtr7haSiCTFtyE4ks4
filters-taxonomic-filter--cohorts-with-realtime-states--light:
@@ -3608,6 +3608,10 @@ snapshots:
hash: v1.k794b7964.08dd6b6ff90babc94016f15cece4f87ac9c733101503ab4d206bef311938de6b.11OskmuMksbFPIaDtmt8ptXswFKCZQsgje5sHpyWAXw
filters-taxonomic-filter--dashboard-property-search--light:
hash: v1.k794b7964.a31bf51a80fdca614f2f36470aa051fd7faaf638ab84f332e7de43c944763c27.CznVxf4UBAP6trCkcSE7LgkjTJ3IazUfzMIhS8XBUMM
+ filters-taxonomic-filter--email-search-query-hint--dark:
+ hash: v1.k794b7964.75780bca10fdc8c61cb0d0383ac6495ddaafdd30baf6f566cf6b38e8fa0f2d90.A257X7pt9K40kv8qTFkP0u04LCWEnzEh2Sy7qv11t2w
+ filters-taxonomic-filter--email-search-query-hint--light:
+ hash: v1.k794b7964.26263d464e79d354fa4a88430db602672c6ec400d23b25e635f39c78f8021c50.oKLH9VgDruDZli-BetTKm3qWMDc2f96jp30LFwHEG9Y
filters-taxonomic-filter--empty-all-tab-with-event-match--dark:
hash: v1.k794b7964.58e7c99b2c92f0300216c4047c2d5ea1745dfa1a606a00270b0ebc779bed3cd5.1h_7F-InpV4zcCU2i8sGo8D9GpR-M9SK0ykFwUh1DDc
filters-taxonomic-filter--empty-all-tab-with-event-match--light:
@@ -8355,9 +8359,9 @@ snapshots:
replay-filters-add-filter-popover--closed--light:
hash: v1.k794b7964.96b26f69ea30de65c06c9a5c6560212a282457b1a4c2d8c93d69cb09e16f73c7.eLGELx_AKoftmQ0cl8oYNeb0tBvCqjnxn4DZww-Hdas
replay-filters-add-filter-popover--open--dark:
- hash: v1.k794b7964.bc245e0bd57be6f5132f5eb4c26a6bbc77a4f0f7b7452bfb1a3ecc1b46709c42.yuMl99pO0kzzNY0Qhl5nI7SJObDlJp9z8N2MCtyHpFg
+ hash: v1.k794b7964.f55c5c353feeac86e59cf7d0ea225940ce8ed62823ff824edd3a0550957df24b.X60_WAaWal9T6e2V3HzzneZ5ERlBm4buTDN1RO98utE
replay-filters-add-filter-popover--open--light:
- hash: v1.k794b7964.4080f7334f9e193fb05511cd995cd581d908f70899ce75791c8a8d63c60c3823.qe1zQijlfLKKWnBKDHrinXnwLaDrf3B_Qd_q_PnRIyw
+ hash: v1.k794b7964.535f94257a9a8a59e9680bd67595ee0d77cde2e0931254c09b981fe4e4eba6a6.zadFN5EUsZMWm7gtpaLpJrUgfsbEQIrFa41s3jdvJuM
replay-overview-tab--many-other-watchers-overview-tab--dark:
hash: v1.k794b7964.131b998b5753ee04c70fcbec9e7208caaedfbbf1f2a49fb33b9cc29a35c182b7.vQJgCoQV7fE9whrQ3bq6m3oEfHLUxAma9aKkDgytWqM
replay-overview-tab--many-other-watchers-overview-tab--light:
diff --git a/frontend/src/lib/components/PropertyFilters/PropertyFilters.component.test.tsx b/frontend/src/lib/components/PropertyFilters/PropertyFilters.component.test.tsx
index 69c2e63bdc68..aaeb0d139bb0 100644
--- a/frontend/src/lib/components/PropertyFilters/PropertyFilters.component.test.tsx
+++ b/frontend/src/lib/components/PropertyFilters/PropertyFilters.component.test.tsx
@@ -462,13 +462,13 @@ describe('PropertyFilters recent selections', () => {
await openNewFilter()
- await switchToTab('taxonomic-tab-recent_filters')
+ await switchToTab('taxonomic-tab-suggested_filters')
await searchFor('pricing')
await waitFor(() => {
- expect(screen.getByTestId('prop-filter-recent_filters-0')).toBeInTheDocument()
- expect(screen.getByTestId('prop-filter-recent_filters-0')).toHaveTextContent(/pricing/i)
+ expect(screen.getByTestId('prop-filter-suggested_filters-0')).toBeInTheDocument()
+ expect(screen.getByTestId('prop-filter-suggested_filters-0')).toHaveTextContent(/pricing/i)
})
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/CategoryDropdown.tsx b/frontend/src/lib/components/TaxonomicFilter/CategoryDropdown.tsx
index 42eab02086c8..fa6bab79dffa 100644
--- a/frontend/src/lib/components/TaxonomicFilter/CategoryDropdown.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/CategoryDropdown.tsx
@@ -25,7 +25,7 @@ export function CategoryDropdown({
joinedToInput?: boolean
}): JSX.Element | null {
const [menuVisible, setMenuVisible] = useState(false)
- const { activeTab, taxonomicGroups, taxonomicGroupTypes } = useValues(taxonomicFilterLogic)
+ const { activeTab, taxonomicGroups, taxonomicGroupTypes, categoryGroupTypes } = useValues(taxonomicFilterLogic)
const { markUserInteraction, setActiveTab } = useActions(taxonomicFilterLogic)
const { categoryRailPinned } = useValues(taxonomicFilterCategoryLayoutLogic)
const { setCategoryRailPinned } = useActions(taxonomicFilterCategoryLayoutLogic)
@@ -49,7 +49,7 @@ export function CategoryDropdown({
const activeGroup = taxonomicGroups.find((g) => g.type === openTab)
const activeLabel = activeGroup?.name ?? openTab
- const categoryItems: LemonMenuItem[] = taxonomicGroupTypes.map((groupType) => {
+ const categoryItems: LemonMenuItem[] = categoryGroupTypes.map((groupType) => {
const group = taxonomicGroups.find((g) => g.type === groupType)
return {
key: groupType,
@@ -84,7 +84,7 @@ export function CategoryDropdown({
},
]
- const activeItemIndex = taxonomicGroupTypes.findIndex((g) => g === openTab)
+ const activeItemIndex = categoryGroupTypes.findIndex((g) => g === openTab)
return (
<LemonMenu
diff --git a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
index d3a138348e5b..a66a785b2775 100644
--- a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
@@ -796,6 +796,8 @@ function InfiniteListEmptyState(): JSX.Element {
Type at least {minSearchQueryLength} characters to search
</span>
</>
+ ) : group?.shouldSearch?.(searchQuery) === false && group.searchQueryHint ? (
+ <span className="text-secondary text-center">{group.searchQueryHint}</span>
) : hiddenEventSearched ? (
// Replaces the generic "no results" line and its recovery buttons: including stale
// events cannot bring back an excluded name, and the category jumps lead away from
diff --git a/frontend/src/lib/components/TaxonomicFilter/InfiniteSelectResults.tsx b/frontend/src/lib/components/TaxonomicFilter/InfiniteSelectResults.tsx
index 0d0ad33613bc..0e295c155dd7 100644
--- a/frontend/src/lib/components/TaxonomicFilter/InfiniteSelectResults.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/InfiniteSelectResults.tsx
@@ -158,8 +158,15 @@ export function InfiniteSelectResults({
popupAnchorElement,
definitionPopoverRenderer,
}: InfiniteSelectResultsProps): JSX.Element {
- const { activeTab, taxonomicGroups, taxonomicGroupTypes, activeTaxonomicGroup, value } =
- useValues(taxonomicFilterLogic)
+ const {
+ activeTab,
+ taxonomicGroups,
+ taxonomicGroupTypes,
+ categoryGroupTypes,
+ activeTaxonomicGroup,
+ value,
+ searchQuery,
+ } = useValues(taxonomicFilterLogic)
const wrapperRef = useRef<HTMLDivElement | null>(null)
const openTab = activeTab || taxonomicGroups[0].type
@@ -209,7 +216,8 @@ export function InfiniteSelectResults({
const showEmptyState =
!showDataWarehouseLoadingState &&
totalListCount === 0 &&
- taxonomicFilterGroupTypesWithEmptyStates.includes(openTab)
+ taxonomicFilterGroupTypesWithEmptyStates.includes(openTab) &&
+ (!searchQuery.trim() || activeTaxonomicGroup?.shouldSearch?.(searchQuery) !== false)
return (
<div ref={wrapperRef} className="@container flex flex-row h-full">
@@ -230,7 +238,7 @@ export function InfiniteSelectResults({
/>
</div>
<div className="taxonomic-pills flex flex-col gap-1">
- {taxonomicGroupTypes.map((groupType) => {
+ {categoryGroupTypes.map((groupType) => {
return (
<CategoryPill
key={groupType}
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
index aa0ca7440037..d57b72638490 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
@@ -578,6 +578,19 @@ export const CategoryDropdown: Story = {
},
}
+export const EmailSearchQueryHint: Story = {
+ render: CategoryDropdownStoryRender,
+ args: {
+ taxonomicFilterLogicKey: 'email-search-query-hint',
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.EmailAddresses],
+ searchQuery: 'sample',
+ },
+ parameters: {
+ featureFlags: [FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING],
+ testOptions: { waitForSelector: '.no-infinite-results' },
+ },
+}
+
export const CategoryRailPinned: Story = {
render: CategoryRailStoryRender,
args: CATEGORY_DROPDOWN_ARGS,
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
index 7d3cc05e1b9a..42b059c663c7 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
@@ -1589,9 +1589,15 @@ describe('TaxonomicFilter', () => {
})
await userEvent.click(await screen.findByTestId('taxonomic-category-dropdown-trigger-pill'))
+ for (const group of ['recent_filters', 'pinned_filters']) {
+ expect(screen.queryByTestId(`taxonomic-category-dropdown-item-${group}`)).not.toBeInTheDocument()
+ }
await userEvent.click(await screen.findByTestId('taxonomic-category-rail-toggle'))
expect(await screen.findByText('Categories')).toBeInTheDocument()
+ for (const group of ['recent_filters', 'pinned_filters']) {
+ expect(screen.queryByTestId(`taxonomic-tab-${group}`)).not.toBeInTheDocument()
+ }
await waitFor(() => {
expect(screen.queryByTestId('taxonomic-category-rail-toggle')).not.toBeInTheDocument()
})
@@ -1811,6 +1817,19 @@ describe('TaxonomicFilter', () => {
expect(requests[0].get('dateFrom')).toBe('2026-01-01T00:00:00Z')
})
+ it.each([
+ [TaxonomicFilterGroupType.EmailAddresses, 'Search for an email address or domain.'],
+ [TaxonomicFilterGroupType.PageviewUrls, 'Search for a URL, domain, or path.'],
+ [TaxonomicFilterGroupType.PageviewEvents, 'Search for a URL, domain, or path.'],
+ ])('explains a skipped value search in %s', async (groupType, hint) => {
+ featureFlagLogicModule.featureFlagLogic.mount()
+ featureFlagLogicModule.featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]: true,
+ })
+ renderFilter({ taxonomicGroupTypes: [groupType], searchQuery: 'sample' })
+ expect(await screen.findByText(hint)).toBeInTheDocument()
+ })
+
describe('excludedOperators', () => {
const seedRecents = (): void => {
const recentLogic = recentTaxonomicFiltersLogic.build()
@@ -1878,13 +1897,13 @@ describe('TaxonomicFilter', () => {
{
name: 'hides cohort recents whose operator is denylisted but keeps other recents',
excludedOperators: { [TaxonomicFilterGroupType.Cohorts]: [PropertyOperator.NotIn] },
- expectInRecent: ['User in Power Users', 'Browser = Chrome'],
+ expectInRecent: ['User in Power Users'],
expectNotInRecent: ['User not in Trial Users'],
},
{
name: 'keeps every recent when no operators are denylisted',
excludedOperators: undefined,
- expectInRecent: ['User in Power Users', 'User not in Trial Users', 'Browser = Chrome'],
+ expectInRecent: ['User in Power Users', 'User not in Trial Users'],
expectNotInRecent: [],
},
])('$name', async ({ excludedOperators, expectInRecent, expectNotInRecent }) => {
@@ -1903,12 +1922,14 @@ describe('TaxonomicFilter', () => {
)
await waitFor(() => {
- expect(screen.getByTestId('taxonomic-tab-recent_filters')).toBeInTheDocument()
+ expect(screen.getByTestId('taxonomic-tab-suggested_filters')).toBeInTheDocument()
})
- await userEvent.click(screen.getByTestId('taxonomic-tab-recent_filters'))
+ await userEvent.click(screen.getByTestId('taxonomic-tab-suggested_filters'))
+
+ await userEvent.type(screen.getByTestId('taxonomic-filter-searchfield'), 'Users')
const recentRowText = (): string =>
- Array.from(document.querySelectorAll('[data-attr^="prop-filter-recent_filters-"]'))
+ Array.from(document.querySelectorAll('[data-attr^="prop-filter-suggested_filters-"]'))
.map((el) => el.textContent ?? '')
.join('||')
@@ -1922,6 +1943,9 @@ describe('TaxonomicFilter', () => {
for (const forbidden of expectNotInRecent) {
expect(allText).not.toContain(forbidden)
}
+ await userEvent.clear(screen.getByTestId('taxonomic-filter-searchfield'))
+ await userEvent.type(screen.getByTestId('taxonomic-filter-searchfield'), 'Chrome')
+ await waitFor(() => expect(recentRowText()).toContain('Browser = Chrome'))
})
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilterKeyOnly.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilterKeyOnly.test.tsx
index 6ee5dba9e5fc..e92928dde330 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilterKeyOnly.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilterKeyOnly.test.tsx
@@ -61,7 +61,10 @@ describe('TaxonomicFilter selectingKeyOnly mode', () => {
return render(
<Provider>
<TaxonomicFilter
- taxonomicGroupTypes={[TaxonomicFilterGroupType.EventProperties]}
+ taxonomicGroupTypes={[
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.PersonProperties,
+ ]}
onChange={jest.fn()}
{...props}
/>
@@ -79,9 +82,9 @@ describe('TaxonomicFilter selectingKeyOnly mode', () => {
})
}
- async function selectRecentCategory(): Promise<void> {
+ async function selectSuggestedCategory(): Promise<void> {
await userEvent.click(await screen.findByTestId('taxonomic-category-dropdown-trigger-pill'))
- await userEvent.click(await screen.findByTestId('taxonomic-category-dropdown-item-recent_filters'))
+ await userEvent.click(await screen.findByTestId('taxonomic-category-dropdown-item-suggested_filters'))
}
describe('recording on selection', () => {
@@ -122,12 +125,12 @@ describe('TaxonomicFilter selectingKeyOnly mode', () => {
renderFilter({ selectingKeyOnly: true, onChange })
- await selectRecentCategory()
+ await selectSuggestedCategory()
await waitFor(() => {
- expect(screen.getByTestId('prop-filter-recent_filters-0')).toBeInTheDocument()
+ expect(screen.getByTestId('prop-filter-suggested_filters-0')).toBeInTheDocument()
})
- await userEvent.click(screen.getByTestId('prop-filter-recent_filters-0'))
+ await userEvent.click(screen.getByTestId('prop-filter-suggested_filters-0'))
// Consumer-facing onChange must hand back an item whose recent context has no
// propertyFilter, so it can't accidentally re-apply "= Chrome" downstream.
@@ -151,7 +154,20 @@ describe('TaxonomicFilter selectingKeyOnly mode', () => {
})
describe('display of recents', () => {
- it('shows the Recent tab in selectingKeyOnly mode when key-only recents exist for the picked group', async () => {
+ it('keeps a complete saved filter available when only one property category is offered', async () => {
+ preloadCompleteRecent('$browser', 'Chrome')
+ renderFilter({ taxonomicGroupTypes: [TaxonomicFilterGroupType.EventProperties] })
+
+ expect(await screen.findByTestId('taxonomic-category-dropdown-trigger-pill')).toHaveTextContent(
+ 'Event properties'
+ )
+ await selectSuggestedCategory()
+ await waitFor(() => {
+ expect(screen.getByTestId('prop-filter-suggested_filters-1')).toHaveTextContent('Chrome')
+ })
+ })
+
+ it('shows recent items in Suggested in selectingKeyOnly mode when key-only recents exist for the picked group', async () => {
recents.actions.recordRecentFilter({
groupType: TaxonomicFilterGroupType.EventProperties,
groupName: 'Event properties',
@@ -162,12 +178,12 @@ describe('TaxonomicFilter selectingKeyOnly mode', () => {
renderFilter({ selectingKeyOnly: true })
- await selectRecentCategory()
+ await selectSuggestedCategory()
await waitFor(() => {
- expect(screen.getByTestId('prop-filter-recent_filters-0')).toBeInTheDocument()
+ expect(screen.getByTestId('prop-filter-suggested_filters-0')).toBeInTheDocument()
})
- const row = screen.getByTestId('prop-filter-recent_filters-0')
+ const row = screen.getByTestId('prop-filter-suggested_filters-0')
expect(row.textContent).toMatch(/OS/)
expect(row.textContent).not.toMatch(/=|equals/i)
})
@@ -177,12 +193,12 @@ describe('TaxonomicFilter selectingKeyOnly mode', () => {
renderFilter({ selectingKeyOnly: true })
- await selectRecentCategory()
+ await selectSuggestedCategory()
await waitFor(() => {
- expect(screen.getByTestId('prop-filter-recent_filters-0')).toBeInTheDocument()
+ expect(screen.getByTestId('prop-filter-suggested_filters-0')).toBeInTheDocument()
})
- const row = screen.getByTestId('prop-filter-recent_filters-0')
+ const row = screen.getByTestId('prop-filter-suggested_filters-0')
expect(row.textContent).toMatch(/Browser/)
// The complete-filter label ("Browser equals Chrome") must NOT be rendered.
expect(row.textContent).not.toMatch(/Chrome/)
@@ -193,15 +209,15 @@ describe('TaxonomicFilter selectingKeyOnly mode', () => {
renderFilter()
- await selectRecentCategory()
+ await selectSuggestedCategory()
await waitFor(() => {
- expect(screen.getByTestId('prop-filter-recent_filters-0')).toBeInTheDocument()
+ expect(screen.getByTestId('prop-filter-suggested_filters-0')).toBeInTheDocument()
})
- const bareKeyRow = screen.getByTestId('prop-filter-recent_filters-0')
+ const bareKeyRow = screen.getByTestId('prop-filter-suggested_filters-0')
expect(bareKeyRow.textContent).toMatch(/Browser/)
expect(bareKeyRow.textContent).not.toMatch(/Chrome/)
- expect(screen.getByTestId('prop-filter-recent_filters-1').textContent).toMatch(/Chrome/)
+ expect(screen.getByTestId('prop-filter-suggested_filters-1').textContent).toMatch(/Chrome/)
})
it('selecting the bare key row hands back an item with no propertyFilter so the user picks a fresh value', async () => {
@@ -210,12 +226,12 @@ describe('TaxonomicFilter selectingKeyOnly mode', () => {
renderFilter({ onChange })
- await selectRecentCategory()
+ await selectSuggestedCategory()
await waitFor(() => {
- expect(screen.getByTestId('prop-filter-recent_filters-1')).toBeInTheDocument()
+ expect(screen.getByTestId('prop-filter-suggested_filters-1')).toBeInTheDocument()
})
- await userEvent.click(screen.getByTestId('prop-filter-recent_filters-0'))
+ await userEvent.click(screen.getByTestId('prop-filter-suggested_filters-0'))
await waitFor(() => {
expect(onChange).toHaveBeenCalled()
@@ -231,12 +247,16 @@ describe('TaxonomicFilter selectingKeyOnly mode', () => {
renderFilter({ selectingKeyOnly: true })
- await selectRecentCategory()
+ await selectSuggestedCategory()
await waitFor(() => {
- expect(screen.getByTestId('prop-filter-recent_filters-0')).toBeInTheDocument()
+ expect(screen.getByTestId('prop-filter-suggested_filters-0')).toBeInTheDocument()
})
- expect(screen.queryByTestId('prop-filter-recent_filters-1')).not.toBeInTheDocument()
+ expect(
+ screen
+ .getAllByTestId(/^prop-filter-suggested_filters-/)
+ .filter((row) => row.textContent?.includes('Browser'))
+ ).toHaveLength(1)
})
})
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilterPinning.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilterPinning.test.tsx
index 42671550dbfc..ed073461c75f 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilterPinning.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilterPinning.test.tsx
@@ -67,7 +67,7 @@ describe('TaxonomicFilter pinning', () => {
await userEvent.click(await screen.findByTestId(`taxonomic-category-dropdown-item-${groupType}`))
}
- it('shows a Pinned tab when there are pinned items', async () => {
+ it('keeps pins in Suggested without a Pinned category', async () => {
const logic = taxonomicFilterPinnedPropertiesLogic.build()
logic.mount()
logic.actions.togglePin(TaxonomicFilterGroupType.PersonProperties, 'Person properties', 'location', {
@@ -76,12 +76,12 @@ describe('TaxonomicFilter pinning', () => {
renderFilter()
- await selectCategory(TaxonomicFilterGroupType.PinnedFilters)
+ await selectCategory(TaxonomicFilterGroupType.SuggestedFilters)
logic.unmount()
})
- it('renders pinned items in the Pinned tab', async () => {
+ it('renders pinned items in Suggested', async () => {
const logic = taxonomicFilterPinnedPropertiesLogic.build()
logic.mount()
logic.actions.togglePin(TaxonomicFilterGroupType.PersonProperties, 'Person properties', 'location', {
@@ -90,21 +90,22 @@ describe('TaxonomicFilter pinning', () => {
renderFilter()
- await selectCategory(TaxonomicFilterGroupType.PinnedFilters)
+ await selectCategory(TaxonomicFilterGroupType.SuggestedFilters)
await waitFor(() => {
- expect(screen.getByTestId('prop-filter-pinned_filters-0')).toBeInTheDocument()
+ expect(screen.getByTestId('prop-filter-suggested_filters-0')).toBeInTheDocument()
})
logic.unmount()
})
- it('shows the Pinned category when no items are pinned', async () => {
+ it('does not show a Pinned category when no items are pinned', async () => {
renderFilter()
- await selectCategory(TaxonomicFilterGroupType.PinnedFilters)
+ await selectCategory(TaxonomicFilterGroupType.SuggestedFilters)
- expect(screen.getByTestId('taxonomic-category-dropdown-trigger-pill')).toHaveTextContent('Pinned')
+ expect(screen.getByTestId('taxonomic-category-dropdown-trigger-pill')).toHaveTextContent('All')
+ expect(screen.queryByTestId('taxonomic-category-dropdown-item-pinned_filters')).not.toBeInTheDocument()
})
it('shows pin button in definition popover on hover', async () => {
@@ -152,13 +153,13 @@ describe('TaxonomicFilter pinning', () => {
])
renderFilter({
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Persons],
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Persons, TaxonomicFilterGroupType.EventProperties],
popoverEnabled: true,
})
- await selectCategory(TaxonomicFilterGroupType.PinnedFilters)
+ await selectCategory(TaxonomicFilterGroupType.SuggestedFilters)
- const pinnedRow = await screen.findByTestId('prop-filter-pinned_filters-0')
+ const pinnedRow = await screen.findByTestId('prop-filter-suggested_filters-0')
// Hovering the row triggers ControlledDefinitionPopover, which calls the
// source group's getValue on the stored item. Before the fix, the old
diff --git a/frontend/src/lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator.ts b/frontend/src/lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator.ts
index 4f208ba34643..221573cd7ebb 100644
--- a/frontend/src/lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator.ts
@@ -3,6 +3,7 @@ import { mockActionDefinition } from '~/test/mocks'
export const taxonomicFilterMocksDecorator = mswDecorator({
get: {
+ '/api/projects/:team_id/surveys/question_labels/': { labels: [] },
'/api/projects/:team_id/actions': { results: [mockActionDefinition] },
'/api/environments/:team_id/persons/properties': [
{ id: 1, name: 'location', count: 1 },
diff --git a/frontend/src/lib/components/TaxonomicFilter/headless/Panel.tsx b/frontend/src/lib/components/TaxonomicFilter/headless/Panel.tsx
index fa418d94bb75..fd923b4742a0 100644
--- a/frontend/src/lib/components/TaxonomicFilter/headless/Panel.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/headless/Panel.tsx
@@ -69,7 +69,7 @@ function TaxonomicFilterActivePanel({
loadingState,
className,
}: ActivePanelProps): JSX.Element {
- const { getGroupListInput, registerActiveList, selectItem } = useTaxonomicFilterContext()
+ const { getGroupListInput, registerActiveList, selectItem, searchQuery } = useTaxonomicFilterContext()
const list: UseGroupListResult = useGroupList(getGroupListInput(group))
// `useTaxonomicResource`'s cache only notifies subscribers once a fetch settles, not when
// it starts, so `list.isFetching` doesn't flip to true for the duration of an imperative
@@ -148,7 +148,11 @@ function TaxonomicFilterActivePanel({
<Empty>
<EmptyHeader>
<EmptyTitle>
- {list.needsMoreSearchCharacters ? 'Type more to search' : 'No results'}
+ {list.needsMoreSearchCharacters
+ ? 'Type more to search'
+ : group.shouldSearch?.(searchQuery) === false
+ ? (group.searchQueryHint ?? 'No results')
+ : 'No results'}
</EmptyTitle>
</EmptyHeader>
</Empty>
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/fetchTaxonomicListPage.test.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/fetchTaxonomicListPage.test.ts
index 5bcf9c039f45..a7bac98eb522 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/fetchTaxonomicListPage.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/fetchTaxonomicListPage.test.ts
@@ -35,4 +35,22 @@ describe('fetchTaxonomicListPage exclude_stale', () => {
const url = apiGet.mock.calls[0][0] as string
expect(url.includes('exclude_stale=true')).toBe(present)
})
+ it.each([
+ ['sample', false],
+ ['sample@', true],
+ ])('fetches %s only when the group accepts the query', async (searchQuery, shouldFetch) => {
+ const searchGroup = {
+ ...group(TaxonomicFilterGroupType.EmailAddresses),
+ shouldSearch: (query: string): boolean => query.includes('@'),
+ }
+ const page = await fetchTaxonomicListPage({
+ group: searchGroup,
+ searchQuery,
+ offset: 0,
+ limit: 100,
+ isExpanded: false,
+ })
+ expect(apiGet).toHaveBeenCalledTimes(shouldFetch ? 1 : 0)
+ expect(page).toMatchObject({ searchQuery, results: [], count: 0 })
+ })
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/fetchTaxonomicListPage.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/fetchTaxonomicListPage.ts
index f7f63e8e87f3..941bfd575cd5 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/fetchTaxonomicListPage.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/fetchTaxonomicListPage.ts
@@ -43,7 +43,10 @@ export async function fetchTaxonomicListPage({
}
const minSearchQueryLength = group.minSearchQueryLength ?? 0
- if (minSearchQueryLength > 0 && searchQuery.length < minSearchQueryLength) {
+ if (
+ (minSearchQueryLength > 0 && searchQuery.length < minSearchQueryLength) ||
+ group.shouldSearch?.(searchQuery) === false
+ ) {
return { ...EMPTY_LIST, searchQuery }
}
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx
index f30520a53722..2e4a81e460d7 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.test.tsx
@@ -153,6 +153,23 @@ describe('useGroupList', () => {
expect(apiGet).not.toHaveBeenCalled()
})
+ it('clears remote rows without fetching when the query no longer passes the group predicate', async () => {
+ apiGet.mockResolvedValue({ results: [{ name: '[email protected]' }], count: 1 })
+ const group = makeGroup({
+ type: TaxonomicFilterGroupType.EmailAddresses,
+ endpoint: 'api/projects/1/persons/values',
+ shouldSearch: (query: string): boolean => query.includes('@'),
+ })
+ const { result, rerender } = renderHook(({ q }: { q: string }) => useGroupList({ group, searchQuery: q }), {
+ initialProps: { q: 'sample@' },
+ })
+ await waitFor(() => expect(result.current.items).toEqual([{ name: '[email protected]' }]))
+ rerender({ q: 'sample' })
+ expect(result.current.items).toEqual([])
+ expect(result.current.isLoading).toBe(false)
+ expect(apiGet).toHaveBeenCalledTimes(1)
+ })
+
it('drops the previous page when the query falls below the minimum length', async () => {
apiGet.mockResolvedValue({ results: [{ name: 'checkout' }], count: 1 })
const group = makeGroup({ endpoint: 'api/projects/1/whatever', minSearchQueryLength: 3 })
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts
index 2a518d99a401..8e3f92b26f63 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useGroupList.ts
@@ -212,7 +212,8 @@ export function useGroupList(input: UseGroupListInput): UseGroupListResult {
const trimmedSearch = searchQuery.trim()
const needsMoreSearchCharacters = minSearchQueryLength > 0 && trimmedSearch.length < minSearchQueryLength
- const remoteEnabled = hasRemoteDataSource && !needsMoreSearchCharacters
+ const remoteEnabled =
+ hasRemoteDataSource && !needsMoreSearchCharacters && group.shouldSearch?.(searchQuery) !== false
// `clientFilterFirstPage` groups (e.g. Cohorts) pin the remote query to
// the empty-search first page and let local Fuse handle keystroke
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
index 7dc0637ab1c8..44af9aa98400 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
@@ -324,6 +324,7 @@ export function useTaxonomicFilter(opts: UseTaxonomicFilterOptions): TaxonomicFi
excludedProperties,
includeHiddenEvents,
propertyAllowList,
+ showNumericalPropsOnly,
selectedProperties,
maxContextOptions,
hideBehavioralCohorts,
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.test.tsx b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.test.tsx
index 26b22a7a6cd4..63672826e0d6 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.test.tsx
@@ -120,6 +120,39 @@ describe('useTaxonomicGroupsContext', () => {
)
})
+ it.each([
+ { restriction: 'none', input: {}, expected: true },
+ {
+ restriction: 'exclusion',
+ input: { excludedProperties: { [TaxonomicFilterGroupType.EventProperties]: ['$pathname'] } },
+ expected: false,
+ },
+ {
+ restriction: 'allowlist mismatch',
+ input: { propertyAllowList: { [TaxonomicFilterGroupType.EventProperties]: ['$host'] } },
+ expected: false,
+ },
+ {
+ restriction: 'empty allowlist',
+ input: { propertyAllowList: { [TaxonomicFilterGroupType.EventProperties]: [] } },
+ expected: false,
+ },
+ {
+ restriction: 'allowlist match',
+ input: { propertyAllowList: { [TaxonomicFilterGroupType.EventProperties]: ['$pathname'] } },
+ expected: true,
+ },
+ { restriction: 'numeric properties only', input: { showNumericalPropsOnly: true }, expected: false },
+ ])('offers a primary property in Suggested with $restriction', ({ input, expected }) => {
+ const { result } = renderHook(() => useTaxonomicGroupsContext({ eventNames: ['$pageview'], ...input }), {
+ wrapper,
+ })
+ const suggested = buildTaxonomicGroups(result.current).find(
+ (group) => group.type === TaxonomicFilterGroupType.SuggestedFilters
+ )
+ expect(suggested?.options?.some((option) => option.name === '$pathname')).toBe(expected)
+ })
+
it('feeds buildTaxonomicGroups end-to-end and produces a non-empty groups array', () => {
const { result } = renderHook(() => useTaxonomicGroupsContext({ eventNames: ['$pageview'] }), {
wrapper,
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts
index f856e31adb39..3ddf29643396 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts
@@ -52,6 +52,7 @@ export interface UseTaxonomicGroupsContextInput {
/** Keep offering events whose data is moving out of the `events` table. See `TaxonomicFilterProps`. */
includeHiddenEvents?: boolean
propertyAllowList?: AllowedProperties
+ showNumericalPropsOnly?: boolean
selectedProperties?: SelectedProperties
maxContextOptions?: MaxContextTaxonomicFilterOption[]
hideBehavioralCohorts?: boolean
@@ -116,6 +117,7 @@ export function useTaxonomicGroupsContext(input: UseTaxonomicGroupsContextInput)
propertyAllowList: input.propertyAllowList as
| Record<TaxonomicFilterGroupType, (string | number | null)[]>
| undefined,
+ showNumericalPropsOnly: input.showNumericalPropsOnly,
}
const hogQLExpressionComponentProps = {
globals: input.hogQLGlobals,
@@ -183,6 +185,7 @@ export function useTaxonomicGroupsContext(input: UseTaxonomicGroupsContextInput)
input.excludedProperties,
input.includeHiddenEvents,
input.propertyAllowList,
+ input.showNumericalPropsOnly,
input.maxContextOptions,
input.hideBehavioralCohorts,
input.showCohortFlagTargeting,
diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts
index 8ee8f4b9015d..3f076ceda79c 100644
--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts
@@ -9,6 +9,8 @@ import {
recentTaxonomicFiltersLogic,
} from 'lib/components/TaxonomicFilter/recentTaxonomicFiltersLogic'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
import { dataWarehouseSettingsSceneLogic } from 'scenes/data-warehouse/settings/dataWarehouseSettingsSceneLogic'
import { teamLogic } from 'scenes/teamLogic'
@@ -106,6 +108,87 @@ describe('infiniteListLogic', () => {
return logicWithProps
}
+ it.each([
+ [TaxonomicFilterGroupType.EmailAddresses, 'sample', true, false],
+ [TaxonomicFilterGroupType.EmailAddresses, 'sample@', true, true],
+ [TaxonomicFilterGroupType.EmailAddresses, 'example.com', true, true],
+ [TaxonomicFilterGroupType.EmailAddresses, 'a@', true, false],
+ [TaxonomicFilterGroupType.PageviewUrls, 'overview', true, false],
+ [TaxonomicFilterGroupType.PageviewUrls, '/overview', true, true],
+ [TaxonomicFilterGroupType.PageviewUrls, 'example.com', true, true],
+ [TaxonomicFilterGroupType.PageviewEvents, 'overview', true, false],
+ [TaxonomicFilterGroupType.PageviewEvents, 'https://example.com', true, true],
+ [TaxonomicFilterGroupType.EmailAddresses, 'sample', false, true],
+ [TaxonomicFilterGroupType.PageviewUrls, 'overview', false, true],
+ [TaxonomicFilterGroupType.PageviewEvents, 'overview', false, true],
+ ])('gates %s search %s with flag=%s and fetch=%s', async (groupType, query, enabled, shouldFetch) => {
+ const searches: string[] = []
+ const valuesResponse = ({
+ request,
+ }: {
+ request: Request
+ }): [number, { results: { name: string }[]; count: number }] => {
+ const value = new URL(request.url).searchParams.get('value') ?? ''
+ searches.push(value)
+ return [200, { results: [{ name: value }], count: 1 }]
+ }
+ useMocks({
+ get: {
+ '/api/projects/:team/persons/values/': valuesResponse,
+ '/api/projects/:team/events/values/': valuesResponse,
+ },
+ })
+ featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]: enabled })
+ const list = logicWith({ listGroupType: groupType, taxonomicGroupTypes: [groupType] })
+ await expectLogic(list, () => list.actions.setSearchQuery(query)).toDispatchActions(['loadRemoteItemsSuccess'])
+ expect(searches).toEqual(shouldFetch ? [query] : [])
+ expect(list.values.remoteItems.results).toEqual(shouldFetch ? [{ name: query }] : [])
+ if (!shouldFetch) {
+ expect(posthog.capture).not.toHaveBeenCalledWith('taxonomic filter empty result', expect.anything())
+ }
+ })
+
+ it('cancels a pending value search when the next query is gated', async () => {
+ useMocks({
+ get: {
+ '/api/projects/:team/persons/values/': () => new Promise(() => {}),
+ },
+ })
+ featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]: true })
+ jest.useFakeTimers()
+ let list: ReturnType<typeof infiniteListLogic.build> | undefined
+ try {
+ list = logicWith({
+ listGroupType: TaxonomicFilterGroupType.EmailAddresses,
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.EmailAddresses],
+ })
+ list.actions.setSearchQuery('sample@')
+ await jest.advanceTimersByTimeAsync(600)
+ const previousController = list.cache.abortController
+ expect(previousController).not.toBeNull()
+ expect(previousController?.signal.aborted).toBe(false)
+
+ list.actions.setSearchQuery('sample')
+ await jest.advanceTimersByTimeAsync(600)
+ expect(previousController?.signal.aborted).toBe(true)
+ expect(list.cache.abortController).toBeNull()
+ expect(list.values.remoteItems).toMatchObject({ searchQuery: 'sample', results: [] })
+
+ await jest.advanceTimersByTimeAsync(31000)
+ expect(list.values.showErrorState).toBe(false)
+ expect(list.values.remoteItems).toMatchObject({ searchQuery: 'sample', results: [] })
+ } finally {
+ list?.unmount()
+ featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]: false,
+ })
+ featureFlagLogic.unmount()
+ jest.useRealTimers()
+ }
+ })
+
it('shows loading while the dashboard list loads', async () => {
let completeDashboardLoad!: () => void
const dashboardLoad = new Promise<void>((resolve) => {
diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
index 722f1a45fb50..bf84a6171a11 100644
--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
@@ -915,11 +915,13 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
minSearchQueryLength,
} = values
- if (!remoteEndpoint) {
- return createEmptyListStorage(searchQuery)
- }
-
- if (minSearchQueryLength > 0 && searchQuery.length < minSearchQueryLength) {
+ if (
+ !remoteEndpoint ||
+ (minSearchQueryLength > 0 && searchQuery.length < minSearchQueryLength) ||
+ values.group?.shouldSearch?.(searchQuery) === false
+ ) {
+ cache.disposables.dispose('abortController')
+ cache.abortController = null
return createEmptyListStorage(searchQuery)
}
@@ -2343,7 +2345,9 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
cache.lastFetchFailedDedupeKey = null
const trimmedQuery = (remoteItems.searchQuery ?? '').trim()
- const queryReachedBackend = trimmedQuery.length >= values.minSearchQueryLength
+ const queryReachedBackend =
+ trimmedQuery.length >= values.minSearchQueryLength &&
+ values.group?.shouldSearch?.(trimmedQuery) !== false
// Only fire on the tab the user is actually looking at — every list runs the same
// search in parallel, so without this gate one keystroke can fire 4-8 empty events
// from background tabs the user never sees, inflating the dead-end metric.
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
index c5ab81adf802..bc5857e97904 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
@@ -9,6 +9,7 @@ import { useState } from 'react'
import { FEATURE_FLAGS } from 'lib/constants'
import * as featureFlagLogicModule from 'lib/logic/featureFlagLogic'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { teamLogic } from 'scenes/teamLogic'
import { FlagEvaluationsModeEnumApi } from '~/generated/core/api.schemas'
@@ -74,6 +75,7 @@ function renderAll(options: {
searchQuery?: string
onCommit?: any
eventNames?: string[]
+ drillTo?: TaxonomicFilterGroupType
}): ReturnType<typeof render> {
return render(
<Provider>
@@ -84,7 +86,7 @@ function renderAll(options: {
eventNames={options.eventNames}
>
<MenuFilterCombobox
- drillTo="all"
+ drillTo={options.drillTo ?? 'all'}
recentEntries={options.recentEntries}
pinnedEntries={options.pinnedEntries}
onCommit={options.onCommit ?? jest.fn()}
@@ -952,7 +954,7 @@ describe('MenuFilterCombobox', () => {
})
it.each(['Recent', 'Pinned'])(
- 'filters the %s category by the query, endpoint-backed rows included',
+ 'filters %s rows in All by the query, endpoint-backed rows included',
async (label) => {
const user = userEvent.setup()
apiGet.mockResolvedValue({ results: [], count: 0 })
@@ -971,7 +973,7 @@ describe('MenuFilterCombobox', () => {
})
await user.click(screen.getByLabelText('Filter category'))
- await user.click(await within(await openedCategoryPopup()).findByText(label))
+ await user.click(await within(await openedCategoryPopup()).findByText('All'))
await waitFor(() => expect(rowTexts().some((t) => t.includes('browser_opened'))).toBe(true))
expect(rowTexts().some((t) => t.includes('checkout_started'))).toBe(false)
@@ -1042,20 +1044,39 @@ describe('MenuFilterCombobox', () => {
expect(rowTexts()[0]).toContain('signup')
})
- it('exposes Recent and Pinned as category options in the dropdown', async () => {
+ it.each([
+ [TaxonomicFilterGroupType.EmailAddresses, 'Search for an email address or domain.'],
+ [TaxonomicFilterGroupType.PageviewUrls, 'Search for a URL, domain, or path.'],
+ [TaxonomicFilterGroupType.PageviewEvents, 'Search for a URL, domain, or path.'],
+ ])('explains a skipped value search in %s', async (groupType, hint) => {
+ featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]: true })
+ renderAll({ groupTypes: [groupType], searchQuery: 'sample', drillTo: groupType })
+ expect(await screen.findByText(hint)).toBeInTheDocument()
+ expect(
+ apiGet.mock.calls.filter(
+ ([url]: string[]) => url.includes('/events/values') || url.includes('/persons/values')
+ )
+ ).toHaveLength(0)
+ expect(captureMock).not.toHaveBeenCalledWith('taxonomic filter empty result', expect.anything())
+ })
+
+ it('keeps recents and pins in All without separate category options', async () => {
const user = userEvent.setup()
apiGet.mockResolvedValue({ results: [], count: 0 })
renderAll({
groupTypes: [TaxonomicFilterGroupType.Events],
- recentEntries: [makeEntry(TaxonomicFilterGroupType.Events, 'r', 'Events')],
- pinnedEntries: [makeEntry(TaxonomicFilterGroupType.EventProperties, 'p', 'Event properties')],
+ recentEntries: [makeEntry(TaxonomicFilterGroupType.Events, 'recent_choice', 'Events')],
+ pinnedEntries: [makeEntry(TaxonomicFilterGroupType.EventProperties, 'pinned_choice', 'Event properties')],
})
await user.click(screen.getByLabelText('Filter category'))
const popup = await openedCategoryPopup()
- expect(await within(popup).findByText('Recent')).toBeInTheDocument()
- expect(within(popup).getByText('Pinned')).toBeInTheDocument()
+ expect(within(popup).queryByText('Recent')).not.toBeInTheDocument()
+ expect(within(popup).queryByText('Pinned')).not.toBeInTheDocument()
+ expect(rowTexts().some((text) => text.includes('recent_choice'))).toBe(true)
+ expect(rowTexts().some((text) => text.includes('pinned_choice'))).toBe(true)
})
it('forwards row selection context on commit and does not emit the legacy event itself', async () => {
@@ -1392,7 +1413,7 @@ describe('MenuFilterCombobox', () => {
expect(screen.queryByTestId('menu-filter-loading')).not.toBeInTheDocument()
})
- it.each(['Recent', 'Pinned'])('never hides %s behind skeletons when switched to mid-search', async (label) => {
+ it.each(['Recent', 'Pinned'])('keeps %s available in All without skeletons during a search', async (label) => {
const user = userEvent.setup()
apiGet.mockResolvedValue({ results: [{ id: 1, name: 'browser_opened' }], count: 1 })
const resolvedEntry = makeEntry(TaxonomicFilterGroupType.Events, `browser_${label.toLowerCase()}`, 'Events')
@@ -1423,7 +1444,7 @@ describe('MenuFilterCombobox', () => {
observer.observe(document.body, { childList: true, subtree: true })
try {
await user.click(screen.getByLabelText('Filter category'))
- await user.click(await within(await openedCategoryPopup()).findByText(label))
+ await user.click(await within(await openedCategoryPopup()).findByText('All'))
await waitFor(() => expect(rowTexts().some((text) => text.includes(resolvedEntry.name))).toBe(true))
} finally {
observer.disconnect()
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
index b72f6683cdbd..d27bee8e3642 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
@@ -329,12 +329,6 @@ 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' }]
- if (recentEntries && recentEntries.length > 0) {
- opts.push({ value: 'recent', label: 'Recent' })
- }
- if (pinnedEntries && pinnedEntries.length > 0) {
- opts.push({ value: 'pinned', label: 'Pinned' })
- }
for (const g of visibleChipGroups) {
// Collapsed groups feed the "all" rows but aren't navigable categories.
if (COLLAPSED_TO_CONTAINS_ROW.has(g.type)) {
@@ -343,7 +337,7 @@ export function MenuFilterCombobox({
opts.push({ value: g.type, label: g.name })
}
return opts
- }, [recentEntries, pinnedEntries, visibleChipGroups])
+ }, [visibleChipGroups])
// Resolve which groups feed the visible list, based on the active chip
// (or the drill scope when chips are hidden).
@@ -806,6 +800,9 @@ export function MenuFilterCombobox({
body: <HiddenEventExplanation />,
}
}
+ if (singleGroup?.shouldSearch?.(searchQuery) === false && singleGroup.searchQueryHint) {
+ return { title: singleGroup.name, body: singleGroup.searchQueryHint }
+ }
const categoryLabel = singleGroup?.name ?? null
if (trimmedLen > 0) {
return {
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.pinned.test.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.pinned.test.tsx
index b3c4b4c0a471..1532f24f37bf 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.pinned.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.pinned.test.tsx
@@ -93,9 +93,11 @@ describe('TaxonomicFilterMenu pinned rows', () => {
await userEvent.click(screen.getByTestId('taxonomic-filter-menu-trigger'))
await waitFor(() => {
- expect(screen.getByText('Pinned')).toBeInTheDocument()
+ expect(screen.getByTestId('taxonomic-filter-menu-new')).toBeInTheDocument()
})
- await userEvent.click(screen.getByText('Pinned'))
+ expect(screen.queryByText('Recent')).not.toBeInTheDocument()
+ expect(screen.queryByText('Pinned')).not.toBeInTheDocument()
+ await userEvent.click(screen.getByTestId('taxonomic-filter-menu-new'))
await waitFor(() => {
expect(pinnedRowTexts().length).toBeGreaterThan(0)
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.stories.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.stories.tsx
index 89e1e22088c0..a15f6658addc 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.stories.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.stories.tsx
@@ -371,7 +371,7 @@ export const DefaultSurfaceWithRecents: Story = {
parameters: {
docs: {
description: {
- story: 'The default "All" surface staff land on, brought in line with the pill variant: recents lead, then pinned, then the cross-tab content in fixed (learnable) order. Recent/pinned rows are tagged with their source (e.g. "Events - recent"), and the category dropdown exposes Recent and Pinned alongside the content categories so they stay navigable.',
+ story: 'The default "All" surface staff land on, brought in line with the pill variant: recents lead, then pinned, then the cross-tab content in fixed (learnable) order. Recent/pinned rows are tagged with their source (e.g. "Events - recent"), and saved items stay in All without separate Recent and Pinned category options.',
},
},
},
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx
index c057b5fc0f83..844d59e0fcf4 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx
@@ -802,21 +802,6 @@ export function TaxonomicFilterMenu({
<IconChevronRight className="ml-auto size-3.5 text-tertiary" />
</DropdownMenuItem>
)}
- {recentEntries.length > 0 && (
- <>
- {!useInputTrigger && <DropdownMenuSeparator />}
- <DropdownMenuItem onClick={() => selectMenuOption('recent', () => openCombobox('recent'))}>
- Recent
- <IconChevronRight className="ml-auto size-3.5 text-tertiary" />
- </DropdownMenuItem>
- </>
- )}
- {pinnedEntries.length > 0 && (
- <DropdownMenuItem onClick={() => selectMenuOption('pinned', () => openCombobox('pinned'))}>
- Pinned
- <IconChevronRight className="ml-auto size-3.5 text-tertiary" />
- </DropdownMenuItem>
- )}
{(hasDwh || hasHogql) && <DropdownMenuSeparator />}
{hasDwh && (
<DropdownMenuItem
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
index 2758dec3f01d..75ee3388cde0 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
@@ -1048,6 +1048,46 @@ describe('taxonomicFilterLogic', () => {
})
describe('SuggestedFilters presence', () => {
+ it.each([
+ { restriction: 'none', props: {}, expected: true },
+ {
+ restriction: 'exclusion',
+ props: { excludedProperties: { [TaxonomicFilterGroupType.EventProperties]: ['$pathname'] } },
+ expected: false,
+ },
+ {
+ restriction: 'allowlist mismatch',
+ props: { propertyAllowList: { [TaxonomicFilterGroupType.EventProperties]: ['$host'] } },
+ expected: false,
+ },
+ {
+ restriction: 'empty allowlist',
+ props: { propertyAllowList: { [TaxonomicFilterGroupType.EventProperties]: [] } },
+ expected: false,
+ },
+ {
+ restriction: 'allowlist match',
+ props: { propertyAllowList: { [TaxonomicFilterGroupType.EventProperties]: ['$pathname'] } },
+ expected: true,
+ },
+ { restriction: 'numeric properties only', props: { showNumericalPropsOnly: true }, expected: false },
+ ])('offers a primary property in Suggested with $restriction', ({ restriction, props, expected }) => {
+ const testLogic = taxonomicFilterLogic({
+ taxonomicFilterLogicKey: `testPrimary-${restriction}`,
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.EventProperties],
+ eventNames: ['$pageview'],
+ ...props,
+ })
+ testLogic.mount()
+
+ const suggested = testLogic.values.taxonomicGroups.find(
+ (group) => group.type === TaxonomicFilterGroupType.SuggestedFilters
+ )
+ expect(suggested?.options?.some((option) => option.name === '$pathname')).toBe(expected)
+
+ testLogic.unmount()
+ })
+
it.each([
{
description: 'keeps SuggestedFilters when explicitly listed in a multi-group picker',
@@ -1066,15 +1106,15 @@ describe('taxonomicFilterLogic', () => {
expectDefault: true,
},
{
- description: 'does not add SuggestedFilters for a single substantive group',
+ description: 'adds SuggestedFilters after a single substantive group without making it the default',
groupTypes: [TaxonomicFilterGroupType.Events],
- expectPresent: false,
+ expectPresent: true,
expectDefault: false,
},
{
- description: 'strips explicitly listed SuggestedFilters for a single substantive group',
+ description: 'moves explicitly listed SuggestedFilters after a single substantive group',
groupTypes: [TaxonomicFilterGroupType.SuggestedFilters, TaxonomicFilterGroupType.Events],
- expectPresent: false,
+ expectPresent: true,
expectDefault: false,
},
])('$description', ({ groupTypes, expectPresent, expectDefault }) => {
@@ -1201,19 +1241,21 @@ describe('taxonomicFilterLogic', () => {
],
},
{
- description: 'single substantive group leads, with Recent/Pinned after it (no All)',
+ description: 'single substantive group leads, with Suggested then Recent/Pinned after it',
groupTypes: [TaxonomicFilterGroupType.Events],
expected: [
TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.SuggestedFilters,
TaxonomicFilterGroupType.RecentFilters,
TaxonomicFilterGroupType.PinnedFilters,
],
},
{
- description: 'single substantive group drops an explicitly-prepended All and still leads',
+ description: 'single substantive group moves an explicitly-prepended All after it',
groupTypes: [TaxonomicFilterGroupType.SuggestedFilters, TaxonomicFilterGroupType.Events],
expected: [
TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.SuggestedFilters,
TaxonomicFilterGroupType.RecentFilters,
TaxonomicFilterGroupType.PinnedFilters,
],
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 608b6dde77ca..17965217a54f 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -59,6 +59,7 @@ import {
getMCPPropertyFilterOptions,
includesMCPAnalyticsEvents,
} from 'lib/components/TaxonomicFilter/utils/mcpProperties'
+import { isEmailLikeSearch, isUrlLikeSearch } from 'lib/components/TaxonomicFilter/utils/valueSearchQuery'
import { FEATURE_FLAGS } from 'lib/constants'
import { IconCohort } from 'lib/lemon-ui/icons'
import { Link } from 'lib/lemon-ui/Link'
@@ -202,11 +203,15 @@ function resolveSuggestedFiltersGroup(
substantiveGroupCount: number
): TaxonomicFilterGroupType[] {
if (substantiveGroupCount === 1) {
- const suggestedIdx = groupTypes.indexOf(TaxonomicFilterGroupType.SuggestedFilters)
- if (suggestedIdx === -1) {
+ if (!availableGroupTypes.has(TaxonomicFilterGroupType.SuggestedFilters)) {
return groupTypes
}
- return [...groupTypes.slice(0, suggestedIdx), ...groupTypes.slice(suggestedIdx + 1)]
+ const withoutSuggested: TaxonomicFilterGroupType[] = groupTypes.filter(
+ (type) => type !== TaxonomicFilterGroupType.SuggestedFilters
+ )
+ const substantiveIdx = withoutSuggested.findIndex((type) => !META_GROUP_TYPES.has(type))
+ withoutSuggested.splice(substantiveIdx + 1, 0, TaxonomicFilterGroupType.SuggestedFilters)
+ return withoutSuggested
}
const shouldLeadWithSuggested =
@@ -522,6 +527,7 @@ export interface taxonomicFilterLogicValues {
allowNonCapturedEvents: boolean
anyGroupLoading: boolean
anyGroupStale: boolean
+ categoryGroupTypes: TaxonomicFilterGroupType[]
cohortGroupOptions: {
hideBehavioralCohorts: boolean
showCohortFlagTargeting: boolean
@@ -569,6 +575,7 @@ export interface taxonomicFilterLogicValues {
excludedProperties: TaxonomicFilterGroupValueMap
includeHiddenEvents: boolean | undefined
propertyAllowList: TaxonomicFilterGroupValueMap | undefined
+ showNumericalPropsOnly: boolean | undefined
}
redistributedTopMatchItems: TopMatchItem[]
revealBarrierOpen: boolean
@@ -692,11 +699,13 @@ export interface taxonomicFilterLogicMeta {
propertyFilters: (
excludedProperties: TaxonomicFilterGroupValueMap,
propertyAllowList: TaxonomicFilterGroupValueMap | undefined,
- arg: any
+ arg: any,
+ arg2: any
) => {
excludedProperties: TaxonomicFilterGroupValueMap
includeHiddenEvents: boolean | undefined
propertyAllowList: TaxonomicFilterGroupValueMap | undefined
+ showNumericalPropsOnly: boolean | undefined
}
allowNonCapturedEvents: (arg: any) => boolean
hideBehavioralCohorts: (arg: any) => boolean
@@ -741,6 +750,7 @@ export interface taxonomicFilterLogicMeta {
excludedProperties: TaxonomicFilterGroupValueMap
includeHiddenEvents: boolean | undefined
propertyAllowList: TaxonomicFilterGroupValueMap | undefined
+ showNumericalPropsOnly: boolean | undefined
},
metadataPropertyDefinitionsByType: {
event: PropertyDefinition[]
@@ -768,6 +778,7 @@ export interface taxonomicFilterLogicMeta {
taxonomicGroups: TaxonomicFilterGroup[],
eventNames: any
) => TaxonomicFilterGroupType[]
+ categoryGroupTypes: (taxonomicGroupTypes: TaxonomicFilterGroupType[]) => TaxonomicFilterGroupType[]
groupAnalyticsTaxonomicGroupNames: (
groupTypes: Map<GroupTypeIndex, GroupType>,
currentTeamId: number | null,
@@ -799,10 +810,7 @@ export interface taxonomicFilterLogicMeta {
taxonomicGroupTypes: TaxonomicFilterGroupType[],
metaGroupTypes: Set<string>
) => TaxonomicFilterGroupType
- currentTabIndex: (
- taxonomicGroupTypes: TaxonomicFilterGroupType[],
- activeTab: TaxonomicFilterGroupType
- ) => number
+ currentTabIndex: (categoryGroupTypes: TaxonomicFilterGroupType[], activeTab: TaxonomicFilterGroupType) => number
searchPlaceholder: (
taxonomicGroups: TaxonomicFilterGroup[],
taxonomicGroupTypes: TaxonomicFilterGroupType[]
@@ -1083,14 +1091,20 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
],
// Combined so `taxonomicGroups` stays under kea's 16-dep tuple type limit.
propertyFilters: [
- (s) => [s.excludedProperties, s.propertyAllowList, (_, props) => props.includeHiddenEvents],
+ (s) => [
+ s.excludedProperties,
+ s.propertyAllowList,
+ (_, props) => props.includeHiddenEvents,
+ (_, props) => props.showNumericalPropsOnly,
+ ],
(
excludedProperties: import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap,
propertyAllowList:
| import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap
| undefined,
- includeHiddenEvents: boolean | undefined
- ) => ({ excludedProperties, propertyAllowList, includeHiddenEvents }),
+ includeHiddenEvents: boolean | undefined,
+ showNumericalPropsOnly: boolean | undefined
+ ) => ({ excludedProperties, propertyAllowList, includeHiddenEvents, showNumericalPropsOnly }),
{ resultEqualityCheck: objectsEqual },
],
allowNonCapturedEvents: [
@@ -1178,6 +1192,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
| import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap
| undefined
includeHiddenEvents: boolean | undefined
+ showNumericalPropsOnly: boolean | undefined
},
{
event: eventMetadataPropertyDefinitions,
@@ -1204,7 +1219,8 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
const { eventNames, primaryPropertiesForContextEvents, mcpExcludedEventProperties } =
eventNamesWithPrimaryProperties
const { id: teamId } = currentTeam
- const { excludedProperties, propertyAllowList, includeHiddenEvents } = propertyFilters
+ const { excludedProperties, propertyAllowList, includeHiddenEvents, showNumericalPropsOnly } =
+ propertyFilters
const groups: TaxonomicFilterGroup[] = [
{
name: 'Events',
@@ -1884,6 +1900,10 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
isQuickFilterItem(option) ? option.filterValue : option.name,
getPopoverHeader: () => `Pageview URL`,
minSearchQueryLength: 3,
+ shouldSearch: featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]
+ ? isUrlLikeSearch
+ : undefined,
+ searchQueryHint: 'Search for a URL, domain, or path.',
searchDescription: 'URLs seen on pageview events',
},
{
@@ -1896,6 +1916,10 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
getValue: (option: SimpleOption) => option.name,
getPopoverHeader: () => `Pageview event`,
minSearchQueryLength: 3,
+ shouldSearch: featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]
+ ? isUrlLikeSearch
+ : undefined,
+ searchQueryHint: 'Search for a URL, domain, or path.',
searchDescription: 'pageview events filtered by URL',
},
// Screens returns a screen name value, used in paths and property filters.
@@ -1935,6 +1959,10 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
getValue: (option: SimpleOption) => option.name,
getPopoverHeader: () => `Email address`,
minSearchQueryLength: 5,
+ shouldSearch: featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]
+ ? isEmailLikeSearch
+ : undefined,
+ searchQueryHint: 'Search for an email address or domain.',
searchDescription: 'email addresses seen in person properties',
},
{
@@ -2192,10 +2220,18 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
// Promoted properties for any event in context come first — if a team
// has marked a property as the one that summarises this event, it's
// the property they almost certainly want to filter or break down by.
- ...primaryPropertiesForContextEvents.map((name) => ({
- name,
- group: TaxonomicFilterGroupType.EventProperties,
- })),
+ ...primaryPropertiesForContextEvents
+ .filter(
+ (name) =>
+ !showNumericalPropsOnly &&
+ !excludedProperties[TaxonomicFilterGroupType.EventProperties]?.includes(name) &&
+ (propertyAllowList?.[TaxonomicFilterGroupType.EventProperties] === undefined ||
+ propertyAllowList[TaxonomicFilterGroupType.EventProperties]?.includes(name))
+ )
+ .map((name) => ({
+ name,
+ group: TaxonomicFilterGroupType.EventProperties,
+ })),
...(eventNames.includes('$autocapture')
? (['text', 'selector'] as const)
.filter(
@@ -2265,6 +2301,16 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
},
{ resultEqualityCheck: objectsEqual },
],
+ categoryGroupTypes: [
+ (s) => [s.taxonomicGroupTypes],
+ (groupTypes: TaxonomicFilterGroupType[]): TaxonomicFilterGroupType[] =>
+ groupTypes.filter(
+ (type) =>
+ type !== TaxonomicFilterGroupType.RecentFilters &&
+ type !== TaxonomicFilterGroupType.PinnedFilters
+ ),
+ { resultEqualityCheck: objectsEqual },
+ ],
groupAnalyticsTaxonomicGroupNames: [
(s) => [s.groupTypes, s.currentTeamId, s.aggregationLabel],
(
@@ -2441,6 +2487,10 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
) {
return propsGroupType
}
+ const substantiveGroupTypes = groupTypes.filter((type) => !META_GROUP_TYPES.has(type))
+ if (substantiveGroupTypes.length === 1) {
+ return substantiveGroupTypes[0]
+ }
// Otherwise lead with the All (Suggested filters) surface so reopening on an
// existing selection still shows recents/pinned + a cross-category search,
// rather than jumping to the selected item's category.
@@ -2454,7 +2504,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
},
],
currentTabIndex: [
- (s) => [s.taxonomicGroupTypes, s.activeTab],
+ (s) => [s.categoryGroupTypes, s.activeTab],
(groupTypes: TaxonomicFilterGroupType[], activeTab: TaxonomicFilterGroupType) =>
Math.max(groupTypes.indexOf(activeTab || ''), 0),
],
@@ -2731,7 +2781,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
},
tabLeft: () => {
- const { currentTabIndex, taxonomicGroupTypes, infiniteListCounts } = values
+ const { currentTabIndex, categoryGroupTypes: taxonomicGroupTypes, infiniteListCounts } = values
for (let i = 1; i < taxonomicGroupTypes.length; i++) {
const newIndex = (currentTabIndex - i + taxonomicGroupTypes.length) % taxonomicGroupTypes.length
if (infiniteListCounts[taxonomicGroupTypes[newIndex]] > 0) {
@@ -2742,7 +2792,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
},
tabRight: () => {
- const { currentTabIndex, taxonomicGroupTypes, infiniteListCounts } = values
+ const { currentTabIndex, categoryGroupTypes: taxonomicGroupTypes, infiniteListCounts } = values
for (let i = 1; i < taxonomicGroupTypes.length; i++) {
const newIndex = (currentTabIndex + i) % taxonomicGroupTypes.length
if (infiniteListCounts[taxonomicGroupTypes[newIndex]] > 0) {
diff --git a/frontend/src/lib/components/TaxonomicFilter/types.ts b/frontend/src/lib/components/TaxonomicFilter/types.ts
index 03b5ee92041f..f2e8dc6f1f7d 100644
--- a/frontend/src/lib/components/TaxonomicFilter/types.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/types.ts
@@ -287,6 +287,8 @@ export interface TaxonomicFilterGroup {
componentProps?: Record<string, any>
/** Minimum number of characters before a remote search is issued. */
minSearchQueryLength?: number
+ shouldSearch?: (query: string) => boolean
+ searchQueryHint?: string
/** Description shown in the empty state when minSearchQueryLength is set. */
searchDescription?: string
/** Synthetic results surfaced inline when the search query matches a keyword.
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
index ba345c42821f..e3da5b60c4d0 100644
--- a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
@@ -25,6 +25,7 @@ import {
getMCPPropertyFilterOptions,
includesMCPAnalyticsEvents,
} from 'lib/components/TaxonomicFilter/utils/mcpProperties'
+import { isEmailLikeSearch, isUrlLikeSearch } from 'lib/components/TaxonomicFilter/utils/valueSearchQuery'
import { FEATURE_FLAGS } from 'lib/constants'
import { IconCohort } from 'lib/lemon-ui/icons'
import { Link } from 'lib/lemon-ui/Link'
@@ -166,6 +167,7 @@ export interface BuildTaxonomicGroupsContext {
propertyFilters: {
excludedProperties: Partial<Record<TaxonomicFilterGroupType, (string | number | null)[]>>
propertyAllowList?: Partial<Record<TaxonomicFilterGroupType, (string | number | null)[]>>
+ showNumericalPropsOnly?: boolean
}
eventMetadataPropertyDefinitions: PropertyDefinition[]
personMetadataPropertyDefinitions: PropertyDefinition[]
@@ -207,7 +209,7 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
includeHiddenEvents,
} = ctx
const { id: teamId } = currentTeam
- const { excludedProperties, propertyAllowList } = propertyFilters
+ const { excludedProperties, propertyAllowList, showNumericalPropsOnly } = propertyFilters
// Opt the cohort picker into the trimmed `?basic=true` payload (drops the
// query/groups/last_error_message/experiment_set fields the picker never reads;
// `filters` is kept). Gated by a flag so the smaller response shape can be rolled
@@ -837,6 +839,10 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
getValue: (option: SimpleOption) => option.name,
getPopoverHeader: () => `Pageview URL`,
minSearchQueryLength: 3,
+ shouldSearch: featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]
+ ? isUrlLikeSearch
+ : undefined,
+ searchQueryHint: 'Search for a URL, domain, or path.',
searchDescription: 'URLs seen on pageview events',
},
{
@@ -849,6 +855,10 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
getValue: (option: SimpleOption) => option.name,
getPopoverHeader: () => `Pageview event`,
minSearchQueryLength: 3,
+ shouldSearch: featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]
+ ? isUrlLikeSearch
+ : undefined,
+ searchQueryHint: 'Search for a URL, domain, or path.',
searchDescription: 'pageview events filtered by URL',
},
// Screens returns a screen name value, used in paths and property filters.
@@ -888,6 +898,10 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
getValue: (option: SimpleOption) => option.name,
getPopoverHeader: () => `Email address`,
minSearchQueryLength: 5,
+ shouldSearch: featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_VALUE_SEARCH_GATING]
+ ? isEmailLikeSearch
+ : undefined,
+ searchQueryHint: 'Search for an email address or domain.',
searchDescription: 'email addresses seen in person properties',
},
{
@@ -1152,10 +1166,18 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
// Promoted properties for any event in context come first — if a team
// has marked a property as the one that summarises this event, it's
// the property they almost certainly want to filter or break down by.
- ...promotedPropertiesForContextEvents.map((name) => ({
- name,
- group: TaxonomicFilterGroupType.EventProperties,
- })),
+ ...promotedPropertiesForContextEvents
+ .filter(
+ (name) =>
+ !showNumericalPropsOnly &&
+ !excludedProperties[TaxonomicFilterGroupType.EventProperties]?.includes(name) &&
+ (propertyAllowList?.[TaxonomicFilterGroupType.EventProperties] === undefined ||
+ propertyAllowList[TaxonomicFilterGroupType.EventProperties]?.includes(name))
+ )
+ .map((name) => ({
+ name,
+ group: TaxonomicFilterGroupType.EventProperties,
+ })),
...(eventNames.includes('$autocapture')
? (['text', 'selector'] as const)
.filter((name) => !excludedProperties[TaxonomicFilterGroupType.Elements]?.includes(name))
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/valueSearchQuery.test.ts b/frontend/src/lib/components/TaxonomicFilter/utils/valueSearchQuery.test.ts
new file mode 100644
index 000000000000..54fc11a8a504
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/valueSearchQuery.test.ts
@@ -0,0 +1,26 @@
+import { isEmailLikeSearch, isUrlLikeSearch } from './valueSearchQuery'
+
+describe('value search queries', () => {
+ it.each([
+ ['sample', false, false],
+ ['email', false, false],
+ ['url', false, false],
+ ['sample@', true, false],
+ ['[email protected]', true, false],
+ ['/overview', false, true],
+ ['docs/overview', false, true],
+ ['https:', false, true],
+ ['HTTPS://', false, true],
+ ['www.', false, true],
+ ['example.com', true, true],
+ ['mail.example.com', true, true],
+ ['example.com:8080', false, true],
+ ['https://example.com', false, true],
+ ['example.com/path', false, true],
+ [' example.com ', true, true],
+ ['a sentence with example.com', false, false],
+ ])('recognizes %s as email=%s and URL=%s', (query, emailLike, urlLike) => {
+ expect(isEmailLikeSearch(query)).toBe(emailLike)
+ expect(isUrlLikeSearch(query)).toBe(urlLike)
+ })
+})
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/valueSearchQuery.ts b/frontend/src/lib/components/TaxonomicFilter/utils/valueSearchQuery.ts
new file mode 100644
index 000000000000..cf5be85a7e02
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/valueSearchQuery.ts
@@ -0,0 +1,14 @@
+export function isEmailLikeSearch(query: string): boolean {
+ return query.includes('@') || /^[^@\s/:]+\.[a-z][^@\s/:]*$/i.test(query.trim())
+}
+
+export function isUrlLikeSearch(query: string): boolean {
+ const trimmed = query.trim()
+ return (
+ !/\s/.test(trimmed) &&
+ (trimmed.includes('/') ||
+ /^https?:/i.test(trimmed) ||
+ /^www\./i.test(trimmed) ||
+ /^[^@]+\.[a-z]/i.test(trimmed))
+ )
+}
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index c9164b815d41..ecc1597cd53e 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -569,6 +569,7 @@ export const FEATURE_FLAGS = {
TAXONOMIC_FILTER_EVENT_MATCH: 'taxonomic-filter-event-match', // owner: @pauldambra multivariate=control,test, experiment: test asks the decision model which core events an events search with no results describes, then suggests them or says why there are none; control asks nothing
TAXONOMIC_FILTER_MENU_REBUILD: 'taxonomic-filter-menu-rebuild', // owner: @adamleith, opt-in to the rebuilt TaxonomicFilter — headless filter panel + new popover menu (column / preview-pane)
TAXONOMIC_FILTER_SEARCH_INTENT: 'taxonomic-filter-search-intent', // owner: @pauldambra multivariate=control,banner,promote, classifies a picker search with the decision model. control changes nothing, banner suggests the right tab, promote moves the predicted group to the top of the All tab
+ TAXONOMIC_FILTER_VALUE_SEARCH_GATING: 'taxonomic-filter-value-search-gating', // owner: @pauldambra
TEXT_CARD_WORD_ART: 'text-card-word-art', // owner: @jonmcwest, gates the word art insert button in dashboard text cards
TODAY_RAIL_NAV: 'today-rail-nav', // owner: @k11kirky, replaces the left navigation with a rail (Home, Spaces, Library, Tools) and makes the Today page the homepage
TODAY_REPORT_JEV: 'today-report-jev', // owner: @puemos, asks the decision model to label the problem, cause and fix in a Today report, to mark the numbers a source states, and to pick the code excerpt a finding describes