Files
Jordi Enric 0c9eb15cba refactor(studio): remove legacy homepage usage section (V1) (#46994)
## Problem

The homepage usage section had two implementations gated by the
`newHomepageUsageV2` ConfigCat flag, with the legacy V1 as the fallback.
That flag has been at 100% in production for months, so V1 is dead code
and the flag branch is unnecessary.

## Fix

- Make V2 the default by removing the `newHomepageUsageV2` flag check in
`Home.tsx`.
- Delete the V1 section (`Home/ProjectUsageSection.tsx`), its chart
(`Home/ProjectUsage.tsx`), and the now-orphaned
`project-log-requests-count-query` plus its query key.
- Shared code (`useProjectLogStatsQuery`, `UsageApiCounts`,
`ProjectLogStatsVariables`) is kept since V2 and other modules still use
it.

The `newHomepageUsageV2` flag can be removed from ConfigCat after this
merges.

## How to test

- Open a project homepage on platform.
- Confirm the usage section still renders (the V2 layout) with no flag
dependency.
- Verify no console errors and no broken imports.
- Expected result: identical homepage usage section to what production
shows today.

## Notes

- This is independent of the in-flight service-health usage charts work
(PR #46373), which is behind its own `newHomepageUsageDeltas` flag.
Whichever merges second will resolve a small conflict on the
`UsageSection` selection in `Home.tsx`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
  * Removed project usage statistics section from the home page.
* Simplified the home page experience by consolidating feature flag
variants into a standardized implementation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 16:17:28 +02:00

175 lines
3.4 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,
orgDailyStats: (
orgSlug: string | undefined,
{
startDate,
endDate,
projectRef,
}: {
startDate?: string
endDate?: string
projectRef?: string
}
) =>
[
'organizations',
orgSlug,
'daily-stats',
{
startDate: isoDateStringToDate(startDate),
endDate: isoDateStringToDate(endDate),
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,
infraMonitoringGroup: (
projectRef: string | undefined,
{
attributes,
startDate,
endDate,
interval,
databaseIdentifier,
}: {
attributes?: string[]
startDate?: string
endDate?: string
interval?: string
databaseIdentifier?: string
}
) =>
[
'projects',
projectRef,
'infra-monitoring',
'group',
{
attributes: attributes ? [...attributes].sort() : undefined,
startDate,
endDate,
interval,
databaseIdentifier,
},
] as const,
usageApiCounts: (projectRef: string | undefined, interval: string | undefined) =>
['projects', projectRef, 'usage.api-counts', interval] as const,
serviceHealth: (
projectRef: string | undefined,
{
startDate,
endDate,
granularity,
}: {
startDate?: string
endDate?: string
granularity?: string
}
) => ['projects', projectRef, 'service-health', { startDate, endDate, granularity }] as const,
}
function isoDateStringToDate(isoDateString: string | undefined): string | undefined {
if (!isoDateString) return isoDateString
return isoDateString.split('T')[0]
}