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(flags): hide $feature_flag_called from query builders (#92840)

Phil Haackb6edae14019f
diff --git a/frontend/src/lib/components/IngestionControls/triggers/EventTrigger.tsx b/frontend/src/lib/components/IngestionControls/triggers/EventTrigger.tsx
index a3f3c13f4088..6f301cd855a6 100644
--- a/frontend/src/lib/components/IngestionControls/triggers/EventTrigger.tsx
+++ b/frontend/src/lib/components/IngestionControls/triggers/EventTrigger.tsx
@@ -39,6 +39,8 @@ export function EventTriggerSelect({
[TaxonomicFilterGroupType.Events]: [null], // This will hide "All events"
}}
taxonomicGroupTypes={[TaxonomicFilterGroupType.Events]}
+ // Chooses which live events to act on rather than saving a query.
+ includeHiddenEvents
/>
}
>
diff --git a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
index 42bf6969825e..578f7cec6356 100644
--- a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
@@ -31,6 +31,7 @@ import {
TaxonomicFilterGroupType,
TaxonomicFilterGroupValueMap,
} from 'lib/components/TaxonomicFilter/types'
+import { hiddenEventMatchingSearch } from 'lib/components/TaxonomicFilter/utils/hiddenEvents'
import { dayjs } from 'lib/dayjs'
import { LemonRow } from 'lib/lemon-ui/LemonRow'
import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
@@ -744,6 +745,17 @@ function InfiniteListEmptyState(): JSX.Element {
(infiniteListResultCounts[groupType] ?? 0) > 0
)
: []
+
+ // Reads the Events group rather than this list's own group: in the pill variant the active tab is
+ // the aggregated one, which carries no exclusions of its own. `taxonomicGroups` holds every group
+ // whether or not this filter offers it, hence the gate.
+ const hiddenEventSearched = taxonomicGroupTypes.includes(TaxonomicFilterGroupType.Events)
+ ? hiddenEventMatchingSearch(
+ searchQuery,
+ taxonomicGroups.find((g) => g.type === TaxonomicFilterGroupType.Events)?.excludedProperties
+ )
+ : null
+
return (
<div className="no-infinite-results flex flex-col gap-y-1 items-center">
{suggestedFiltersBeforeSearching ? (
@@ -763,6 +775,21 @@ function InfiniteListEmptyState(): JSX.Element {
Type at least {minSearchQueryLength} characters to search
</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
+ // the answer.
+ <div className="flex flex-col gap-y-1 items-center" data-attr="taxonomic-hidden-event">
+ <IconArchive className="text-5xl text-tertiary" />
+ <span className="text-center">
+ <strong>{hiddenEventSearched}</strong> isn't available here
+ </span>
+ <span className="max-w-80 text-center text-secondary">
+ PostHog still collects this event, but you can't build a saved query on it. Its data is moving,
+ so a saved query would stop returning results. To see how a flag is used, open the flag and
+ check its Usage tab.
+ </span>
+ </div>
) : (
<>
<IconArchive className="text-5xl text-tertiary" />
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
index 2918c46a1fa2..627712d2c4fa 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
@@ -435,6 +435,91 @@ describe('TaxonomicFilter', () => {
// ...but the render-backed SQL expression tab is not.
expect(screen.queryByTestId('taxonomic-switch-to-hogql_expression')).not.toBeInTheDocument()
})
+
+ // Searching an event this picker hides has to say so. Dropping it from the list and then
+ // reporting "no results" tells someone who knows the event exists that it never did.
+ // The rebuild's half of this lives in menu/Combobox.test.tsx.
+ describe('an event hidden because its data is moving', () => {
+ let unmountFeatureFlagLogic: (() => void) | null = null
+
+ beforeEach(() => {
+ unmountFeatureFlagLogic = featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS], {
+ [FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS]: true,
+ })
+ })
+
+ afterEach(() => {
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ unmountFeatureFlagLogic?.()
+ unmountFeatureFlagLogic = null
+ })
+
+ it('explains the absence instead of reporting no results', async () => {
+ renderFilter({ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events] })
+
+ await activateGroupWithResults('taxonomic-tab-events')
+ await withoutDebounceDelay((user) =>
+ user.type(screen.getByTestId('taxonomic-filter-searchfield'), '$feature_flag_called')
+ )
+
+ await waitFor(() => {
+ expect(inVisibleTab(screen.getAllByTestId('taxonomic-hidden-event'))).toBeTruthy()
+ })
+ expect(screen.queryByText(/No results for/)).not.toBeInTheDocument()
+ })
+
+ // The aggregated tab's own group carries no exclusions, so reading the active list's
+ // group instead of the Events group leaves this arm silent.
+ it('explains it on the aggregated tab too', async () => {
+ renderFilter({
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.SuggestedFilters,
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.PersonProperties,
+ ],
+ })
+
+ // Real timers: SuggestedFilters is present, see the sibling tests above.
+ await userEvent.type(screen.getByTestId('taxonomic-filter-searchfield'), '$feature_flag_called')
+
+ await waitFor(() => {
+ expect(inVisibleTab(screen.getAllByTestId('taxonomic-hidden-event'))).toBeTruthy()
+ })
+ })
+
+ it('reports no results as usual once the kill switch is off', async () => {
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ renderFilter({ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events] })
+
+ await activateGroupWithResults('taxonomic-tab-events')
+ await withoutDebounceDelay((user) =>
+ user.type(screen.getByTestId('taxonomic-filter-searchfield'), '$feature_flag_called')
+ )
+
+ await waitFor(() => {
+ expect(inVisibleTab(screen.getAllByText(/No results for/))).toBeTruthy()
+ })
+ expect(screen.queryByTestId('taxonomic-hidden-event')).not.toBeInTheDocument()
+ })
+
+ // A picker on a live-event surface (the survey and product-tour event triggers, live
+ // events, ingestion triggers) opts in with `includeHiddenEvents`, so the flag must not
+ // hide the event or explain an absence there.
+ it('keeps offering the event when the picker opts in', async () => {
+ renderFilter({ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events], includeHiddenEvents: true })
+
+ await activateGroupWithResults('taxonomic-tab-events')
+ await withoutDebounceDelay((user) =>
+ user.type(screen.getByTestId('taxonomic-filter-searchfield'), '$feature_flag_called')
+ )
+
+ await waitFor(() => {
+ expect(inVisibleTab(screen.getAllByText(/No results for/))).toBeTruthy()
+ })
+ expect(screen.queryByTestId('taxonomic-hidden-event')).not.toBeInTheDocument()
+ })
+ })
})
describe('tab switching', () => {
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx
index 5bcb0e7dbc9f..6fa956cf3328 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx
@@ -40,6 +40,7 @@ export function TaxonomicFilter({
height,
width,
excludedProperties,
+ includeHiddenEvents,
selectedProperties,
popoverEnabled = true,
selectFirstItem = true,
@@ -88,6 +89,7 @@ export function TaxonomicFilter({
popoverEnabled,
selectFirstItem,
excludedProperties,
+ includeHiddenEvents,
selectedProperties,
metadataSource,
propertyAllowList,
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.test.tsx
index 69b5ba1edaa9..cbc5aad869be 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.test.tsx
@@ -2,6 +2,9 @@ import { act, cleanup, renderHook } from '@testing-library/react'
import { Provider } from 'kea'
import { ReactNode } from 'react'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+
import { useMocks } from '~/mocks/jest'
import { actionsModel } from '~/models/actionsModel'
import { groupsModel } from '~/models/groupsModel'
@@ -43,6 +46,40 @@ describe('useTaxonomicFilter', () => {
afterEach(() => cleanup())
+ // Nothing enforces parity between the legacy logic and this rebuild, so the same rule is asserted
+ // on both. The legacy half lives in taxonomicFilterLogic.test.ts.
+ describe('events whose data is moving out of the events table', () => {
+ const HIDDEN_EVENT = '$feature_flag_called'
+
+ const renderFilter = (input: Record<string, any> = {}): ReturnType<typeof useTaxonomicFilter> => {
+ featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS]: true })
+ const { result } = renderHook(
+ () => useTaxonomicFilter({ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events], ...input }),
+ { wrapper }
+ )
+ return result.current
+ }
+
+ const eventsGroupExclusions = (input: Record<string, any> = {}): (string | null)[] =>
+ renderFilter(input).groups.find((g) => g.type === TaxonomicFilterGroupType.Events)?.excludedProperties ?? []
+
+ it('hides them by default', () => {
+ expect(eventsGroupExclusions()).toContain(HIDDEN_EVENT)
+ })
+
+ it('offers them to a picker that opts out', () => {
+ expect(eventsGroupExclusions({ includeHiddenEvents: true })).not.toContain(HIDDEN_EVENT)
+ })
+
+ // The Recent and Pinned tabs and the menu shortcut rows filter against this record rather
+ // than the group's own list, so a pin saved before the event was hidden only drops if the
+ // names reach here too.
+ it('folds them into the record the Recent and Pinned surfaces read', () => {
+ expect(renderFilter().excludedProperties?.[TaxonomicFilterGroupType.Events]).toContain(HIDDEN_EVENT)
+ })
+ })
+
it('exposes groups in the consumer-requested order, with Recent/Pinned auto-injected', () => {
const { result } = renderHook(
() =>
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
index 1f1944c285d7..1aa2d18a34da 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
@@ -21,6 +21,7 @@
* and `taxonomicFilterPinnedPropertiesLogic`; the orchestrator only reads
* them via the bridge, doesn't write)
*/
+import { useValues } from 'kea'
import { useCallback, useMemo, useRef, useState } from 'react'
import {
@@ -44,6 +45,8 @@ import {
import { isQuickFilterItem } from 'lib/components/TaxonomicFilter/types'
import { buildTaxonomicGroups } from 'lib/components/TaxonomicFilter/utils/buildTaxonomicGroups'
import { isContainsShortcutItem } from 'lib/components/TaxonomicFilter/utils/collapsedContainsRow'
+import { withHiddenEventsExcluded } from 'lib/components/TaxonomicFilter/utils/hiddenEvents'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { MaxContextTaxonomicFilterOption } from 'scenes/max/maxTypes'
import { teamLogic } from 'scenes/teamLogic'
@@ -76,6 +79,8 @@ export interface UseTaxonomicFilterOptions {
metadataSource?: AnyDataNode
suggestedFiltersLabel?: string
excludedProperties?: ExcludedProperties
+ /** Keep offering events whose data is moving out of the `events` table. See `TaxonomicFilterProps`. */
+ includeHiddenEvents?: boolean
selectedProperties?: SelectedProperties
propertyAllowList?: AllowedProperties
maxContextOptions?: MaxContextTaxonomicFilterOption[]
@@ -278,7 +283,8 @@ export function useTaxonomicFilter(opts: UseTaxonomicFilterOptions): TaxonomicFi
schemaColumnsLoading,
metadataSource,
suggestedFiltersLabel,
- excludedProperties,
+ excludedProperties: callerExcludedProperties,
+ includeHiddenEvents,
selectedProperties,
propertyAllowList,
maxContextOptions,
@@ -297,6 +303,14 @@ export function useTaxonomicFilter(opts: UseTaxonomicFilterOptions): TaxonomicFi
excludedOperators,
} = opts
+ const { featureFlags } = useValues(featureFlagLogic)
+ // Every surface below reads exclusions from this one record: the group builder, the Recent and
+ // Pinned tabs, and the menu's shortcut rows. Folding the hidden names in here reaches all of them.
+ const excludedProperties = useMemo(
+ () => withHiddenEventsExcluded(callerExcludedProperties, featureFlags, includeHiddenEvents),
+ [callerExcludedProperties, featureFlags, includeHiddenEvents]
+ )
+
const ctx = useTaxonomicGroupsContext({
eventNames,
taxonomicGroupTypes,
@@ -305,6 +319,7 @@ export function useTaxonomicFilter(opts: UseTaxonomicFilterOptions): TaxonomicFi
metadataSource,
suggestedFiltersLabel,
excludedProperties,
+ includeHiddenEvents,
propertyAllowList,
selectedProperties,
maxContextOptions,
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts
index ddc21f7a645e..feb877e0156e 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicGroupsContext.ts
@@ -49,6 +49,8 @@ export interface UseTaxonomicGroupsContextInput {
metadataSource?: AnyDataNode
suggestedFiltersLabel?: string
excludedProperties?: ExcludedProperties
+ /** Keep offering events whose data is moving out of the `events` table. See `TaxonomicFilterProps`. */
+ includeHiddenEvents?: boolean
propertyAllowList?: AllowedProperties
selectedProperties?: SelectedProperties
maxContextOptions?: MaxContextTaxonomicFilterOption[]
@@ -153,6 +155,7 @@ export function useTaxonomicGroupsContext(input: UseTaxonomicGroupsContextInput)
// `Record<string, boolean | string | undefined>` the
// taxonomic-groups builder accepts.
featureFlags: featureFlags as unknown as BuildTaxonomicGroupsContext['featureFlags'],
+ includeHiddenEvents: input.includeHiddenEvents,
}
}, [
currentTeam,
@@ -175,6 +178,7 @@ export function useTaxonomicGroupsContext(input: UseTaxonomicGroupsContextInput)
input.metadataSource,
input.suggestedFiltersLabel,
input.excludedProperties,
+ input.includeHiddenEvents,
input.propertyAllowList,
input.maxContextOptions,
input.hideBehavioralCohorts,
diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts
index 6af77dd5c95e..eeddf816fceb 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'
@@ -916,6 +918,31 @@ describe('infiniteListLogic', () => {
})
})
+ describe('events a picker excludes', () => {
+ const HIDDEN_EVENT = '$feature_flag_called'
+
+ afterEach(() => {
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ })
+
+ // The Pinned and Recent tabs filter against the caller's record rather than the Events
+ // group's own list, so the hidden names have to reach that record for a pin saved before
+ // the event was hidden to drop.
+ it('folds the hidden names into the record the Recent and Pinned tabs read', () => {
+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS]: true })
+ const listLogic = infiniteListLogic({
+ taxonomicFilterLogicKey: 'hidden-events',
+ listGroupType: TaxonomicFilterGroupType.Events,
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events],
+ showNumericalPropsOnly: false,
+ })
+ listLogic.mount()
+ expect(listLogic.values.excludedPropertiesWithHiddenEvents?.[TaxonomicFilterGroupType.Events]).toContain(
+ HIDDEN_EVENT
+ )
+ })
+ })
+
// Transformation filters exclude `$exception` while allowing uncaptured events, so an excluded
// name must never be offered as "not seen yet".
describe('the "not seen yet" option and excluded names', () => {
@@ -943,6 +970,36 @@ describe('infiniteListLogic', () => {
})
})
+ // A hidden event is excluded by its label and case variants, not just its raw name, so a picker
+ // that allows uncaptured events must not offer any of those forms as "not seen yet" — that would
+ // commit a name no event carries and hide the explanation of the event's absence.
+ describe('the "not seen yet" option and hidden events', () => {
+ afterEach(() => {
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ })
+
+ it.each([['$feature_flag_called'], ['$FEATURE_FLAG_CALLED'], ['Feature flag called']])(
+ 'does not offer the option when searching %p',
+ async (query) => {
+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS]: true })
+ const listLogic = infiniteListLogic({
+ taxonomicFilterLogicKey: `hidden-not-seen-${query}`,
+ listGroupType: TaxonomicFilterGroupType.Events,
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events],
+ showNumericalPropsOnly: false,
+ allowNonCapturedEvents: true,
+ })
+ listLogic.mount()
+
+ await expectLogic(listLogic, () => {
+ listLogic.actions.setSearchQuery(query)
+ })
+ .toFinishAllListeners()
+ .toMatchValues({ showNonCapturedEventOption: false })
+ }
+ )
+ })
+
describe('data warehouse pin lifecycle', () => {
beforeEach(() => {
const databaseLogic = databaseTableListLogic()
diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
index 334a3e18c53e..b737ed09b3d9 100644
--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
@@ -58,12 +58,14 @@ import {
recentSourceKey,
} from 'lib/components/TaxonomicFilter/utils/floatRecentPinned'
import { floatToFront } from 'lib/components/TaxonomicFilter/utils/floatToFront'
+import { hiddenEventMatchingSearch, withHiddenEventsExcluded } from 'lib/components/TaxonomicFilter/utils/hiddenEvents'
import { promoteMatchingProperties } from 'lib/components/TaxonomicFilter/utils/promoteProperties'
import {
filterPinnedForContext,
filterRecentsForContext,
} from 'lib/components/TaxonomicFilter/utils/suggestedContextFilters'
import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { createFuse } from 'lib/utils/fuseSearch'
import { mapGroupQueryResponse } from 'lib/utils/groups'
@@ -71,6 +73,7 @@ import { getCoreFilterDefinition } from '~/taxonomy/helpers'
import { CohortType, EventDefinition, GroupTypeIndex, PropertyType } from '~/types'
import { teamLogic } from '../../../scenes/teamLogic'
+import type { FeatureFlagsSet } from '../../logic/featureFlagLogic'
import { getItemGroup } from './InfiniteList'
import type { SelectItemMeta, TopMatchItem } from './taxonomicFilterLogic'
@@ -255,6 +258,7 @@ async function fetchCachedListResponse(
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface infiniteListLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
recentFilterItems: TaxonomicDefinitionTypes[] // recentTaxonomicFiltersLogic
activeTab: TaxonomicFilterGroupType // taxonomicFilterLogic
anyGroupLoading: boolean // taxonomicFilterLogic
@@ -273,6 +277,7 @@ export interface infiniteListLogicValues {
contextFilteredRecentItems: TaxonomicDefinitionTypes[]
dedupedTopMatches: (SkeletonItem | TaxonomicDefinitionTypes)[]
excludedProperties: string[] | undefined
+ excludedPropertiesWithHiddenEvents: ExcludedProperties | undefined
expandedCount: number
expandedCountResult: {
count: number
@@ -543,17 +548,26 @@ export interface infiniteListLogicMeta {
isSuggestedFilters: (listGroupType: TaxonomicFilterGroupType) => boolean
trimmedSearchQuery: (searchQuery: string) => string
isActiveTab: (listGroupType: TaxonomicFilterGroupType, activeTab: TaxonomicFilterGroupType) => boolean
+ excludedPropertiesWithHiddenEvents: (
+ arg: import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap | undefined,
+ featureFlags: FeatureFlagsSet,
+ arg2: boolean | undefined
+ ) => ExcludedProperties | undefined
contextFilteredRecentItems: (
recentFilterItems: TaxonomicDefinitionTypes[],
taxonomicGroupTypes: TaxonomicFilterGroupType[],
arg: ExcludedOperators | undefined,
arg2: SelectingKeyOnly | undefined,
- arg3: import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap | undefined
+ excludedPropertiesWithHiddenEvents:
+ | import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap
+ | undefined
) => TaxonomicDefinitionTypes[]
contextFilteredPinnedItems: (
pinnedFilterItems: TaxonomicDefinitionTypes[],
taxonomicGroupTypes: TaxonomicFilterGroupType[],
- arg: import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap | undefined
+ excludedPropertiesWithHiddenEvents:
+ | import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap
+ | undefined
) => TaxonomicDefinitionTypes[]
isSoleSubstantiveGroup: (
listGroupType: TaxonomicFilterGroupType,
@@ -819,6 +833,8 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
['recentFilterItems'],
taxonomicFilterPinnedPropertiesLogic,
['pinnedFilterItems'],
+ featureFlagLogic,
+ ['featureFlags'],
],
actions: [
taxonomicFilterLogic(props),
@@ -1116,13 +1132,28 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
(listGroupType: TaxonomicFilterGroupType, activeTab: TaxonomicFilterGroupType): boolean =>
listGroupType === activeTab,
],
+ // The Recent and Pinned tabs filter against the caller's record, so the names the Events
+ // group hides from its own option list have to be folded in for them to drop too.
+ excludedPropertiesWithHiddenEvents: [
+ (s) => [
+ (_, props: InfiniteListLogicProps) => props.excludedProperties,
+ s.featureFlags,
+ (_, props: InfiniteListLogicProps) => props.includeHiddenEvents,
+ ],
+ (
+ excludedProperties: ExcludedProperties | undefined,
+ featureFlags: FeatureFlagsSet,
+ includeHiddenEvents: boolean | undefined
+ ): ExcludedProperties | undefined =>
+ withHiddenEventsExcluded(excludedProperties, featureFlags, includeHiddenEvents),
+ ],
contextFilteredRecentItems: [
(s) => [
s.recentFilterItems,
s.taxonomicGroupTypes,
(_, props: InfiniteListLogicProps) => props.excludedOperators,
(_, props: InfiniteListLogicProps) => props.selectingKeyOnly,
- (_, props: InfiniteListLogicProps) => props.excludedProperties,
+ s.excludedPropertiesWithHiddenEvents,
],
(
recentFilterItems: TaxonomicDefinitionTypes[],
@@ -1140,11 +1171,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
),
],
contextFilteredPinnedItems: [
- (s) => [
- s.pinnedFilterItems,
- s.taxonomicGroupTypes,
- (_, props: InfiniteListLogicProps) => props.excludedProperties,
- ],
+ (s) => [s.pinnedFilterItems, s.taxonomicGroupTypes, s.excludedPropertiesWithHiddenEvents],
(
pinnedFilterItems: TaxonomicDefinitionTypes[],
taxonomicGroupTypes: TaxonomicFilterGroupType[],
@@ -1296,8 +1323,14 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
return false
}
// Offering an excluded name would let it be selected as a non-captured event,
- // committing the value the exclusion forbids.
- if (excludedProperties?.includes(trimmedSearch)) {
+ // committing the value the exclusion forbids. A hidden event is excluded by its
+ // label and case variants too, so match it the same way the empty state does —
+ // otherwise a label search offers a "not seen yet" row for a name no event carries
+ // and suppresses the explanation of the event's absence.
+ if (
+ excludedProperties?.includes(trimmedSearch) ||
+ hiddenEventMatchingSearch(searchQuery, excludedProperties)
+ ) {
return false
}
// Keyword-shortcut QuickFilterItems don't represent captured events — ignore them
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
index e19f7c143d61..e411acffbbf3 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
@@ -5,6 +5,9 @@ import userEvent from '@testing-library/user-event'
import { Provider } from 'kea'
import { useState } from 'react'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+
import { useMocks } from '~/mocks/jest'
import { actionsModel } from '~/models/actionsModel'
import { groupsModel } from '~/models/groupsModel'
@@ -1116,6 +1119,50 @@ describe('MenuFilterCombobox', () => {
expect(screen.queryByText('Check for results in other categories')).not.toBeInTheDocument()
})
+ // Parity with the legacy picker, whose half lives in TaxonomicFilter.test.tsx. Nothing enforces
+ // that the two agree, so the same rule is asserted on both.
+ describe('an event hidden because its data is moving', () => {
+ let unmountFeatureFlagLogic: (() => void) | null = null
+
+ beforeEach(() => {
+ apiGet.mockResolvedValue({ results: [], count: 0 })
+ unmountFeatureFlagLogic = featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS], {
+ [FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS]: true,
+ })
+ })
+
+ afterEach(() => {
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ unmountFeatureFlagLogic?.()
+ unmountFeatureFlagLogic = null
+ })
+
+ it('explains the absence, and drops recovery buttons that cannot recover it', async () => {
+ renderAll({
+ groupTypes: [TaxonomicFilterGroupType.Events],
+ searchQuery: '$feature_flag_called',
+ })
+
+ const empty = await waitFor(() => screen.getByTestId('menu-filter-empty'))
+ expect(within(empty).getByText(/\$feature_flag_called isn't available here/)).toBeInTheDocument()
+ expect(screen.queryByTestId('menu-filter-include-stale-events')).not.toBeInTheDocument()
+ expect(screen.queryByTestId('menu-filter-check-other-categories')).not.toBeInTheDocument()
+ })
+
+ it('reports no matches as usual once the kill switch is off', async () => {
+ featureFlagLogic.actions.setFeatureFlags([], {})
+
+ renderAll({
+ groupTypes: [TaxonomicFilterGroupType.Events],
+ searchQuery: '$feature_flag_called',
+ })
+
+ const empty = await waitFor(() => screen.getByTestId('menu-filter-empty'))
+ expect(within(empty).queryByText(/isn't available here/)).not.toBeInTheDocument()
+ })
+ })
+
describe('reveal barrier', () => {
it('waits for contributing categories but not their full expansion counts', async () => {
let resolveProperties!: (value: { results: { id: number; name: string }[]; count: number }) => void
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
index 3de8b8d6cbdb..2a2231fbf04c 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
@@ -56,6 +56,7 @@ import {
urlContainsRowLabel,
} from '../utils/collapsedContainsRow'
import { floatToFront } from '../utils/floatToFront'
+import { hiddenEventMatchingSearch } from '../utils/hiddenEvents'
import { promoteMatchingBy } from '../utils/promoteProperties'
import { MenuFilterHeader } from './Header'
import { MatchedValueBadge } from './MatchedValueBadge'
@@ -742,6 +743,20 @@ export function MenuFilterCombobox({
body: `Type at least ${minLen} characters to search ${description} we have seen.`,
}
}
+ // `groups` is already narrowed to the tabs this filter offers, so no group-type gate is
+ // needed here, unlike the mirror of this branch in InfiniteList.tsx.
+ const hiddenEventSearched = hiddenEventMatchingSearch(
+ searchQuery,
+ groups.find((g) => g.type === TaxonomicFilterGroupType.Events)?.excludedProperties
+ )
+ if (hiddenEventSearched) {
+ // `body` is load-bearing, not decoration: the recovery buttons below render only when it
+ // is absent, and neither of them can bring back an excluded name.
+ return {
+ title: `${hiddenEventSearched} isn't available here`,
+ body: "PostHog still collects this event, but you can't build a saved query on it. Its data is moving, so a saved query would stop returning results. To see how a flag is used, open the flag and check its Usage tab.",
+ }
+ }
const categoryLabel = singleGroup?.name ?? null
if (trimmedLen > 0) {
return {
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
index edffd4bdca0f..582aff2345b5 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
@@ -950,6 +950,51 @@ describe('taxonomicFilterLogic', () => {
)
})
+ describe('events whose data is moving out of the events table', () => {
+ const HIDDEN_EVENT = '$feature_flag_called'
+
+ afterEach(() => {
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ })
+
+ const eventsGroupExclusions = (props: Record<string, any>): (string | null)[] => {
+ featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS]: true,
+ })
+ const testLogic = taxonomicFilterLogic({
+ taxonomicFilterLogicKey: `hidden-events-${JSON.stringify(props)}`,
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events],
+ ...props,
+ })
+ testLogic.mount()
+ const exclusions =
+ testLogic.values.taxonomicGroups.find((g) => g.type === TaxonomicFilterGroupType.Events)
+ ?.excludedProperties ?? []
+ testLogic.unmount()
+ return exclusions
+ }
+
+ // Hiding is the picker's default, so a picker added later is covered without having to know
+ // about any of this. Surfaces that read live data opt back in explicitly.
+ it('hides them by default', () => {
+ expect(eventsGroupExclusions({})).toContain(HIDDEN_EVENT)
+ })
+
+ it('offers them to a picker that opts out', () => {
+ expect(eventsGroupExclusions({ includeHiddenEvents: true })).not.toContain(HIDDEN_EVENT)
+ })
+
+ // Cohorts exclude "All events" and transformations exclude $exception; adding ours must not
+ // drop either.
+ it("keeps the picker's own exclusions", () => {
+ const exclusions = eventsGroupExclusions({
+ excludedProperties: { [TaxonomicFilterGroupType.Events]: [null, '$exception'] },
+ })
+ expect(exclusions).toContain('$exception')
+ expect(exclusions).toContain(HIDDEN_EVENT)
+ })
+ })
+
describe('SuggestedFilters presence by variant', () => {
afterEach(() => {
featureFlagLogic.actions.setFeatureFlags([], {
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 4dbeade1cab0..552cbfea58f6 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -50,6 +50,7 @@ import {
TaxonomicFilterValue,
isQuickFilterItem,
} from 'lib/components/TaxonomicFilter/types'
+import { hiddenEventNames } from 'lib/components/TaxonomicFilter/utils/hiddenEvents'
import {
MCP_TOOL_CALL_EVENT,
MCP_TOOL_CALL_SUGGESTED_PROPERTIES,
@@ -563,6 +564,7 @@ export interface taxonomicFilterLogicValues {
propertyAllowList: TaxonomicFilterGroupValueMap | undefined
propertyFilters: {
excludedProperties: TaxonomicFilterGroupValueMap
+ includeHiddenEvents: boolean | undefined
propertyAllowList: TaxonomicFilterGroupValueMap | undefined
}
redistributedTopMatchItems: TopMatchItem[]
@@ -682,9 +684,11 @@ export interface taxonomicFilterLogicMeta {
propertyAllowList: (arg: any) => TaxonomicFilterGroupValueMap | undefined
propertyFilters: (
excludedProperties: TaxonomicFilterGroupValueMap,
- propertyAllowList: TaxonomicFilterGroupValueMap | undefined
+ propertyAllowList: TaxonomicFilterGroupValueMap | undefined,
+ arg: any
) => {
excludedProperties: TaxonomicFilterGroupValueMap
+ includeHiddenEvents: boolean | undefined
propertyAllowList: TaxonomicFilterGroupValueMap | undefined
}
allowNonCapturedEvents: (arg: any) => boolean
@@ -720,6 +724,7 @@ export interface taxonomicFilterLogicMeta {
suggestedFiltersLabel: any,
propertyFilters: {
excludedProperties: TaxonomicFilterGroupValueMap
+ includeHiddenEvents: boolean | undefined
propertyAllowList: TaxonomicFilterGroupValueMap | undefined
},
metadataPropertyDefinitionsByType: {
@@ -1048,14 +1053,16 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
(propertyAllowList) => propertyAllowList as TaxonomicFilterLogicProps['propertyAllowList'],
{ resultEqualityCheck: objectsEqual },
],
+ // Combined so `taxonomicGroups` stays under kea's 16-dep tuple type limit.
propertyFilters: [
- (s) => [s.excludedProperties, s.propertyAllowList],
+ (s) => [s.excludedProperties, s.propertyAllowList, (_, props) => props.includeHiddenEvents],
(
excludedProperties: import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap,
propertyAllowList:
| import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap
- | undefined
- ) => ({ excludedProperties, propertyAllowList }),
+ | undefined,
+ includeHiddenEvents: boolean | undefined
+ ) => ({ excludedProperties, propertyAllowList, includeHiddenEvents }),
{ resultEqualityCheck: objectsEqual },
],
allowNonCapturedEvents: [
@@ -1129,6 +1136,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
propertyAllowList:
| import('lib/components/TaxonomicFilter/types').TaxonomicFilterGroupValueMap
| undefined
+ includeHiddenEvents: boolean | undefined
},
{
event: eventMetadataPropertyDefinitions,
@@ -1149,7 +1157,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
const { eventNames, primaryPropertiesForContextEvents, mcpExcludedEventProperties } =
eventNamesWithPrimaryProperties
const { id: teamId } = currentTeam
- const { excludedProperties, propertyAllowList } = propertyFilters
+ const { excludedProperties, propertyAllowList, includeHiddenEvents } = propertyFilters
const groups: TaxonomicFilterGroup[] = [
{
name: 'Events',
@@ -1162,8 +1170,10 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
event_type: EventDefinitionType.Event,
exclude_hidden: true,
}).url,
- excludedProperties:
- excludedProperties?.[TaxonomicFilterGroupType.Events]?.filter(isString) ?? [],
+ excludedProperties: [
+ ...(excludedProperties?.[TaxonomicFilterGroupType.Events]?.filter(isString) ?? []),
+ ...hiddenEventNames(featureFlags, includeHiddenEvents),
+ ],
...withKeywordShortcuts<Record<string, any>>(
{
getName: (eventDefinition) => eventDefinition.name,
diff --git a/frontend/src/lib/components/TaxonomicFilter/types.ts b/frontend/src/lib/components/TaxonomicFilter/types.ts
index 143e1d203423..454aa107dbec 100644
--- a/frontend/src/lib/components/TaxonomicFilter/types.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/types.ts
@@ -141,6 +141,12 @@ export interface TaxonomicFilterProps {
autoSelectItem?: boolean
/** use to filter results in a group by name, currently only working for EventProperties */
excludedProperties?: ExcludedProperties
+ /**
+ * Keep offering events whose data is moving out of the `events` table. Set it where the surface
+ * still needs such an event: it reads live capture, or it measures experiment exposure. Leave it
+ * unset everywhere else, so a picker stops saving queries that return nothing once the data moves.
+ */
+ includeHiddenEvents?: boolean
/** use to indicate if a result in a group is selected */
selectedProperties?: SelectedProperties
propertyAllowList?: AllowedProperties // only return properties in this list, currently only working for EventProperties and PersonProperties
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
index 251740bf413f..5170d97e38a6 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 { hiddenEventNames } from 'lib/components/TaxonomicFilter/utils/hiddenEvents'
import { withKeywordShortcuts } from 'lib/components/TaxonomicFilter/utils/keywordShortcuts'
import {
MCP_TOOL_CALL_EVENT,
@@ -173,6 +174,8 @@ export interface BuildTaxonomicGroupsContext {
showBreakdownLabelHint: boolean
}
featureFlags: Record<string, boolean | string | undefined>
+ /** Keep offering events whose data is moving out of the `events` table. See `TaxonomicFilterProps`. */
+ includeHiddenEvents?: boolean
}
export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): TaxonomicFilterGroup[] {
@@ -195,6 +198,7 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
endpointFilters,
hogQLExpressionComponentProps,
featureFlags,
+ includeHiddenEvents,
} = ctx
const { id: teamId } = currentTeam
const { excludedProperties, propertyAllowList } = propertyFilters
@@ -215,7 +219,15 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
event_type: EventDefinitionType.Event,
exclude_hidden: true,
}).url,
- excludedProperties: excludedProperties?.[TaxonomicFilterGroupType.Events]?.filter(isString) ?? [],
+ // The caller's record already carries the hidden names. Appending them again keeps the
+ // group hiding them even if some future caller passes a record that skipped the fold,
+ // and the set drops the repeat so it stays out of `useGroupList`'s cache key.
+ excludedProperties: [
+ ...new Set([
+ ...(excludedProperties?.[TaxonomicFilterGroupType.Events]?.filter(isString) ?? []),
+ ...hiddenEventNames(featureFlags, includeHiddenEvents),
+ ]),
+ ],
...withKeywordShortcuts<Record<string, any>>(
{
getName: (eventDefinition) => eventDefinition.name,
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/hiddenEvents.test.ts b/frontend/src/lib/components/TaxonomicFilter/utils/hiddenEvents.test.ts
new file mode 100644
index 000000000000..7232822d5b92
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/hiddenEvents.test.ts
@@ -0,0 +1,67 @@
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import {
+ hiddenEventMatchingSearch,
+ hiddenEventNames,
+ withHiddenEventsExcluded,
+} from 'lib/components/TaxonomicFilter/utils/hiddenEvents'
+import { FEATURE_FLAGS } from 'lib/constants'
+
+const FLAG_ON = { [FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS]: true }
+const FLAG_OFF = {}
+
+describe('events hidden from query builders', () => {
+ // The whole feature keys off this taxonomy entry.
+ it('hides $feature_flag_called while the kill switch is on', () => {
+ expect(hiddenEventNames(FLAG_ON)).toContain('$feature_flag_called')
+ })
+
+ it.each([
+ ['the kill switch is off', FLAG_OFF, undefined],
+ // Pickers that read live event data, and the experiment exposure pickers, opt back in.
+ ['the picker opts out', FLAG_ON, true],
+ ])('hides nothing when %s', (_label, featureFlags, includeHiddenEvents) => {
+ expect(hiddenEventNames(featureFlags, includeHiddenEvents)).toEqual([])
+ })
+
+ describe('withHiddenEventsExcluded', () => {
+ // Cohort pickers exclude "All events" as null, so appending must not replace what came in.
+ it('adds the hidden names to the Events group and keeps the ones the caller passed', () => {
+ const merged = withHiddenEventsExcluded({ [TaxonomicFilterGroupType.Events]: [null] }, FLAG_ON)
+ expect(merged?.[TaxonomicFilterGroupType.Events]).toEqual([null, '$feature_flag_called'])
+ })
+
+ it('leaves the record alone while the kill switch is off', () => {
+ const merged = withHiddenEventsExcluded({ [TaxonomicFilterGroupType.Events]: [null] }, FLAG_OFF)
+ expect(merged?.[TaxonomicFilterGroupType.Events]).toEqual([null])
+ })
+ })
+
+ describe('hiddenEventMatchingSearch', () => {
+ const EXCLUDED = [null, '$feature_flag_called']
+
+ it.each([
+ ['the name as typed', '$feature_flag_called', EXCLUDED, '$feature_flag_called'],
+ ['the name with stray case and spacing', ' $FEATURE_FLAG_CALLED ', EXCLUDED, '$feature_flag_called'],
+ // Lists render core events by label, so this is the other string a user may type.
+ ['the label lists show', 'Feature flag called', EXCLUDED, '$feature_flag_called'],
+ // A substring rule would claim this, and "feature" is a search someone really makes.
+ ['a word the name merely contains', 'feature', EXCLUDED, null],
+ // Someone could legitimately want to create an event under this name.
+ ['the name without its $', 'feature_flag_called', EXCLUDED, null],
+ // The picker opted in, so it is hiding nothing and has nothing to explain.
+ ['a picker excluding nothing', '$feature_flag_called', [null], null],
+ ['a group with no exclusions', '$feature_flag_called', undefined, null],
+ ['an empty search', ' ', EXCLUDED, null],
+ ])('matches %s', (_label, searchQuery, excluded, expected) => {
+ expect(hiddenEventMatchingSearch(searchQuery, excluded)).toBe(expected)
+ })
+
+ // Two derivations off the same taxonomy scan. If they disagree, a picker hides an event it
+ // then refuses to explain.
+ it('recognizes every name the Events group hides', () => {
+ for (const name of hiddenEventNames(FLAG_ON)) {
+ expect(hiddenEventMatchingSearch(name, [name])).toBe(name)
+ }
+ })
+ })
+})
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/hiddenEvents.ts b/frontend/src/lib/components/TaxonomicFilter/utils/hiddenEvents.ts
new file mode 100644
index 000000000000..4ac0395fc64f
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/hiddenEvents.ts
@@ -0,0 +1,92 @@
+import { ExcludedProperties, TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import { FEATURE_FLAGS } from 'lib/constants'
+
+import { CORE_FILTER_DEFINITIONS_BY_GROUP } from '~/taxonomy/taxonomy'
+
+/**
+ * Events whose rows are moving out of the `events` table. A query saved against one of these stops
+ * returning data once the move happens, so event pickers leave them out by default.
+ *
+ * `searchTerms` are every string a search has to equal for us to treat it as a hunt for that event.
+ * The label is in there because lists render core events by their label, so "Feature flag called" is
+ * a string the user has actually seen and is as likely to type as the raw key.
+ */
+const EVENTS_HIDDEN_IN_QUERY_BUILDERS: { name: string; searchTerms: string[] }[] = Object.entries(
+ CORE_FILTER_DEFINITIONS_BY_GROUP.events
+)
+ // The "All Events" remap in the taxonomy leaves the '' key holding no definition, so read defensively.
+ .filter(([, definition]) => definition?.hidden_in_query_builders)
+ .map(([name, definition]) => ({
+ name,
+ searchTerms: [name, definition.label]
+ .filter((term): term is string => typeof term === 'string' && term.length > 0)
+ .map((term) => term.toLowerCase()),
+ }))
+
+const HIDDEN_EVENT_NAMES = EVENTS_HIDDEN_IN_QUERY_BUILDERS.map(({ name }) => name)
+
+/**
+ * Names the Events group adds to its own exclusions.
+ *
+ * Empty for a picker that passes `includeHiddenEvents`, which is how surfaces that browse captured
+ * events (the activity explorer, live events, a group's event feed, ingestion triggers) and the
+ * experiment pickers keep offering them.
+ */
+export function hiddenEventNames(
+ featureFlags: Record<string, boolean | string | undefined>,
+ includeHiddenEvents?: boolean
+): string[] {
+ if (includeHiddenEvents || !featureFlags[FEATURE_FLAGS.HIDE_EVENTS_IN_QUERY_BUILDERS]) {
+ return []
+ }
+ return HIDDEN_EVENT_NAMES
+}
+
+/**
+ * The hidden event this search was looking for, or null. Lets a picker explain an absence it caused
+ * rather than reporting no results.
+ *
+ * Reads the Events group's own exclusions rather than the feature flag, so a picker that opted in,
+ * and a user without the flag, both match nothing: a picker only ever explains what it hides itself.
+ *
+ * Matches the whole query, never a prefix, because "feature" is a plausible real search.
+ */
+export function hiddenEventMatchingSearch(
+ searchQuery: string,
+ excludedEventNames: readonly (string | number | null)[] | undefined
+): string | null {
+ if (!excludedEventNames?.length) {
+ return null
+ }
+ const query = searchQuery.trim().toLowerCase()
+ if (!query) {
+ return null
+ }
+ const match = EVENTS_HIDDEN_IN_QUERY_BUILDERS.find(({ searchTerms }) => searchTerms.includes(query))
+ return match && excludedEventNames.includes(match.name) ? match.name : null
+}
+
+/**
+ * The caller's `excludedProperties`, with the hidden names folded into the Events group.
+ *
+ * The Recent and Pinned tabs read this record rather than the built group's exclusions, so without
+ * the names here a pin saved before an event was hidden stays one click from selection. Returns the
+ * input unchanged when nothing is hidden, so callers keep a stable reference to memoize on.
+ */
+export function withHiddenEventsExcluded(
+ excludedProperties: ExcludedProperties | undefined,
+ featureFlags: Record<string, boolean | string | undefined>,
+ includeHiddenEvents?: boolean
+): ExcludedProperties | undefined {
+ const hidden = hiddenEventNames(featureFlags, includeHiddenEvents)
+ if (!hidden.length) {
+ return excludedProperties
+ }
+ return {
+ ...excludedProperties,
+ [TaxonomicFilterGroupType.Events]: [
+ ...(excludedProperties?.[TaxonomicFilterGroupType.Events] ?? []),
+ ...hidden,
+ ],
+ }
+}
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.test.ts b/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.test.ts
index 91ea42e8d507..284c69d1f932 100644
--- a/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/suggestedContextFilters.test.ts
@@ -160,4 +160,10 @@ describe('suggestedContextFilters', () => {
expect(names(filterPinnedForContext(items, types, excludedProperties))).toEqual(expected)
})
})
+
+ it('drops a pinned value that is excluded for its group, keeping others', () => {
+ const items = [pinned(Events, '$feature_flag_called'), pinned(Events, '$pageview')]
+ const out = filterPinnedForContext(items, [Events], { [Events]: ['$feature_flag_called'] })
+ expect(names(out)).toEqual(['$pageview'])
+ })
})
diff --git a/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopover.tsx b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopover.tsx
index cd82ec54d2f4..d6a4e4737063 100644
--- a/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopover.tsx
+++ b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopover.tsx
@@ -49,6 +49,7 @@ export interface TaxonomicPopoverProps<ValueType extends TaxonomicFilterValue =
style?: React.CSSProperties
closeOnChange?: boolean
excludedProperties?: ExcludedProperties
+ includeHiddenEvents?: boolean
selectedProperties?: SelectedProperties
metadataSource?: AnyDataNode
showNumericalPropsOnly?: boolean
@@ -91,6 +92,7 @@ export const TaxonomicPopover = forwardRef(function TaxonomicPopover_<
allowClear = false,
closeOnChange = true,
excludedProperties,
+ includeHiddenEvents,
selectedProperties,
metadataSource,
schemaColumns,
@@ -159,6 +161,7 @@ export const TaxonomicPopover = forwardRef(function TaxonomicPopover_<
schemaColumns={schemaColumns}
metadataSource={metadataSource}
excludedProperties={excludedProperties}
+ includeHiddenEvents={includeHiddenEvents}
selectedProperties={selectedProperties}
showNumericalPropsOnly={showNumericalPropsOnly}
dataWarehousePopoverFields={dataWarehousePopoverFields}
@@ -241,6 +244,7 @@ export const TaxonomicPopover = forwardRef(function TaxonomicPopover_<
schemaColumns={schemaColumns}
metadataSource={metadataSource}
excludedProperties={excludedProperties}
+ includeHiddenEvents={includeHiddenEvents}
selectedProperties={selectedProperties}
showNumericalPropsOnly={showNumericalPropsOnly}
dataWarehousePopoverFields={dataWarehousePopoverFields}
diff --git a/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.tsx b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.tsx
index 3ce1a7defcda..e58c9d45dd84 100644
--- a/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.tsx
+++ b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.tsx
@@ -82,6 +82,7 @@ export interface TaxonomicPopoverMenuProps<ValueType extends TaxonomicFilterValu
schemaColumns?: DatabaseSchemaField[]
metadataSource?: AnyDataNode
excludedProperties?: ExcludedProperties
+ includeHiddenEvents?: boolean
selectedProperties?: SelectedProperties
propertyAllowList?: AllowedProperties
optionsFromProp?: Partial<Record<TaxonomicFilterGroupType, SimpleOption[]>>
@@ -220,6 +221,7 @@ function ArmedTaxonomicPopoverMenu<ValueType extends TaxonomicFilterValue = Taxo
schemaColumns,
metadataSource,
excludedProperties,
+ includeHiddenEvents,
selectedProperties,
propertyAllowList,
optionsFromProp,
@@ -302,6 +304,7 @@ function ArmedTaxonomicPopoverMenu<ValueType extends TaxonomicFilterValue = Taxo
schemaColumns={schemaColumns}
metadataSource={metadataSource}
excludedProperties={excludedProperties}
+ includeHiddenEvents={includeHiddenEvents}
selectedProperties={selectedProperties}
propertyAllowList={propertyAllowList}
optionsFromProp={optionsFromProp}
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 3efe9dbb336f..83fc4e476d42 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -344,6 +344,9 @@ export const FEATURE_FLAGS = {
GITHUB_WORKFLOW_TRIGGERS: 'github-workflow-triggers', // owner: #team-workflows-cdp
GROUP_PROFILE_EXPERIMENT: 'group-profile-experiment', // owner: @arthurdedeus #team-customer-analytics
HEALTH_ASK_AI: 'health-ask-ai', // owner: @jordanm-posthog #team-web-analytics, gates the "Ask PostHog AI" buttons on the Health overview
+ // Disabling this for an org restores every event marked hidden_in_query_builders at once, in every
+ // picker. There is no per-event or per-picker granularity, so weigh that before marking a second event.
+ HIDE_EVENTS_IN_QUERY_BUILDERS: 'hide-events-in-query-builders', // owner: #team-feature-flags, kill switch for hiding events marked hidden_in_query_builders from insight/cohort/destination pickers
HOGQL_WAREHOUSE_ACCESS_CONTROL: 'hogql-warehouse-access-control', // owner: @a-lider #team-platform-features, gates per-object access control for warehouse tables and views
IDENTITY_MATCHING: 'identity-matching', // owner: @fercgomes #team-growth, gates new identity matching scene on marketing analytics
INBOX_REDESIGN: 'inbox-redesign', // owner: #team-self-driving, gates the inbox redesign: report sections, triage mode, the Settings tab, and scout cards
diff --git a/frontend/src/queries/nodes/DataTable/DataTable.tsx b/frontend/src/queries/nodes/DataTable/DataTable.tsx
index 60a5895896b6..aa9ceb17f5ca 100644
--- a/frontend/src/queries/nodes/DataTable/DataTable.tsx
+++ b/frontend/src/queries/nodes/DataTable/DataTable.tsx
@@ -840,10 +840,20 @@ export function DataTable({
/>
) : null,
showEventFilter && sourceFeatures.has(QueryFeature.eventNameFilter) ? (
- <EventName key="event-name" query={query.source as EventsQuery | SessionsQuery} setQuery={setQuerySource} />
+ <EventName
+ key="event-name"
+ query={query.source as EventsQuery | SessionsQuery}
+ setQuery={setQuerySource}
+ includeHiddenEvents={context?.includeHiddenEvents}
+ />
) : null,
showEventsFilter && isEventsQuery(query.source) ? (
- <EventsFilter key="events-filter" query={query.source} setQuery={setQuerySource} />
+ <EventsFilter
+ key="events-filter"
+ query={query.source}
+ setQuery={setQuerySource}
+ includeHiddenEvents={context?.includeHiddenEvents}
+ />
) : null,
showSearch && sourceFeatures.has(QueryFeature.personsSearch) ? (
<PersonsSearch key="persons-search" query={query.source as PersonsNode} setQuery={setQuerySource} />
diff --git a/frontend/src/queries/nodes/EventsNode/EventName.tsx b/frontend/src/queries/nodes/EventsNode/EventName.tsx
index ec7c06c9c6de..69aa5a5c3492 100644
--- a/frontend/src/queries/nodes/EventsNode/EventName.tsx
+++ b/frontend/src/queries/nodes/EventsNode/EventName.tsx
@@ -7,9 +7,11 @@ import { EventName as EventNameComponent } from 'products/actions/frontend/compo
interface EventNameProps {
query: EventsNode | EventsQuery | SessionsQuery
setQuery?: (query: EventsNode | EventsQuery | SessionsQuery) => void
+ /** See `QueryContext.includeHiddenEvents`. The hosting surface decides, not this component. */
+ includeHiddenEvents?: boolean
}
-export function EventName({ query, setQuery }: EventNameProps): JSX.Element {
+export function EventName({ query, setQuery, includeHiddenEvents }: EventNameProps): JSX.Element {
return (
<EventNameComponent
value={query.event ?? ''}
@@ -17,6 +19,7 @@ export function EventName({ query, setQuery }: EventNameProps): JSX.Element {
onChange={(value) => setQuery?.({ ...query, event: value })}
allEventsOption="clear"
groupTypes={[TaxonomicFilterGroupType.Events]}
+ includeHiddenEvents={includeHiddenEvents}
/>
)
}
diff --git a/frontend/src/queries/nodes/EventsNode/EventsFilter.tsx b/frontend/src/queries/nodes/EventsNode/EventsFilter.tsx
index 8201ab82acc6..63ac0870533b 100644
--- a/frontend/src/queries/nodes/EventsNode/EventsFilter.tsx
+++ b/frontend/src/queries/nodes/EventsNode/EventsFilter.tsx
@@ -13,9 +13,11 @@ import { EventsQuery } from '~/queries/schema/schema-general'
interface EventsFilterProps {
query: EventsQuery
setQuery?: (query: EventsQuery) => void
+ /** See `QueryContext.includeHiddenEvents`. The hosting surface decides, not this component. */
+ includeHiddenEvents?: boolean
}
-export function EventsFilter({ query, setQuery }: EventsFilterProps): JSX.Element {
+export function EventsFilter({ query, setQuery, includeHiddenEvents }: EventsFilterProps): JSX.Element {
const events = query.events || []
const [adding, setAdding] = useState(false)
@@ -54,6 +56,7 @@ export function EventsFilter({ query, setQuery }: EventsFilterProps): JSX.Elemen
onUpdate={(value) => handleUpdateEvent(index, value)}
onRemove={() => handleRemoveEvent(index)}
disabled={!setQuery}
+ includeHiddenEvents={includeHiddenEvents}
/>
))}
<Popover
@@ -66,6 +69,7 @@ export function EventsFilter({ query, setQuery }: EventsFilterProps): JSX.Elemen
onChange={(_group, value) => handleAddEvent(String(value))}
taxonomicGroupTypes={[TaxonomicFilterGroupType.Events]}
excludedProperties={{ [TaxonomicFilterGroupType.Events]: [null] }}
+ includeHiddenEvents={includeHiddenEvents}
selectedProperties={{ [TaxonomicFilterGroupType.Events]: events }}
/>
}
@@ -91,9 +95,19 @@ interface EventChipProps {
onUpdate: (value: string) => void
onRemove: () => void
disabled?: boolean
+ includeHiddenEvents?: boolean
}
-function EventChip({ event, selectedEvents, onUpdate, onRemove, disabled }: EventChipProps): JSX.Element {
+// Kept in step with the "Select events" popover above: a surface that can add a hidden event has to
+// let you find it again when swapping this chip, or the edit list silently drops the pick.
+function EventChip({
+ event,
+ selectedEvents,
+ onUpdate,
+ onRemove,
+ disabled,
+ includeHiddenEvents,
+}: EventChipProps): JSX.Element {
const [editing, setEditing] = useState(false)
return (
@@ -110,6 +124,7 @@ function EventChip({ event, selectedEvents, onUpdate, onRemove, disabled }: Even
}}
taxonomicGroupTypes={[TaxonomicFilterGroupType.Events]}
excludedProperties={{ [TaxonomicFilterGroupType.Events]: [null] }}
+ includeHiddenEvents={includeHiddenEvents}
selectedProperties={{ [TaxonomicFilterGroupType.Events]: selectedEvents }}
/>
}
diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.ts
index c9653b8e42bd..dce0b36485b9 100644
--- a/frontend/src/queries/types.ts
+++ b/frontend/src/queries/types.ts
@@ -93,6 +93,13 @@ export interface QueryContext<Q extends QuerySchema = QuerySchema> {
* (e.g. the Error tracking insights tab) and the suggestions would not be actionable.
*/
suppressSlowQuerySuggestions?: boolean
+ /**
+ * Let this table's event pickers offer events whose data is moving out of the `events` table.
+ * Set it where the pick is thrown away with the page. A surface whose query gets saved (an
+ * insight, a dashboard tile, a notebook, a table view) leaves it unset, so it stops saving a
+ * filter that returns nothing once the data moves. See `TaxonomicFilterProps.includeHiddenEvents`.
+ */
+ includeHiddenEvents?: boolean
}
export type QueryContextColumnTitleComponent = ComponentType<{
diff --git a/frontend/src/scenes/activity/explore/EventsScene.tsx b/frontend/src/scenes/activity/explore/EventsScene.tsx
index 16e0cb29cc1e..bb5ba61c1861 100644
--- a/frontend/src/scenes/activity/explore/EventsScene.tsx
+++ b/frontend/src/scenes/activity/explore/EventsScene.tsx
@@ -36,6 +36,8 @@ export function EventsScene(): JSX.Element {
showOpenEditorButton: true,
extraDataTableQueryFeatures: [QueryFeature.highlightExceptionEventRows],
dataTableMaxPaginationLimit: 200,
+ // A live-data explorer over captured events, so it keeps the hidden ones selectable.
+ includeHiddenEvents: true,
}}
/>
</SceneContent>
diff --git a/frontend/src/scenes/activity/explore/SessionsScene.tsx b/frontend/src/scenes/activity/explore/SessionsScene.tsx
index 7d919ebcba24..6d8c5cc4e661 100644
--- a/frontend/src/scenes/activity/explore/SessionsScene.tsx
+++ b/frontend/src/scenes/activity/explore/SessionsScene.tsx
@@ -43,6 +43,8 @@ export function SessionsScene(): JSX.Element {
extraDataTableQueryFeatures: [QueryFeature.highlightExceptionEventRows],
dataTableMaxPaginationLimit: 200,
dataTableRowsTransformer,
+ // A live-data explorer over captured events, so it keeps the hidden ones selectable.
+ includeHiddenEvents: true,
}}
/>
</SceneContent>
diff --git a/frontend/src/scenes/activity/live/LiveEventsTable.tsx b/frontend/src/scenes/activity/live/LiveEventsTable.tsx
index 110ae4be825e..80626fe90b49 100644
--- a/frontend/src/scenes/activity/live/LiveEventsTable.tsx
+++ b/frontend/src/scenes/activity/live/LiveEventsTable.tsx
@@ -84,6 +84,8 @@ export function LiveEventsTable(): JSX.Element {
onChange={(value) => setFilters({ ...filters, eventType: value })}
placeholder="Filter by event"
allEventsOption="clear"
+ // Narrows the live feed in memory rather than saving a query.
+ includeHiddenEvents
/>
<PropertyFilters
pageKey="live-events"
diff --git a/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx b/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx
index ed7f2ad5ab22..e56e61afb774 100644
--- a/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx
+++ b/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx
@@ -65,8 +65,8 @@ function InclusionActionFilter({
entitiesLimit={1}
mathAvailability={MathAvailability.None}
showNumericalPropsOnly={false}
+ {...commonActionFilterProps}
actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
- propertiesTaxonomicGroupTypes={commonActionFilterProps.propertiesTaxonomicGroupTypes}
/>
)
}
@@ -97,8 +97,8 @@ function ActivationActionFilter({
entitiesLimit={1}
mathAvailability={MathAvailability.None}
showNumericalPropsOnly={false}
+ {...commonActionFilterProps}
actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
- propertiesTaxonomicGroupTypes={commonActionFilterProps.propertiesTaxonomicGroupTypes}
/>
)
}
diff --git a/frontend/src/scenes/experiments/ExperimentMetricForm.tsx b/frontend/src/scenes/experiments/ExperimentMetricForm.tsx
index ef0b6f2d70f0..5a645e806b56 100644
--- a/frontend/src/scenes/experiments/ExperimentMetricForm.tsx
+++ b/frontend/src/scenes/experiments/ExperimentMetricForm.tsx
@@ -416,8 +416,7 @@ export function ExperimentMetricForm({
// showNumericalPropsOnly={true}
mathAvailability={mathAvailability}
allowedMathTypes={allowedMathTypes}
- actionsTaxonomicGroupTypes={commonActionFilterProps.actionsTaxonomicGroupTypes}
- propertiesTaxonomicGroupTypes={commonActionFilterProps.propertiesTaxonomicGroupTypes}
+ {...commonActionFilterProps}
dataWarehousePopoverFields={dataWarehousePopoverFields}
/>
)}
diff --git a/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx b/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx
index d6b90dfb4ee0..b797bd335556 100644
--- a/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx
+++ b/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx
@@ -169,8 +169,8 @@ export function ExposureCriteriaModal({ onSave }: ExposureCriteriaModalProps): J
entitiesLimit={1}
mathAvailability={MathAvailability.None}
showNumericalPropsOnly={true}
+ {...commonActionFilterProps}
actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
- propertiesTaxonomicGroupTypes={commonActionFilterProps.propertiesTaxonomicGroupTypes}
/>
</div>
)}
@@ -195,8 +195,8 @@ export function ExposureCriteriaModal({ onSave }: ExposureCriteriaModalProps): J
entitiesLimit={1}
mathAvailability={MathAvailability.None}
showNumericalPropsOnly={true}
+ {...commonActionFilterProps}
actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
- propertiesTaxonomicGroupTypes={commonActionFilterProps.propertiesTaxonomicGroupTypes}
/>
</div>
)}
diff --git a/frontend/src/scenes/experiments/Metrics/Selectors.tsx b/frontend/src/scenes/experiments/Metrics/Selectors.tsx
index db8b6cdc06d0..03e3d9c66534 100644
--- a/frontend/src/scenes/experiments/Metrics/Selectors.tsx
+++ b/frontend/src/scenes/experiments/Metrics/Selectors.tsx
@@ -16,6 +16,12 @@ import { groupsModel } from '~/models/groupsModel'
import { BreakdownAttributionType, FunnelConversionWindowTimeUnit, StepOrderValue } from '~/types'
export const commonActionFilterProps = {
+ // Offers events whose data is moving out of the events table. Exposure is still measured with
+ // $feature_flag_called, and every picker spreading this object shares the setting, so metric
+ // definitions get it too. A metric saved on such an event stops returning data once the move
+ // happens. Drop this once ingestion duplicates multivariate $feature_flag_called into
+ // $experiment_exposure for every team and exposure reads that event instead.
+ includeHiddenEvents: true,
actionsTaxonomicGroupTypes: [
TaxonomicFilterGroupType.Events,
TaxonomicFilterGroupType.Actions,
diff --git a/frontend/src/scenes/groups/Group.tsx b/frontend/src/scenes/groups/Group.tsx
index fad8c5b0fe94..366c2e9cde0e 100644
--- a/frontend/src/scenes/groups/Group.tsx
+++ b/frontend/src/scenes/groups/Group.tsx
@@ -168,6 +168,9 @@ export function Group(): JSX.Element {
setQuery={setGroupEventsQuery}
context={{
refresh: 'force_blocking',
+ // Browses this group's captured events. The query carries no
+ // contextKey, so the pick is never saved as a table view.
+ includeHiddenEvents: true,
customActions: (
<LemonButton
key="reset-group-events-filters"
diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilter.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilter.tsx
index ffeaf3831424..2eaabb555a83 100644
--- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilter.tsx
+++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilter.tsx
@@ -109,6 +109,7 @@ export interface ActionFilterProps {
addFilterDocLink?: string
/** Properties to exclude from the properties filter */
excludedProperties?: TaxonomicPopoverProps['excludedProperties']
+ includeHiddenEvents?: TaxonomicPopoverProps['includeHiddenEvents']
/** Allow adding non-captured events */
allowNonCapturedEvents?: boolean
hogQLGlobals?: Record<string, any>
@@ -152,6 +153,7 @@ export const ActionFilter = React.forwardRef<HTMLDivElement, ActionFilterProps>(
filtersLeftPadding,
addFilterDocLink,
excludedProperties,
+ includeHiddenEvents,
allowNonCapturedEvents,
hogQLGlobals,
definitionPopoverRenderer,
@@ -224,6 +226,7 @@ export const ActionFilter = React.forwardRef<HTMLDivElement, ActionFilterProps>(
filtersLeftPadding,
addFilterDocLink,
excludedProperties,
+ includeHiddenEvents,
allowNonCapturedEvents,
hogQLGlobals,
operatorAllowlist,
@@ -290,6 +293,7 @@ export const ActionFilter = React.forwardRef<HTMLDivElement, ActionFilterProps>(
actionsTaxonomicGroupTypes={actionsTaxonomicGroupTypes}
dataWarehousePopoverFields={dataWarehousePopoverFields}
excludedProperties={excludedProperties}
+ includeHiddenEvents={includeHiddenEvents}
insightType={filters.insight}
definitionPopoverRenderer={definitionPopoverRenderer}
/>
diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterGroup/ActionFilterGroup.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterGroup/ActionFilterGroup.tsx
index bc4a2e606a8a..7aa10cdd73af 100644
--- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterGroup/ActionFilterGroup.tsx
+++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterGroup/ActionFilterGroup.tsx
@@ -52,6 +52,7 @@ interface ActionFilterGroupProps {
showNumericalPropsOnly?: boolean
dataWarehousePopoverFields?: any[]
excludedProperties?: TaxonomicPopoverProps['excludedProperties']
+ includeHiddenEvents?: TaxonomicPopoverProps['includeHiddenEvents']
groupTitle?: string
trendsDisplayCategory?: any
insightType?: InsightType
@@ -74,6 +75,7 @@ export function ActionFilterGroup({
showNumericalPropsOnly,
dataWarehousePopoverFields,
excludedProperties,
+ includeHiddenEvents,
groupTitle,
trendsDisplayCategory,
insightType,
@@ -369,6 +371,7 @@ export function ActionFilterGroup({
showNumericalPropsOnly={showNumericalPropsOnly}
dataWarehousePopoverFields={dataWarehousePopoverFields}
excludedProperties={excludedProperties}
+ includeHiddenEvents={includeHiddenEvents}
definitionPopoverRenderer={definitionPopoverRenderer}
/>
{eventIndex < nestedFilters.length - 1 && (
@@ -423,6 +426,7 @@ export function ActionFilterGroup({
showNumericalPropsOnly={showNumericalPropsOnly}
dataWarehousePopoverFields={dataWarehousePopoverFields}
excludedProperties={excludedProperties}
+ includeHiddenEvents={includeHiddenEvents}
/>
</div>
)}
diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx
index fd838f0d1c09..bb2122b1e75e 100644
--- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx
+++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx
@@ -117,12 +117,14 @@ export function ActionFilterRow({
filtersLeftPadding = false,
addFilterDocLink,
excludedProperties,
+ includeHiddenEvents,
allowNonCapturedEvents,
hogQLGlobals,
inlineEventsDocLink,
definitionPopoverRenderer,
operatorAllowlist,
-}: ActionFilterRowProps & Pick<TaxonomicPopoverProps, 'excludedProperties' | 'allowNonCapturedEvents'>): JSX.Element {
+}: ActionFilterRowProps &
+ Pick<TaxonomicPopoverProps, 'excludedProperties' | 'includeHiddenEvents' | 'allowNonCapturedEvents'>): JSX.Element {
const effectiveActionsTaxonomicGroupTypes = [
TaxonomicFilterGroupType.SuggestedFilters,
...actionsTaxonomicGroupTypes,
@@ -409,6 +411,7 @@ export function ActionFilterRow({
typeKey === 'plugin-filters' ? ([] as DataWarehousePopoverField[]) : dataWarehousePopoverFields
}
excludedProperties={excludedProperties}
+ includeHiddenEvents={includeHiddenEvents}
allowNonCapturedEvents={allowNonCapturedEvents}
definitionPopoverRenderer={definitionPopoverRenderer}
/>
diff --git a/frontend/src/scenes/surveys/AddEventButton.tsx b/frontend/src/scenes/surveys/AddEventButton.tsx
index 7d9902cc345c..a97dedc86f16 100644
--- a/frontend/src/scenes/surveys/AddEventButton.tsx
+++ b/frontend/src/scenes/surveys/AddEventButton.tsx
@@ -38,6 +38,8 @@ export function AddEventButton({
}}
allowNonCapturedEvents
taxonomicGroupTypes={[TaxonomicFilterGroupType.CustomEvents, TaxonomicFilterGroupType.Events]}
+ // Configures client-side SDK triggers rather than saving a query, so hidden events stay selectable.
+ includeHiddenEvents
/>
}
visible={popoverOpen}
diff --git a/frontend/src/taxonomy/core-filter-definitions-by-group.json b/frontend/src/taxonomy/core-filter-definitions-by-group.json
index 7a1491cbd815..1ced3767958f 100644
--- a/frontend/src/taxonomy/core-filter-definitions-by-group.json
+++ b/frontend/src/taxonomy/core-filter-definitions-by-group.json
@@ -1604,7 +1604,7 @@
"label": "External click URL"
},
"$feature_flag": {
- "description": "The feature flag that was called.\n\nWarning! This only works in combination with the $feature_flag_called and $experiment_exposure events. If you want to filter other events, try \"Active feature flags\".",
+ "description": "The key of the feature flag, sent on \"Feature flag called\", \"Experiment exposure\", and \"Feature enrollment\" events. To find other events where a flag was active, use \"Active feature flags\".",
"examples": [
"beta-feature"
],
@@ -4107,10 +4107,11 @@
"label": "Feature enrollment"
},
"$feature_flag_called": {
- "description": "The feature flag that was called.\n\nWarning! This only works in combination with the $feature_flag event. If you want to filter other events, try \"Active feature flags\".",
+ "description": "Sent by PostHog SDKs each time a feature flag is evaluated.\n\nPostHog still collects this event, but its data is moving, so a saved query built on it will stop returning results. To see how a flag is used, open the flag and check its Usage tab.",
"examples": [
"beta-feature"
],
+ "hidden_in_query_builders": true,
"ignored_in_assistant": true,
"label": "Feature flag called",
"primary_property": "$feature_flag"
@@ -6329,7 +6330,7 @@
"type": "String"
},
"$feature_flag": {
- "description": "The feature flag that was called.\n\nWarning! This only works in combination with the $feature_flag_called and $experiment_exposure events. If you want to filter other events, try \"Active feature flags\".",
+ "description": "The key of the feature flag, sent on \"Feature flag called\", \"Experiment exposure\", and \"Feature enrollment\" events. To find other events where a flag was active, use \"Active feature flags\".",
"examples": [
"beta-feature"
],
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 85238853036b..0533b1d14553 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -5174,6 +5174,8 @@ export interface CoreFilterDefinition {
used_for_debug?: boolean
/** Name of a single property on events of this name that UIs should display alongside the event. */
primary_property?: string
+ /** Keep this event out of pickers that build a query someone saves and runs later. Surfaces that read live event data still offer it. */
+ hidden_in_query_builders?: boolean
}
export interface TileParams {
diff --git a/posthog/taxonomy/taxonomy.py b/posthog/taxonomy/taxonomy.py
index 4e5d99b11c35..d5c2343e7380 100644
--- a/posthog/taxonomy/taxonomy.py
+++ b/posthog/taxonomy/taxonomy.py
@@ -19,6 +19,11 @@ class CoreFilterDefinition(TypedDict):
virtual: NotRequired[bool]
used_for_debug: NotRequired[bool]
primary_property: NotRequired[str]
+ # Keep this event out of pickers that build a query someone saves and runs later, because its rows
+ # are moving out of the events table. Surfaces that read live event data still offer it.
+ # This marks a migration in progress, not a permanent trait: drop the field once every event
+ # carrying it has moved and its old artifacts are migrated (RFC #1209).
+ hidden_in_query_builders: NotRequired[bool]
def is_hidden_from_assistant(definition: CoreFilterDefinition) -> bool:
@@ -177,10 +182,11 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {
"$feature_flag_called": {
"label": "Feature flag called",
"description": (
- 'The feature flag that was called.\n\nWarning! This only works in combination with the $feature_flag event. If you want to filter other events, try "Active feature flags".'
+ "Sent by PostHog SDKs each time a feature flag is evaluated.\n\nPostHog still collects this event, but its data is moving, so a saved query built on it will stop returning results. To see how a flag is used, open the flag and check its Usage tab."
),
"examples": ["beta-feature"],
"ignored_in_assistant": True, # Mostly irrelevant product-wise
+ "hidden_in_query_builders": True,
"primary_property": "$feature_flag",
},
"$experiment_exposure": {
@@ -1774,7 +1780,7 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {
},
"$feature_flag": {
"label": "Feature flag",
- "description": 'The feature flag that was called.\n\nWarning! This only works in combination with the $feature_flag_called and $experiment_exposure events. If you want to filter other events, try "Active feature flags".',
+ "description": 'The key of the feature flag, sent on "Feature flag called", "Experiment exposure", and "Feature enrollment" events. To find other events where a flag was active, use "Active feature flags".',
"examples": ["beta-feature"],
},
"$feature_flag_reason": {
diff --git a/products/actions/frontend/components/EventName.tsx b/products/actions/frontend/components/EventName.tsx
index 374864fccbb6..33b6af917b8d 100644
--- a/products/actions/frontend/components/EventName.tsx
+++ b/products/actions/frontend/components/EventName.tsx
@@ -26,7 +26,7 @@ export function EventName({
allEventsOption,
...props
}: (EventNamePropsWithAllEvents | EventNamePropsWithoutAllEvents) &
- Pick<TaxonomicPopoverProps, 'placement' | 'groupTypes'>): JSX.Element {
+ Pick<TaxonomicPopoverProps, 'placement' | 'groupTypes' | 'includeHiddenEvents'>): JSX.Element {
return (
<TaxonomicPopover
groupType={TaxonomicFilterGroupType.Events}