Files
supabase/apps/studio/data/analytics/keys.ts
T
ZiincandJordi Enric 2049e75c1d feat: more charts, use functions.combined-stats (#38128)
* feat: more charts, use functions.combined-stats

* fix padding bottom

* spacing fix

* fix empty state missing title

* fix spacing

* fix api types

* fix api types 2

* fix type errors

* add flag

* rm consolelog

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2025-09-05 10:43:57 +00:00

165 lines
3.2 KiB
TypeScript

export const analyticsKeys = {
// logs/reports endpoints
functionsCombinedStats: (
projectRef: string | undefined,
{
interval,
functionId,
}: {
functionId: string | undefined
interval: string | undefined
}
) =>
[
'projects',
projectRef,
'functions-combined-stats',
{
interval,
functionId,
},
] as const,
functionsInvStats: (
projectRef: string | undefined,
{
interval,
functionId,
}: {
functionId: string | undefined
interval: string | undefined
}
) =>
[
'projects',
projectRef,
'functions-inv-stats',
{
interval,
functionId,
},
] as const,
functionsReqStats: (
projectRef: string | undefined,
{
interval,
functionId,
}: {
functionId: string | undefined
interval: string | undefined
}
) =>
[
'projects',
projectRef,
'functions-req-stats',
{
interval,
functionId,
},
] as const,
functionsResourceUsage: (
projectRef: string | undefined,
{
interval,
functionId,
}: {
functionId: string | undefined
interval: string | undefined
}
) =>
[
'projects',
projectRef,
'functions-resource-usage',
{
interval,
functionId,
},
] as const,
orgDailyComputeStats: (
orgSlug: string | undefined,
{
startDate,
endDate,
projectRef,
}: {
startDate?: string
endDate?: string
projectRef?: string
}
) =>
[
'organizations',
orgSlug,
'daily-stats-compute',
{
startDate: isoDateStringToDate(startDate),
endDate: isoDateStringToDate(endDate),
projectRef,
},
] as const,
orgDailyStats: (
orgSlug: string | undefined,
{
metric,
startDate,
endDate,
interval,
projectRef,
}: {
metric?: string
startDate?: string
endDate?: string
interval?: string
projectRef?: string
}
) =>
[
'organizations',
orgSlug,
'daily-stats',
{
metric,
startDate: isoDateStringToDate(startDate),
endDate: isoDateStringToDate(endDate),
interval,
projectRef,
},
] as const,
infraMonitoring: (
projectRef: string | undefined,
{
attribute,
startDate,
endDate,
interval,
databaseIdentifier,
}: {
attribute?: string
startDate?: string
endDate?: string
interval?: string
databaseIdentifier?: string
}
) =>
[
'projects',
projectRef,
'infra-monitoring',
{ attribute, startDate, endDate, interval, databaseIdentifier },
] as const,
usageApiCounts: (projectRef: string | undefined, interval: string | undefined) =>
['projects', projectRef, 'usage.api-counts', interval] as const,
usageApiRequestsCount: (projectRef: string | undefined) =>
['projects', projectRef, 'usage.api-requests-count'] as const,
}
function isoDateStringToDate(isoDateString: string | undefined): string | undefined {
if (!isoDateString) return isoDateString
return isoDateString.split('T')[0]
}