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.

revert(taxonomic-filter): undo extraction stack (#59817-#59826) (#60485)

Paul D'Ambra4a2899dbd723
diff --git a/frontend/src/lib/components/TaxonomicFilter/apmTaxonomicGroupsLogic.ts b/frontend/src/lib/components/TaxonomicFilter/apmTaxonomicGroupsLogic.ts
deleted file mode 100644
index 611bed861f36..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/apmTaxonomicGroupsLogic.ts
+++ /dev/null
@@ -1,172 +0,0 @@
-import { connect, kea, key, path, props, selectors } from 'kea'
-import { combineUrl } from 'kea-router'
-
-import {
- SimpleOption,
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
-} from 'lib/components/TaxonomicFilter/types'
-import { projectLogic } from 'scenes/projectLogic'
-
-import type { apmTaxonomicGroupsLogicType } from './apmTaxonomicGroupsLogicType'
-
-export const apmTaxonomicGroupsLogic = kea<apmTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'apmTaxonomicGroupsLogic', key]),
-
- connect(() => ({
- values: [projectLogic, ['currentProjectId']],
- })),
-
- selectors({
- endpointFilters: [
- () => [(_, props) => props.endpointFilters],
- (endpointFilters: Record<string, any>) => endpointFilters,
- ],
- apmTaxonomicGroups: [
- (s) => [s.currentProjectId, s.endpointFilters],
- (projectId, endpointFilters: Record<string, any> | undefined): TaxonomicFilterGroup[] => [
- {
- name: 'Logs',
- searchPlaceholder: 'logs',
- type: TaxonomicFilterGroupType.Logs,
- options: [
- { key: 'message', name: 'message', propertyFilterType: 'log' },
- { key: 'severity_level', name: 'severity_level', propertyFilterType: 'log' },
- { key: 'trace_id', name: 'trace_id', propertyFilterType: 'log' },
- { key: 'span_id', name: 'span_id', propertyFilterType: 'log' },
- ],
- localItemsSearch: (items: any[], q: string): any[] => {
- if (!q) {
- return items
- }
- return [
- {
- key: 'message',
- name: 'Search log message for "' + q + '"',
- value: q,
- propertyFilterType: 'log',
- },
- ].concat(items.filter((item) => item.name?.toLowerCase().includes(q.toLowerCase())))
- },
- getName: (option: { key: string; name: string }) => option.name,
- getValue: (option: { key: string; name: string }) => option.key,
- getPopoverHeader: () => 'Log attributes',
- },
- {
- name: 'Log attributes',
- searchPlaceholder: 'attributes',
- type: TaxonomicFilterGroupType.LogAttributes,
- endpoint: combineUrl(`api/environments/${projectId}/logs/attributes`, {
- attribute_type: 'log',
- search_values: 'true',
- ...endpointFilters,
- }).url,
- valuesEndpoint: (key) =>
- combineUrl(`api/environments/${projectId}/logs/values`, {
- attribute_type: 'log',
- key: key,
- ...endpointFilters,
- }).url,
- getName: (option: SimpleOption) => option.name,
- getValue: (option: SimpleOption) => option.name,
- getPopoverHeader: () => 'Log attributes',
- },
- {
- name: 'Resource attributes',
- searchPlaceholder: 'resources',
- type: TaxonomicFilterGroupType.LogResourceAttributes,
- endpoint: combineUrl(`api/environments/${projectId}/logs/attributes`, {
- attribute_type: 'resource',
- search_values: 'true',
- ...endpointFilters,
- }).url,
- valuesEndpoint: (key) =>
- combineUrl(`api/environments/${projectId}/logs/values`, {
- attribute_type: 'resource',
- key: key,
- ...endpointFilters,
- }).url,
- getName: (option: SimpleOption) => option.name,
- getValue: (option: SimpleOption) => option.name,
- getPopoverHeader: () => 'Resource attributes',
- },
- {
- name: 'Spans',
- searchPlaceholder: 'spans',
- type: TaxonomicFilterGroupType.Spans,
- options: [
- { key: 'name', name: 'name', propertyFilterType: 'span' },
- { key: 'kind', name: 'kind', propertyFilterType: 'span' },
- { key: 'duration', name: 'duration (ms)', propertyFilterType: 'span' },
- { key: 'trace_id', name: 'trace_id', propertyFilterType: 'span' },
- { key: 'span_id', name: 'span_id', propertyFilterType: 'span' },
- { key: 'status_code', name: 'status code', propertyFilterType: 'span' },
- ],
- valuesEndpoint: (key) =>
- key === 'name'
- ? combineUrl(`api/environments/${projectId}/tracing/spans/values`, {
- attribute_type: 'span',
- key: key,
- ...endpointFilters,
- }).url
- : undefined,
- localItemsSearch: (items: any[], q: string): any[] => {
- if (!q) {
- return items
- }
- return [
- {
- key: 'message',
- name: 'Search span message for "' + q + '"',
- value: q,
- propertyFilterType: 'span',
- },
- ].concat(items.filter((item) => item.name?.toLowerCase().includes(q.toLowerCase())))
- },
- getName: (option: { key: string; name: string }) => option.name,
- getValue: (option: { key: string; name: string }) => option.key,
- getPopoverHeader: () => 'Span attributes',
- },
- {
- name: 'Span attributes',
- searchPlaceholder: 'span attributes',
- type: TaxonomicFilterGroupType.SpanAttributes,
- endpoint: combineUrl(`api/environments/${projectId}/tracing/spans/attributes`, {
- attribute_type: 'span_attribute',
- ...endpointFilters,
- }).url,
- valuesEndpoint: (key) =>
- combineUrl(`api/environments/${projectId}/tracing/spans/values`, {
- attribute_type: 'span_attribute',
- key: key,
- ...endpointFilters,
- }).url,
- getName: (option: SimpleOption) => option.name,
- getValue: (option: SimpleOption) => option.name,
- getPopoverHeader: () => 'Span attributes',
- },
- {
- name: 'Span resource attributes',
- searchPlaceholder: 'span resources',
- type: TaxonomicFilterGroupType.SpanResourceAttributes,
- endpoint: combineUrl(`api/environments/${projectId}/tracing/spans/attributes`, {
- attribute_type: 'span_resource_attribute',
- ...endpointFilters,
- }).url,
- valuesEndpoint: (key) =>
- combineUrl(`api/environments/${projectId}/tracing/spans/values`, {
- attribute_type: 'span_resource_attribute',
- key: key,
- ...endpointFilters,
- }).url,
- getName: (option: SimpleOption) => option.name,
- getValue: (option: SimpleOption) => option.name,
- getPopoverHeader: () => 'Span resource attributes',
- },
- ],
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/cohortTaxonomicGroupsLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/cohortTaxonomicGroupsLogic.tsx
deleted file mode 100644
index d0c9fe8d5ab7..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/cohortTaxonomicGroupsLogic.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-import { connect, kea, key, path, props, selectors } from 'kea'
-import { combineUrl } from 'kea-router'
-
-import {
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
-} from 'lib/components/TaxonomicFilter/types'
-import { IconCohort } from 'lib/lemon-ui/icons'
-import { Link } from 'lib/lemon-ui/Link'
-import { COHORT_BEHAVIORAL_LIMITATIONS_URL } from 'scenes/feature-flags/constants'
-import { projectLogic } from 'scenes/projectLogic'
-
-import { CohortType } from '~/types'
-
-import type { cohortTaxonomicGroupsLogicType } from './cohortTaxonomicGroupsLogicType'
-
-// Stable reference for CohortsWithAllUsers options to prevent cascading re-renders.
-// taxonomicGroups has 14 dependencies that change during initial mount. Each change creates
-// new group objects with inline options arrays, causing rawLocalItems → fuse → localItems →
-// items → selectedItem reference changes. With CohortsWithAllUsers, selectedItemHasPopover
-// returns true (getValue returns 'all'), so ControlledDefinitionPopover renders and its
-// useEffect dispatches setDefinition on every selectedItem change, triggering kea store updates
-// that combined with react-window's layout effect setState exceed React's 50-update limit.
-const COHORTS_WITH_ALL_USERS_OPTIONS: CohortType[] = [{ id: 'all', name: 'All Users*' } as unknown as CohortType]
-
-export const cohortTaxonomicGroupsLogic = kea<cohortTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'cohortTaxonomicGroupsLogic', key]),
-
- connect(() => ({
- values: [projectLogic, ['currentProjectId']],
- })),
-
- selectors({
- hideBehavioralCohorts: [
- () => [(_, props) => props.hideBehavioralCohorts],
- (hideBehavioralCohorts: boolean | undefined) => hideBehavioralCohorts ?? false,
- ],
- cohortTaxonomicGroups: [
- (s) => [s.currentProjectId, s.hideBehavioralCohorts],
- (projectId, hideBehavioralCohorts): TaxonomicFilterGroup[] => [
- {
- name: 'Cohorts',
- searchPlaceholder: 'cohorts',
- type: TaxonomicFilterGroupType.Cohorts,
- endpoint: combineUrl(`api/projects/${projectId}/cohorts/`).url,
- value: 'cohorts',
- getName: (cohort: CohortType) => cohort.name || `Cohort ${cohort.id}`,
- getValue: (cohort: CohortType) => cohort.id,
- getPopoverHeader: (cohort: CohortType) => `${cohort.is_static ? 'Static' : 'Dynamic'} Cohort`,
- getIcon: function _getIcon(): JSX.Element {
- return <IconCohort className="taxonomy-icon taxonomy-icon-muted" />
- },
- footerMessage: hideBehavioralCohorts ? (
- <>
- <Link to={COHORT_BEHAVIORAL_LIMITATIONS_URL} target="_blank">
- Some cohorts excluded due to containing behavioral filters.
- </Link>
- </>
- ) : undefined,
- },
- {
- name: 'Cohorts',
- searchPlaceholder: 'cohorts',
- type: TaxonomicFilterGroupType.CohortsWithAllUsers,
- endpoint: combineUrl(`api/projects/${projectId}/cohorts/`).url,
- options: COHORTS_WITH_ALL_USERS_OPTIONS,
- getName: (cohort: CohortType) => cohort.name || `Cohort ${cohort.id}`,
- getValue: (cohort: CohortType) => cohort.id,
- getPopoverHeader: () => `All Users`,
- getIcon: function _getIcon(): JSX.Element {
- return <IconCohort className="taxonomy-icon taxonomy-icon-muted" />
- },
- },
- ],
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/eventMetadataTaxonomicGroupsLogic.ts b/frontend/src/lib/components/TaxonomicFilter/eventMetadataTaxonomicGroupsLogic.ts
deleted file mode 100644
index da5e597aa647..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/eventMetadataTaxonomicGroupsLogic.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { connect, kea, key, path, props, selectors } from 'kea'
-
-import {
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
-} from 'lib/components/TaxonomicFilter/types'
-import { getEventMetadataDefinitionIcon } from 'scenes/data-management/events/DefinitionHeader'
-
-import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'
-import { getCoreFilterDefinition } from '~/taxonomy/helpers'
-import { PropertyDefinition } from '~/types'
-
-import type { eventMetadataTaxonomicGroupsLogicType } from './eventMetadataTaxonomicGroupsLogicType'
-
-export const eventMetadataTaxonomicGroupsLogic = kea<eventMetadataTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'eventMetadataTaxonomicGroupsLogic', key]),
-
- connect(() => ({
- values: [propertyDefinitionsModel, ['eventMetadataPropertyDefinitions']],
- })),
-
- selectors({
- eventMetadataTaxonomicGroups: [
- (s) => [s.eventMetadataPropertyDefinitions],
- (eventMetadataPropertyDefinitions): TaxonomicFilterGroup[] => [
- {
- name: 'Event metadata',
- searchPlaceholder: 'event metadata',
- type: TaxonomicFilterGroupType.EventMetadata,
- options: eventMetadataPropertyDefinitions,
- getIcon: (option: PropertyDefinition) => getEventMetadataDefinitionIcon(option),
- getName: (option: PropertyDefinition) => {
- const coreDefinition = getCoreFilterDefinition(
- option.id,
- TaxonomicFilterGroupType.EventMetadata
- )
- return coreDefinition ? coreDefinition.label : option.name
- },
- getValue: (option: PropertyDefinition) => option.id,
- valuesEndpoint: (key) => {
- return `api/event/values/?key=${encodeURIComponent(key)}&is_column=true`
- },
- getPopoverHeader: () => 'Event metadata',
- },
- ],
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/groupAnalyticsTaxonomicGroupsLogic.ts b/frontend/src/lib/components/TaxonomicFilter/groupAnalyticsTaxonomicGroupsLogic.ts
deleted file mode 100644
index cb98ad504e1b..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/groupAnalyticsTaxonomicGroupsLogic.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import { connect, kea, key, path, props, selectors } from 'kea'
-import { combineUrl } from 'kea-router'
-
-import {
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
-} from 'lib/components/TaxonomicFilter/types'
-import { capitalizeFirstLetter, toParams } from 'lib/utils'
-import { getPropertyDefinitionIcon } from 'scenes/data-management/events/DefinitionHeader'
-import { groupDisplayId } from 'scenes/persons/GroupActorDisplay'
-import { projectLogic } from 'scenes/projectLogic'
-import { teamLogic } from 'scenes/teamLogic'
-
-import { groupsModel } from '~/models/groupsModel'
-import { Group } from '~/types'
-
-import type { groupAnalyticsTaxonomicGroupsLogicType } from './groupAnalyticsTaxonomicGroupsLogicType'
-
-export const groupAnalyticsTaxonomicGroupsLogic = kea<groupAnalyticsTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'groupAnalyticsTaxonomicGroupsLogic', key]),
-
- connect(() => ({
- values: [
- teamLogic,
- ['currentTeamId'],
- projectLogic,
- ['currentProjectId'],
- groupsModel,
- ['groupTypes', 'aggregationLabel'],
- ],
- })),
-
- selectors({
- groupAnalyticsTaxonomicGroupNames: [
- (s) => [s.groupTypes, s.currentTeamId, s.aggregationLabel],
- (groupTypes, teamId, aggregationLabel): TaxonomicFilterGroup[] =>
- Array.from(groupTypes.values()).map((type) => ({
- name: `${capitalizeFirstLetter(aggregationLabel(type.group_type_index).plural)}`,
- searchPlaceholder: `${aggregationLabel(type.group_type_index).plural}`,
- type: `${TaxonomicFilterGroupType.GroupNamesPrefix}_${type.group_type_index}` as unknown as TaxonomicFilterGroupType,
- endpoint: combineUrl(`api/environments/${teamId}/groups/`, {
- group_type_index: type.group_type_index,
- }).url,
- getPopoverHeader: () => `Group Names`,
- getName: (group: Group) => groupDisplayId(group.group_key, group.group_properties),
- getValue: (group: Group) => group.group_key,
- groupTypeIndex: type.group_type_index,
- })),
- ],
- groupAnalyticsTaxonomicGroups: [
- (s) => [s.groupTypes, s.currentProjectId, s.aggregationLabel],
- (groupTypes, projectId, aggregationLabel): TaxonomicFilterGroup[] =>
- Array.from(groupTypes.values()).map((type) => ({
- name: `${capitalizeFirstLetter(aggregationLabel(type.group_type_index).singular)} properties`,
- searchPlaceholder: `${aggregationLabel(type.group_type_index).singular} properties`,
- type: `${TaxonomicFilterGroupType.GroupsPrefix}_${type.group_type_index}` as unknown as TaxonomicFilterGroupType,
- endpoint: combineUrl(`api/projects/${projectId}/property_definitions`, {
- type: 'group',
- group_type_index: type.group_type_index,
- exclude_hidden: true,
- exclude_restricted: true,
- }).url,
- valuesEndpoint: (key) =>
- `api/projects/${projectId}/groups/property_values?${toParams({
- key,
- group_type_index: type.group_type_index,
- })}`,
- getName: (group) => group.name,
- getValue: (group) => group.name,
- getPopoverHeader: () => `Property`,
- getIcon: getPropertyDefinitionIcon,
- groupTypeIndex: type.group_type_index,
- })),
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/hogQLExpressionTaxonomicGroupsLogic.ts b/frontend/src/lib/components/TaxonomicFilter/hogQLExpressionTaxonomicGroupsLogic.ts
deleted file mode 100644
index 9197a666343c..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/hogQLExpressionTaxonomicGroupsLogic.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import { kea, key, path, props, selectors } from 'kea'
-
-import {
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
-} from 'lib/components/TaxonomicFilter/types'
-
-import { AnyDataNode, NodeKind } from '~/queries/schema/schema-general'
-
-import type { hogQLExpressionTaxonomicGroupsLogicType } from './hogQLExpressionTaxonomicGroupsLogicType'
-import { InlineHogQLEditor } from './InlineHogQLEditor'
-
-export const hogQLExpressionTaxonomicGroupsLogic = kea<hogQLExpressionTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'hogQLExpressionTaxonomicGroupsLogic', key]),
-
- selectors({
- metadataSource: [
- () => [(_, props) => props.metadataSource],
- (metadataSource): AnyDataNode =>
- metadataSource ?? { kind: NodeKind.HogQLQuery, query: 'select event from events' },
- ],
- hogQLExpressionComponentProps: [
- () => [(_, props) => props.hogQLGlobals, (_, props) => props.hogQLExpressionShowBreakdownLabelHint],
- (
- hogQLGlobals: Record<string, any> | undefined,
- showBreakdownLabelHint: boolean | undefined
- ): { globals?: Record<string, any>; showBreakdownLabelHint: boolean } => ({
- globals: hogQLGlobals,
- showBreakdownLabelHint: showBreakdownLabelHint ?? false,
- }),
- ],
- hogQLExpressionTaxonomicGroups: [
- (s) => [s.metadataSource, s.hogQLExpressionComponentProps],
- (metadataSource, hogQLExpressionComponentProps): TaxonomicFilterGroup[] => [
- {
- name: 'SQL expression',
- searchPlaceholder: null,
- categoryLabel: () => 'SQL expression',
- type: TaxonomicFilterGroupType.HogQLExpression,
- render: InlineHogQLEditor,
- getPopoverHeader: () => 'SQL expression',
- componentProps: { metadataSource, ...hogQLExpressionComponentProps },
- },
- ],
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/maxAIContextTaxonomicGroupsLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/maxAIContextTaxonomicGroupsLogic.tsx
deleted file mode 100644
index b52fb64ca99e..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/maxAIContextTaxonomicGroupsLogic.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { kea, key, path, props, selectors } from 'kea'
-
-import {
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
-} from 'lib/components/TaxonomicFilter/types'
-import { MaxContextTaxonomicFilterOption } from 'scenes/max/maxTypes'
-
-import type { maxAIContextTaxonomicGroupsLogicType } from './maxAIContextTaxonomicGroupsLogicType'
-
-export const maxAIContextTaxonomicGroupsLogic = kea<maxAIContextTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'maxAIContextTaxonomicGroupsLogic', key]),
-
- selectors({
- maxContextOptions: [
- () => [(_, props) => props.maxContextOptions],
- (maxContextOptions) => maxContextOptions ?? [],
- ],
- maxAIContextTaxonomicGroups: [
- (s) => [s.maxContextOptions],
- (maxContextOptions: MaxContextTaxonomicFilterOption[]): TaxonomicFilterGroup[] => [
- {
- name: 'On this page',
- searchPlaceholder: 'elements from this page',
- type: TaxonomicFilterGroupType.MaxAIContext,
- options: maxContextOptions,
- getName: (option: MaxContextTaxonomicFilterOption) => option.name,
- getValue: (option: MaxContextTaxonomicFilterOption) => option.value,
- getIcon: (option: MaxContextTaxonomicFilterOption) => {
- const IconComponent = option.icon
- return <IconComponent />
- },
- getPopoverHeader: () => 'On this page',
- },
- ],
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/posthogResourcesTaxonomicGroupsLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/posthogResourcesTaxonomicGroupsLogic.tsx
deleted file mode 100644
index ecfd4c12cdaf..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/posthogResourcesTaxonomicGroupsLogic.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-import clsx from 'clsx'
-import { connect, kea, key, path, props, selectors } from 'kea'
-import { combineUrl } from 'kea-router'
-
-import { IconFlag } from '@posthog/icons'
-
-import {
- ExcludedProperties,
- TaxonomicDefinitionTypes,
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
-} from 'lib/components/TaxonomicFilter/types'
-import { isString } from 'lib/utils'
-import { experimentsLogic } from 'scenes/experiments/experimentsLogic'
-import { NotebookType } from 'scenes/notebooks/types'
-import { projectLogic } from 'scenes/projectLogic'
-import { teamLogic } from 'scenes/teamLogic'
-
-import { dashboardsModel } from '~/models/dashboardsModel'
-import { DashboardType, Experiment, FeatureFlagType, QueryBasedInsightModel } from '~/types'
-
-import type { posthogResourcesTaxonomicGroupsLogicType } from './posthogResourcesTaxonomicGroupsLogicType'
-
-export const posthogResourcesTaxonomicGroupsLogic = kea<posthogResourcesTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'posthogResourcesTaxonomicGroupsLogic', key]),
-
- connect(() => ({
- values: [teamLogic, ['currentTeam'], projectLogic, ['currentProjectId']],
- })),
-
- selectors({
- excludedProperties: [
- () => [(_, props) => props.excludedProperties],
- (excludedProperties) => (excludedProperties ?? {}) as ExcludedProperties,
- ],
- posthogResourcesTaxonomicGroups: [
- (s) => [s.currentTeam, s.currentProjectId, s.excludedProperties],
- (currentTeam, projectId, excludedProperties): TaxonomicFilterGroup[] => {
- const teamId = currentTeam?.id
- return [
- {
- name: 'Insights',
- searchPlaceholder: 'insights',
- type: TaxonomicFilterGroupType.Insights,
- endpoint: combineUrl(`api/environments/${teamId}/insights/`, {
- saved: true,
- }).url,
- getName: (insight: QueryBasedInsightModel) => insight.name,
- getValue: (insight: QueryBasedInsightModel) => insight.short_id,
- getPopoverHeader: () => `Insights`,
- },
- {
- name: 'Feature Flags',
- searchPlaceholder: 'feature flags',
- type: TaxonomicFilterGroupType.FeatureFlags, // Feature flag dependencies
- endpoint: combineUrl(`api/projects/${projectId}/feature_flags/`).url,
- getName: (featureFlag: FeatureFlagType) => {
- const name = featureFlag.key || featureFlag.name
- const isInactive = !featureFlag.active
- return isInactive ? `${name} (disabled)` : name
- },
- getValue: (featureFlag: FeatureFlagType) => featureFlag.id || '',
- getPopoverHeader: () => `Feature Flags`,
- getIcon: (featureFlag: FeatureFlagType) => (
- <IconFlag className={clsx('size-4', !featureFlag.active && 'text-muted-alt opacity-50')} />
- ),
- getIsDisabled: (featureFlag: FeatureFlagType) => !featureFlag.active,
- localItemsSearch: (
- items: TaxonomicDefinitionTypes[],
- query: string
- ): TaxonomicDefinitionTypes[] => {
- // Note: This function doesn't have direct access to the current value
- // The actual filtering logic needs to be implemented in the infinite list logic
- // For now, just handle search filtering
- if (!query) {
- return items
- }
-
- return items.filter((item: TaxonomicDefinitionTypes) => {
- // Type guard for FeatureFlagType
- if ('key' in item && 'name' in item) {
- const flag = item as unknown as FeatureFlagType
- return (flag.key || flag.name || '').toLowerCase().includes(query.toLowerCase())
- }
- // For other types, check if they have a name property
- if ('name' in item) {
- return (item.name || '').toLowerCase().includes(query.toLowerCase())
- }
- return true
- })
- },
- excludedProperties:
- excludedProperties?.[TaxonomicFilterGroupType.FeatureFlags]?.filter(isString),
- },
- {
- name: 'Experiments',
- searchPlaceholder: 'experiments',
- type: TaxonomicFilterGroupType.Experiments,
- logic: experimentsLogic,
- value: 'experiments',
- getName: (experiment: Experiment) => experiment.name,
- getValue: (experiment: Experiment) => experiment.id,
- getPopoverHeader: () => `Experiments`,
- },
- {
- name: 'Dashboards',
- searchPlaceholder: 'dashboards',
- type: TaxonomicFilterGroupType.Dashboards,
- logic: dashboardsModel,
- value: 'nameSortedDashboards',
- getName: (dashboard: DashboardType) => dashboard.name,
- getValue: (dashboard: DashboardType) => dashboard.id,
- getPopoverHeader: () => `Dashboards`,
- },
- {
- name: 'Notebooks',
- searchPlaceholder: 'notebooks',
- type: TaxonomicFilterGroupType.Notebooks,
- value: 'notebooks',
- endpoint: `api/projects/${projectId}/notebooks/`,
- getName: (notebook: NotebookType) => notebook.title || `Notebook ${notebook.short_id}`,
- getValue: (notebook: NotebookType) => notebook.short_id,
- getPopoverHeader: () => 'Notebooks',
- },
- ]
- },
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/recentPinnedTaxonomicGroupsLogic.ts b/frontend/src/lib/components/TaxonomicFilter/recentPinnedTaxonomicGroupsLogic.ts
deleted file mode 100644
index c1baeb31b76e..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/recentPinnedTaxonomicGroupsLogic.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import { kea, key, path, props, selectors } from 'kea'
-
-import { recentTaxonomicFiltersLogic } from 'lib/components/TaxonomicFilter/recentTaxonomicFiltersLogic'
-import { taxonomicFilterPinnedPropertiesLogic } from 'lib/components/TaxonomicFilter/taxonomicFilterPinnedPropertiesLogic'
-import {
- TaxonomicDefinitionTypes,
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
- TaxonomicFilterValue,
-} from 'lib/components/TaxonomicFilter/types'
-
-import type { recentPinnedTaxonomicGroupsLogicType } from './recentPinnedTaxonomicGroupsLogicType'
-
-export const recentPinnedTaxonomicGroupsLogic = kea<recentPinnedTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'recentPinnedTaxonomicGroupsLogic', key]),
-
- selectors({
- recentPinnedTaxonomicGroups: [
- () => [],
- (): TaxonomicFilterGroup[] => [
- {
- name: 'Recent',
- searchPlaceholder: 'recent',
- type: TaxonomicFilterGroupType.RecentFilters,
- isLocalOnly: true,
- isMetaGroup: true,
- logic: recentTaxonomicFiltersLogic,
- value: 'recentFilterItems',
- getName: (item: TaxonomicDefinitionTypes) => ('name' in item ? item.name : '') || '',
- getValue: (item: TaxonomicDefinitionTypes): TaxonomicFilterValue =>
- 'name' in item ? (item.name ?? null) : null,
- getPopoverHeader: () => 'Recent',
- } as TaxonomicFilterGroup,
- {
- name: 'Pinned',
- searchPlaceholder: 'pinned',
- type: TaxonomicFilterGroupType.PinnedFilters,
- isLocalOnly: true,
- isMetaGroup: true,
- logic: taxonomicFilterPinnedPropertiesLogic,
- value: 'pinnedFilterItems',
- getName: (item: TaxonomicDefinitionTypes) => ('name' in item ? item.name : '') || '',
- getValue: (item: TaxonomicDefinitionTypes): TaxonomicFilterValue =>
- 'name' in item ? (item.name ?? null) : null,
- getPopoverHeader: () => 'Pinned',
- } as TaxonomicFilterGroup,
- ],
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/replayTaxonomicGroupsLogic.ts b/frontend/src/lib/components/TaxonomicFilter/replayTaxonomicGroupsLogic.ts
deleted file mode 100644
index 954eeb36e27a..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/replayTaxonomicGroupsLogic.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-import { connect, kea, key, path, props, selectors } from 'kea'
-import { combineUrl } from 'kea-router'
-
-import {
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
-} from 'lib/components/TaxonomicFilter/types'
-import { projectLogic } from 'scenes/projectLogic'
-import { SavedFiltersTaxonomicGroup } from 'scenes/session-recordings/filters/SavedFiltersTaxonomicGroup'
-import { teamLogic } from 'scenes/teamLogic'
-
-import { getFilterLabel } from '~/taxonomy/helpers'
-import { PropertyFilterType, SessionRecordingPlaylistType } from '~/types'
-
-import type { replayTaxonomicGroupsLogicType } from './replayTaxonomicGroupsLogicType'
-
-export const replayTaxonomicGroupsLogic = kea<replayTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'replayTaxonomicGroupsLogic', key]),
-
- connect(() => ({
- values: [teamLogic, ['currentTeam'], projectLogic, ['currentProjectId']],
- })),
-
- selectors({
- replayTaxonomicGroups: [
- (s) => [s.currentTeam, s.currentProjectId],
- (currentTeam, projectId): TaxonomicFilterGroup[] => {
- const teamId = currentTeam?.id
- return [
- {
- name: 'Replay',
- searchPlaceholder: 'Replay',
- type: TaxonomicFilterGroupType.Replay,
- options: [
- {
- key: 'visited_page',
- name: getFilterLabel('visited_page', TaxonomicFilterGroupType.Replay),
- propertyFilterType: PropertyFilterType.Recording,
- },
- {
- key: 'snapshot_source',
- name: getFilterLabel('snapshot_source', TaxonomicFilterGroupType.Replay),
- propertyFilterType: PropertyFilterType.Recording,
- },
- {
- key: 'level',
- name: getFilterLabel('level', TaxonomicFilterGroupType.LogEntries),
- propertyFilterType: PropertyFilterType.LogEntry,
- },
- {
- key: 'message',
- name: getFilterLabel('message', TaxonomicFilterGroupType.LogEntries),
- propertyFilterType: PropertyFilterType.LogEntry,
- },
- {
- key: 'comment_text',
- name: getFilterLabel('comment_text', TaxonomicFilterGroupType.Replay),
- propertyFilterType: PropertyFilterType.Recording,
- },
- ],
- getName: (option: Record<string, any>) => option.name,
- getValue: (option: Record<string, any>) => option.key,
- valuesEndpoint: (key) => {
- if (key === 'visited_page') {
- return (
- `api/environments/${teamId}/events/values/?key=` +
- encodeURIComponent('$current_url') +
- '&event_name=' +
- encodeURIComponent('$pageview')
- )
- }
- },
- getPopoverHeader: () => 'Replay',
- },
- {
- name: 'Saved filters',
- searchPlaceholder: 'saved filters',
- type: TaxonomicFilterGroupType.ReplaySavedFilters,
- endpoint: combineUrl(`api/projects/${projectId}/session_recording_playlists/`, {
- type: 'filters',
- order: '-last_modified_at',
- }).url,
- render: SavedFiltersTaxonomicGroup,
- getName: (filter: SessionRecordingPlaylistType) =>
- filter.name || filter.derived_name || 'Unnamed',
- getValue: (filter: SessionRecordingPlaylistType) => filter.short_id,
- getPopoverHeader: () => 'Saved filter',
- },
- ]
- },
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/suggestedFiltersTaxonomicGroupsLogic.ts b/frontend/src/lib/components/TaxonomicFilter/suggestedFiltersTaxonomicGroupsLogic.ts
deleted file mode 100644
index b5f565ba1524..000000000000
--- a/frontend/src/lib/components/TaxonomicFilter/suggestedFiltersTaxonomicGroupsLogic.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { connect, kea, key, path, props, selectors } from 'kea'
-
-import {
- TaxonomicDefinitionTypes,
- TaxonomicFilterGroup,
- TaxonomicFilterGroupType,
- TaxonomicFilterLogicProps,
- TaxonomicFilterValue,
-} from 'lib/components/TaxonomicFilter/types'
-import { getDistinctPrimaryPropertiesForEvents } from 'lib/utils/primaryEventProperty'
-
-import { primaryEventPropertiesModel } from '~/models/primaryEventPropertiesModel'
-
-import type { suggestedFiltersTaxonomicGroupsLogicType } from './suggestedFiltersTaxonomicGroupsLogicType'
-
-export const suggestedFiltersTaxonomicGroupsLogic = kea<suggestedFiltersTaxonomicGroupsLogicType>([
- props({} as TaxonomicFilterLogicProps),
- key((props) => `${props.taxonomicFilterLogicKey}`),
- path((key) => ['lib', 'components', 'TaxonomicFilter', 'suggestedFiltersTaxonomicGroupsLogic', key]),
-
- connect(() => ({
- values: [primaryEventPropertiesModel, ['primaryProperties']],
- })),
-
- selectors({
- suggestedFiltersLabel: [
- () => [(_, props) => props.suggestedFiltersLabel],
- (suggestedFiltersLabel) => suggestedFiltersLabel,
- ],
- eventNames: [() => [(_, props) => props.eventNames], (eventNames) => eventNames ?? []],
- primaryPropertiesForContextEvents: [
- (s) => [s.eventNames, s.primaryProperties],
- (eventNames: string[], primaryProperties: Record<string, string>): string[] =>
- getDistinctPrimaryPropertiesForEvents(eventNames, primaryProperties),
- ],
- suggestedFiltersTaxonomicGroups: [
- (s) => [s.suggestedFiltersLabel, s.eventNames, s.primaryPropertiesForContextEvents],
- (
- suggestedFiltersLabel: string | undefined,
- eventNames: string[],
- primaryPropertiesForContextEvents: string[]
- ): TaxonomicFilterGroup[] => [
- {
- name: suggestedFiltersLabel ?? 'Suggested filters',
- searchPlaceholder: (suggestedFiltersLabel ?? 'Suggested filters').toLowerCase(),
- categoryLabel: (count: number) =>
- (suggestedFiltersLabel ?? 'Suggested filters') + (count > 0 ? `: ${count}` : ''),
- type: TaxonomicFilterGroupType.SuggestedFilters,
- isLocalOnly: true,
- isMetaGroup: true,
- options: [
- // Promoted properties for any event in context come first — if a team
- // has marked a property as the one that summarises this event, it's
- // the property they almost certainly want to filter or break down by.
- ...primaryPropertiesForContextEvents.map((name) => ({
- name,
- group: TaxonomicFilterGroupType.EventProperties,
- })),
- ...(eventNames.includes('$autocapture')
- ? (['text', 'selector'] as const).map((name) => ({
- name,
- group: TaxonomicFilterGroupType.Elements,
- }))
- : []),
- ],
- getName: (item: TaxonomicDefinitionTypes) => ('name' in item ? item.name : '') || '',
- getValue: (item: TaxonomicDefinitionTypes): TaxonomicFilterValue =>
- 'name' in item ? (item.name ?? null) : null,
- getPopoverHeader: () => suggestedFiltersLabel ?? 'Suggested filters',
- },
- ],
- ],
- }),
-])
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 38f6e7e43f6a..61127f53b2d9 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -1,3 +1,4 @@
+import clsx from 'clsx'
import {
BuiltLogic,
actions,
@@ -16,7 +17,7 @@ import {
import { combineUrl } from 'kea-router'
import posthog from 'posthog-js'
-import { IconCursor, IconServer } from '@posthog/icons'
+import { IconCursor, IconFlag, IconServer } from '@posthog/icons'
import {
buildAutocaptureSeriesShortcuts,
@@ -29,7 +30,10 @@ import {
recentTaxonomicFiltersLogic,
stripRecentContext,
} from 'lib/components/TaxonomicFilter/recentTaxonomicFiltersLogic'
-import { hasPinnedContext } from 'lib/components/TaxonomicFilter/taxonomicFilterPinnedPropertiesLogic'
+import {
+ hasPinnedContext,
+ taxonomicFilterPinnedPropertiesLogic,
+} from 'lib/components/TaxonomicFilter/taxonomicFilterPinnedPropertiesLogic'
import {
DataWarehousePopoverField,
ExcludedProperties,
@@ -46,37 +50,57 @@ import {
isQuickFilterItem,
} from 'lib/components/TaxonomicFilter/types'
import { FEATURE_FLAGS } from 'lib/constants'
+import { IconCohort } from 'lib/lemon-ui/icons'
+import { Link } from 'lib/lemon-ui/Link'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { isString, objectsEqual, pluralize } from 'lib/utils'
+import { capitalizeFirstLetter, isString, objectsEqual, pluralize, toParams } from 'lib/utils'
import { isDefinitionStale } from 'lib/utils/definitions'
+import { getPrimaryPropertyForEvent } from 'lib/utils/primaryEventProperty'
import {
getEventDefinitionIcon,
+ getEventMetadataDefinitionIcon,
getPropertyDefinitionIcon,
getRevenueAnalyticsDefinitionIcon,
} from 'scenes/data-management/events/DefinitionHeader'
import { dataWarehouseSettingsSceneLogic } from 'scenes/data-warehouse/settings/dataWarehouseSettingsSceneLogic'
+import { experimentsLogic } from 'scenes/experiments/experimentsLogic'
+import { COHORT_BEHAVIORAL_LIMITATIONS_URL } from 'scenes/feature-flags/constants'
import {
getProductEventFilterOptions,
getProductEventPropertyFilterOptions,
} from 'scenes/hog-functions/filters/HogFunctionFiltersInternal'
+import { MaxContextTaxonomicFilterOption } from 'scenes/max/maxTypes'
+import { NotebookType } from 'scenes/notebooks/types'
+import { groupDisplayId } from 'scenes/persons/GroupActorDisplay'
import { projectLogic } from 'scenes/projectLogic'
+import { SavedFiltersTaxonomicGroup } from 'scenes/session-recordings/filters/SavedFiltersTaxonomicGroup'
import { teamLogic } from 'scenes/teamLogic'
import { actionsModel } from '~/models/actionsModel'
+import { dashboardsModel } from '~/models/dashboardsModel'
+import { groupsModel } from '~/models/groupsModel'
import { primaryEventPropertiesModel } from '~/models/primaryEventPropertiesModel'
-import { updatePropertyDefinitions } from '~/models/propertyDefinitionsModel'
-import { DatabaseSchemaField, DatabaseSchemaTable } from '~/queries/schema/schema-general'
-import { getCoreFilterDefinition } from '~/taxonomy/helpers'
+import { propertyDefinitionsModel, updatePropertyDefinitions } from '~/models/propertyDefinitionsModel'
+import { AnyDataNode, DatabaseSchemaField, DatabaseSchemaTable, NodeKind } from '~/queries/schema/schema-general'
+import { getCoreFilterDefinition, getFilterLabel } from '~/taxonomy/helpers'
import { CORE_FILTER_DEFINITIONS_BY_GROUP } from '~/taxonomy/taxonomy'
import {
ActionType,
+ CohortType,
CoreFilterDefinition,
+ DashboardType,
EventDefinition,
EventDefinitionType,
+ Experiment,
+ FeatureFlagType,
+ Group,
PersonProperty,
PersonType,
PropertyDefinition,
PropertyDefinitionType,
+ PropertyFilterType,
+ QueryBasedInsightModel,
+ SessionRecordingPlaylistType,
TeamType,
} from '~/types'
@@ -84,16 +108,7 @@ import { joinsLogic } from 'products/data_warehouse/frontend/shared/logics/joins
import { HogFlowTaxonomicFilters } from 'products/workflows/frontend/Workflows/hogflows/filters/HogFlowTaxonomicFilters'
import { PROPERTY_FILTER_TYPE_TO_TAXONOMIC_FILTER_GROUP_TYPE } from '../PropertyFilters/utils'
-import { apmTaxonomicGroupsLogic } from './apmTaxonomicGroupsLogic'
-import { cohortTaxonomicGroupsLogic } from './cohortTaxonomicGroupsLogic'
-import { eventMetadataTaxonomicGroupsLogic } from './eventMetadataTaxonomicGroupsLogic'
-import { groupAnalyticsTaxonomicGroupsLogic } from './groupAnalyticsTaxonomicGroupsLogic'
-import { hogQLExpressionTaxonomicGroupsLogic } from './hogQLExpressionTaxonomicGroupsLogic'
-import { maxAIContextTaxonomicGroupsLogic } from './maxAIContextTaxonomicGroupsLogic'
-import { posthogResourcesTaxonomicGroupsLogic } from './posthogResourcesTaxonomicGroupsLogic'
-import { recentPinnedTaxonomicGroupsLogic } from './recentPinnedTaxonomicGroupsLogic'
-import { replayTaxonomicGroupsLogic } from './replayTaxonomicGroupsLogic'
-import { suggestedFiltersTaxonomicGroupsLogic } from './suggestedFiltersTaxonomicGroupsLogic'
+import { InlineHogQLEditor } from './InlineHogQLEditor'
import type { taxonomicFilterLogicType } from './taxonomicFilterLogicType'
const PROPERTY_TAXONOMIC_GROUP_TYPES = new Set(Object.values(PROPERTY_FILTER_TYPE_TO_TAXONOMIC_FILTER_GROUP_TYPE))
@@ -280,6 +295,15 @@ function withKeywordShortcuts<T>(
}
}
+// Stable reference for CohortsWithAllUsers options to prevent cascading re-renders.
+// taxonomicGroups has 14 dependencies that change during initial mount. Each change creates
+// new group objects with inline options arrays, causing rawLocalItems → fuse → localItems →
+// items → selectedItem reference changes. With CohortsWithAllUsers, selectedItemHasPopover
+// returns true (getValue returns 'all'), so ControlledDefinitionPopover renders and its
+// useEffect dispatches setDefinition on every selectedItem change, triggering kea store updates
+// that combined with react-window's layout effect setState exceed React's 50-update limit.
+const COHORTS_WITH_ALL_USERS_OPTIONS: CohortType[] = [{ id: 'all', name: 'All Users*' } as unknown as CohortType]
+
export const defaultDataWarehousePopoverFields: DataWarehousePopoverField[] = [
{
key: 'id_field',
@@ -307,32 +331,18 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
['currentTeamId', 'currentTeam'],
projectLogic,
['currentProjectId'],
+ groupsModel,
+ ['groupTypes', 'aggregationLabel'],
dataWarehouseSettingsSceneLogic, // This logic needs to be connected to stop the popover from erroring out
['dataWarehouseTables'],
joinsLogic,
['columnsJoinedToPersons'],
+ propertyDefinitionsModel,
+ ['eventMetadataPropertyDefinitions'],
featureFlagLogic,
['featureFlags'],
- groupAnalyticsTaxonomicGroupsLogic,
- ['groupAnalyticsTaxonomicGroups', 'groupAnalyticsTaxonomicGroupNames'],
- cohortTaxonomicGroupsLogic,
- ['cohortTaxonomicGroups'],
- hogQLExpressionTaxonomicGroupsLogic,
- ['hogQLExpressionTaxonomicGroups'],
- eventMetadataTaxonomicGroupsLogic,
- ['eventMetadataTaxonomicGroups'],
- maxAIContextTaxonomicGroupsLogic,
- ['maxAIContextTaxonomicGroups'],
- suggestedFiltersTaxonomicGroupsLogic,
- ['suggestedFiltersTaxonomicGroups'],
- apmTaxonomicGroupsLogic,
- ['apmTaxonomicGroups'],
- recentPinnedTaxonomicGroupsLogic,
- ['recentPinnedTaxonomicGroups'],
- replayTaxonomicGroupsLogic,
- ['replayTaxonomicGroups'],
- posthogResourcesTaxonomicGroupsLogic,
- ['posthogResourcesTaxonomicGroups'],
+ primaryEventPropertiesModel,
+ ['primaryProperties'],
],
actions: [primaryEventPropertiesModel, ['ensureLoadedForEvents']],
})),
@@ -473,30 +483,49 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
(taxonomicFilterLogicKey) => taxonomicFilterLogicKey,
],
eventNames: [() => [(_, props) => props.eventNames], (eventNames) => eventNames ?? []],
- // Combined into a single selector so taxonomicGroups stays under kea's 16-dep
- // tuple type limit; consumers spread directly.
- allGroupAnalyticsTaxonomicGroups: [
- (s) => [s.groupAnalyticsTaxonomicGroups, s.groupAnalyticsTaxonomicGroupNames],
- (
- groupAnalyticsTaxonomicGroups: TaxonomicFilterGroup[],
- groupAnalyticsTaxonomicGroupNames: TaxonomicFilterGroup[]
- ): TaxonomicFilterGroup[] => [...groupAnalyticsTaxonomicGroups, ...groupAnalyticsTaxonomicGroupNames],
- ],
- // Combined into a single selector so taxonomicGroups stays under kea's 16-dep
- // tuple type limit; consumers spread directly. Both are meta-groups appearing
- // adjacent at the end of taxonomicGroups.
- allMetaTaxonomicGroups: [
- (s) => [s.suggestedFiltersTaxonomicGroups, s.recentPinnedTaxonomicGroups],
+ // Combined selector that returns both event names and the distinct primary properties
+ // for those events. Combined into a single selector so taxonomicGroups stays under
+ // kea's 16-dep tuple type limit; consumers destructure both fields.
+ eventNamesWithPrimaryProperties: [
+ (s) => [s.eventNames, s.primaryProperties],
(
- suggestedFiltersTaxonomicGroups: TaxonomicFilterGroup[],
- recentPinnedTaxonomicGroups: TaxonomicFilterGroup[]
- ): TaxonomicFilterGroup[] => [...suggestedFiltersTaxonomicGroups, ...recentPinnedTaxonomicGroups],
+ eventNames: string[],
+ primaryProperties: Record<string, string>
+ ): {
+ eventNames: string[]
+ primaryPropertiesForContextEvents: string[]
+ } => {
+ const distinct = new Set<string>()
+ for (const eventName of eventNames) {
+ const primary = getPrimaryPropertyForEvent(eventName, primaryProperties)
+ if (primary) {
+ distinct.add(primary)
+ }
+ }
+ return {
+ eventNames,
+ primaryPropertiesForContextEvents: Array.from(distinct),
+ }
+ },
],
schemaColumns: [() => [(_, props) => props.schemaColumns], (schemaColumns) => schemaColumns ?? []],
+ maxContextOptions: [
+ () => [(_, props) => props.maxContextOptions],
+ (maxContextOptions) => maxContextOptions ?? [],
+ ],
dataWarehousePopoverFields: [
() => [(_, props) => props.dataWarehousePopoverFields],
(dataWarehousePopoverFields) => dataWarehousePopoverFields ?? [],
],
+ suggestedFiltersLabel: [
+ () => [(_, props) => props.suggestedFiltersLabel],
+ (suggestedFiltersLabel) => suggestedFiltersLabel,
+ ],
+ metadataSource: [
+ () => [(_, props) => props.metadataSource],
+ (metadataSource): AnyDataNode =>
+ metadataSource ?? { kind: NodeKind.HogQLQuery, query: 'select event from events' },
+ ],
excludedProperties: [
() => [(_, props) => props.excludedProperties],
(excludedProperties) => (excludedProperties ?? {}) as ExcludedProperties,
@@ -521,43 +550,64 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
() => [(_, props) => props.hideBehavioralCohorts],
(hideBehavioralCohorts: boolean | undefined) => hideBehavioralCohorts ?? false,
],
+ hogQLExpressionComponentProps: [
+ () => [(_, props) => props.hogQLGlobals, (_, props) => props.hogQLExpressionShowBreakdownLabelHint],
+ (
+ hogQLGlobals: Record<string, any> | undefined,
+ showBreakdownLabelHint: boolean | undefined
+ ): { globals?: Record<string, any>; showBreakdownLabelHint: boolean } => ({
+ globals: hogQLGlobals,
+ showBreakdownLabelHint: showBreakdownLabelHint ?? false,
+ }),
+ ],
+ endpointFilters: [
+ () => [(_, props) => props.endpointFilters],
+ (endpointFilters: Record<string, any>) => endpointFilters,
+ ],
taxonomicGroups: [
(s) => [
s.currentTeam,
s.currentProjectId,
- s.allGroupAnalyticsTaxonomicGroups,
- s.eventNames,
+ s.groupAnalyticsTaxonomicGroups,
+ s.groupAnalyticsTaxonomicGroupNames,
+ s.eventNamesWithPrimaryProperties,
s.schemaColumns,
(_, props) => props.schemaColumnsLoading,
- s.hogQLExpressionTaxonomicGroups,
- s.allMetaTaxonomicGroups,
+ s.metadataSource,
+ s.suggestedFiltersLabel,
s.propertyFilters,
- s.eventMetadataTaxonomicGroups,
- s.maxAIContextTaxonomicGroups,
- s.cohortTaxonomicGroups,
- s.apmTaxonomicGroups,
+ s.eventMetadataPropertyDefinitions,
+ s.maxContextOptions,
+ s.hideBehavioralCohorts,
+ s.endpointFilters,
+ s.hogQLExpressionComponentProps,
s.featureFlags,
- s.replayTaxonomicGroups,
- s.posthogResourcesTaxonomicGroups,
],
(
currentTeam: TeamType,
projectId: number | null,
- allGroupAnalyticsTaxonomicGroups: TaxonomicFilterGroup[],
- eventNames: string[],
+ groupAnalyticsTaxonomicGroups: TaxonomicFilterGroup[],
+ groupAnalyticsTaxonomicGroupNames: TaxonomicFilterGroup[],
+ eventNamesWithPrimaryProperties: {
+ eventNames: string[]
+ primaryPropertiesForContextEvents: string[]
+ },
schemaColumns: DatabaseSchemaField[],
schemaColumnsLoading: boolean | undefined,
- hogQLExpressionTaxonomicGroups: TaxonomicFilterGroup[],
- allMetaTaxonomicGroups: TaxonomicFilterGroup[],
+ metadataSource: AnyDataNode,
+ suggestedFiltersLabel: string | undefined,
propertyFilters,
- eventMetadataTaxonomicGroups: TaxonomicFilterGroup[],
- maxAIContextTaxonomicGroups: TaxonomicFilterGroup[],
- cohortTaxonomicGroups: TaxonomicFilterGroup[],
- apmTaxonomicGroups: TaxonomicFilterGroup[],
- featureFlags: Record<string, boolean | string | undefined>,
- replayTaxonomicGroups: TaxonomicFilterGroup[],
- posthogResourcesTaxonomicGroups: TaxonomicFilterGroup[]
+ eventMetadataPropertyDefinitions: PropertyDefinition[],
+ maxContextOptions: MaxContextTaxonomicFilterOption[],
+ hideBehavioralCohorts: boolean,
+ endpointFilters: Record<string, any> | undefined,
+ hogQLExpressionComponentProps: {
+ globals?: Record<string, any>
+ showBreakdownLabelHint: boolean
+ },
+ featureFlags: Record<string, boolean | string | undefined>
): TaxonomicFilterGroup[] => {
+ const { eventNames, primaryPropertiesForContextEvents } = eventNamesWithPrimaryProperties
const { id: teamId } = currentTeam
const { excludedProperties, propertyAllowList } = propertyFilters
const groups: TaxonomicFilterGroup[] = [
@@ -762,7 +812,25 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
getIcon: getPropertyDefinitionIcon,
getPopoverHeader: () => 'Internal event properties',
},
- ...eventMetadataTaxonomicGroups,
+ {
+ name: 'Event metadata',
+ searchPlaceholder: 'event metadata',
+ type: TaxonomicFilterGroupType.EventMetadata,
+ options: eventMetadataPropertyDefinitions,
+ getIcon: (option: PropertyDefinition) => getEventMetadataDefinitionIcon(option),
+ getName: (option: PropertyDefinition) => {
+ const coreDefinition = getCoreFilterDefinition(
+ option.id,
+ TaxonomicFilterGroupType.EventMetadata
+ )
+ return coreDefinition ? coreDefinition.label : option.name
+ },
+ getValue: (option: PropertyDefinition) => option.id,
+ valuesEndpoint: (key) => {
+ return `api/event/values/?key=${encodeURIComponent(key)}&is_column=true`
+ },
+ getPopoverHeader: () => 'Event metadata',
+ },
{
name: 'Feature flags',
searchPlaceholder: 'feature flags',
@@ -871,7 +939,144 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
},
getPopoverHeader: () => 'Revenue analytics properties',
},
- ...apmTaxonomicGroups,
+ {
+ name: 'Logs',
+ searchPlaceholder: 'logs',
+ type: TaxonomicFilterGroupType.Logs,
+ options: [
+ { key: 'message', name: 'message', propertyFilterType: 'log' },
+ { key: 'severity_level', name: 'severity_level', propertyFilterType: 'log' },
+ { key: 'trace_id', name: 'trace_id', propertyFilterType: 'log' },
+ { key: 'span_id', name: 'span_id', propertyFilterType: 'log' },
+ ],
+ localItemsSearch: (items: any[], q: string): any[] => {
+ if (!q) {
+ return items
+ }
+ return [
+ {
+ key: 'message',
+ name: 'Search log message for "' + q + '"',
+ value: q,
+ propertyFilterType: 'log',
+ },
+ ].concat(items.filter((item) => item.name?.toLowerCase().includes(q.toLowerCase())))
+ },
+ getName: (option: { key: string; name: string }) => option.name,
+ getValue: (option: { key: string; name: string }) => option.key,
+ getPopoverHeader: () => 'Log attributes',
+ },
+ {
+ name: 'Log attributes',
+ searchPlaceholder: 'attributes',
+ type: TaxonomicFilterGroupType.LogAttributes,
+ endpoint: combineUrl(`api/environments/${projectId}/logs/attributes`, {
+ attribute_type: 'log',
+ search_values: 'true',
+ ...endpointFilters,
+ }).url,
+ valuesEndpoint: (key) =>
+ combineUrl(`api/environments/${projectId}/logs/values`, {
+ attribute_type: 'log',
+ key: key,
+ ...endpointFilters,
+ }).url,
+ getName: (option: SimpleOption) => option.name,
+ getValue: (option: SimpleOption) => option.name,
+ getPopoverHeader: () => 'Log attributes',
+ },
+ {
+ name: 'Resource attributes',
+ searchPlaceholder: 'resources',
+ type: TaxonomicFilterGroupType.LogResourceAttributes,
+ endpoint: combineUrl(`api/environments/${projectId}/logs/attributes`, {
+ attribute_type: 'resource',
+ search_values: 'true',
+ ...endpointFilters,
+ }).url,
+ valuesEndpoint: (key) =>
+ combineUrl(`api/environments/${projectId}/logs/values`, {
+ attribute_type: 'resource',
+ key: key,
+ ...endpointFilters,
+ }).url,
+ getName: (option: SimpleOption) => option.name,
+ getValue: (option: SimpleOption) => option.name,
+ getPopoverHeader: () => 'Resource attributes',
+ },
+ {
+ name: 'Spans',
+ searchPlaceholder: 'spans',
+ type: TaxonomicFilterGroupType.Spans,
+ options: [
+ { key: 'name', name: 'name', propertyFilterType: 'span' },
+ { key: 'kind', name: 'kind', propertyFilterType: 'span' },
+ { key: 'duration', name: 'duration (ms)', propertyFilterType: 'span' },
+ { key: 'trace_id', name: 'trace_id', propertyFilterType: 'span' },
+ { key: 'span_id', name: 'span_id', propertyFilterType: 'span' },
+ { key: 'status_code', name: 'status code', propertyFilterType: 'span' },
+ ],
+ valuesEndpoint: (key) =>
+ key === 'name'
+ ? combineUrl(`api/environments/${projectId}/tracing/spans/values`, {
+ attribute_type: 'span',
+ key: key,
+ ...endpointFilters,
+ }).url
+ : undefined,
+ localItemsSearch: (items: any[], q: string): any[] => {
+ if (!q) {
+ return items
+ }
+ return [
+ {
+ key: 'message',
+ name: 'Search span message for "' + q + '"',
+ value: q,
+ propertyFilterType: 'span',
+ },
+ ].concat(items.filter((item) => item.name?.toLowerCase().includes(q.toLowerCase())))
+ },
+ getName: (option: { key: string; name: string }) => option.name,
+ getValue: (option: { key: string; name: string }) => option.key,
+ getPopoverHeader: () => 'Span attributes',
+ },
+ {
+ name: 'Span attributes',
+ searchPlaceholder: 'span attributes',
+ type: TaxonomicFilterGroupType.SpanAttributes,
+ endpoint: combineUrl(`api/environments/${projectId}/tracing/spans/attributes`, {
+ attribute_type: 'span_attribute',
+ ...endpointFilters,
+ }).url,
+ valuesEndpoint: (key) =>
+ combineUrl(`api/environments/${projectId}/tracing/spans/values`, {
+ attribute_type: 'span_attribute',
+ key: key,
+ ...endpointFilters,
+ }).url,
+ getName: (option: SimpleOption) => option.name,
+ getValue: (option: SimpleOption) => option.name,
+ getPopoverHeader: () => 'Span attributes',
+ },
+ {
+ name: 'Span resource attributes',
+ searchPlaceholder: 'span resources',
+ type: TaxonomicFilterGroupType.SpanResourceAttributes,
+ endpoint: combineUrl(`api/environments/${projectId}/tracing/spans/attributes`, {
+ attribute_type: 'span_resource_attribute',
+ ...endpointFilters,
+ }).url,
+ valuesEndpoint: (key) =>
+ combineUrl(`api/environments/${projectId}/tracing/spans/values`, {
+ attribute_type: 'span_resource_attribute',
+ key: key,
+ ...endpointFilters,
+ }).url,
+ getName: (option: SimpleOption) => option.name,
+ getValue: (option: SimpleOption) => option.name,
+ getPopoverHeader: () => 'Span resource attributes',
+ },
{
name: 'Numerical event properties',
searchPlaceholder: 'numerical event properties',
@@ -902,7 +1107,39 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
propertyAllowList?.[TaxonomicFilterGroupType.PersonProperties]?.filter(isString),
...propertyTaxonomicGroupProps(CORE_FILTER_DEFINITIONS_BY_GROUP.person_properties),
},
- ...cohortTaxonomicGroups,
+ {
+ name: 'Cohorts',
+ searchPlaceholder: 'cohorts',
+ type: TaxonomicFilterGroupType.Cohorts,
+ endpoint: combineUrl(`api/projects/${projectId}/cohorts/`).url,
+ value: 'cohorts',
+ getName: (cohort: CohortType) => cohort.name || `Cohort ${cohort.id}`,
+ getValue: (cohort: CohortType) => cohort.id,
+ getPopoverHeader: (cohort: CohortType) => `${cohort.is_static ? 'Static' : 'Dynamic'} Cohort`,
+ getIcon: function _getIcon(): JSX.Element {
+ return <IconCohort className="taxonomy-icon taxonomy-icon-muted" />
+ },
+ footerMessage: hideBehavioralCohorts ? (
+ <>
+ <Link to={COHORT_BEHAVIORAL_LIMITATIONS_URL} target="_blank">
+ Some cohorts excluded due to containing behavioral filters.
+ </Link>
+ </>
+ ) : undefined,
+ },
+ {
+ name: 'Cohorts',
+ searchPlaceholder: 'cohorts',
+ type: TaxonomicFilterGroupType.CohortsWithAllUsers,
+ endpoint: combineUrl(`api/projects/${projectId}/cohorts/`).url,
+ options: COHORTS_WITH_ALL_USERS_OPTIONS,
+ getName: (cohort: CohortType) => cohort.name || `Cohort ${cohort.id}`,
+ getValue: (cohort: CohortType) => cohort.id,
+ getPopoverHeader: () => `All Users`,
+ getIcon: function _getIcon(): JSX.Element {
+ return <IconCohort className="taxonomy-icon taxonomy-icon-muted" />
+ },
+ },
// PageviewUrls returns a URL string value, used in paths and property filters.
// PageviewEvents creates a $pageview event with $current_url property filter,
// used in trends and funnels series pickers.
@@ -1011,7 +1248,90 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
getValue: (person: PersonType) => person.distinct_ids?.[0],
getPopoverHeader: () => `Person`,
},
- ...posthogResourcesTaxonomicGroups,
+ {
+ name: 'Insights',
+ searchPlaceholder: 'insights',
+ type: TaxonomicFilterGroupType.Insights,
+ endpoint: combineUrl(`api/environments/${teamId}/insights/`, {
+ saved: true,
+ }).url,
+ getName: (insight: QueryBasedInsightModel) => insight.name,
+ getValue: (insight: QueryBasedInsightModel) => insight.short_id,
+ getPopoverHeader: () => `Insights`,
+ },
+ {
+ name: 'Feature Flags',
+ searchPlaceholder: 'feature flags',
+ type: TaxonomicFilterGroupType.FeatureFlags, // Feature flag dependencies
+ endpoint: combineUrl(`api/projects/${projectId}/feature_flags/`).url,
+ getName: (featureFlag: FeatureFlagType) => {
+ const name = featureFlag.key || featureFlag.name
+ const isInactive = !featureFlag.active
+ return isInactive ? `${name} (disabled)` : name
+ },
+ getValue: (featureFlag: FeatureFlagType) => featureFlag.id || '',
+ getPopoverHeader: () => `Feature Flags`,
+ getIcon: (featureFlag: FeatureFlagType) => (
+ <IconFlag className={clsx('size-4', !featureFlag.active && 'text-muted-alt opacity-50')} />
+ ),
+ getIsDisabled: (featureFlag: FeatureFlagType) => !featureFlag.active,
+ localItemsSearch: (
+ items: TaxonomicDefinitionTypes[],
+ query: string
+ ): TaxonomicDefinitionTypes[] => {
+ // Note: This function doesn't have direct access to the current value
+ // The actual filtering logic needs to be implemented in the infinite list logic
+ // For now, just handle search filtering
+ if (!query) {
+ return items
+ }
+
+ return items.filter((item: TaxonomicDefinitionTypes) => {
+ // Type guard for FeatureFlagType
+ if ('key' in item && 'name' in item) {
+ const flag = item as unknown as FeatureFlagType
+ return (flag.key || flag.name || '').toLowerCase().includes(query.toLowerCase())
+ }
+ // For other types, check if they have a name property
+ if ('name' in item) {
+ return (item.name || '').toLowerCase().includes(query.toLowerCase())
+ }
+ return true
+ })
+ },
+ excludedProperties:
+ excludedProperties?.[TaxonomicFilterGroupType.FeatureFlags]?.filter(isString),
+ },
+ {
+ name: 'Experiments',
+ searchPlaceholder: 'experiments',
+ type: TaxonomicFilterGroupType.Experiments,
+ logic: experimentsLogic,
+ value: 'experiments',
+ getName: (experiment: Experiment) => experiment.name,
+ getValue: (experiment: Experiment) => experiment.id,
+ getPopoverHeader: () => `Experiments`,
+ },
+ {
+ name: 'Dashboards',
+ searchPlaceholder: 'dashboards',
+ type: TaxonomicFilterGroupType.Dashboards,
+ logic: dashboardsModel,
+ value: 'nameSortedDashboards',
+ getName: (dashboard: DashboardType) => dashboard.name,
+ getValue: (dashboard: DashboardType) => dashboard.id,
+ getPopoverHeader: () => `Dashboards`,
+ },
+ {
+ name: 'Notebooks',
+ searchPlaceholder: 'notebooks',
+ type: TaxonomicFilterGroupType.Notebooks,
+ value: 'notebooks',
+ endpoint: `api/projects/${projectId}/notebooks/`,
+ getName: (notebook: NotebookType) => notebook.title || `Notebook ${notebook.short_id}`,
+ getValue: (notebook: NotebookType) => notebook.short_id,
+ getPopoverHeader: () => 'Notebooks',
+ },
{
name: 'Session properties',
searchPlaceholder: 'sessions',
@@ -1033,11 +1353,143 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
getPopoverHeader: () => 'Session',
getIcon: getPropertyDefinitionIcon,
},
- ...hogQLExpressionTaxonomicGroups,
- ...replayTaxonomicGroups,
- ...maxAIContextTaxonomicGroups,
- ...allMetaTaxonomicGroups,
- ...allGroupAnalyticsTaxonomicGroups,
+ {
+ name: 'SQL expression',
+ searchPlaceholder: null,
+ categoryLabel: () => 'SQL expression',
+ type: TaxonomicFilterGroupType.HogQLExpression,
+ render: InlineHogQLEditor,
+ getPopoverHeader: () => 'SQL expression',
+ componentProps: { metadataSource, ...hogQLExpressionComponentProps },
+ },
+ {
+ name: 'Replay',
+ searchPlaceholder: 'Replay',
+ type: TaxonomicFilterGroupType.Replay,
+ options: [
+ {
+ key: 'visited_page',
+ name: getFilterLabel('visited_page', TaxonomicFilterGroupType.Replay),
+ propertyFilterType: PropertyFilterType.Recording,
+ },
+ {
+ key: 'snapshot_source',
+ name: getFilterLabel('snapshot_source', TaxonomicFilterGroupType.Replay),
+ propertyFilterType: PropertyFilterType.Recording,
+ },
+ {
+ key: 'level',
+ name: getFilterLabel('level', TaxonomicFilterGroupType.LogEntries),
+ propertyFilterType: PropertyFilterType.LogEntry,
+ },
+ {
+ key: 'message',
+ name: getFilterLabel('message', TaxonomicFilterGroupType.LogEntries),
+ propertyFilterType: PropertyFilterType.LogEntry,
+ },
+ {
+ key: 'comment_text',
+ name: getFilterLabel('comment_text', TaxonomicFilterGroupType.Replay),
+ propertyFilterType: PropertyFilterType.Recording,
+ },
+ ],
+ getName: (option: Record<string, any>) => option.name,
+ getValue: (option: Record<string, any>) => option.key,
+ valuesEndpoint: (key) => {
+ if (key === 'visited_page') {
+ return (
+ `api/environments/${teamId}/events/values/?key=` +
+ encodeURIComponent('$current_url') +
+ '&event_name=' +
+ encodeURIComponent('$pageview')
+ )
+ }
+ },
+ getPopoverHeader: () => 'Replay',
+ },
+ {
+ name: 'Saved filters',
+ searchPlaceholder: 'saved filters',
+ type: TaxonomicFilterGroupType.ReplaySavedFilters,
+ endpoint: combineUrl(`api/projects/${projectId}/session_recording_playlists/`, {
+ type: 'filters',
+ order: '-last_modified_at',
+ }).url,
+ render: SavedFiltersTaxonomicGroup,
+ getName: (filter: SessionRecordingPlaylistType) =>
+ filter.name || filter.derived_name || 'Unnamed',
+ getValue: (filter: SessionRecordingPlaylistType) => filter.short_id,
+ getPopoverHeader: () => 'Saved filter',
+ },
+ {
+ name: 'On this page',
+ searchPlaceholder: 'elements from this page',
+ type: TaxonomicFilterGroupType.MaxAIContext,
+ options: maxContextOptions,
+ getName: (option: MaxContextTaxonomicFilterOption) => option.name,
+ getValue: (option: MaxContextTaxonomicFilterOption) => option.value,
+ getIcon: (option: MaxContextTaxonomicFilterOption) => {
+ const IconComponent = option.icon
+ return <IconComponent />
+ },
+ getPopoverHeader: () => 'On this page',
+ },
+ {
+ name: suggestedFiltersLabel ?? 'Suggested filters',
+ searchPlaceholder: (suggestedFiltersLabel ?? 'Suggested filters').toLowerCase(),
+ categoryLabel: (count: number) =>
+ (suggestedFiltersLabel ?? 'Suggested filters') + (count > 0 ? `: ${count}` : ''),
+ type: TaxonomicFilterGroupType.SuggestedFilters,
+ isLocalOnly: true,
+ isMetaGroup: true,
+ options: [
+ // Promoted properties for any event in context come first — if a team
+ // has marked a property as the one that summarises this event, it's
+ // the property they almost certainly want to filter or break down by.
+ ...primaryPropertiesForContextEvents.map((name) => ({
+ name,
+ group: TaxonomicFilterGroupType.EventProperties,
+ })),
+ ...(eventNames.includes('$autocapture')
+ ? (['text', 'selector'] as const).map((name) => ({
+ name,
+ group: TaxonomicFilterGroupType.Elements,
+ }))
+ : []),
+ ],
+ getName: (item: TaxonomicDefinitionTypes) => ('name' in item ? item.name : '') || '',
+ getValue: (item: TaxonomicDefinitionTypes): TaxonomicFilterValue =>
+ 'name' in item ? (item.name ?? null) : null,
+ getPopoverHeader: () => suggestedFiltersLabel ?? 'Suggested filters',
+ },
+ {
+ name: 'Recent',
+ searchPlaceholder: 'recent',
+ type: TaxonomicFilterGroupType.RecentFilters,
+ isLocalOnly: true,
+ isMetaGroup: true,
+ logic: recentTaxonomicFiltersLogic,
+ value: 'recentFilterItems',
+ getName: (item: TaxonomicDefinitionTypes) => ('name' in item ? item.name : '') || '',
+ getValue: (item: TaxonomicDefinitionTypes): TaxonomicFilterValue =>
+ 'name' in item ? (item.name ?? null) : null,
+ getPopoverHeader: () => 'Recent',
+ } as TaxonomicFilterGroup,
+ {
+ name: 'Pinned',
+ searchPlaceholder: 'pinned',
+ type: TaxonomicFilterGroupType.PinnedFilters,
+ isLocalOnly: true,
+ isMetaGroup: true,
+ logic: taxonomicFilterPinnedPropertiesLogic,
+ value: 'pinnedFilterItems',
+ getName: (item: TaxonomicDefinitionTypes) => ('name' in item ? item.name : '') || '',
+ getValue: (item: TaxonomicDefinitionTypes): TaxonomicFilterValue =>
+ 'name' in item ? (item.name ?? null) : null,
+ getPopoverHeader: () => 'Pinned',
+ } as TaxonomicFilterGroup,
+ ...groupAnalyticsTaxonomicGroups,
+ ...groupAnalyticsTaxonomicGroupNames,
]
return groups
@@ -1119,6 +1571,47 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
return filtered
},
],
+ groupAnalyticsTaxonomicGroupNames: [
+ (s) => [s.groupTypes, s.currentTeamId, s.aggregationLabel],
+ (groupTypes, teamId, aggregationLabel): TaxonomicFilterGroup[] =>
+ Array.from(groupTypes.values()).map((type) => ({
+ name: `${capitalizeFirstLetter(aggregationLabel(type.group_type_index).plural)}`,
+ searchPlaceholder: `${aggregationLabel(type.group_type_index).plural}`,
+ type: `${TaxonomicFilterGroupType.GroupNamesPrefix}_${type.group_type_index}` as unknown as TaxonomicFilterGroupType,
+ endpoint: combineUrl(`api/environments/${teamId}/groups/`, {
+ group_type_index: type.group_type_index,
+ }).url,
+ getPopoverHeader: () => `Group Names`,
+ getName: (group: Group) => groupDisplayId(group.group_key, group.group_properties),
+ getValue: (group: Group) => group.group_key,
+ groupTypeIndex: type.group_type_index,
+ })),
+ ],
+ groupAnalyticsTaxonomicGroups: [
+ (s) => [s.groupTypes, s.currentProjectId, s.aggregationLabel],
+ (groupTypes, projectId, aggregationLabel): TaxonomicFilterGroup[] =>
+ Array.from(groupTypes.values()).map((type) => ({
+ name: `${capitalizeFirstLetter(aggregationLabel(type.group_type_index).singular)} properties`,
+ searchPlaceholder: `${aggregationLabel(type.group_type_index).singular} properties`,
+ type: `${TaxonomicFilterGroupType.GroupsPrefix}_${type.group_type_index}` as unknown as TaxonomicFilterGroupType,
+ endpoint: combineUrl(`api/projects/${projectId}/property_definitions`, {
+ type: 'group',
+ group_type_index: type.group_type_index,
+ exclude_hidden: true,
+ exclude_restricted: true,
+ }).url,
+ valuesEndpoint: (key) =>
+ `api/projects/${projectId}/groups/property_values?${toParams({
+ key,
+ group_type_index: type.group_type_index,
+ })}`,
+ getName: (group) => group.name,
+ getValue: (group) => group.name,
+ getPopoverHeader: () => `Property`,
+ getIcon: getPropertyDefinitionIcon,
+ groupTypeIndex: type.group_type_index,
+ })),
+ ],
infiniteListLogics: [
(s) => [s.taxonomicGroupTypes, (_, props) => props],
(taxonomicGroupTypes, props): Record<string, BuiltLogic<infiniteListLogicType>> =>
diff --git a/frontend/src/lib/utils/primaryEventProperty.test.ts b/frontend/src/lib/utils/primaryEventProperty.test.ts
index a83f5478707a..b13617dbafbb 100644
--- a/frontend/src/lib/utils/primaryEventProperty.test.ts
+++ b/frontend/src/lib/utils/primaryEventProperty.test.ts
@@ -1,5 +1,4 @@
import {
- getDistinctPrimaryPropertiesForEvents,
getEventsWithPrimaryProperty,
getPrimaryPropertyForEvent,
hasTaxonomyPrimaryProperty,
@@ -79,55 +78,6 @@ describe('getEventsWithPrimaryProperty', () => {
})
})
-describe('getDistinctPrimaryPropertiesForEvents', () => {
- it.each([
- {
- name: 'collects taxonomy defaults across events',
- eventNames: ['$pageview', '$screen'],
- overrides: undefined,
- expected: ['$pathname', '$screen_name'],
- },
- {
- name: 'deduplicates when multiple events resolve to the same property',
- eventNames: ['$pageview', '$pageleave'],
- overrides: undefined,
- expected: ['$pathname'],
- },
- {
- name: 'returns an empty list when no events have a primary property',
- eventNames: ['$autocapture', 'arbitrary_custom'],
- overrides: undefined,
- expected: [],
- },
- {
- name: 'returns an empty list for an empty event list',
- eventNames: [],
- overrides: undefined,
- expected: [],
- },
- {
- name: 'picks up team overrides for events without a taxonomy default',
- eventNames: ['order_placed', 'just_viewed'],
- overrides: { order_placed: 'order_id' },
- expected: ['order_id'],
- },
- {
- name: 'taxonomy default still wins over an attempted override',
- eventNames: ['$pageview'],
- overrides: { $pageview: '$current_url' },
- expected: ['$pathname'],
- },
- {
- name: 'mixes taxonomy defaults and team overrides without duplicates',
- eventNames: ['$pageview', 'order_placed'],
- overrides: { order_placed: '$pathname' },
- expected: ['$pathname'],
- },
- ])('$name', ({ eventNames, overrides, expected }) => {
- expect(getDistinctPrimaryPropertiesForEvents(eventNames, overrides)).toEqual(expected)
- })
-})
-
describe('hasTaxonomyPrimaryProperty', () => {
it('is true for built-in events that have a primary property', () => {
expect(hasTaxonomyPrimaryProperty('$pageview')).toBe(true)
diff --git a/frontend/src/lib/utils/primaryEventProperty.ts b/frontend/src/lib/utils/primaryEventProperty.ts
index e00b31878780..73cf68673ad1 100644
--- a/frontend/src/lib/utils/primaryEventProperty.ts
+++ b/frontend/src/lib/utils/primaryEventProperty.ts
@@ -40,22 +40,3 @@ export function getEventsWithPrimaryProperty<T extends { event: string }>(
): T[] {
return events.filter((e) => getPrimaryPropertyForEvent(e.event, overrides) !== null)
}
-
-/**
- * Given a list of event names, returns the deduplicated primary properties
- * associated with them (taxonomy default or team override). Pure client-side
- * wrapper over `getPrimaryPropertyForEvent`.
- */
-export function getDistinctPrimaryPropertiesForEvents(
- eventNames: string[],
- overrides?: Record<string, string | null | undefined>
-): string[] {
- const distinct = new Set<string>()
- for (const eventName of eventNames) {
- const primary = getPrimaryPropertyForEvent(eventName, overrides)
- if (primary) {
- distinct.add(primary)
- }
- }
- return Array.from(distinct)
-}