: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(error-tracking): show the distinct id in the timeline metadata tab (#128195)
James Gill87080d0e0ab5
diff --git a/frontend/src/lib/components/SessionTimeline/timeline/items/eventDetails.test.tsx b/frontend/src/lib/components/SessionTimeline/timeline/items/eventDetails.test.tsxnew file mode 100644index 000000000000..d2a9f4d30eec--- /dev/null+++ b/frontend/src/lib/components/SessionTimeline/timeline/items/eventDetails.test.tsx@@ -0,0 +1,48 @@+import { fireEvent, render } from '@testing-library/react'++import api from 'lib/api'+import { dayjs } from 'lib/dayjs'++import { initKeaTests } from '~/test/init'++import { ItemCategory } from '..'+import { LazyEventDetailsRenderer } from './eventDetails'++const STORED_EVENT: Record<string, unknown> = {+ uuid: 'event-uuid-1',+ event: '$pageview',+ timestamp: '2026-01-01T00:00:00.000Z',+ properties: JSON.stringify({ $current_url: 'https://example.com' }),+ distinct_id: 'user-distinct-id-1',+}++describe('LazyEventDetailsRenderer', () => {+ beforeEach(() => {+ initKeaTests()+ // Answer with the columns the request selects, so a column the query omits comes back missing.+ jest.spyOn(api, 'query').mockImplementation(async (query: any) => ({+ results: [query.select.map((column: string) => STORED_EVENT[column])],+ }))+ })++ afterEach(() => {+ jest.restoreAllMocks()+ })++ it('shows the event distinct id in the metadata tab', async () => {+ const { findByText } = render(+ <LazyEventDetailsRenderer+ item={{+ id: 'event-uuid-1',+ category: ItemCategory.PAGE_VIEWS,+ timestamp: dayjs('2026-01-01T00:00:00.000Z'),+ payload: {},+ }}+ />+ )++ fireEvent.click(await findByText('Metadata'))++ expect(await findByText('user-distinct-id-1')).toBeTruthy()+ })+})diff --git a/frontend/src/lib/components/SessionTimeline/timeline/items/eventDetails.tsx b/frontend/src/lib/components/SessionTimeline/timeline/items/eventDetails.tsxindex 1aaf404a27cf..7f237f594b37 100644--- a/frontend/src/lib/components/SessionTimeline/timeline/items/eventDetails.tsx+++ b/frontend/src/lib/components/SessionTimeline/timeline/items/eventDetails.tsx@@ -17,7 +17,7 @@ const EVENT_DETAILS_CACHE_MAX_ENTRIES = 200const EVENT_DETAILS_QUERY_WINDOW_MS = 1000const EVENT_DETAILS_QUERY_LIMIT = 100-type EventDetailsRow = [uuid: unknown, eventName: unknown, timestamp: unknown, properties: unknown]+type EventDetailsRow = [uuid: unknown, eventName: unknown, timestamp: unknown, properties: unknown, distinctId: unknown]interface EventDetailsQueryResponse {results?: unknown[]@@ -62,11 +62,11 @@ function buildEventDetailsWhere(item: TimelineItem, sessionId?: string): string[}function buildEventFromRow(row: unknown): RecordingEventType | null {- if (!Array.isArray(row) || row.length < 4) {+ if (!Array.isArray(row) || row.length < 5) {return null}- const [uuid, eventName, timestamp, properties] = row as EventDetailsRow+ const [uuid, eventName, timestamp, properties, distinctId] = row as EventDetailsRowconst parsedProperties = parseRecordIfJSONString(properties)const event: RecordingEventType & { uuid: string } = {@@ -74,6 +74,7 @@ function buildEventFromRow(row: unknown): RecordingEventType | null {uuid: String(uuid),event: String(eventName),timestamp: String(timestamp),+ distinct_id: String(distinctId),properties: parsedProperties,elements: [],playerTime: null,@@ -123,7 +124,7 @@ async function fetchEventDetails(item: TimelineItem, sessionId?: string): Promisconst request = api.query({kind: NodeKind.EventsQuery,- select: ['uuid', 'event', 'timestamp', 'properties'],+ select: ['uuid', 'event', 'timestamp', 'properties', 'distinct_id'],where: buildEventDetailsWhere(item, sessionId),after: item.timestamp.subtract(EVENT_DETAILS_QUERY_WINDOW_MS, 'millisecond').toISOString(),before: item.timestamp.add(EVENT_DETAILS_QUERY_WINDOW_MS, 'millisecond').toISOString(),diff --git a/products/error_tracking/frontend/components/ExceptionCard/ExceptionCard.stories.tsx b/products/error_tracking/frontend/components/ExceptionCard/ExceptionCard.stories.tsxindex 6905b177bc1d..cb1134664f4e 100644--- a/products/error_tracking/frontend/components/ExceptionCard/ExceptionCard.stories.tsx+++ b/products/error_tracking/frontend/components/ExceptionCard/ExceptionCard.stories.tsx@@ -302,7 +302,13 @@ type StoryCombinedEventRow = [exceptionIssueId: string | null,]-type StoryEventDetailsRow = [uuid: string, eventName: string, timestamp: string, properties: Record<string, unknown>]+type StoryEventDetailsRow = [+ uuid: string,+ eventName: string,+ timestamp: string,+ properties: Record<string, unknown>,+ distinctId: string,+]type StoryExceptionRow = [uuid: string, timestamp: string, properties: string]type StoryPageRow = [uuid: string, timestamp: string, url: string, lib: string]type StoryCustomRow = [uuid: string, eventName: string, timestamp: string, lib: string]@@ -381,7 +387,7 @@ function sessionTimelineParameters(event: ErrorEventType): Record<string, unknow}const properties = uuid === event.uuid ? event.properties : baseProperties- return [String(uuid), [uuid, eventName, ts, properties]]+ return [String(uuid), [uuid, eventName, ts, properties, 'story-user-distinct-id']]})