mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 19:35:06 +03:00
## What When the unified logs preview is enabled, clicking a chart bar that links to a logs view now opens **unified logs** (scoped to the service and time bucket) instead of the legacy logs explorer. Surfaces updated: - Homepage project usage charts (`ProjectUsageSectionDeltas`, `ProjectUsageSection`) - Observability overview service health table (`ObservabilityOverview`) — also fixes the API Gateway row and passes the time range via the `date` param unified logs actually reads Adds a small `buildUnifiedLogsUrl` helper so the deep-link format (`filter=log_type:eq:<type>` + `date` epoch-ms range) lives in one place. When the preview is off, behavior is unchanged (legacy logs explorer). Resolves O11Y-2133. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added unified logs navigation for project usage and observability charts. * Chart bar clicks now open the unified logs view with service-specific filtering and a computed time window. * **Bug Fixes** * Updated observability and usage charts to generate the correct unified logs URLs (including `log_type` filtering and optional date ranges). * Preserved legacy log navigation behavior when unified logs are disabled. * **Tests** * Added unit tests covering unified logs URL generation, query parameters, and date handling. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { buildUnifiedLogsUrl } from './UnifiedLogs.utils'
|
|
|
|
describe('buildUnifiedLogsUrl', () => {
|
|
const parse = (url: string) => {
|
|
const [path, query] = url.split('?')
|
|
return { path, params: new URLSearchParams(query) }
|
|
}
|
|
|
|
it('targets the project logs route with a log_type filter', () => {
|
|
const { path, params } = parse(buildUnifiedLogsUrl({ projectRef: 'abc', logType: 'postgres' }))
|
|
expect(path).toBe('/project/abc/logs')
|
|
expect(params.get('filter')).toBe('log_type:eq:postgres')
|
|
expect(params.has('date')).toBe(false)
|
|
})
|
|
|
|
it('preserves multi-word log types once decoded', () => {
|
|
const { params } = parse(buildUnifiedLogsUrl({ projectRef: 'abc', logType: 'edge function' }))
|
|
expect(params.get('filter')).toBe('log_type:eq:edge function')
|
|
})
|
|
|
|
it('adds the date range as an epoch-ms pair when start and end are provided', () => {
|
|
const start = new Date('2026-05-08T00:00:00.000Z')
|
|
const end = new Date('2026-05-08T01:00:00.000Z')
|
|
const { params } = parse(
|
|
buildUnifiedLogsUrl({ projectRef: 'abc', logType: 'auth', start, end })
|
|
)
|
|
expect(params.get('date')).toBe(`${start.valueOf()}-${end.valueOf()}`)
|
|
})
|
|
|
|
it('accepts ISO strings for the date range', () => {
|
|
const start = '2026-05-08T00:00:00.000Z'
|
|
const end = '2026-05-08T01:00:00.000Z'
|
|
const { params } = parse(
|
|
buildUnifiedLogsUrl({ projectRef: 'abc', logType: 'auth', start, end })
|
|
)
|
|
expect(params.get('date')).toBe(`${new Date(start).valueOf()}-${new Date(end).valueOf()}`)
|
|
})
|
|
|
|
it('omits the date range when only one bound is provided', () => {
|
|
const { params } = parse(
|
|
buildUnifiedLogsUrl({ projectRef: 'abc', logType: 'storage', start: new Date() })
|
|
)
|
|
expect(params.has('date')).toBe(false)
|
|
})
|
|
})
|