Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(persons): search person properties by their humanized label (#61825)

Georgis Andonis4aecf4d3928c
diff --git a/frontend/src/lib/components/PropertiesTable/PropertiesTable.test.tsx b/frontend/src/lib/components/PropertiesTable/PropertiesTable.test.tsx
index 0e235cbc6a02..a23445d8b4a6 100644
--- a/frontend/src/lib/components/PropertiesTable/PropertiesTable.test.tsx
+++ b/frontend/src/lib/components/PropertiesTable/PropertiesTable.test.tsx
@@ -174,4 +174,29 @@ describe('PropertiesTable inline editor', () => {
expect(screen.getByRole('textbox')).toBeInTheDocument()
})
})
+
+ describe('search by humanized label', () => {
+ const renderSearchable = (type: PropertyDefinitionType): void => {
+ render(
+ <Provider>
+ <PropertiesTable type={type} properties={{ $geoip_city_name: 'London' }} searchable />
+ </Provider>
+ )
+ }
+
+ const search = (term: string): void => {
+ fireEvent.change(screen.getByPlaceholderText('Search property keys and values'), {
+ target: { value: term },
+ })
+ }
+
+ it.each<[PropertyDefinitionType, string, string]>([
+ [PropertyDefinitionType.Person, 'latest', 'Latest city name'],
+ [PropertyDefinitionType.Event, 'city', 'City name'],
+ ])('matches %s properties by their group label (%s → %s)', (type, term) => {
+ renderSearchable(type)
+ search(term)
+ expect(screen.getByText('London')).toBeInTheDocument()
+ })
+ })
})
diff --git a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
index 25220612334c..5cff1faf64bb 100644
--- a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
+++ b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
@@ -25,7 +25,7 @@ import {
POSTHOG_EVENT_PROMOTED_PROPERTIES,
isPostHogProperty,
} from '~/taxonomy/taxonomy'
-import { CORE_FILTER_DEFINITIONS_BY_GROUP, PROPERTY_KEYS } from '~/taxonomy/taxonomy'
+import { PROPERTY_KEYS } from '~/taxonomy/taxonomy'
import { PropertyDefinitionType, PropertyType } from '~/types'
import { CopyToClipboardInline } from '../CopyToClipboard'
@@ -256,34 +256,35 @@ export function PropertiesTable({
return []
}
+ // Map the property definition type to its taxonomic group so labels (e.g. "Latest city name"
+ // for person properties vs "City name" for event properties) resolve correctly when sorting and searching.
+ const propertyTypeMap: Record<PropertyDefinitionType, TaxonomicFilterGroupType> = {
+ [PropertyDefinitionType.Event]: TaxonomicFilterGroupType.EventProperties,
+ [PropertyDefinitionType.EventMetadata]: TaxonomicFilterGroupType.EventMetadata,
+ [PropertyDefinitionType.RevenueAnalytics]: TaxonomicFilterGroupType.RevenueAnalyticsProperties,
+ [PropertyDefinitionType.Person]: TaxonomicFilterGroupType.PersonProperties,
+ [PropertyDefinitionType.Group]: TaxonomicFilterGroupType.GroupsPrefix,
+ [PropertyDefinitionType.Session]: TaxonomicFilterGroupType.SessionProperties,
+ [PropertyDefinitionType.LogEntry]: TaxonomicFilterGroupType.LogEntries,
+ [PropertyDefinitionType.Meta]: TaxonomicFilterGroupType.Metadata,
+ [PropertyDefinitionType.Resource]: TaxonomicFilterGroupType.Resources,
+ [PropertyDefinitionType.Log]: TaxonomicFilterGroupType.Logs,
+ [PropertyDefinitionType.LogAttribute]: TaxonomicFilterGroupType.LogAttributes,
+ [PropertyDefinitionType.LogResourceAttribute]: TaxonomicFilterGroupType.LogResourceAttributes,
+ [PropertyDefinitionType.Span]: TaxonomicFilterGroupType.Spans,
+ [PropertyDefinitionType.SpanAttribute]: TaxonomicFilterGroupType.SpanAttributes,
+ [PropertyDefinitionType.SpanResourceAttribute]: TaxonomicFilterGroupType.SpanResourceAttributes,
+ [PropertyDefinitionType.FlagValue]: TaxonomicFilterGroupType.FeatureFlags,
+ [PropertyDefinitionType.WorkflowVariable]: TaxonomicFilterGroupType.WorkflowVariables,
+ }
+ const propertyGroupType = propertyTypeMap[type] || TaxonomicFilterGroupType.EventProperties
+
let entries = Object.entries(properties)
if (sortProperties) {
entries = entries.sort((a, b) => {
// if this is a posthog property we want to sort by its label
- const propertyTypeMap: Record<PropertyDefinitionType, TaxonomicFilterGroupType> = {
- [PropertyDefinitionType.Event]: TaxonomicFilterGroupType.EventProperties,
- [PropertyDefinitionType.EventMetadata]: TaxonomicFilterGroupType.EventMetadata,
- [PropertyDefinitionType.RevenueAnalytics]: TaxonomicFilterGroupType.RevenueAnalyticsProperties,
- [PropertyDefinitionType.Person]: TaxonomicFilterGroupType.PersonProperties,
- [PropertyDefinitionType.Group]: TaxonomicFilterGroupType.GroupsPrefix,
- [PropertyDefinitionType.Session]: TaxonomicFilterGroupType.SessionProperties,
- [PropertyDefinitionType.LogEntry]: TaxonomicFilterGroupType.LogEntries,
- [PropertyDefinitionType.Meta]: TaxonomicFilterGroupType.Metadata,
- [PropertyDefinitionType.Resource]: TaxonomicFilterGroupType.Resources,
- [PropertyDefinitionType.Log]: TaxonomicFilterGroupType.Logs,
- [PropertyDefinitionType.LogAttribute]: TaxonomicFilterGroupType.LogAttributes,
- [PropertyDefinitionType.LogResourceAttribute]: TaxonomicFilterGroupType.LogResourceAttributes,
- [PropertyDefinitionType.Span]: TaxonomicFilterGroupType.Spans,
- [PropertyDefinitionType.SpanAttribute]: TaxonomicFilterGroupType.SpanAttributes,
- [PropertyDefinitionType.SpanResourceAttribute]: TaxonomicFilterGroupType.SpanResourceAttributes,
- [PropertyDefinitionType.FlagValue]: TaxonomicFilterGroupType.FeatureFlags,
- [PropertyDefinitionType.WorkflowVariable]: TaxonomicFilterGroupType.WorkflowVariables,
- }
-
- const propertyType = propertyTypeMap[type] || TaxonomicFilterGroupType.EventProperties
-
- const left = getCoreFilterDefinition(a[0], propertyType)?.label || a[0]
- const right = getCoreFilterDefinition(b[0], propertyType)?.label || b[0]
+ const left = getCoreFilterDefinition(a[0], propertyGroupType)?.label || a[0]
+ const right = getCoreFilterDefinition(b[0], propertyGroupType)?.label || b[0]
if (left < right) {
return -1
@@ -310,7 +311,7 @@ export function PropertiesTable({
if (searchTerm) {
const normalizedSearchTerm = searchTerm.toLowerCase()
entries = entries.filter(([key, value]) => {
- const label = CORE_FILTER_DEFINITIONS_BY_GROUP.event_properties[key]?.label?.toLowerCase()
+ const label = getCoreFilterDefinition(key, propertyGroupType)?.label?.toLowerCase()
return (
key.toLowerCase().includes(normalizedSearchTerm) ||
(label && label.includes(normalizedSearchTerm)) ||
@@ -339,7 +340,7 @@ export function PropertiesTable({
})
}
return entries
- }, [properties, sortProperties, searchTerm, hidePostHogPropertiesInTable, hideNullValues]) // oxlint-disable-line react-hooks/exhaustive-deps
+ }, [properties, sortProperties, searchTerm, hidePostHogPropertiesInTable, hideNullValues, type]) // oxlint-disable-line react-hooks/exhaustive-deps
if (Array.isArray(properties)) {
return (