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): stop linking placeholder person IDs in event tables (#103539)

posthog[bot]271a3137df20
diff --git a/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx b/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx
new file mode 100644
index 000000000000..c550c5d5ec3e
--- /dev/null
+++ b/frontend/src/queries/nodes/DataTable/renderColumn.test.tsx
@@ -0,0 +1,61 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { Provider } from 'kea'
+
+import { DataTableNode, NodeKind } from '~/queries/schema/schema-general'
+import { setLatestVersionsOnQuery } from '~/queries/utils'
+import { initKeaTests } from '~/test/init'
+
+import { renderColumn } from './renderColumn'
+import { defaultDataTableColumns } from './utils'
+
+const select = defaultDataTableColumns(NodeKind.EventsQuery)
+const eventsTable = setLatestVersionsOnQuery({
+ kind: NodeKind.DataTableNode,
+ source: { kind: NodeKind.EventsQuery, select },
+}) as DataTableNode
+
+function renderPersonCell(displayName: string): void {
+ render(
+ <Provider>
+ {renderColumn(
+ 'person_display_name',
+ {
+ id: 'c3b1f6a2-0000-0000-0000-000000000000',
+ distinct_id: 'the-distinct-id',
+ display_name: displayName,
+ },
+ select.map(() => null),
+ 0,
+ 1,
+ eventsTable
+ )}
+ </Provider>
+ )
+}
+
+describe('renderColumn', () => {
+ beforeEach(() => initKeaTests())
+ afterEach(() => cleanup())
+
+ it.each([
+ ['a person profile supplied the name', '[email protected]', 1],
+ ['the name fell back to the distinct ID', 'the-distinct-id', 0],
+ ])('person_display_name links %s: %s', (_case, displayName, links) => {
+ renderPersonCell(displayName)
+
+ expect(screen.getByText(displayName)).toBeInTheDocument()
+ expect(screen.queryAllByRole('link')).toHaveLength(links)
+ })
+
+ it('opens the person popover even when the name fell back to the distinct ID', async () => {
+ // A profile created after the event still answers a lookup by distinct ID, so the popover
+ // is the reader's only path to it. Suppressing it strands them on an unlinked cell.
+ renderPersonCell('the-distinct-id')
+ await userEvent.click(screen.getByText('the-distinct-id'))
+
+ expect(await screen.findByText('No profile associated with this ID')).toBeInTheDocument()
+ })
+})
diff --git a/frontend/src/queries/nodes/DataTable/renderColumn.tsx b/frontend/src/queries/nodes/DataTable/renderColumn.tsx
index 35178fd385ee..665bf855cb5a 100644
--- a/frontend/src/queries/nodes/DataTable/renderColumn.tsx
+++ b/frontend/src/queries/nodes/DataTable/renderColumn.tsx
@@ -357,15 +357,20 @@ export function renderColumn(
return <PersonDisplay {...displayProps} />
} else if (key === 'person_display_name') {
- // Hide the popover on people list only
- const noPopover = isActorsQuery(query.source)
+ // The column coalesces the display-name properties down to the distinct ID, so a name of its own
+ // is the only evidence the row reached a person profile. An event captured without person
+ // processing carries a placeholder person ID that links to "Person not found", and a `properties`
+ // key is what makes PersonDisplay render that link. The popover stays on either way, because it
+ // looks the person up by distinct ID and so still finds a profile created after the event.
+ const nameCameFromProfile = value.display_name !== value.distinct_id
const displayProps: PersonDisplayProps = {
withIcon: true,
- // `properties: {}` marks this row as an identified profile so PersonDisplay still renders the link;
- // the server-side `person_display_name` column omits `properties` even though these rows are profiled.
- person: { id: value.id, distinct_id: value.distinct_id, properties: {} },
+ person: nameCameFromProfile
+ ? { id: value.id, distinct_id: value.distinct_id, properties: {} }
+ : { id: value.id, distinct_id: value.distinct_id },
displayName: value.display_name,
- noPopover,
+ // Hide the popover on people list only
+ noPopover: isActorsQuery(query.source),
}
return <PersonDisplay {...displayProps} />
} else if (key === 'group' && typeof value === 'object') {