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): make fuzzy event search a control and test flag (#124148)

Paul D'Ambrab4b873f48d98
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.test.tsx b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.test.tsx
index dd44ab577449..75d68e319f3a 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.test.tsx
@@ -172,18 +172,20 @@ describe('useTaxonomicGroupsContext', () => {
})
it.each([
- [TaxonomicFilterGroupType.Events, true, false, 'true'],
- [TaxonomicFilterGroupType.CustomEvents, true, false, 'true'],
- [TaxonomicFilterGroupType.Events, true, true, 'false'],
- [TaxonomicFilterGroupType.CustomEvents, true, true, 'false'],
+ [TaxonomicFilterGroupType.Events, 'test', false, 'true'],
+ [TaxonomicFilterGroupType.CustomEvents, 'test', false, 'true'],
+ [TaxonomicFilterGroupType.Events, 'test', true, 'false'],
+ [TaxonomicFilterGroupType.CustomEvents, 'test', true, 'false'],
+ [TaxonomicFilterGroupType.Events, 'control', false, 'false'],
+ [TaxonomicFilterGroupType.CustomEvents, 'control', false, 'false'],
[TaxonomicFilterGroupType.Events, false, false, 'false'],
[TaxonomicFilterGroupType.CustomEvents, false, false, 'false'],
])(
'for %s with the flag %p and allowNonCapturedEvents %p, fuzzy_search is %p',
- (groupType, flagEnabled, allowNonCapturedEvents, expected) => {
+ (groupType, flagValue, allowNonCapturedEvents, expected) => {
featureFlagLogic.mount()
featureFlagLogic.actions.setFeatureFlags([], {
- [FEATURE_FLAGS.TAXONOMIC_FILTER_FUZZY_EVENT_SEARCH]: flagEnabled,
+ [FEATURE_FLAGS.TAXONOMIC_FILTER_FUZZY_EVENT_SEARCH]: flagValue,
})
const { result } = renderHook(() => useTaxonomicGroupsContext({ allowNonCapturedEvents }), { wrapper })
const group = buildTaxonomicGroups(result.current).find((item) => item.type === groupType)
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
index d4f62c611fcf..e08ea1e29080 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
@@ -124,20 +124,22 @@ describe('taxonomicFilterLogic', () => {
})
it.each([
- [TaxonomicFilterGroupType.Events, true, false, 'true'],
- [TaxonomicFilterGroupType.CustomEvents, true, false, 'true'],
- [TaxonomicFilterGroupType.Events, true, true, 'false'],
- [TaxonomicFilterGroupType.CustomEvents, true, true, 'false'],
+ [TaxonomicFilterGroupType.Events, 'test', false, 'true'],
+ [TaxonomicFilterGroupType.CustomEvents, 'test', false, 'true'],
+ [TaxonomicFilterGroupType.Events, 'test', true, 'false'],
+ [TaxonomicFilterGroupType.CustomEvents, 'test', true, 'false'],
+ [TaxonomicFilterGroupType.Events, 'control', false, 'false'],
+ [TaxonomicFilterGroupType.CustomEvents, 'control', false, 'false'],
[TaxonomicFilterGroupType.Events, false, false, 'false'],
[TaxonomicFilterGroupType.CustomEvents, false, false, 'false'],
])(
'for %s with the flag %p and allowNonCapturedEvents %p, fuzzy_search is %p',
- (groupType, flagEnabled, allowNonCapturedEvents, expected) => {
+ (groupType, flagValue, allowNonCapturedEvents, expected) => {
featureFlagLogic.actions.setFeatureFlags([], {
- [FEATURE_FLAGS.TAXONOMIC_FILTER_FUZZY_EVENT_SEARCH]: flagEnabled,
+ [FEATURE_FLAGS.TAXONOMIC_FILTER_FUZZY_EVENT_SEARCH]: flagValue,
})
const fuzzyLogic = taxonomicFilterLogic({
- taxonomicFilterLogicKey: `fuzzy-${groupType}-${flagEnabled}-${allowNonCapturedEvents}`,
+ taxonomicFilterLogicKey: `fuzzy-${groupType}-${flagValue}-${allowNonCapturedEvents}`,
taxonomicGroupTypes: [groupType],
allowNonCapturedEvents,
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 84f9c2a23fab..124f795d3e04 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -52,6 +52,7 @@ import {
TaxonomicFilterValue,
isQuickFilterItem,
} from 'lib/components/TaxonomicFilter/types'
+import { fuzzyEventSearchEnabled } from 'lib/components/TaxonomicFilter/utils/fuzzyEventSearch'
import { hiddenEventNames } from 'lib/components/TaxonomicFilter/utils/hiddenEvents'
import {
MCP_TOOL_CALL_EVENT,
@@ -1250,8 +1251,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
showNumericalPropsOnly,
allowNonCapturedEvents,
} = propertyFilters
- const fuzzyEventSearch =
- !!featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_FUZZY_EVENT_SEARCH] && !allowNonCapturedEvents
+ const fuzzyEventSearch = fuzzyEventSearchEnabled(featureFlags, allowNonCapturedEvents)
const groups: TaxonomicFilterGroup[] = [
{
name: 'Events',
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
index 521e6893fb70..2f3b464446fa 100644
--- a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
@@ -16,6 +16,7 @@ import {
TaxonomicFilterGroupType,
TaxonomicFilterValue,
} from 'lib/components/TaxonomicFilter/types'
+import { fuzzyEventSearchEnabled } from 'lib/components/TaxonomicFilter/utils/fuzzyEventSearch'
import { hiddenEventNames } from 'lib/components/TaxonomicFilter/utils/hiddenEvents'
import { withKeywordShortcuts } from 'lib/components/TaxonomicFilter/utils/keywordShortcuts'
import {
@@ -212,8 +213,7 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
allowNonCapturedEvents,
} = ctx
const { id: teamId } = currentTeam
- const fuzzyEventSearch =
- !!featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_FUZZY_EVENT_SEARCH] && !allowNonCapturedEvents
+ const fuzzyEventSearch = fuzzyEventSearchEnabled(featureFlags, allowNonCapturedEvents)
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;
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/fuzzyEventSearch.ts b/frontend/src/lib/components/TaxonomicFilter/utils/fuzzyEventSearch.ts
new file mode 100644
index 000000000000..5acd36d47b7e
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/fuzzyEventSearch.ts
@@ -0,0 +1,9 @@
+import { FEATURE_FLAGS } from 'lib/constants'
+
+// The `control` variant is truthy, so a plain flag check would give control the fuzzy search too.
+export function fuzzyEventSearchEnabled(
+ featureFlags: Record<string, boolean | string | undefined>,
+ allowNonCapturedEvents: boolean | undefined
+): boolean {
+ return featureFlags[FEATURE_FLAGS.TAXONOMIC_FILTER_FUZZY_EVENT_SEARCH] === 'test' && !allowNonCapturedEvents
+}
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 8cb40bb6acbe..81bc851bbcbf 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -540,7 +540,7 @@ export const FEATURE_FLAGS = {
TASK_TOOL: 'phai-task-tool', // owner: @kappa90 #team-posthog-ai
TASKS: 'tasks', // owner: #team-ai-observability
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_FUZZY_EVENT_SEARCH: 'taxonomic-filter-fuzzy-event-search', // owner: @pauldambra, Events and Custom events searches with no match ask the API for similar event names
+ TAXONOMIC_FILTER_FUZZY_EVENT_SEARCH: 'taxonomic-filter-fuzzy-event-search', // owner: @pauldambra multivariate=control,test, experiment: test makes Events and Custom events searches with no match ask the API for similar event names
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