: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): stop one event from breaking the whole issue page (#83683)
Christiaan Hendriksen154e5b11b023
diff --git a/frontend/src/lib/components/Errors/utils.ts b/frontend/src/lib/components/Errors/utils.tsindex 44cfa6448d10..ad2ac478d637 100644--- a/frontend/src/lib/components/Errors/utils.ts+++ b/frontend/src/lib/components/Errors/utils.ts@@ -128,6 +128,20 @@ export function getExceptionAttributes(properties: Record<string, any>): Excepti}}+export function getExceptionTypeAndValue(properties: ErrorEventProperties): {+ type?: string+ value?: string+} {+ const [exception] = Array.isArray(properties.$exception_list) ? properties.$exception_list : []+ const type = properties.$exception_types?.[0] || properties.$exception_type || exception?.type+ const value = properties.$exception_values?.[0] || properties.$exception_message || exception?.value++ return {+ type: type ? stringify(type) : undefined,+ value: value ? stringify(value) : undefined,+ }+}+export function getExceptionList(properties: ErrorEventProperties): ErrorTrackingException[] {const { $sentry_exception } = propertiesdiff --git a/products/error_tracking/frontend/components/EventsTable/EventsTable.test.tsx b/products/error_tracking/frontend/components/EventsTable/EventsTable.test.tsxindex 9c933fa1215b..8ccb237d6e07 100644--- a/products/error_tracking/frontend/components/EventsTable/EventsTable.test.tsx+++ b/products/error_tracking/frontend/components/EventsTable/EventsTable.test.tsx@@ -1,6 +1,6 @@import '@testing-library/jest-dom'-import { cleanup, render } from '@testing-library/react'+import { cleanup, render, screen } from '@testing-library/react'import type { ErrorEventType } from 'lib/components/Errors/types'@@ -61,6 +61,56 @@ describe('EventsTable', () => {expect(scrollIntoView).not.toHaveBeenCalled()})+ it.each([+ [+ 'reads the derived exception arrays when present',+ { $exception_types: ['TypeError'], $exception_values: ['Something failed'] },+ 'TypeError',+ 'Something failed',+ ],+ [+ 'falls back to the exception list when the derived arrays are absent',+ { $exception_list: [{ type: 'ValueError', value: 'Widget not found' }] },+ 'ValueError',+ 'Widget not found',+ ],+ [+ 'falls back to the exception list when the derived arrays are empty',+ { $exception_types: [], $exception_values: [], $exception_list: [{ type: 'Error', value: 'Boom' }] },+ 'Error',+ 'Boom',+ ],+ [+ 'falls back to the legacy singular properties when there is no exception list',+ { $exception_type: 'SyntaxError', $exception_message: 'Unexpected token' },+ 'SyntaxError',+ 'Unexpected token',+ ],+ ['labels the row when nothing is available', {}, 'Unknown', 'No message'],+ [+ 'stringifies a non-string exception value',+ { $exception_types: ['TypeError'], $exception_values: [{}] },+ 'TypeError',+ '{}',+ ],+ ])('%s', (_name, properties, expectedType, expectedValue) => {+ const record = { ...event, properties } as ErrorEventType++ render(+ <EventsTable+ items={[record]}+ hasMore={false}+ loading={false}+ selectedEvent={null}+ onEventSelect={jest.fn()}+ onLoadMore={jest.fn()}+ />+ )++ expect(screen.getByText(expectedType)).toBeInTheDocument()+ expect(screen.getByText(expectedValue)).toBeInTheDocument()+ })+it('scrolls to the newly selected event when the selection changes', () => {const scrollIntoView = jest.fn()Element.prototype.scrollIntoView = scrollIntoViewdiff --git a/products/error_tracking/frontend/components/EventsTable/EventsTable.tsx b/products/error_tracking/frontend/components/EventsTable/EventsTable.tsxindex 876b0b5056de..d355afd99ad8 100644--- a/products/error_tracking/frontend/components/EventsTable/EventsTable.tsx+++ b/products/error_tracking/frontend/components/EventsTable/EventsTable.tsx@@ -3,7 +3,7 @@ import { useEffect, useRef } from 'react'import { Link } from '@posthog/lemon-ui'import { ErrorEventType } from 'lib/components/Errors/types'-import { getRuntimeFromLib } from 'lib/components/Errors/utils'+import { getExceptionTypeAndValue, getRuntimeFromLib } from 'lib/components/Errors/utils'import { TZLabel } from 'lib/components/TZLabel'import {Button,@@ -162,13 +162,16 @@ function EventRow({function EventTitle({ record }: { record: ErrorEventType }): JSX.Element {const library = record.properties.$libconst runtime = getRuntimeFromLib(typeof library === 'string' ? library : null)+ const { type, value } = getExceptionTypeAndValue(record.properties)return (<div className="grid w-full min-w-0 grid-cols-[0.75rem_minmax(0,1fr)] items-center gap-x-2 gap-y-0.5 py-0.5"><RuntimeIcon runtime={runtime} fontSize="0.75rem" />- <div className="min-w-0 truncate text-sm font-semibold">{record.properties.$exception_types[0]}</div>+ <div className="min-w-0 truncate text-sm font-semibold">+ {type ?? <span className="italic text-muted-foreground">Unknown</span>}+ </div><div className="col-span-2 min-w-0 truncate text-xs text-muted-foreground">- {record.properties.$exception_values[0]}+ {value ?? <span className="italic">No message</span>}</div></div>)