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(logs): show value-match indicator in rebuilt taxonomic filter menu (#64058)

Frank Hamandc8db8ee277b9
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
index aacc321ad47d..3da915419357 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
@@ -56,6 +56,7 @@ import {
} from '../utils/collapsedContainsRow'
import { promoteMatchingBy } from '../utils/promoteProperties'
import { MenuFilterHeader } from './Header'
+import { MatchedValueBadge } from './MatchedValueBadge'
import { PreviewPane } from './PreviewPane'
import { CommitFn, CommitSelectionContext, DrillCategory, MenuFilterEntry, TAXONOMIC_FILTER_SURFACE } from './types'
import { VerificationBadge } from './VerificationBadge'
@@ -1271,6 +1272,7 @@ function Row({ entry, showCategory, recency, opensSubmenu, selectedRowId, onSele
)}
{showCategory && <MenuLabel className="text-tertiary/50 text-xxs p-0 mt-1">{category}</MenuLabel>}
</div>
+ <MatchedValueBadge entry={entry} />
{recency && (
<Badge variant="default" className="gap-1 shrink-0">
{recency === 'recent' ? <IconClock className="size-3" /> : <IconPinFilled className="size-3" />}
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/MatchedValueBadge.test.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/MatchedValueBadge.test.tsx
new file mode 100644
index 000000000000..3124ab70ab21
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/MatchedValueBadge.test.tsx
@@ -0,0 +1,40 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen } from '@testing-library/react'
+
+import { getMatchedValue, MatchedValueBadge } from './MatchedValueBadge'
+import { MenuFilterEntry } from './types'
+
+function makeEntry(item: Record<string, any>): MenuFilterEntry {
+ return {
+ item,
+ group: { type: 'log_attributes', name: 'Log attributes' },
+ name: item.name ?? 'attr',
+ } as unknown as MenuFilterEntry
+}
+
+describe('MatchedValueBadge', () => {
+ afterEach(cleanup)
+
+ it('renders the matched value when the item matched on value', () => {
+ render(<MatchedValueBadge entry={makeEntry({ name: 'level', matchedOn: 'value', matchedValue: 'error' })} />)
+ expect(screen.getByLabelText('Matched on value')).toHaveTextContent('error')
+ })
+
+ it('truncates long matched values', () => {
+ const long = 'a'.repeat(40)
+ render(<MatchedValueBadge entry={makeEntry({ name: 'level', matchedOn: 'value', matchedValue: long })} />)
+ expect(screen.getByLabelText('Matched on value')).toHaveTextContent('…')
+ })
+
+ it.each([
+ ['matched on name', { name: 'level', matchedOn: 'name', matchedValue: 'error' }],
+ ['no matchedValue', { name: 'level', matchedOn: 'value' }],
+ ['empty matchedValue', { name: 'level', matchedOn: 'value', matchedValue: '' }],
+ ['plain attribute', { name: 'level' }],
+ ])('renders nothing for %s', (_label, item) => {
+ const { container } = render(<MatchedValueBadge entry={makeEntry(item)} />)
+ expect(container).toBeEmptyDOMElement()
+ expect(getMatchedValue(makeEntry(item))).toBeNull()
+ })
+})
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/MatchedValueBadge.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/MatchedValueBadge.tsx
new file mode 100644
index 000000000000..1c943ced045d
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/MatchedValueBadge.tsx
@@ -0,0 +1,61 @@
+/**
+ * "Matched on value" badge for taxonomic filter rows + preview pane.
+ *
+ * Some groups (log / resource attributes) search attribute *values* as well
+ * as names via `search_values=true`. When a row surfaces because the query
+ * matched one of its values — not the attribute name — the endpoint tags the
+ * item with `matchedOn: 'value'` and the `matchedValue`. Surfacing it tells
+ * the user why an attribute appears for a query that isn't in its name.
+ */
+import { Badge, cn, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
+
+import { MenuFilterEntry } from './types'
+
+const VALUE_MATCH_MAX_LENGTH = 30
+
+export function getMatchedValue(entry: MenuFilterEntry): string | null {
+ const item = entry.item as { matchedOn?: string; matchedValue?: string } | null
+ if (item && item.matchedOn === 'value' && typeof item.matchedValue === 'string' && item.matchedValue.length > 0) {
+ return item.matchedValue
+ }
+ return null
+}
+
+export function MatchedValueBadge({
+ entry,
+ className,
+}: {
+ entry: MenuFilterEntry
+ className?: string
+}): JSX.Element | null {
+ const matchedValue = getMatchedValue(entry)
+ if (!matchedValue) {
+ return null
+ }
+ const truncated =
+ matchedValue.length > VALUE_MATCH_MAX_LENGTH
+ ? matchedValue.slice(0, VALUE_MATCH_MAX_LENGTH) + '…'
+ : matchedValue
+ return (
+ <Tooltip>
+ {/* Trigger must render a host element so base-ui's hover ref attaches —
+ `Badge` is a plain component (not forwardRef). See VerificationBadge. */}
+ <TooltipTrigger
+ delay={300}
+ render={(triggerProps) => (
+ <span {...triggerProps} className={cn('inline-flex min-w-0', className)}>
+ <Badge
+ variant="default"
+ aria-label="Matched on value"
+ data-attr="taxonomic-value-match-indicator"
+ className="max-w-48 shrink-0 truncate font-mono"
+ >
+ {truncated}
+ </Badge>
+ </span>
+ )}
+ />
+ <TooltipContent className="max-w-64">Matched on value: "{matchedValue}"</TooltipContent>
+ </Tooltip>
+ )
+}
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx
index 20b4b162d7d8..7a9f24719257 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/PreviewPane.tsx
@@ -21,6 +21,7 @@ import { ActionType, CohortType, EventDefinition, PropertyDefinition } from '~/t
import { useTaxonomicAutocompleteItemDetails } from '../headless'
import { TaxonomicFilterGroupType } from '../types'
+import { getMatchedValue } from './MatchedValueBadge'
import { ActionMatchGroups } from './preview/ActionMatchGroups'
import { MenuFilterEntry } from './types'
import { VerificationBadge } from './VerificationBadge'
@@ -58,6 +59,7 @@ function PreviewBody({ entry }: { entry: MenuFilterEntry }): JSX.Element | null
// for event first/last seen (handled later if needed).
const isAction = entry.group.type === TaxonomicFilterGroupType.Actions
const viewUrl = resolveViewUrl(entry)
+ const matchedValue = getMatchedValue(entry)
return (
<ScrollArea className="flex-1 min-h-0">
@@ -79,6 +81,13 @@ function PreviewBody({ entry }: { entry: MenuFilterEntry }): JSX.Element | null
</div>
)}
+ {matchedValue && (
+ <div className="flex flex-col gap-0.5 border-t pt-2">
+ <div className="text-xxs uppercase tracking-wide text-secondary">Matched on value</div>
+ <code className="break-all font-mono text-xs text-tertiary">{matchedValue}</code>
+ </div>
+ )}
+
{isAction && <ActionMatchGroups item={entry.item} />}
</div>
</ScrollArea>