: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(aio): use raw error value in trace links (#69387)
Radu Raiceaade33f5c364d
diff --git a/products/ai_observability/frontend/AIObservabilityErrors.test.ts b/products/ai_observability/frontend/AIObservabilityErrors.test.tsnew file mode 100644index 000000000000..324e0881a483--- /dev/null+++ b/products/ai_observability/frontend/AIObservabilityErrors.test.ts@@ -0,0 +1,45 @@+import { router } from 'kea-router'++import { urls } from 'scenes/urls'++import { initKeaTests } from '~/test/init'+import { type AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'++import { buildErrorTracesUrl } from './AIObservabilityErrors'++describe('AIObservabilityErrors', () => {+ beforeEach(() => {+ initKeaTests()+ })++ it('links to traces with the raw normalized error value', () => {+ const existingFilter: AnyPropertyFilter = {+ type: PropertyFilterType.Event,+ key: '$ai_model',+ operator: PropertyOperator.Exact,+ value: 'gpt-4o',+ }+ const errorString = 'TypeError: Cannot read "message" at C:\\app\\index.ts'++ const url = buildErrorTracesUrl(errorString, { date_from: '-24h' }, [existingFilter])+ router.actions.push(url)++ expect(router.values.location.pathname.endsWith(urls.aiObservabilityTraces())).toBe(true)+ expect(router.values.searchParams).toMatchObject({ date_from: '-24h' })+ expect(router.values.searchParams.filters).toEqual([+ existingFilter,+ {+ type: PropertyFilterType.Event,+ key: '$ai_is_error',+ operator: PropertyOperator.Exact,+ value: 'true',+ },+ {+ type: PropertyFilterType.Event,+ key: '$ai_error_normalized',+ operator: PropertyOperator.Exact,+ value: errorString,+ },+ ])+ })+})diff --git a/products/ai_observability/frontend/AIObservabilityErrors.tsx b/products/ai_observability/frontend/AIObservabilityErrors.tsxindex 04342d6b8127..0c04a381998e 100644--- a/products/ai_observability/frontend/AIObservabilityErrors.tsx+++ b/products/ai_observability/frontend/AIObservabilityErrors.tsx@@ -12,12 +12,37 @@ import { urls } from 'scenes/urls'import { DataTable } from '~/queries/nodes/DataTable/DataTable'import { type InsightVizNode, NodeKind } from '~/queries/schema/schema-general'import { isHogQLQuery } from '~/queries/utils'-import { PropertyFilterType, PropertyOperator } from '~/types'+import { type AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'import { buildApplyUrlStatePayload, aiObservabilitySharedLogic } from './aiObservabilitySharedLogic'import { useSortableColumns } from './hooks/useSortableColumns'import { aiObservabilityErrorsLogic } from './tabs/aiObservabilityErrorsLogic'+export function buildErrorTracesUrl(+ errorString: string,+ searchParams: Record<string, unknown>,+ currentPropertyFilters: AnyPropertyFilter[]+): string {+ return combineUrl(urls.aiObservabilityTraces(), {+ ...searchParams,+ filters: [+ ...currentPropertyFilters,+ {+ type: PropertyFilterType.Event,+ key: '$ai_is_error',+ operator: PropertyOperator.Exact,+ value: 'true',+ },+ {+ type: PropertyFilterType.Event,+ key: '$ai_error_normalized',+ operator: PropertyOperator.Exact,+ value: errorString,+ },+ ],+ }).url+}+export function AIObservabilityErrors(): JSX.Element {const sharedLogic = useMountedLogic(aiObservabilitySharedLogic)const { applyUrlState } = useActions(aiObservabilitySharedLogic)@@ -90,28 +115,7 @@ export function AIObservabilityErrors(): JSX.Element {<div className="flex items-center gap-1"><Tooltip title={errorString}><Link- to={- combineUrl(urls.aiObservabilityTraces(), {- ...searchParams,- filters: [- {- type: PropertyFilterType.Event,- key: '$ai_is_error',- operator: PropertyOperator.Exact,- value: 'true',- },- {- type: PropertyFilterType.Event,- key: '$ai_error_normalized',- operator: PropertyOperator.Exact,- // Escape backslashes and quotes to match HogQL's JSONExtractRaw extraction- value: errorString- .replace(/\\/g, '\\\\')- .replace(/"/g, '\\"'),- },- ],- }).url- }+ to={buildErrorTracesUrl(errorString, searchParams, currentPropertyFilters)}className="font-mono text-sm"data-attr="llm-errors-row-click">