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.

fix(feature-flags): hide non-`in` cohort recents from picker (#57560)

posthog[bot]7916deb217bd
diff --git a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
index 86850e9fed92..03425deebaa1 100644
--- a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
+++ b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
@@ -6,7 +6,9 @@ import React, { useEffect, useState } from 'react'
import { TaxonomicPropertyFilter } from 'lib/components/PropertyFilters/components/TaxonomicPropertyFilter'
import {
AllowedProperties,
+ ExcludedOperators,
ExcludedProperties,
+ SelectingKeyOnly,
TaxonomicFilterGroupType,
TaxonomicFilterProps,
} from 'lib/components/TaxonomicFilter/types'
@@ -51,7 +53,8 @@ export interface PropertyFiltersProps {
excludedProperties?: ExcludedProperties
allowRelativeDateOptions?: boolean
disabledReason?: string
- exactMatchFeatureFlagCohortOperators?: boolean
+ excludedOperators?: ExcludedOperators
+ selectingKeyOnly?: SelectingKeyOnly
hideBehavioralCohorts?: boolean
addFilterDocLink?: string
operatorAllowlist?: OperatorValueSelectProps['operatorAllowlist']
@@ -88,7 +91,8 @@ export function PropertyFilters({
excludedProperties,
allowRelativeDateOptions,
disabledReason = undefined,
- exactMatchFeatureFlagCohortOperators = false,
+ excludedOperators,
+ selectingKeyOnly,
hideBehavioralCohorts,
addFilterDocLink,
operatorAllowlist,
@@ -159,7 +163,8 @@ export function PropertyFilters({
excludedProperties={excludedProperties}
taxonomicFilterOptionsFromProp={taxonomicFilterOptionsFromProp}
allowRelativeDateOptions={allowRelativeDateOptions}
- exactMatchFeatureFlagCohortOperators={exactMatchFeatureFlagCohortOperators}
+ excludedOperators={excludedOperators}
+ selectingKeyOnly={selectingKeyOnly}
hideBehavioralCohorts={hideBehavioralCohorts}
size={buttonSize}
addFilterDocLink={addFilterDocLink}
diff --git a/frontend/src/lib/components/PropertyFilters/components/OperatorValueSelect.tsx b/frontend/src/lib/components/PropertyFilters/components/OperatorValueSelect.tsx
index 5df6e15f14e6..8c64c5822f08 100644
--- a/frontend/src/lib/components/PropertyFilters/components/OperatorValueSelect.tsx
+++ b/frontend/src/lib/components/PropertyFilters/components/OperatorValueSelect.tsx
@@ -112,10 +112,17 @@ export interface OperatorValueSelectProps {
size?: 'xsmall' | 'small' | 'medium'
startVisible?: LemonDropdownProps['startVisible']
/**
- * in some contexts you want to externally limit the available operators
- * this won't add an operator if it isn't valid
- * i.e. it limits the options shown from the options that would have been shown
- * **/
+ * Narrows the *operator dropdown options* shown for the active filter.
+ * Flat list — applies to whichever filter type is currently active in this
+ * `OperatorValueSelect`. Won't add operators that wouldn't otherwise be valid.
+ *
+ * Different concern from `excludedOperators` on the picker / `PropertyFilters`:
+ * - `operatorAllowlist` (here) governs which entries appear inside the operator
+ * dropdown next to a filter value.
+ * - `excludedOperators` governs which *recent property filters* surface in the
+ * picker's Recent tab (and whether the operator dropdown is shown at all),
+ * keyed per source group type.
+ */
operatorAllowlist?: Array<PropertyOperator>
/**
* Force single-select mode regardless of operator type
diff --git a/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.selectingKeyOnly.test.tsx b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.selectingKeyOnly.test.tsx
new file mode 100644
index 000000000000..69e28831b02f
--- /dev/null
+++ b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.selectingKeyOnly.test.tsx
@@ -0,0 +1,129 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen, waitFor } from '@testing-library/react'
+import { Provider } from 'kea'
+
+import { COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS } from 'scenes/feature-flags/cohortPickerProps'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+import { mockGetEventDefinitions, mockGetPropertyDefinitions } from '~/test/mocks'
+import { CohortPropertyFilter, CohortType, EventPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
+
+import { TaxonomicFilterGroupType } from '../../TaxonomicFilter/types'
+import { PropertyFilters } from '../PropertyFilters'
+
+jest.mock('lib/components/AutoSizer', () => ({
+ AutoSizer: ({ renderProp }: { renderProp: (size: { height: number; width: number }) => React.ReactNode }) =>
+ renderProp({ height: 400, width: 400 }),
+}))
+
+const cohortPowerUsers: Partial<CohortType> = { id: 1, name: 'Power Users' }
+
+describe('TaxonomicPropertyFilter selectingKeyOnly', () => {
+ beforeEach(() => {
+ initKeaTests()
+ useMocks({
+ get: {
+ '/api/projects/:team/event_definitions': mockGetEventDefinitions,
+ '/api/projects/:team/property_definitions': mockGetPropertyDefinitions,
+ '/api/projects/:team/cohorts/': {
+ results: [cohortPowerUsers],
+ next: null,
+ count: 1,
+ },
+ '/api/projects/:team/actions': { results: [] },
+ },
+ post: {
+ '/api/environments/:team/query': { results: [] },
+ },
+ })
+ })
+
+ afterEach(() => {
+ cleanup()
+ })
+
+ const cohortFilter: CohortPropertyFilter = {
+ type: PropertyFilterType.Cohort,
+ key: 'id',
+ value: 1,
+ operator: PropertyOperator.In,
+ cohort_name: 'Power Users',
+ }
+
+ const eventFilter: EventPropertyFilter = {
+ type: PropertyFilterType.Event,
+ key: '$browser',
+ value: 'Chrome',
+ operator: PropertyOperator.Exact,
+ }
+
+ function renderWith(props: Partial<React.ComponentProps<typeof PropertyFilters>>): void {
+ render(
+ <Provider>
+ <PropertyFilters
+ pageKey="selecting-key-only-test"
+ propertyFilters={[cohortFilter]}
+ onChange={jest.fn()}
+ disablePopover
+ taxonomicGroupTypes={[TaxonomicFilterGroupType.Cohorts, TaxonomicFilterGroupType.EventProperties]}
+ {...props}
+ />
+ </Provider>
+ )
+ }
+
+ it('renders the operator+value pair for a cohort row when selectingKeyOnly is unset', async () => {
+ renderWith({})
+
+ await waitFor(() => {
+ expect(document.querySelector('[data-attr="taxonomic-operator"]')).toBeInTheDocument()
+ })
+ })
+
+ it.each([
+ {
+ name: 'feature-flag preset hides the operator+value pair for cohort rows',
+ extraProps: COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS,
+ },
+ {
+ name: 'inline selectingKeyOnly={{ Cohorts: true }} also hides it',
+ extraProps: { selectingKeyOnly: { [TaxonomicFilterGroupType.Cohorts]: true } },
+ },
+ {
+ name: 'selectingKeyOnly: true (whole picker) also hides it',
+ extraProps: { selectingKeyOnly: true },
+ },
+ ])('$name', async ({ extraProps }) => {
+ renderWith(extraProps)
+
+ // Wait for the cohort row to render.
+ await waitFor(() => {
+ expect(screen.getByText('Power Users')).toBeInTheDocument()
+ })
+
+ expect(document.querySelector('[data-attr="taxonomic-operator"]')).not.toBeInTheDocument()
+ expect(document.querySelector('[data-attr="taxonomic-value-select"]')).not.toBeInTheDocument()
+ })
+
+ it('keeps the operator+value pair on event-property rows even when Cohorts is key-only', async () => {
+ // Event-property filter alongside the cohort one — only the cohort should be key-only.
+ render(
+ <Provider>
+ <PropertyFilters
+ pageKey="selecting-key-only-event-test"
+ propertyFilters={[eventFilter]}
+ onChange={jest.fn()}
+ disablePopover
+ taxonomicGroupTypes={[TaxonomicFilterGroupType.Cohorts, TaxonomicFilterGroupType.EventProperties]}
+ {...COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS}
+ />
+ </Provider>
+ )
+
+ await waitFor(() => {
+ expect(document.querySelector('[data-attr="taxonomic-operator"]')).toBeInTheDocument()
+ })
+ })
+})
diff --git a/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
index 2eac399250f1..693976fc6cc7 100644
--- a/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
+++ b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
@@ -22,6 +22,7 @@ import {
TaxonomicFilterGroup,
TaxonomicFilterGroupType,
TaxonomicFilterValue,
+ isKeyOnlyForGroup,
} from 'lib/components/TaxonomicFilter/types'
import { isOperatorMulti, isOperatorRegex, toParams } from 'lib/utils'
import { teamLogic } from 'scenes/teamLogic'
@@ -72,7 +73,8 @@ export function TaxonomicPropertyFilter({
excludedProperties,
taxonomicFilterOptionsFromProp,
allowRelativeDateOptions,
- exactMatchFeatureFlagCohortOperators,
+ excludedOperators,
+ selectingKeyOnly,
hideBehavioralCohorts,
addFilterDocLink,
editable = true,
@@ -117,14 +119,10 @@ export function TaxonomicPropertyFilter({
const showInitialSearchInline =
!disablePopover &&
((!filter?.type && (!filter || !(filter as any)?.key)) || filter?.type === PropertyFilterType.HogQL)
+ const filterTaxonomicGroupType = filter ? propertyFilterTypeToTaxonomicFilterType(filter) : undefined
+ const isKeyOnlyRow = isKeyOnlyForGroup(selectingKeyOnly, filterTaxonomicGroupType)
const showOperatorValueSelect =
- filter?.type &&
- filter?.key &&
- !(filter?.type === PropertyFilterType.HogQL) &&
- // If we're in a feature flag, we don't want to show operators for cohorts because
- // we don't support any cohort matching operators other than "in"
- // See https://github.com/PostHog/posthog/pull/25149/
- !(filter?.type === PropertyFilterType.Cohort && exactMatchFeatureFlagCohortOperators)
+ filter?.type && filter?.key && !(filter?.type === PropertyFilterType.HogQL) && !isKeyOnlyRow
const placeOperatorValueSelectOnLeft = filter?.type && filter?.key && filter?.type === PropertyFilterType.Cohort
const { propertyDefinitionsByType } = useValues(propertyDefinitionsModel)
@@ -162,7 +160,7 @@ export function TaxonomicPropertyFilter({
const taxonomicFilter = (
<TaxonomicFilter
- groupType={filter ? propertyFilterTypeToTaxonomicFilterType(filter) : undefined}
+ groupType={filterTaxonomicGroupType}
value={cohortOrOtherValue}
onChange={taxonomicOnChange}
taxonomicGroupTypes={groupTypes}
@@ -176,6 +174,8 @@ export function TaxonomicPropertyFilter({
selectFirstItem={!cohortOrOtherValue}
endpointFilters={endpointFilters}
hogQLGlobals={hogQLGlobals}
+ excludedOperators={excludedOperators}
+ selectingKeyOnly={selectingKeyOnly}
enableKeywordShortcuts
/>
)
diff --git a/frontend/src/lib/components/PropertyFilters/types.ts b/frontend/src/lib/components/PropertyFilters/types.ts
index 22b759e67bce..94f40588e591 100644
--- a/frontend/src/lib/components/PropertyFilters/types.ts
+++ b/frontend/src/lib/components/PropertyFilters/types.ts
@@ -1,7 +1,9 @@
import { OperatorValueSelectProps } from 'lib/components/PropertyFilters/components/OperatorValueSelect'
import {
AllowedProperties,
+ ExcludedOperators,
ExcludedProperties,
+ SelectingKeyOnly,
TaxonomicFilterGroup,
TaxonomicFilterGroupType,
TaxonomicFilterProps,
@@ -60,7 +62,8 @@ export interface PropertyFilterInternalProps {
metadataSource?: AnyDataNode
excludedProperties?: ExcludedProperties
allowRelativeDateOptions?: boolean
- exactMatchFeatureFlagCohortOperators?: boolean
+ excludedOperators?: ExcludedOperators
+ selectingKeyOnly?: SelectingKeyOnly
hideBehavioralCohorts?: boolean
addFilterDocLink?: string
endpointFilters?: Record<string, any>
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
index 1b17ac628481..ffb3c2a6bc90 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
@@ -19,7 +19,9 @@ import {
mockGetEventDefinitions,
mockGetPropertyDefinitions,
} from '~/test/mocks'
+import { PropertyFilterType, PropertyOperator } from '~/types'
+import { recentTaxonomicFiltersLogic } from './recentTaxonomicFiltersLogic'
import { TaxonomicFilter } from './TaxonomicFilter'
import { TaxonomicFilterGroupType } from './types'
@@ -1191,4 +1193,118 @@ describe('TaxonomicFilter', () => {
)
})
})
+
+ describe('excludedOperators', () => {
+ const seedRecents = (): void => {
+ const recentLogic = recentTaxonomicFiltersLogic.build()
+ recentLogic.mount()
+ recentLogic.actions.recordRecentFilter({
+ groupType: TaxonomicFilterGroupType.Cohorts,
+ groupName: 'Cohorts',
+ value: 1,
+ item: { name: 'Power Users' },
+ propertyFilter: {
+ type: PropertyFilterType.Cohort,
+ key: 'id',
+ value: 1,
+ operator: PropertyOperator.In,
+ cohort_name: 'Power Users',
+ },
+ })
+ recentLogic.actions.recordRecentFilter({
+ groupType: TaxonomicFilterGroupType.Cohorts,
+ groupName: 'Cohorts',
+ value: 2,
+ item: { name: 'Trial Users' },
+ propertyFilter: {
+ type: PropertyFilterType.Cohort,
+ key: 'id',
+ value: 2,
+ operator: PropertyOperator.NotIn,
+ cohort_name: 'Trial Users',
+ },
+ })
+ recentLogic.actions.recordRecentFilter({
+ groupType: TaxonomicFilterGroupType.EventProperties,
+ groupName: 'Event properties',
+ value: '$browser',
+ item: { name: '$browser' },
+ propertyFilter: {
+ type: PropertyFilterType.Event,
+ key: '$browser',
+ value: 'Chrome',
+ operator: PropertyOperator.Exact,
+ },
+ })
+ }
+
+ beforeEach(() => {
+ useMocks({
+ get: {
+ '/api/projects/:team/event_definitions': mockGetEventDefinitions,
+ '/api/projects/:team/property_definitions': mockGetPropertyDefinitions,
+ '/api/projects/:team/cohorts/': { results: [], next: null, count: 0 },
+ '/api/projects/:team/actions': { results: [] },
+ },
+ post: {
+ '/api/environments/:team/query': { results: [] },
+ },
+ })
+ localStorage.clear()
+ const recentLogic = recentTaxonomicFiltersLogic.build()
+ recentLogic.mount()
+ recentLogic.actions.clearRecentFilters()
+ seedRecents()
+ })
+
+ it.each([
+ {
+ name: 'hides cohort recents whose operator is denylisted but keeps other recents',
+ excludedOperators: { [TaxonomicFilterGroupType.Cohorts]: [PropertyOperator.NotIn] },
+ expectInRecent: ['User in Power Users', 'Browser = Chrome'],
+ 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'],
+ expectNotInRecent: [],
+ },
+ ])('$name', async ({ excludedOperators, expectInRecent, expectNotInRecent }) => {
+ render(
+ <Provider>
+ <TaxonomicFilter
+ taxonomicGroupTypes={[
+ TaxonomicFilterGroupType.Cohorts,
+ TaxonomicFilterGroupType.EventProperties,
+ ]}
+ excludedOperators={excludedOperators}
+ onChange={onChangeMock}
+ onClose={onCloseMock}
+ />
+ </Provider>
+ )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('taxonomic-tab-recent_filters')).toBeInTheDocument()
+ })
+ await userEvent.click(screen.getByTestId('taxonomic-tab-recent_filters'))
+
+ const recentRowText = (): string =>
+ Array.from(document.querySelectorAll('[data-attr^="prop-filter-recent_filters-"]'))
+ .map((el) => el.textContent ?? '')
+ .join('||')
+
+ await waitFor(() => {
+ for (const expected of expectInRecent) {
+ expect(recentRowText()).toContain(expected)
+ }
+ })
+
+ const allText = recentRowText()
+ for (const forbidden of expectNotInRecent) {
+ expect(allText).not.toContain(forbidden)
+ }
+ })
+ })
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx
index ebdf7cf5dff6..e3d6a66407b5 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx
@@ -59,6 +59,7 @@ export function TaxonomicFilter({
hideSearchInput,
searchQuery: controlledSearchQuery,
enableKeywordShortcuts,
+ excludedOperators,
selectingKeyOnly,
}: TaxonomicFilterProps): JSX.Element {
// Generate a unique key for each unique TaxonomicFilter that's rendered
@@ -105,6 +106,7 @@ export function TaxonomicFilter({
minSearchQueryLength,
suggestedFiltersLabel: resolvedSuggestedFiltersLabel,
enableKeywordShortcuts,
+ excludedOperators,
selectingKeyOnly,
}
diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts
index 59f28235cf7d..ed5fc6ac1a7a 100644
--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts
@@ -3,6 +3,10 @@ import { MOCK_TEAM_ID } from 'lib/api.mock'
import { expectLogic, partial } from 'kea-test-utils'
import posthog from 'posthog-js'
+import {
+ hasRecentContext,
+ recentTaxonomicFiltersLogic,
+} from 'lib/components/TaxonomicFilter/recentTaxonomicFiltersLogic'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
import { dataWarehouseSettingsSceneLogic } from 'scenes/data-warehouse/settings/dataWarehouseSettingsSceneLogic'
@@ -15,7 +19,6 @@ import { AppContext, PropertyDefinition, PropertyFilterType, PropertyOperator, P
import { joinsLogic } from 'products/data_warehouse/frontend/shared/logics/joinsLogic'
import { infiniteListLogic } from './infiniteListLogic'
-import { hasRecentContext, recentTaxonomicFiltersLogic } from './recentTaxonomicFiltersLogic'
import { taxonomicFilterLogic } from './taxonomicFilterLogic'
window.POSTHOG_APP_CONTEXT = {
@@ -874,106 +877,152 @@ describe('infiniteListLogic', () => {
})
})
- describe('contextFilteredRecentItems with selectingKeyOnly mode', () => {
- beforeEach(() => {
- localStorage.clear()
- recentTaxonomicFiltersLogic.mount()
- })
-
- afterEach(() => {
- recentTaxonomicFiltersLogic.unmount()
- })
-
- const recordKeyOnly = (key: string, item: Record<string, any> = { name: key }): void => {
- recentTaxonomicFiltersLogic.actions.recordRecentFilter({
- groupType: TaxonomicFilterGroupType.EventProperties,
- groupName: 'Event properties',
- value: key,
- item: item,
- selectingKeyOnly: true,
- })
+ describe('contextFilteredRecentItems', () => {
+ // Generic wrapper around hasRecentContext so .filter() preserves the input type
+ // (the production type guard uses `unknown` which TS can't narrow through Array.filter).
+ const onlyWithRecentContext = <T>(
+ item: T
+ ): item is T & {
+ _recentContext: { sourceGroupType: TaxonomicFilterGroupType; propertyFilter?: { value?: any } }
+ } => hasRecentContext(item)
+
+ // Recent cohort filters can carry any operator the user previously chose elsewhere
+ // (insights, recordings, etc). Feature flag release conditions intentionally hide
+ // the operator dropdown for cohorts (only `in` is supported), so a non-`in` recent
+ // must not surface there — otherwise the picker would offer an option the
+ // surrounding UI is hiding. Hosts express this via excludedOperators.
+ const recentCohortIn = {
+ name: 'Power Users',
+ _recentContext: {
+ sourceGroupType: TaxonomicFilterGroupType.Cohorts,
+ sourceGroupName: 'Cohorts',
+ propertyFilter: {
+ type: PropertyFilterType.Cohort,
+ key: 'id',
+ value: 1,
+ operator: PropertyOperator.In,
+ cohort_name: 'Power Users',
+ },
+ },
}
-
- const recordComplete = (key: string, value: string): void => {
- recentTaxonomicFiltersLogic.actions.recordRecentFilter({
- groupType: TaxonomicFilterGroupType.EventProperties,
- groupName: 'Event properties',
- value: key,
- item: { name: key },
+ const recentCohortNotIn = {
+ name: 'Trial Users',
+ _recentContext: {
+ sourceGroupType: TaxonomicFilterGroupType.Cohorts,
+ sourceGroupName: 'Cohorts',
+ propertyFilter: {
+ type: PropertyFilterType.Cohort,
+ key: 'id',
+ value: 2,
+ operator: PropertyOperator.NotIn,
+ cohort_name: 'Trial Users',
+ },
+ },
+ }
+ const recentEventProperty = {
+ name: '$browser',
+ _recentContext: {
+ sourceGroupType: TaxonomicFilterGroupType.EventProperties,
+ sourceGroupName: 'Event properties',
propertyFilter: {
type: PropertyFilterType.Event,
- key,
+ key: '$browser',
+ value: 'Chrome',
operator: PropertyOperator.Exact,
- value,
},
- })
+ },
}
- it('strips propertyFilter from recents and dedups by key when selectingKeyOnly is set', () => {
- recordComplete('$browser', 'Chrome')
- recordComplete('$browser', 'Safari')
- recordKeyOnly('$os')
+ const seedRecents = (items: Record<string, any>[]): void => {
+ const recentLogic = recentTaxonomicFiltersLogic.build()
+ recentLogic.mount()
+ for (const item of items) {
+ recentLogic.actions.recordRecentFilter({
+ groupType: item._recentContext.sourceGroupType,
+ groupName: item._recentContext.sourceGroupName,
+ value: item._recentContext.propertyFilter.value,
+ item: { name: item.name },
+ propertyFilter: item._recentContext.propertyFilter,
+ })
+ }
+ }
- const listLogic = logicWith({
- listGroupType: TaxonomicFilterGroupType.EventProperties,
- taxonomicGroupTypes: [TaxonomicFilterGroupType.EventProperties],
- selectingKeyOnly: true,
+ it('hides recents whose operator is excluded for their source group', () => {
+ seedRecents([recentCohortIn, recentCohortNotIn, recentEventProperty])
+
+ const listLogic = infiniteListLogic({
+ taxonomicFilterLogicKey: 'flag-recents-test',
+ listGroupType: TaxonomicFilterGroupType.RecentFilters,
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.Cohorts,
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.RecentFilters,
+ ],
+ showNumericalPropsOnly: false,
+ excludedOperators: { [TaxonomicFilterGroupType.Cohorts]: [PropertyOperator.NotIn] },
})
+ listLogic.mount()
- const items = listLogic.values.contextFilteredRecentItems
- expect(items).toHaveLength(2)
- for (const item of items) {
- expect(hasRecentContext(item)).toBe(true)
- if (hasRecentContext(item)) {
- expect(item._recentContext.propertyFilter).toBeUndefined()
- }
- }
- expect(items.map((i) => ('name' in i ? i.name : null))).toEqual(['$os', '$browser'])
+ const filtered = listLogic.values.contextFilteredRecentItems
+ const cohortValues = filtered
+ .filter(onlyWithRecentContext)
+ .filter((i) => i._recentContext.sourceGroupType === TaxonomicFilterGroupType.Cohorts)
+ .map((i) => i._recentContext.propertyFilter?.value)
+ expect(cohortValues).toEqual([1])
+ expect(filtered.some((i) => 'name' in i && i.name === '$browser')).toBe(true)
})
- it('preserves complete recents (with their propertyFilter) when selectingKeyOnly is not set', () => {
- recordComplete('$browser', 'Chrome')
+ it('keeps cohort recents whose operator is undefined even when excludedOperators is set', () => {
+ const recentCohortNoOperator = {
+ name: 'Static Users',
+ _recentContext: {
+ sourceGroupType: TaxonomicFilterGroupType.Cohorts,
+ sourceGroupName: 'Cohorts',
+ propertyFilter: {
+ type: PropertyFilterType.Cohort,
+ key: 'id',
+ value: 3,
+ operator: undefined,
+ cohort_name: 'Static Users',
+ },
+ },
+ }
+ seedRecents([recentCohortIn, recentCohortNoOperator, recentCohortNotIn])
- const listLogic = logicWith({
- listGroupType: TaxonomicFilterGroupType.EventProperties,
- taxonomicGroupTypes: [TaxonomicFilterGroupType.EventProperties],
+ const listLogic = infiniteListLogic({
+ taxonomicFilterLogicKey: 'flag-recents-no-op-test',
+ listGroupType: TaxonomicFilterGroupType.RecentFilters,
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Cohorts, TaxonomicFilterGroupType.RecentFilters],
+ showNumericalPropsOnly: false,
+ excludedOperators: { [TaxonomicFilterGroupType.Cohorts]: [PropertyOperator.NotIn] },
})
+ listLogic.mount()
- const items = listLogic.values.contextFilteredRecentItems
- expect(items).toHaveLength(1)
- const [item] = items
- expect(hasRecentContext(item) && item._recentContext.propertyFilter).toBeTruthy()
+ const cohortValues = listLogic.values.contextFilteredRecentItems
+ .filter(onlyWithRecentContext)
+ .filter((i) => i._recentContext.sourceGroupType === TaxonomicFilterGroupType.Cohorts)
+ .map((i) => i._recentContext.propertyFilter?.value)
+ // The undefined-operator recent stays (1 + 3); the explicit NotIn (2) is hidden.
+ expect(cohortValues).toEqual(expect.arrayContaining([1, 3]))
+ expect(cohortValues).not.toContain(2)
})
- it('dedups by storage value, not by display name (cohorts/actions style)', () => {
- // Two cohorts have been recorded with the same display name ("Power users") but
- // distinct ids — they are genuinely different recents. A name-based dedup would
- // collapse them into one row; sourceValue-based dedup keeps them apart.
- recentTaxonomicFiltersLogic.actions.recordRecentFilter({
- groupType: TaxonomicFilterGroupType.Cohorts,
- groupName: 'Cohorts',
- value: 42,
- item: { name: 'Power users' },
- selectingKeyOnly: true,
- })
- recentTaxonomicFiltersLogic.actions.recordRecentFilter({
- groupType: TaxonomicFilterGroupType.Cohorts,
- groupName: 'Cohorts',
- value: 43,
- item: { name: 'Power users' },
- selectingKeyOnly: true,
- })
+ it('keeps all recents when excludedOperators is not set', () => {
+ seedRecents([recentCohortIn, recentCohortNotIn])
- const listLogic = logicWith({
- listGroupType: TaxonomicFilterGroupType.Cohorts,
- taxonomicGroupTypes: [TaxonomicFilterGroupType.Cohorts],
- selectingKeyOnly: true,
+ const listLogic = infiniteListLogic({
+ taxonomicFilterLogicKey: 'insight-recents-test',
+ listGroupType: TaxonomicFilterGroupType.RecentFilters,
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Cohorts, TaxonomicFilterGroupType.RecentFilters],
+ showNumericalPropsOnly: false,
})
+ listLogic.mount()
- const items = listLogic.values.contextFilteredRecentItems
- expect(items).toHaveLength(2)
- const sourceValues = items.map((i) => hasRecentContext(i) && i._recentContext.sourceValue)
- expect(new Set(sourceValues)).toEqual(new Set([42, 43]))
+ const cohortValues = listLogic.values.contextFilteredRecentItems
+ .filter(onlyWithRecentContext)
+ .filter((i) => i._recentContext.sourceGroupType === TaxonomicFilterGroupType.Cohorts)
+ .map((i) => i._recentContext.propertyFilter?.value)
+ expect(cohortValues).toEqual(expect.arrayContaining([1, 2]))
})
})
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
index 0ad3de692705..e7f924dd0414 100644
--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
@@ -15,6 +15,7 @@ import {
taxonomicFilterPinnedPropertiesLogic,
} from 'lib/components/TaxonomicFilter/taxonomicFilterPinnedPropertiesLogic'
import {
+ ExcludedOperators,
InfiniteListLogicProps,
QuickFilterItem,
SkeletonItem,
@@ -431,20 +432,34 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
(s) => [
s.recentFilterItems,
s.taxonomicGroupTypes,
+ (_, props: InfiniteListLogicProps) => props.excludedOperators,
(_, props: InfiniteListLogicProps) => props.selectingKeyOnly,
],
(
recentFilterItems: TaxonomicDefinitionTypes[],
taxonomicGroupTypes: TaxonomicFilterGroupType[],
+ excludedOperators: ExcludedOperators | undefined,
selectingKeyOnly: boolean | undefined
): TaxonomicDefinitionTypes[] => {
if (!recentFilterItems?.length) {
return []
}
const availableTypes = new Set(taxonomicGroupTypes)
- const inScope = recentFilterItems.filter(
- (item) => hasRecentContext(item) && availableTypes.has(item._recentContext.sourceGroupType)
- )
+ const inScope = recentFilterItems.filter((item) => {
+ if (!hasRecentContext(item) || !availableTypes.has(item._recentContext.sourceGroupType)) {
+ return false
+ }
+ const excludedForGroup = excludedOperators?.[item._recentContext.sourceGroupType]
+ if (excludedForGroup?.length) {
+ const propertyFilter = item._recentContext.propertyFilter
+ const operator =
+ propertyFilter && 'operator' in propertyFilter ? propertyFilter.operator : undefined
+ if (operator && excludedForGroup.includes(operator)) {
+ return false
+ }
+ }
+ return true
+ })
if (!selectingKeyOnly) {
return inScope
}
diff --git a/frontend/src/lib/components/TaxonomicFilter/isKeyOnlyForGroup.test.ts b/frontend/src/lib/components/TaxonomicFilter/isKeyOnlyForGroup.test.ts
new file mode 100644
index 000000000000..eabd920a133f
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/isKeyOnlyForGroup.test.ts
@@ -0,0 +1,45 @@
+import { TaxonomicFilterGroupType, isKeyOnlyForGroup } from 'lib/components/TaxonomicFilter/types'
+
+describe('isKeyOnlyForGroup', () => {
+ it.each([
+ { name: 'undefined prop -> false', prop: undefined, group: TaxonomicFilterGroupType.Cohorts, expected: false },
+ {
+ name: 'true prop -> true for any group',
+ prop: true,
+ group: TaxonomicFilterGroupType.Cohorts,
+ expected: true,
+ },
+ {
+ name: 'true prop -> true even for events',
+ prop: true,
+ group: TaxonomicFilterGroupType.EventProperties,
+ expected: true,
+ },
+ {
+ name: 'per-group dict matches the asked group',
+ prop: { [TaxonomicFilterGroupType.Cohorts]: true },
+ group: TaxonomicFilterGroupType.Cohorts,
+ expected: true,
+ },
+ {
+ name: 'per-group dict does not match a different group',
+ prop: { [TaxonomicFilterGroupType.Cohorts]: true },
+ group: TaxonomicFilterGroupType.EventProperties,
+ expected: false,
+ },
+ {
+ name: 'per-group dict with explicit false',
+ prop: { [TaxonomicFilterGroupType.Cohorts]: false },
+ group: TaxonomicFilterGroupType.Cohorts,
+ expected: false,
+ },
+ {
+ name: 'undefined group -> false',
+ prop: { [TaxonomicFilterGroupType.Cohorts]: true },
+ group: undefined,
+ expected: false,
+ },
+ ])('$name', ({ prop, group, expected }) => {
+ expect(isKeyOnlyForGroup(prop, group)).toBe(expected)
+ })
+})
diff --git a/frontend/src/lib/components/TaxonomicFilter/types.ts b/frontend/src/lib/components/TaxonomicFilter/types.ts
index b2cb25d5a85f..a59544440a4a 100644
--- a/frontend/src/lib/components/TaxonomicFilter/types.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/types.ts
@@ -62,6 +62,58 @@ export type ExcludedProperties = TaxonomicFilterGroupValueMap
export type SelectedProperties = TaxonomicFilterGroupValueMap
export type AllowedProperties = TaxonomicFilterGroupValueMap
+/**
+ * Per-group-type **denylist of property-filter operators** the host cannot represent.
+ * Acts only on the **Recent tab** — items whose stored operator is denylisted for
+ * their source group are hidden so the picker never surfaces a value the
+ * surrounding UI can't reproduce.
+ *
+ * Pairs with `selectingKeyOnly` when a host wants both (a) no operator/value
+ * slot in the row *and* (b) impossible recents kept out of the picker — the two
+ * concerns are deliberately separate so callers can use one without the other:
+ * - `selectingKeyOnly` decides whether the row renders an operator+value pair
+ * (UI shape concern).
+ * - `excludedOperators` decides which stored operators the host is willing to
+ * surface in Recent (history concern).
+ *
+ * NOT the same as `operatorAllowlist` on `OperatorValueSelect` — that's a flat
+ * list narrowing the *options inside* the operator dropdown for the active
+ * filter (e.g. survey trigger surfaces only `=` / `contains` regardless of
+ * filter type).
+ */
+export type ExcludedOperators = { [key in TaxonomicFilterGroupType]?: PropertyOperator[] }
+
+/**
+ * Tells `TaxonomicPropertyFilter` to render a row as key-only — the picked
+ * value IS the answer, no operator+value pair alongside it. Used when a
+ * specific filter type's operator is implicit (e.g. feature flag release
+ * conditions accept any operator on event properties but treat cohort rows
+ * as key-only because the cohort *is* the value and the operator is
+ * implicitly `in`).
+ *
+ * - `true` — every row in this `PropertyFilters` is key-only.
+ * - `Partial<Record<TaxonomicFilterGroupType, boolean>>` — per-group switch.
+ *
+ * Hosts that go key-only for a group almost always also want
+ * `excludedOperators` set for that group, otherwise a recent stored with a
+ * different operator silently applies as that operator with no UI to show it.
+ * The shared `COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS` preset bundles both.
+ */
+export type SelectingKeyOnly = boolean | { [key in TaxonomicFilterGroupType]?: boolean }
+
+export function isKeyOnlyForGroup(
+ selectingKeyOnly: SelectingKeyOnly | undefined,
+ groupType: TaxonomicFilterGroupType | undefined
+): boolean {
+ if (selectingKeyOnly === true) {
+ return true
+ }
+ if (!selectingKeyOnly || !groupType) {
+ return false
+ }
+ return !!selectingKeyOnly[groupType]
+}
+
export interface TaxonomicFilterProps {
groupType?: TaxonomicFilterGroupType
value?: TaxonomicFilterValue
@@ -115,11 +167,17 @@ export interface TaxonomicFilterProps {
* query matches a known autocapture interaction keyword. Consumers must handle
* `isQuickFilterItem(item)` in their onChange to avoid mis-selecting as an event name. */
enableKeywordShortcuts?: boolean
- /** Treat every selection as final — there is no operator/value picker after the user picks a key
- * (e.g. picking columns to add, or picking an event name). Selections from property groups are
- * recorded to recents directly instead of waiting for `propertyFilterLogic` to record a complete
- * filter, and only key-only recents are surfaced in the recents tab. */
- selectingKeyOnly?: boolean
+ /** Hide recent property filters whose operator is denylisted for their source group, so the
+ * picker never surfaces a value the surrounding UI can't represent. See `ExcludedOperators`
+ * above for how this differs from `operatorAllowlist` on `OperatorValueSelect`. */
+ excludedOperators?: ExcludedOperators
+ /** Mark the picker (or specific groups within it) as key-only — the picked value is the final
+ * selection, no operator+value pair is rendered alongside it. Consumed in two places:
+ * - `taxonomicFilterLogic` records key-only selections directly to recents (column / event-name
+ * pickers etc. — see #57309).
+ * - `TaxonomicPropertyFilter` hides the operator+value pair on rows whose group is key-only.
+ * See `SelectingKeyOnly` for the boolean-or-per-group-dict shape. */
+ selectingKeyOnly?: SelectingKeyOnly
}
export interface DataWarehousePopoverField {
diff --git a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.tsx b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.tsx
index 4c7ce53966f9..f8e553f923bf 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditions.tsx
@@ -42,6 +42,7 @@ import {
PropertyOperator,
} from '~/types'
+import { COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS } from './cohortPickerProps'
import { featureFlagLogic } from './featureFlagLogic'
import {
FeatureFlagReleaseConditionsLogicProps,
@@ -389,7 +390,7 @@ export function FeatureFlagReleaseConditions({
})
: null
}
- exactMatchFeatureFlagCohortOperators={true}
+ {...COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS}
hideBehavioralCohorts={!realtimeCohortFlagTargeting}
/>
</div>
diff --git a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx
index 43698e438abd..82ddfd75a2b2 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlagReleaseConditionsCollapsible.tsx
@@ -16,7 +16,7 @@ import React, { useRef, useState } from 'react'
import { v4 as uuidv4 } from 'uuid'
import {
- IconBrackets,
+ IconBalance,
IconCollapse,
IconCopy,
IconEllipsis,
@@ -69,6 +69,7 @@ import {
import { INTENT_METADATA } from 'products/feature_flags/frontend/featureFlagTemplateConstants'
+import { COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS } from './cohortPickerProps'
import { FeatureFlagConditionDragHandle } from './FeatureFlagConditionDragHandle'
import { FeatureFlagConditionWarning } from './FeatureFlagConditionWarning'
import { FlagIntent, featureFlagIntentWarningLogic } from './featureFlagIntentWarningLogic'
@@ -91,18 +92,6 @@ interface FeatureFlagReleaseConditionsCollapsibleProps extends FeatureFlagReleas
hideMatchOptions?: boolean
}
-const PERSON = 'person' as const
-type AggregationValue = number | typeof PERSON
-
-type MatchByOption = {
- value: string
- icon: JSX.Element
- label: string
- description: string
- badge?: { type: 'warning' | 'highlight'; text: string }
- learnMoreUrl?: string
-}
-
function summarizeProperties(properties: AnyPropertyFilter[], aggregationTargetName: string): string {
if (!properties || properties.length === 0) {
// Capitalize first letter of aggregation target name
@@ -312,8 +301,8 @@ interface ConditionProps {
taxonomicGroupTypesForCondition: (conditionGroupTypeIndex: number | null | undefined) => TaxonomicFilterGroupType[]
groupTypes: Map<GroupTypeIndex, GroupType>
setConditionAggregation: (index: number, groupTypeIndex: number | null) => void
- isTargetingV2Enabled: boolean
- isDeviceTargeting: boolean
+ isMixedTargetingEnabled: boolean
+ mixedGroupTypeIndex: number
onMoveUp: () => void
onMoveDown: () => void
onDuplicate: () => void
@@ -381,8 +370,8 @@ const ConditionContent = ({
taxonomicGroupTypesForCondition,
groupTypes,
setConditionAggregation,
- isTargetingV2Enabled,
- isDeviceTargeting,
+ isMixedTargetingEnabled,
+ mixedGroupTypeIndex,
onMoveUp,
onMoveDown,
onDuplicate,
@@ -529,46 +518,39 @@ const ConditionContent = ({
/>
</div>
- {isTargetingV2Enabled && groupTypes.size > 0 && !isDeviceTargeting && (
+ {isMixedTargetingEnabled && groupTypes.size > 0 && (
<div>
- <LemonLabel className="mb-1">Target by</LemonLabel>
- <LemonSelect<AggregationValue>
+ <LemonLabel className="mb-1">Targeting criteria</LemonLabel>
+ <LemonSelect
size="small"
data-attr={`condition-set-${index}-aggregation`}
- value={
- group.aggregation_group_type_index ??
- releaseFilters.aggregation_group_type_index ??
- PERSON
- }
+ value={group.aggregation_group_type_index != null ? 'group' : 'person'}
onChange={(value) => {
- setConditionAggregation(index, value === PERSON ? null : value)
+ setConditionAggregation(
+ index,
+ value === 'person' ? null : mixedGroupTypeIndex
+ )
}}
- options={[
- {
- options: [
- {
- value: PERSON,
- label: 'Users',
- icon: <IconPerson />,
- },
- ],
- },
- {
- title: 'Group types',
- options: Array.from(groupTypes.values()).map((gt) => ({
- value: gt.group_type_index as number,
- label:
- gt.name_plural ||
- gt.group_type.charAt(0).toUpperCase() +
- gt.group_type.slice(1) +
- 's',
- icon: <IconPeople />,
- })),
- },
- ]}
+ options={(() => {
+ const gt = groupTypes.get(mixedGroupTypeIndex as GroupTypeIndex)
+ const groupLabel = gt
+ ? gt.name_plural ||
+ gt.group_type.charAt(0).toUpperCase() +
+ gt.group_type.slice(1) +
+ 's'
+ : 'Groups'
+ return [
+ { value: 'person' as const, label: 'Users' },
+ {
+ value: 'group' as const,
+ label: groupLabel,
+ },
+ ]
+ })()}
/>
</div>
)}
+
<div>
<LemonLabel className="mb-1">Match filters</LemonLabel>
<PropertyFilters
@@ -586,7 +568,7 @@ const ConditionContent = ({
)}
taxonomicFilterOptionsFromProp={filtersTaxonomicOptions}
hasRowOperator={false}
- exactMatchFeatureFlagCohortOperators={true}
+ {...COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS}
hideBehavioralCohorts={!realtimeCohortFlagTargeting}
/>
</div>
@@ -809,15 +791,14 @@ export function FeatureFlagReleaseConditionsCollapsible({
openConditions,
properties,
isMixedTargeting,
+ mixedGroupTypeIndex,
isAnyItemDragging,
draggedGroup,
} = useValues(releaseConditionsLogic)
const { featureFlags } = useValues(featureFlagLogic)
const isDragDropEnabled = !!featureFlags[FEATURE_FLAGS.FEATURE_FLAG_DRAG_DROP_CONDITIONS]
- // The mixed-targeting flag now gates the unified v2 UI (Properties / Device with full per-condition group-type selector).
- // The legacy 4-card path is reached only when the flag is off.
- const isTargetingV2Enabled = !!featureFlags[FEATURE_FLAGS.FEATURE_FLAG_MIXED_TARGETING]
+ const isMixedTargetingEnabled = !!featureFlags[FEATURE_FLAGS.FEATURE_FLAG_MIXED_TARGETING]
// Ref map for focus management
const optionRefs = useRef<Record<string, HTMLDivElement | null>>({})
@@ -837,6 +818,7 @@ export function FeatureFlagReleaseConditionsCollapsible({
setOpenConditions,
setIsMixedTargeting,
switchToMixedTargeting,
+ setMixedGroupTypeIndex,
setIsAnyItemDragging,
setDraggedGroup,
} = useActions(releaseConditionsLogic)
@@ -933,90 +915,18 @@ export function FeatureFlagReleaseConditionsCollapsible({
}
const showGroupsOptions = groupTypes.size > 0
- const isDeviceTargeting = bucketingIdentifier === FeatureFlagBucketingIdentifier.DEVICE_ID
-
- const v2MatchByOptions = [
- {
- value: 'properties',
- icon: <IconBrackets className="text-base shrink-0" />,
- label: 'Properties',
- description: showGroupsOptions
- ? 'Target by user or group property filters. Each condition picks its own targeting type.'
- : 'Target by user property filters.',
- },
- ...(onBucketingIdentifierChange
- ? [
- {
- value: 'device',
- icon: <IconLaptop className="text-base shrink-0" />,
- label: 'Device',
- description: 'Stable assignment per device. Good fit for experiments on anonymous users.',
- badge: { type: 'warning' as const, text: 'BETA' },
- learnMoreUrl: 'https://posthog.com/docs/feature-flags/device-bucketing',
- },
- ]
- : []),
- ] satisfies MatchByOption[]
-
- const legacyMatchByOptions = [
- {
- value: 'user',
- icon: <IconPerson className="text-base shrink-0" />,
- label: 'User',
- description: 'Stable assignment for logged-in users based on their distinct ID.',
- },
- ...(onBucketingIdentifierChange
- ? [
- {
- value: 'device',
- icon: <IconLaptop className="text-base shrink-0" />,
- label: 'Device',
- description: 'Stable assignment per device. Good fit for experiments on anonymous users.',
- badge: { type: 'warning' as const, text: 'BETA' },
- learnMoreUrl: 'https://posthog.com/docs/feature-flags/device-bucketing',
- },
- ]
- : []),
- ...(showGroupsOptions
- ? [
- {
- value: 'group',
- icon: <IconPeople className="text-base shrink-0" />,
- label: 'Group',
- description:
- 'Stable assignment for everyone in an organization, company, or other custom group type.',
- },
- ]
- : []),
- ] satisfies MatchByOption[]
-
- const matchByOptions: MatchByOption[] = isTargetingV2Enabled ? v2MatchByOptions : legacyMatchByOptions
// Compute current selected option (shared between keyboard navigation and selection rendering)
- const currentSelected = isTargetingV2Enabled
- ? isDeviceTargeting && onBucketingIdentifierChange
- ? 'device'
- : 'properties'
+ const currentSelected = isMixedTargeting
+ ? 'mixed'
: releaseFilters.aggregation_group_type_index != null
? 'group'
- : isDeviceTargeting
+ : bucketingIdentifier === FeatureFlagBucketingIdentifier.DEVICE_ID
? 'device'
: 'user'
// Handler for option selection logic (shared by click and keyboard events)
const selectMatchByOption = (value: string): void => {
- if (isTargetingV2Enabled) {
- // v2: Properties subsumes User / Group / User & Group; only bucketing_identifier differs
- if (value === 'properties') {
- onBucketingIdentifierChange?.(FeatureFlagBucketingIdentifier.DISTINCT_ID)
- } else if (value === 'device') {
- // Device mode forces Users-scoped conditions. setAggregationGroupTypeIndex(null)
- // clears any group-scoped conditions and preserves person-scoped properties.
- setAggregationGroupTypeIndex(null)
- onBucketingIdentifierChange?.(FeatureFlagBucketingIdentifier.DEVICE_ID)
- }
- return
- }
if (value === 'user') {
setIsMixedTargeting(false)
setAggregationGroupTypeIndex(null)
@@ -1077,13 +987,12 @@ export function FeatureFlagReleaseConditionsCollapsible({
// Handle arrow key navigation for radio group
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
e.preventDefault()
- const options = isTargetingV2Enabled
- ? ['properties', ...(onBucketingIdentifierChange ? ['device'] : [])]
- : [
- 'user',
- ...(onBucketingIdentifierChange ? ['device'] : []),
- ...(showGroupsOptions ? ['group'] : []),
- ]
+ const options = [
+ 'user',
+ ...(onBucketingIdentifierChange ? ['device'] : []),
+ ...(showGroupsOptions ? ['group'] : []),
+ ...(showGroupsOptions && isMixedTargetingEnabled ? ['mixed'] : []),
+ ]
const currentIndex = options.indexOf(currentSelected)
let nextIndex = currentIndex
@@ -1101,7 +1010,49 @@ export function FeatureFlagReleaseConditionsCollapsible({
}
}}
>
- {matchByOptions.map((option) => {
+ {[
+ {
+ value: 'user',
+ icon: <IconPerson className="text-base shrink-0" />,
+ label: 'User',
+ description: 'Stable assignment for logged-in users based on their distinct ID.',
+ },
+ ...(onBucketingIdentifierChange
+ ? [
+ {
+ value: 'device',
+ icon: <IconLaptop className="text-base shrink-0" />,
+ label: 'Device',
+ description:
+ 'Stable assignment per device. Good fit for experiments on anonymous users.',
+ learnMoreUrl: 'https://posthog.com/docs/feature-flags/device-bucketing',
+ },
+ ]
+ : []),
+ ...(showGroupsOptions
+ ? [
+ {
+ value: 'group',
+ icon: <IconPeople className="text-base shrink-0" />,
+ label: 'Group',
+ description:
+ 'Stable assignment for everyone in an organization, company, or other custom group type.',
+ },
+ ]
+ : []),
+ ...(showGroupsOptions && isMixedTargetingEnabled
+ ? [
+ {
+ value: 'mixed',
+ icon: <IconBalance className="text-base shrink-0" />,
+ label: 'User & Group',
+ description:
+ 'Mix user and group targeting across condition sets. Each condition set picks its own targeting type.',
+ badge: { type: 'highlight' as const, text: 'NEW' },
+ },
+ ]
+ : []),
+ ].map((option) => {
const isSelected = option.value === currentSelected
return (
@@ -1183,6 +1134,29 @@ export function FeatureFlagReleaseConditionsCollapsible({
{groupTypeValues[0]?.group_type}
</span>
))}
+ {/* Mixed group type selector */}
+ {option.value === 'mixed' &&
+ isSelected &&
+ isMixedTargeting &&
+ groupTypeValues.length > 1 && (
+ <div onClick={(e) => e.stopPropagation()}>
+ <LemonSelect
+ size="xsmall"
+ dropdownMatchSelectWidth={false}
+ data-attr="feature-flag-mixed-group-type-select"
+ value={mixedGroupTypeIndex}
+ onChange={(value) => {
+ if (value != null) {
+ setMixedGroupTypeIndex(value)
+ }
+ }}
+ options={groupTypeValues.map((groupType) => ({
+ value: groupType.group_type_index,
+ label: groupType.group_type,
+ }))}
+ />
+ </div>
+ )}
</div>
</div>
)
@@ -1261,8 +1235,8 @@ export function FeatureFlagReleaseConditionsCollapsible({
taxonomicGroupTypesForCondition={taxonomicGroupTypesForCondition}
groupTypes={groupTypes}
setConditionAggregation={setConditionAggregation}
- isTargetingV2Enabled={isTargetingV2Enabled}
- isDeviceTargeting={isDeviceTargeting}
+ isMixedTargetingEnabled={isMixedTargeting}
+ mixedGroupTypeIndex={mixedGroupTypeIndex}
onMoveUp={() => moveConditionSetUp(index)}
onMoveDown={() => moveConditionSetDown(index)}
onDuplicate={() => duplicateConditionSet(index)}
@@ -1335,8 +1309,8 @@ export function FeatureFlagReleaseConditionsCollapsible({
taxonomicGroupTypesForCondition={taxonomicGroupTypesForCondition}
groupTypes={groupTypes}
setConditionAggregation={setConditionAggregation}
- isTargetingV2Enabled={isTargetingV2Enabled}
- isDeviceTargeting={isDeviceTargeting}
+ isMixedTargetingEnabled={isMixedTargeting}
+ mixedGroupTypeIndex={mixedGroupTypeIndex}
onMoveUp={() => moveConditionSetUp(index)}
onMoveDown={() => moveConditionSetDown(index)}
onDuplicate={() => duplicateConditionSet(index)}
@@ -1385,8 +1359,8 @@ export function FeatureFlagReleaseConditionsCollapsible({
taxonomicGroupTypesForCondition={taxonomicGroupTypesForCondition}
groupTypes={groupTypes}
setConditionAggregation={setConditionAggregation}
- isTargetingV2Enabled={isTargetingV2Enabled}
- isDeviceTargeting={isDeviceTargeting}
+ isMixedTargetingEnabled={isMixedTargeting}
+ mixedGroupTypeIndex={mixedGroupTypeIndex}
onMoveUp={() => moveConditionSetUp(index)}
onMoveDown={() => moveConditionSetDown(index)}
onDuplicate={() => duplicateConditionSet(index)}
@@ -1417,8 +1391,8 @@ export function FeatureFlagReleaseConditionsCollapsible({
taxonomicGroupTypesForCondition={taxonomicGroupTypesForCondition}
groupTypes={groupTypes}
setConditionAggregation={setConditionAggregation}
- isTargetingV2Enabled={isTargetingV2Enabled}
- isDeviceTargeting={isDeviceTargeting}
+ isMixedTargetingEnabled={isMixedTargeting}
+ mixedGroupTypeIndex={mixedGroupTypeIndex}
onMoveUp={() => moveConditionSetUp(index)}
onMoveDown={() => moveConditionSetDown(index)}
onDuplicate={() => duplicateConditionSet(index)}
diff --git a/frontend/src/scenes/feature-flags/cohortPickerProps.ts b/frontend/src/scenes/feature-flags/cohortPickerProps.ts
new file mode 100644
index 000000000000..6b5f7ea064fd
--- /dev/null
+++ b/frontend/src/scenes/feature-flags/cohortPickerProps.ts
@@ -0,0 +1,23 @@
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+
+import { PropertyOperator } from '~/types'
+
+/**
+ * Picker props for surfaces where cohort filters are restricted to `in` only —
+ * feature flag release conditions and workflow event triggers. Hides recents
+ * carrying any other cohort operator and renders cohort rows as key-only
+ * (the cohort *is* the value, operator is implicit).
+ *
+ * Three call sites use this preset:
+ * - `FeatureFlagReleaseConditions.tsx`
+ * - `FeatureFlagReleaseConditionsCollapsible.tsx`
+ * - `products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx`
+ *
+ * Spread into `PropertyFilters` / `TaxonomicPropertyFilter` rather than
+ * passing each prop individually so the configuration travels as one named
+ * idea and a future change (e.g. allowing `not_in`) edits one place.
+ */
+export const COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS = {
+ excludedOperators: { [TaxonomicFilterGroupType.Cohorts]: [PropertyOperator.NotIn] },
+ selectingKeyOnly: { [TaxonomicFilterGroupType.Cohorts]: true },
+}
diff --git a/products/llm_analytics/frontend/prompts/llmPromptsLogicType.ts b/products/llm_analytics/frontend/prompts/llmPromptsLogicType.ts
index 403931790046..ba3ed9a0c3da 100644
--- a/products/llm_analytics/frontend/prompts/llmPromptsLogicType.ts
+++ b/products/llm_analytics/frontend/prompts/llmPromptsLogicType.ts
@@ -1,4 +1,4 @@
-// Generated by kea-typegen on Fri, 20 Mar 2026 16:48:32 GMT. DO NOT EDIT THIS FILE MANUALLY.
+// Generated by kea-typegen on Tue, 05 May 2026 14:14:29 GMT. DO NOT EDIT THIS FILE MANUALLY.
import type { Logic } from 'kea'
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx b/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx
index 4b2fb4a42c43..418e54ba2175 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx
@@ -37,6 +37,7 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { humanFriendlyNumber } from 'lib/utils'
import { publicWebhooksHostOrigin } from 'lib/utils/apiHost'
import { createFuse } from 'lib/utils/fuseSearch'
+import { COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS } from 'scenes/feature-flags/cohortPickerProps'
import { TestAccountFilter } from 'scenes/insights/filters/TestAccountFilter/TestAccountFilter'
import { PropertyFilterType } from '~/types'
@@ -553,7 +554,7 @@ function StepTriggerConfigurationBatch({
orFiltering
sendAllKeyUpdates
allowRelativeDateOptions
- exactMatchFeatureFlagCohortOperators
+ {...COHORTS_ONLY_SUPPORT_IN_PICKER_PROPS}
hideBehavioralCohorts
logicalRowDivider
onChange={(properties) =>