mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
Enables Braintrust tracing and feedback for Assistant chats on EU-region projects. This was the final holdout that makes it so that tracing is applied consistently across all projects. Adds `projectRegion` metadata to root traces so the project’s region is recorded with each chat (consistent with the existing [isHighComplianceProject metadata](https://github.com/supabase/supabase/blob/917dcb388939b8c54ea13c1e31b3c7285fb2ca65/apps/studio/lib/ai/generate-assistant-response.ts#L188)). Verified in staging with a [successful Assistant trace recording `projectRegion: eu-central-1`](https://www.braintrust.dev/app/supabase.io/p/Assistant/logs?r=1b4a05d7a6c1414e62f532094aa39dc1&sid=4fdc76b08a4c5a43). <img width="2656" height="1560" alt="CleanShot 2026-11-12 at 1 12 30 PM@2x" src="https://github.com/user-attachments/assets/4e81033a-c754-46db-845d-586d1d71e035" /> Closes AI-1197
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { hideSpanErrorFromTrace, redactHiddenSpanError } from './braintrust-logger'
|
|
import { NO_DATA_ERROR } from './tools/execute-sql-output'
|
|
|
|
describe('redactHiddenSpanError', () => {
|
|
it('hides child errors until the hidden span ends', () => {
|
|
hideSpanErrorFromTrace('parent')
|
|
const childError = (span_id: string) => ({
|
|
span_id,
|
|
span_parents: ['parent'],
|
|
error: 'key (email)=(a@b.c)',
|
|
})
|
|
|
|
for (const span_id of ['tool-1', 'tool-2']) {
|
|
expect(redactHiddenSpanError(childError(span_id))).toEqual({
|
|
...childError(span_id),
|
|
error: NO_DATA_ERROR,
|
|
})
|
|
}
|
|
redactHiddenSpanError({ span_id: 'parent', metrics: { end: 1 } })
|
|
expect(redactHiddenSpanError(childError('tool-3'))).toEqual(childError('tool-3'))
|
|
})
|
|
|
|
it('leaves errors on other spans alone', () => {
|
|
hideSpanErrorFromTrace('hidden')
|
|
const otherError = { span_id: 'other', span_parents: ['root'], error: 'boom' }
|
|
|
|
expect(redactHiddenSpanError(otherError)).toEqual(otherError)
|
|
})
|
|
})
|