mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem Observability date labels ignore the timezone set in the profile. They always show the browser timezone or UTC. The header range label (for example "Nov 27, 12:40pm → 12:50pm") uses bare `dayjs()`. The Data API charts (Total Requests, Error Counts, Response Speed, Network Traffic) pass `displayDateInUtc`, so the first and last timestamps under each chart always show UTC. ## Solution - Format the header range label with `useFormatDateTime()` on the Database, Auth, Storage, Realtime, PostgREST and Edge Functions observability pages. - Remove `displayDateInUtc` from the four Data API charts in `ApiRenderers.tsx`. - Use `text-xs` for the date labels in `BarChart`, so they match `ComposedChart` and `StackedBarChart`. This is a separate commit. ## Review instructions 1. Open Observability, Database, and set a timezone in your profile that differs from your browser. 2. Check that the range label next to the date picker and the tooltip show the same timezone. 3. Open Observability, Data API. Check that the labels under each chart follow the profile timezone and use the same font size as the Database charts. <details> <summary>Screenshots</summary> <img width="1124" height="844" alt="CleanShot 2026-11-27 at 13 37 14@2x" src="https://github.com/user-attachments/assets/e3d29c77-317a-4489-aa4c-1fbf4783cb57" /> font in Data API <img width="318" height="72" alt="CleanShot 2026-11-27 at 13 40 19@2x" src="https://github.com/user-attachments/assets/06e4d12f-245f-4d4e-9dc9-b7f2f7879e52" /> font in Database <img width="342" height="66" alt="CleanShot 2026-11-27 at 13 41 08@2x" src="https://github.com/user-attachments/assets/de200eb2-4351-471d-a220-bacea142b0d9" /> </details> ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill (not applicable, no docs changes)
413 lines
15 KiB
TypeScript
413 lines
15 KiB
TypeScript
import { useQueryClient } from '@tanstack/react-query'
|
|
import { createFileRoute, useNavigate } from '@tanstack/react-router'
|
|
import { useFlag } from 'common'
|
|
import { ArrowRightIcon, LogsIcon, RefreshCwIcon } from 'lucide-react'
|
|
import { parseAsJson, useQueryState } from 'nuqs'
|
|
import { useState } from 'react'
|
|
import { Button } from 'ui'
|
|
|
|
import { OBSERVABILITY_DOCS_HREFS } from '@/components/interfaces/Observability/Observability.constants'
|
|
import ReportFilterBar from '@/components/interfaces/Reports/ReportFilterBar'
|
|
import { ReportHeader } from '@/components/interfaces/Reports/ReportHeader'
|
|
import { ReportPadding } from '@/components/interfaces/Reports/ReportPadding'
|
|
import { REPORT_DATERANGE_HELPER_LABELS } from '@/components/interfaces/Reports/Reports.constants'
|
|
import ReportStickyNav from '@/components/interfaces/Reports/ReportStickyNav'
|
|
import { SharedAPIReport } from '@/components/interfaces/Reports/SharedAPIReport/SharedAPIReport'
|
|
import { useSharedAPIReport } from '@/components/interfaces/Reports/SharedAPIReport/SharedAPIReport.constants'
|
|
import { ReportChartV2 } from '@/components/interfaces/Reports/v2/ReportChartV2'
|
|
import { ReportSectionHeader } from '@/components/interfaces/Reports/v2/ReportSectionHeader'
|
|
import {
|
|
numericFilterSchema,
|
|
ReportsNumericFilter,
|
|
} from '@/components/interfaces/Reports/v2/ReportsNumericFilter'
|
|
import {
|
|
ReportsSelectFilter,
|
|
selectFilterSchema,
|
|
} from '@/components/interfaces/Reports/v2/ReportsSelectFilter'
|
|
import { LogsDatePicker } from '@/components/interfaces/Settings/Logs/Logs.DatePickers'
|
|
import UpgradePrompt from '@/components/interfaces/Settings/Logs/UpgradePrompt'
|
|
import type { ChartHighlightAction } from '@/components/ui/Charts/ChartHighlightActions'
|
|
import { ReportSettings } from '@/components/ui/Charts/ReportSettings'
|
|
import { DocsButton } from '@/components/ui/DocsButton'
|
|
import { ObservabilityLink } from '@/components/ui/ObservabilityLink'
|
|
import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
|
|
import { reportKeys } from '@/data/reports/keys'
|
|
import {
|
|
createErrorsReportConfig,
|
|
createLatencyReportConfig,
|
|
createUsageReportConfig,
|
|
} from '@/data/reports/v2/auth.config'
|
|
import { useRefreshHandler, useReportDateRange } from '@/hooks/misc/useReportDateRange'
|
|
import { useFormatDateTime } from '@/lib/datetime'
|
|
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
|
import { useShortcut } from '@/state/shortcuts/useShortcut'
|
|
|
|
export const Route = createFileRoute('/project/$ref/observability/auth')({
|
|
component: AuthReport,
|
|
staticData: {
|
|
observabilityLayoutTitle: 'Auth',
|
|
},
|
|
})
|
|
|
|
function AuthReport() {
|
|
return (
|
|
<ReportPadding>
|
|
<AuthUsage />
|
|
</ReportPadding>
|
|
)
|
|
}
|
|
|
|
const REPORT_TITLE = 'Auth'
|
|
|
|
const AuthUsage = () => {
|
|
const { ref } = Route.useParams()
|
|
const queryClient = useQueryClient()
|
|
const useOtel = useFlag('otelReports')
|
|
const chartSyncId = `auth-report`
|
|
const queryGroup = useOtel ? 'auth-otel' : 'auth-bigquery'
|
|
|
|
const {
|
|
selectedDateRange,
|
|
updateDateRange,
|
|
datePickerValue,
|
|
datePickerHelpers,
|
|
showUpgradePrompt,
|
|
setShowUpgradePrompt,
|
|
handleDatePickerChange,
|
|
} = useReportDateRange(REPORT_DATERANGE_HELPER_LABELS.LAST_60_MINUTES)
|
|
const formatDateTime = useFormatDateTime()
|
|
|
|
const {
|
|
data,
|
|
error,
|
|
isLoading,
|
|
refetch,
|
|
isRefetching,
|
|
filters,
|
|
addFilter,
|
|
removeFilters,
|
|
isLoadingData,
|
|
sql,
|
|
} = useSharedAPIReport({
|
|
filterBy: 'auth',
|
|
start: selectedDateRange?.period_start?.date,
|
|
end: selectedDateRange?.period_end?.date,
|
|
})
|
|
|
|
const [isRefreshing, setIsRefreshing] = useState(false)
|
|
const [showDatePicker, setShowDatePicker] = useState(false)
|
|
|
|
const [monitoringStatusCodeFilter, setMonitoringStatusCodeFilter] = useQueryState(
|
|
'monitoring_status_code',
|
|
parseAsJson(numericFilterSchema.parse)
|
|
)
|
|
|
|
const [usageProviderFilter, setUsageProviderFilter] = useQueryState(
|
|
'usage_provider',
|
|
parseAsJson(selectFilterSchema.parse)
|
|
)
|
|
|
|
const providerOptions = [
|
|
{ label: 'Email', value: 'email' },
|
|
{ label: 'Google', value: 'google' },
|
|
{ label: 'Apple', value: 'apple' },
|
|
{ label: 'Phone', value: 'phone' },
|
|
{ label: 'Discord', value: 'discord' },
|
|
{ label: 'Azure', value: 'azure' },
|
|
{ label: 'GitHub', value: 'github' },
|
|
{ label: 'Kakao', value: 'kakao' },
|
|
{ label: 'TOTP', value: 'totp' },
|
|
{ label: 'Twitter', value: 'twitter' },
|
|
{ label: 'SAML', value: 'saml' },
|
|
{ label: 'Recovery', value: 'recovery' },
|
|
{ label: 'SSO/SAML', value: 'sso/saml' },
|
|
{ label: 'Magic link', value: 'magiclink' },
|
|
{ label: 'Keycloak', value: 'keycloak' },
|
|
{ label: 'Facebook', value: 'facebook' },
|
|
{ label: 'Twitch', value: 'twitch' },
|
|
{ label: 'LinkedIn OIDC', value: 'linkedin_oidc' },
|
|
{ label: 'Spotify', value: 'spotify' },
|
|
{ label: 'Email Change', value: 'email_change' },
|
|
{ label: 'Snapchat', value: 'snapchat' },
|
|
{ label: 'WorkOS', value: 'workos' },
|
|
{ label: 'Notion', value: 'notion' },
|
|
{ label: 'Slack OIDC', value: 'slack_oidc' },
|
|
{ label: 'Figma', value: 'figma' },
|
|
{ label: 'GitLab', value: 'gitlab' },
|
|
{ label: 'LinkedIn', value: 'linkedin' },
|
|
{ label: 'Zoom', value: 'zoom' },
|
|
]
|
|
|
|
const usageReportConfig = createUsageReportConfig({
|
|
projectRef: ref || '',
|
|
startDate: selectedDateRange?.period_start?.date,
|
|
endDate: selectedDateRange?.period_end?.date,
|
|
interval: selectedDateRange?.interval,
|
|
filters: { provider: usageProviderFilter },
|
|
useOtel,
|
|
})
|
|
|
|
const errorsReportConfig = createErrorsReportConfig({
|
|
projectRef: ref || '',
|
|
startDate: selectedDateRange?.period_start?.date,
|
|
endDate: selectedDateRange?.period_end?.date,
|
|
interval: selectedDateRange?.interval,
|
|
filters: { status_code: monitoringStatusCodeFilter },
|
|
useOtel,
|
|
})
|
|
|
|
const latencyReportConfig = createLatencyReportConfig({
|
|
projectRef: ref || '',
|
|
startDate: selectedDateRange?.period_start?.date,
|
|
endDate: selectedDateRange?.period_end?.date,
|
|
interval: selectedDateRange?.interval,
|
|
filters: {},
|
|
useOtel,
|
|
})
|
|
|
|
const onRefreshReport = useRefreshHandler(
|
|
datePickerValue,
|
|
datePickerHelpers,
|
|
handleDatePickerChange,
|
|
async () => {
|
|
if (!selectedDateRange) return
|
|
|
|
setIsRefreshing(true)
|
|
try {
|
|
await Promise.all([
|
|
refetch(),
|
|
queryClient.invalidateQueries({ queryKey: reportKeys.charts(ref) }),
|
|
])
|
|
} finally {
|
|
setIsRefreshing(false)
|
|
}
|
|
}
|
|
)
|
|
|
|
useShortcut(SHORTCUT_IDS.OBSERVABILITY_REFRESH, onRefreshReport, {
|
|
enabled: !isRefreshing,
|
|
})
|
|
useShortcut(SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER, () => {
|
|
setShowDatePicker((open) => !open)
|
|
})
|
|
|
|
const navigate = useNavigate()
|
|
|
|
const highlightActions: ChartHighlightAction[] = [
|
|
{
|
|
id: 'api-gateway-logs',
|
|
label: 'Open in API Gateway Logs',
|
|
icon: <LogsIcon size={12} />,
|
|
onSelect: ({ start, end, chartId }) => {
|
|
const filter = chartId?.includes('errors')
|
|
? `{"product":{"auth":true},"status_code":{"error":true,"warning":true}}`
|
|
: `{"product":{"auth":true}}`
|
|
|
|
void navigate({
|
|
to: '/project/$ref/logs/edge-logs',
|
|
params: { ref },
|
|
search: { its: start, ite: end, f: filter },
|
|
})
|
|
},
|
|
},
|
|
{
|
|
id: 'auth-logs',
|
|
label: 'Open in Auth Logs',
|
|
icon: <LogsIcon size={12} />,
|
|
onSelect: ({ start, end }) => {
|
|
void navigate({
|
|
to: '/project/$ref/logs/auth-logs',
|
|
params: { ref },
|
|
search: { its: start, ite: end },
|
|
})
|
|
},
|
|
},
|
|
]
|
|
|
|
return (
|
|
<>
|
|
<ReportHeader title={REPORT_TITLE} showDatabaseSelector={false} />
|
|
<ReportStickyNav
|
|
content={
|
|
<div className="flex flex-col gap-2 w-full">
|
|
<div className="w-full flex items-center gap-2 flex-wrap">
|
|
<ShortcutTooltip
|
|
shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
|
|
label="Refresh report"
|
|
side="bottom"
|
|
>
|
|
<Button
|
|
disabled={isRefreshing}
|
|
icon={<RefreshCwIcon className={isRefreshing ? 'animate-spin' : ''} />}
|
|
className="w-7"
|
|
onClick={onRefreshReport}
|
|
/>
|
|
</ShortcutTooltip>
|
|
<ReportSettings chartId={chartSyncId} />
|
|
<LogsDatePicker
|
|
onSubmit={handleDatePickerChange}
|
|
value={datePickerValue}
|
|
helpers={datePickerHelpers}
|
|
open={showDatePicker}
|
|
onOpenChange={setShowDatePicker}
|
|
shortcutId={SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER}
|
|
/>
|
|
<UpgradePrompt
|
|
show={showUpgradePrompt}
|
|
setShowUpgradePrompt={setShowUpgradePrompt}
|
|
title="Report date range"
|
|
description="Report data can be stored for a maximum of 3 months depending on the plan that your project is on."
|
|
source="authReportDateRange"
|
|
/>
|
|
{selectedDateRange && (
|
|
<div className="order-last flex w-full flex-wrap items-center gap-x-2 text-xs xl:order-none xl:w-auto">
|
|
<p className="text-foreground-light">
|
|
{formatDateTime(selectedDateRange.period_start.date, 'MMM D, h:mma')}
|
|
</p>
|
|
<p className="text-foreground-light">
|
|
<ArrowRightIcon size={12} />
|
|
</p>
|
|
<p className="text-foreground-light">
|
|
{formatDateTime(selectedDateRange.period_end.date, 'MMM D, h:mma')}
|
|
</p>
|
|
</div>
|
|
)}
|
|
<DocsButton
|
|
href={OBSERVABILITY_DOCS_HREFS.auth}
|
|
topic={REPORT_TITLE}
|
|
className="ml-auto"
|
|
/>
|
|
</div>
|
|
</div>
|
|
}
|
|
>
|
|
<div className="mt-8 flex flex-col gap-8 pb-8">
|
|
<div className="flex flex-col gap-4" id="usage">
|
|
<div>
|
|
<ReportSectionHeader
|
|
id="usage"
|
|
title="Usage"
|
|
description="Monitor user activity, sign-ins, sign-ups, and password reset requests to understand how users interact with your authentication system."
|
|
/>
|
|
<ReportsSelectFilter
|
|
label="Provider"
|
|
options={providerOptions}
|
|
value={usageProviderFilter || []}
|
|
onChange={setUsageProviderFilter}
|
|
isLoading={isRefreshing}
|
|
showSearch={true}
|
|
/>
|
|
</div>
|
|
<div className="grid @4xl:grid-cols-2 gap-4">
|
|
{usageReportConfig.map((metric) => (
|
|
<ReportChartV2
|
|
key={`${metric.id}`}
|
|
report={metric}
|
|
projectRef={ref!}
|
|
interval={selectedDateRange.interval}
|
|
startDate={selectedDateRange?.period_start?.date}
|
|
endDate={selectedDateRange?.period_end?.date}
|
|
updateDateRange={updateDateRange}
|
|
syncId={chartSyncId}
|
|
queryGroup={queryGroup}
|
|
filters={{ provider: usageProviderFilter }}
|
|
highlightActions={highlightActions}
|
|
/>
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-4" id="monitoring">
|
|
<div>
|
|
<ReportSectionHeader
|
|
id="monitoring"
|
|
title="Monitoring"
|
|
description="Track authentication errors by status code and error type to identify issues and improve user experience."
|
|
/>
|
|
|
|
<ReportsNumericFilter
|
|
label="Status Code"
|
|
value={monitoringStatusCodeFilter}
|
|
onChange={setMonitoringStatusCodeFilter}
|
|
defaultOperator="="
|
|
isLoading={isRefreshing}
|
|
/>
|
|
</div>
|
|
<div className="grid @4xl:grid-cols-2 gap-4">
|
|
{errorsReportConfig.map((metric) => (
|
|
<ReportChartV2
|
|
key={`${metric.id}`}
|
|
report={metric}
|
|
projectRef={ref!}
|
|
interval={selectedDateRange.interval}
|
|
startDate={selectedDateRange?.period_start?.date}
|
|
endDate={selectedDateRange?.period_end?.date}
|
|
updateDateRange={updateDateRange}
|
|
syncId={chartSyncId}
|
|
queryGroup={queryGroup}
|
|
filters={{ status_code: monitoringStatusCodeFilter }}
|
|
highlightActions={highlightActions}
|
|
/>
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-4" id="performance">
|
|
<ReportSectionHeader
|
|
id="performance"
|
|
title="Performance"
|
|
description="Monitor sign-in and sign-up performance metrics including average, percentiles, and request counts to ensure optimal authentication speed."
|
|
/>
|
|
<div className="grid @4xl:grid-cols-2 gap-4">
|
|
{latencyReportConfig.map((metric) => (
|
|
<ReportChartV2
|
|
key={`${metric.id}`}
|
|
report={metric}
|
|
projectRef={ref!}
|
|
interval={selectedDateRange.interval}
|
|
startDate={selectedDateRange?.period_start?.date}
|
|
endDate={selectedDateRange?.period_end?.date}
|
|
updateDateRange={updateDateRange}
|
|
syncId={chartSyncId}
|
|
queryGroup={queryGroup}
|
|
filters={{}}
|
|
highlightActions={highlightActions}
|
|
/>
|
|
))}
|
|
</div>
|
|
</div>
|
|
<div id="auth-api-gateway">
|
|
<div className="mb-4 space-y-4">
|
|
<ReportSectionHeader
|
|
id="auth-api-gateway"
|
|
title="Auth API Gateway"
|
|
description="Monitor user activity, sign-ins, sign-ups, and password reset requests to understand how users interact with your authentication system."
|
|
/>
|
|
<ReportFilterBar
|
|
filters={filters}
|
|
onAddFilter={addFilter}
|
|
onRemoveFilters={removeFilters}
|
|
isLoading={isLoadingData || isRefetching}
|
|
hideDatepicker={true}
|
|
datepickerHelpers={datePickerHelpers}
|
|
selectedProduct={'auth'}
|
|
showDatabaseSelector={false}
|
|
/>
|
|
</div>
|
|
<SharedAPIReport
|
|
data={data}
|
|
error={error}
|
|
isLoading={isLoading}
|
|
isRefetching={isRefetching}
|
|
sql={sql}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</ReportStickyNav>
|
|
<div className="pb-8">
|
|
<ObservabilityLink />
|
|
</div>
|
|
</>
|
|
)
|
|
}
|