fix(studio): make user-journey log queries endpoint/flag-aware

Remove the hardcoded logsAllEndpointUrl(true) from the (parked) timeline
analytics queries; callers now pass useOtel from useFlag('otelUnifiedLogs'),
matching the Unified Logs hooks. SQL stays OTEL-only by design.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
kemalandClaude Opus 4.8 committed 2026-07-09 10:39:15 +01:00
1 parent 82f514acab
commit 2d5d2f261e
2 files changed
+31 -11

No files matched your search

@@ -1,4 +1,4 @@
import { useParams } from 'common'
import { useFlag, useParams } from 'common'
import { AlertTriangle, Info, RefreshCw } from 'lucide-react'
import { useCallback, useEffect, useState } from 'react'
import {
@@ -41,6 +41,7 @@ export const UserJourneySheet = ({ identifier, onOpenChange }: UserJourneySheetP
const { data: project } = useSelectedProjectQuery()
const { getEntitlementNumericValue } = useCheckEntitlements('log.retention_days')
const retentionDays = getEntitlementNumericValue() || 1
const useOtel = useFlag('otelUnifiedLogs')
const [isLoading, setIsLoading] = useState(true)
const [isRefreshing, setIsRefreshing] = useState(false)
@@ -71,8 +72,20 @@ export const UserJourneySheet = ({ identifier, onOpenChange }: UserJourneySheetP
const authRows = await (
isId
? fetchAuthLogsByActorId(projectRef, identifier, start.toISOString(), end.toISOString())
: fetchAuthLogsByEmail(projectRef, identifier, start.toISOString(), end.toISOString())
? fetchAuthLogsByActorId(
projectRef,
identifier,
start.toISOString(),
end.toISOString(),
useOtel
)
: fetchAuthLogsByEmail(
projectRef,
identifier,
start.toISOString(),
end.toISOString(),
useOtel
)
).catch(() => {
errors.push('Auth')
return []
@@ -95,7 +108,8 @@ export const UserJourneySheet = ({ identifier, onOpenChange }: UserJourneySheetP
projectRef,
userId,
start.toISOString(),
end.toISOString()
end.toISOString(),
useOtel
).catch(() => {
errors.push('Postgres')
return []
@@ -110,7 +124,7 @@ export const UserJourneySheet = ({ identifier, onOpenChange }: UserJourneySheetP
setTruncated(didTruncate)
setSourcesUsed(Array.from(new Set(allEvents.map((e) => e.source))))
setSourceErrors(errors)
}, [projectRef, identifier, isId, project?.connectionString, retentionDays])
}, [projectRef, identifier, isId, project?.connectionString, retentionDays, useOtel])
useEffect(() => {
if (!identifier) return
@@ -6,9 +6,12 @@ import { logsAllEndpointUrl } from '@/data/logs/logs-endpoint'
import { analyticsLiteral, safeSql } from '@/data/logs/safe-analytics-sql'
import { executeSql } from '@/data/sql/execute-sql-mutation'
// This feature only targets the OTEL (ClickHouse) logs path — see phase 1 findings,
// the legacy BigQuery path has no auth_event.* / user-correlation fields ported to it.
const otelEndpoint = logsAllEndpointUrl(true)
// The SQL below is OTEL/ClickHouse-only — the legacy BigQuery path has no
// auth_event.* / user-correlation fields (phase 1 finding). The endpoint is no
// longer hardcoded: callers pass `useOtel` (from `useFlag('otelUnifiedLogs')`,
// the same flag the Unified Logs hooks read) so the two backends never get
// crossed. When the flag is off there is no BigQuery equivalent to run, which is
// acceptable while this timeline is parked pending the auth_logs pipeline fix.
export interface LogRow {
id: string
@@ -72,6 +75,7 @@ export async function fetchAuthLogsByActorId(
userId: string,
isoStart: string,
isoEnd: string,
useOtel: boolean,
signal?: AbortSignal
): Promise<LogRow[]> {
const idLit = analyticsLiteral(userId)
@@ -86,7 +90,7 @@ export async function fetchAuthLogsByActorId(
`
const data = await executeAnalyticsSql({
projectRef,
endpoint: otelEndpoint,
endpoint: logsAllEndpointUrl(useOtel),
sql,
iso_timestamp_start: isoStart,
iso_timestamp_end: isoEnd,
@@ -105,6 +109,7 @@ export async function fetchAuthLogsByEmail(
email: string,
isoStart: string,
isoEnd: string,
useOtel: boolean,
signal?: AbortSignal
): Promise<LogRow[]> {
const emailLit = analyticsLiteral(email)
@@ -121,7 +126,7 @@ export async function fetchAuthLogsByEmail(
`
const data = await executeAnalyticsSql({
projectRef,
endpoint: otelEndpoint,
endpoint: logsAllEndpointUrl(useOtel),
sql,
iso_timestamp_start: isoStart,
iso_timestamp_end: isoEnd,
@@ -143,6 +148,7 @@ export async function fetchPostgresErrorsForUser(
userId: string,
isoStart: string,
isoEnd: string,
useOtel: boolean,
signal?: AbortSignal
): Promise<LogRow[]> {
const idPattern = analyticsLiteral(`%${userId}%`)
@@ -158,7 +164,7 @@ export async function fetchPostgresErrorsForUser(
`
const data = await executeAnalyticsSql({
projectRef,
endpoint: otelEndpoint,
endpoint: logsAllEndpointUrl(useOtel),
sql,
iso_timestamp_start: isoStart,
iso_timestamp_end: isoEnd,