mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
* move to new ReportConfig * separate types * add auth report config * add auth report transofmration test * add fetchlogs util for reports * rm auth-charts * rm auth-report-query * rm dupped code * simplify upsell compo * rm unnecessary hook * use upsell in database report instead of old component * rip ReportChart you wont be missed * more tests * rm unnecessary import * Fix SQL in active users * support hide inside report chart component * add max bar size to avoid having big ass bars when theres little data * fix incorrect timestamp key passed on to fillTimeseries * add tooltip to auth report * fix bug with timestamp key inside tooltips * add report settings * rm debugging check * Update apps/studio/data/reports/v2/auth.config.ts Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * safely access result * fix sign in latency query * add toggleable attributes * handle toggleable attributes * pass on hideHighlightedValue * fix signup latency * pass hideHighlighted * report chart pass on hide highlighted value * cleanup finalChartData * simplify tests, use timestamp for everything * fix test * rm dupped attribute * add tooltip to auth errors * Update apps/studio/data/reports/v2/auth.config.ts Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * Update apps/studio/components/ui/Charts/ComposedChart.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * prettify --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
91 lines
2.7 KiB
TypeScript
91 lines
2.7 KiB
TypeScript
import { AnalyticsInterval } from 'data/analytics/constants'
|
|
import { useEdgeFunctionsQuery } from 'data/edge-functions/edge-functions-query'
|
|
import { get } from 'data/fetchers'
|
|
|
|
export type Granularity = 'minute' | 'hour' | 'day'
|
|
export function analyticsIntervalToGranularity(interval: AnalyticsInterval): Granularity {
|
|
switch (interval) {
|
|
case '1m':
|
|
return 'minute'
|
|
case '5m':
|
|
return 'minute'
|
|
case '10m':
|
|
return 'minute'
|
|
case '30m':
|
|
return 'minute'
|
|
case '1h':
|
|
return 'hour'
|
|
case '1d':
|
|
return 'day'
|
|
default:
|
|
return 'hour'
|
|
}
|
|
}
|
|
|
|
export const REPORT_STATUS_CODE_COLORS: { [key: string]: { light: string; dark: string } } = {
|
|
'400': { light: '#FFD54F', dark: '#FFF176' },
|
|
'401': { light: '#FF8A65', dark: '#FFAB91' },
|
|
'403': { light: '#FFB74D', dark: '#FFCC80' },
|
|
'404': { light: '#90A4AE', dark: '#B0BEC5' },
|
|
'409': { light: '#BA68C8', dark: '#CE93D8' },
|
|
'410': { light: '#A1887F', dark: '#BCAAA4' },
|
|
'422': { light: '#FF9800', dark: '#FFB74D' },
|
|
'429': { light: '#E65100', dark: '#F57C00' },
|
|
'500': { light: '#B71C1C', dark: '#D32F2F' },
|
|
'502': { light: '#9575CD', dark: '#B39DDB' },
|
|
'503': { light: '#0097A7', dark: '#4DD0E1' },
|
|
'504': { light: '#C0CA33', dark: '#D4E157' },
|
|
default: { light: '#757575', dark: '#9E9E9E' },
|
|
}
|
|
|
|
export const useEdgeFnIdToName = ({ projectRef }: { projectRef: string }) => {
|
|
const { data: edgeFunctions, isLoading } = useEdgeFunctionsQuery({
|
|
projectRef,
|
|
})
|
|
|
|
function edgeFnIdToName(id: string) {
|
|
return edgeFunctions?.find((fn) => fn.id === id)?.name
|
|
}
|
|
|
|
return {
|
|
edgeFnIdToName,
|
|
isLoading,
|
|
}
|
|
}
|
|
|
|
export async function fetchLogs(
|
|
projectRef: string,
|
|
sql: string,
|
|
startDate: string,
|
|
endDate: string
|
|
) {
|
|
const { data, error } = await get(`/platform/projects/{ref}/analytics/endpoints/logs.all`, {
|
|
params: {
|
|
path: { ref: projectRef },
|
|
query: {
|
|
sql,
|
|
iso_timestamp_start: startDate,
|
|
iso_timestamp_end: endDate,
|
|
},
|
|
},
|
|
})
|
|
if (error) throw error
|
|
return data
|
|
}
|
|
|
|
export const STATUS_CODE_COLORS: { [key: string]: { light: string; dark: string } } = {
|
|
'400': { light: '#FFD54F', dark: '#FFF176' },
|
|
'401': { light: '#FF8A65', dark: '#FFAB91' },
|
|
'403': { light: '#FFB74D', dark: '#FFCC80' },
|
|
'404': { light: '#90A4AE', dark: '#B0BEC5' },
|
|
'409': { light: '#BA68C8', dark: '#CE93D8' },
|
|
'410': { light: '#A1887F', dark: '#BCAAA4' },
|
|
'422': { light: '#FF9800', dark: '#FFB74D' },
|
|
'429': { light: '#E65100', dark: '#F57C00' },
|
|
'500': { light: '#B71C1C', dark: '#D32F2F' },
|
|
'502': { light: '#9575CD', dark: '#B39DDB' },
|
|
'503': { light: '#0097A7', dark: '#4DD0E1' },
|
|
'504': { light: '#C0CA33', dark: '#D4E157' },
|
|
default: { light: '#757575', dark: '#9E9E9E' },
|
|
}
|