: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(persons): stop the AI observability renderer claiming every person column (#103997)
Thomas Obermülleraa7303b6c84f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex af3987c79bc7..439f3fd0eff1 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -2805,9 +2805,9 @@ snapshots:exporter-other--adhoc-sql-chart-export--light:hash: v1.k794b7964.429f5e6200733b14339b016a8b074fbd2b13e5873bba17b6d7254b743fed71df.693B2MhUpAxXyTGNXF3XhYxBuf8lIco8usK44hlA5Esexporter-other--event-table-insight--dark:- hash: v1.k794b7964.b49f709fd4150d9aa62e5e72280c1a01d36b8ce9a73151d49cdc903394406476.HroHAic6d-U6xImox3yNijT04GTbLpTRTwvaxN46Frg+ hash: v1.k794b7964.abd06174826129b65a142f649b3beb3e8c615709577be8482cdd4b64541d6375.gWupXoDYXUDXnTfMUsQP9sunUNanpKshqgn2DkEEnS8exporter-other--event-table-insight--light:- hash: v1.k794b7964.655c2dbcc0cda7fd429e49ad8ead4aea6dcae244177f2d728577ae1bf5eaeee8.mVijpDuuRVzAe4xP3WNK7k0LIhE2HLssRrnMWDeRiYs+ hash: v1.k794b7964.847d6e6bcf504bddcd478ce4949cc7db74039f8aef074f241023f7218a85838c.kBTSDwHdo5ocFMwbkIxYdVeC5ouyrq1AghOKZijnjOEexporter-other--event-table-insight-no-results--dark:hash: v1.k794b7964.e8e554b9ea9b5821be4434ce02def6d01297dbf2ad7b649ee03972b7bb3a68e1.WCXI0-68HMyUCcBkDUV4nHfGzHMhblTOvtkh72CcQrYexporter-other--event-table-insight-no-results--light:@@ -9793,9 +9793,9 @@ snapshots:scenes-app-notebooks-widget-views--feature-flag-views--light:hash: v1.k794b7964.3fb450c33fc8b53cff6d2297e2f1dfa8541b3b78710fcc1f9a024c1d38bd9430._Cbxuhq_opGeFh8v_hBOeWQRNNOu728aMhEzYQm3Yukscenes-app-notebooks-widget-views--group-views--dark:- hash: v1.k794b7964.dcceb542721da480037e72715ba0bba0d2bca53a393992f29409e3b0ec648087.oC_G7MirEPp1zwj9ZPPPaLhKeZuAXn5EJo9XDI4CD6o+ hash: v1.k794b7964.9a7c7daaa561a479ae6f14e262be21c61396433b4085bf9034fabfe8fd243c41.CBNLLM0sHFX_xeV6ADy1vQlz-0TmD1nfIxz2XKy5RDgscenes-app-notebooks-widget-views--group-views--light:- hash: v1.k794b7964.a622eda529140b0da26febf0295d5afe02224a095b690d699c90d37d189fd615.2nmLTPSj2A2MQ3TYzkrkcCOHhvvB3-4GiRvFJN_9tXI+ hash: v1.k794b7964.3844ddec20fcd7f37bffaca53a98740dfc150d5ec61c040435d9d5683b78c49f.ti5pquIH9vqC56HbmyWDpO9r23A4XSrzBN0zcHNo08Mscenes-app-notebooks-widget-views--insight-views--dark:hash: v1.k794b7964.e25c1892d4ab208af5c14ddbd62850287baa0f564b2bcd67309e9357ebae2e9c.uP6ZYZ2y2epiADizyQmS0p921z8XYO4RssS_4Ns2228scenes-app-notebooks-widget-views--insight-views--light:@@ -9805,9 +9805,9 @@ snapshots:scenes-app-notebooks-widget-views--llm-trace-views--light:hash: v1.k794b7964.5ea0b08a632473328c05d164a1e756ba869f65fd4513a518d17e8d87f337db00.tKEfQQ8Zx_MevnV47TTxcctA5K5F6FdDOj6s9mloQOgscenes-app-notebooks-widget-views--person-views--dark:- hash: v1.k794b7964.047e00389cf1891ef58caefeb8cd76489d87a93f382e227e96fb422af44d974c.dsIVmb8vhajsyOEOPdG37OjOzSP3aiO-6KJOZbkKKAc+ hash: v1.k794b7964.a684c61c291fa7ca998553913da4d5a3fa59e14306c5f39f6038a0a066025950.Bsey5Xq3F5B9f5PnlX0_gVBe8TW2MO7q6zN4C7PCH0Escenes-app-notebooks-widget-views--person-views--light:- hash: v1.k794b7964.1dd5b786b96c3462886d42162b9703203977ede8d290bc7657632e3b4df8949b.oyLUpi8rxuFCKijnY6y58HN4M6aSuagvT18L8gTz2jY+ hash: v1.k794b7964.2d62f4b20d69c9a40eae3c8d3a624ba0b357518a02ec7ca93dbd5c6e242e201e.LgsC1L0SjCtp20JuRGzVImzFyRMi1p9rpp4rS6Q_jg4scenes-app-notebooks-widget-views--recording-playlist-views--dark:hash: v1.k794b7964.348e1cd39145cc74118e51b175e384003180756ed2e37f059d7377f4e59bc337.6_JpQpRvZD6qtG1waq0WNkr8zlUs-XVfX8rLLpds5Q0scenes-app-notebooks-widget-views--recording-playlist-views--light:diff --git a/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx b/frontend/src/queries/nodes/DataTable/renderColumn.test.tsxindex c550c5d5ec3e..7c0710dd7dd1 100644--- a/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx+++ b/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx@@ -1,6 +1,6 @@import '@testing-library/jest-dom'-import { cleanup, render, screen } from '@testing-library/react'+import { cleanup, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { Provider } from 'kea'@@ -17,6 +17,31 @@ const eventsTable = setLatestVersionsOnQuery({source: { kind: NodeKind.EventsQuery, select },}) as DataTableNode+const personSelect = ['*', 'event', 'person', 'timestamp']+const personColumnTable = setLatestVersionsOnQuery({+ kind: NodeKind.DataTableNode,+ source: { kind: NodeKind.EventsQuery, select: personSelect },+}) as DataTableNode+const actorsTable = setLatestVersionsOnQuery({+ kind: NodeKind.DataTableNode,+ source: { kind: NodeKind.ActorsQuery, select: ['person', 'id'] },+}) as DataTableNode++function renderPersonColumnCell(value: Record<string, unknown>, query: DataTableNode = personColumnTable): void {+ render(+ <Provider>+ {renderColumn(+ 'person',+ value,+ personSelect.map(() => null),+ 0,+ 1,+ query+ )}+ </Provider>+ )+}+function renderPersonCell(displayName: string): void {render(<Provider>@@ -58,4 +83,36 @@ describe('renderColumn', () => {expect(await screen.findByText('No profile associated with this ID')).toBeInTheDocument()})++ it.each([+ // A profile with no display properties still serializes `properties`, which is the signal+ ['resolved a profile', { distinct_id: 'the-distinct-id', properties: {} }, 1, 0],+ ['resolved none', { distinct_id: 'the-distinct-id' }, 0, 1],+ ])('person column, query runner %s', async (_case, value, popovers, notices) => {+ renderPersonColumnCell(value as Record<string, unknown>)+ await userEvent.click(screen.getByText('the-distinct-id'))++ await waitFor(() => {+ // PersonPreview mounting is the probe for the popover. It reports no profile either way,+ // because this test leaves the persons API unmocked.+ expect(screen.queryAllByText('No profile associated with this ID')).toHaveLength(popovers as number)+ expect(screen.queryAllByText('This distinct ID has no person profile.')).toHaveLength(notices as number)+ })+ })++ it('renders the actors person column through the core renderer', () => {+ // A product renderer registered under the bare key `person` used to win here and render+ // "Unknown", because it matches on `distinct_id` and an actor carries `distinct_ids`.+ renderPersonColumnCell(+ {+ id: 'c3b1f6a2-0000-0000-0000-000000000000',+ distinct_ids: ['the-distinct-id'],+ properties: { email: '[email protected]' },+ },+ actorsTable+ )++ expect(screen.getByText('[email protected]')).toBeInTheDocument()+ expect(screen.queryByText('Unknown')).toBeNull()+ })})diff --git a/frontend/src/queries/nodes/DataTable/renderColumn.tsx b/frontend/src/queries/nodes/DataTable/renderColumn.tsxindex 665bf855cb5a..7893528d0335 100644--- a/frontend/src/queries/nodes/DataTable/renderColumn.tsx+++ b/frontend/src/queries/nodes/DataTable/renderColumn.tsx@@ -42,7 +42,7 @@ import {} from '~/queries/utils'import { AnyPropertyFilter, EventType, PersonType, PropertyFilterType, PropertyOperator } from '~/types'-import { aiObservabilityColumnRenderers } from 'products/ai_observability/frontend/aiObservabilityColumnRenderers'+import { aiObservabilityGlobalColumnRenderers } from 'products/ai_observability/frontend/aiObservabilityColumnRenderers'import { GroupActorDisplay } from 'products/persons/frontend/components/GroupActorDisplay'import { PersonDisplay, PersonDisplayProps } from 'products/persons/frontend/components/PersonDisplay'import { pickBestPersonDistinctId } from 'products/persons/frontend/person-utils'@@ -63,9 +63,11 @@ function JSONCell(props: ReactJsonViewProps): JSX.Element {}// Registry for product-specific column renderers-// Products can add their custom column renderers here to have them automatically applied across all DataTable instances+// Products can add their custom column renderers here to have them automatically applied across all DataTable instances.+// An entry wins over the core renderer for that column name in every DataTable, so a product registers only namespaced+// keys here and passes the rest through its own scene's QueryContext.const productColumnRenderers: Record<string, QueryContextColumn> = {- ...aiObservabilityColumnRenderers,+ ...aiObservabilityGlobalColumnRenderers,...sessionColumnRenderers,}@@ -335,6 +337,22 @@ export function renderColumn(if (isEventsQuery(query.source)) {displayProps.person = value.distinct_id ? (value as EventsQueryPersonColumn) : value+ // The query runner resolves this column against Postgres by distinct ID, so a row without+ // `properties` has no profile behind it. The popover would repeat that same lookup to show+ // an empty card, so the cell says it in place instead.+ if (!value?.properties) {+ return (+ <Tooltip+ title="This distinct ID has no person profile."+ docLink="https://posthog.com/docs/data/persons#capturing-person-profiles"+ openOnClick+ >+ <span>+ <PersonDisplay {...displayProps} />+ </span>+ </Tooltip>+ )+ }displayProps.noPopover = false // If we are in an events list, the popover experience is better}diff --git a/products/ai_observability/frontend/aiObservabilityColumnRenderers.tsx b/products/ai_observability/frontend/aiObservabilityColumnRenderers.tsxindex 5bf82c424c3d..9d215568d642 100644--- a/products/ai_observability/frontend/aiObservabilityColumnRenderers.tsx+++ b/products/ai_observability/frontend/aiObservabilityColumnRenderers.tsx@@ -536,3 +536,14 @@ export const aiObservabilityColumnRenderers: Record<string, QueryContextColumn>},},}++// The subset that `renderColumn` applies to every DataTable in the app. A key here wins over the+// core renderer for that column name everywhere, so only namespaced keys belong: a `$ai_` property,+// or a name carrying the `__llm_` prefix. A plain name such as `person` would take the column over+// in the events table and the persons list too. Scenes opt into the rest through their own+// QueryContext, the way AIObservabilityTracesScene does.+export const aiObservabilityGlobalColumnRenderers: Record<string, QueryContextColumn> = Object.fromEntries(+ Object.entries(aiObservabilityColumnRenderers).filter(+ ([key]) => key.startsWith('properties.$ai_') || key.startsWith('__llm_')+ )+)