mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 02:09:50 -04:00
01c178e159
## Summary
The `homeNew` PostHog experiment has concluded. This PR graduates it by
making the new homepage (`ProjectHome`, formerly `HomeV2`) the permanent
default for all users, and removes all dead code from the old
experiment.
## Changes
- Remove `homeNew` PostHog feature flag checks and `home_new` experiment
exposure tracking from 3 files
- Rename `HomeNew/` → `ProjectHome/` directory and `HomeV2` →
`ProjectHome` export
- Delete old `Home/Home.tsx` component (shared components like
`ProjectList/` are kept — still used by org pages)
- Delete `pages/project/[ref]/building.tsx` and add a server-side
redirect from `/project/:ref/building` → `/project/:ref` to prevent 404s
during rollout (old cached JS bundles may still route to `/building`)
- Simplify `ContentWrapper` building-state logic in `ProjectLayout` —
always redirect building projects to home, always suppress building
interstitial on home page
- Always route to `/project/{ref}` after project creation (remove
`/building` path)
- Update all Observability imports from `HomeNew` → `ProjectHome`
## Self-hosted behavior change
Self-hosted Studio previously showed the old `Home` component (client
libraries + example projects) since PostHog flags don't load. This PR
changes self-hosted to show `ProjectHome` (TopSection with service
status + instance diagram, advisor, custom reports). All sections query
backend APIs that exist on self-hosted. E2E tests pass against the
self-hosted build.
## Testing
- [x] `pnpm turbo run build --filter=studio` passes
- [x] No remaining references to `homeNew`, `home_new`, or `HomeNew` in
codebase
- [x] No broken imports to deleted files
- [x] Self-hosted E2E tests pass (145 passed, 1 flaky, 4 skipped)
- [x] `/building` redirect added to both platform and self-hosted config
blocks
**Quick test:**
1. Navigate to any project homepage — should render the ProjectHome
component
2. Create a new project — should redirect to `/project/{ref}` (not
`/building`)
3. Visit a project in `COMING_UP` state on a non-home route — should
redirect to home
4. Visit `/project/{ref}/building` directly — should 302 redirect to
`/project/{ref}`
## Linear
- fixes GROWTH-671
105 lines
2.7 KiB
TypeScript
105 lines
2.7 KiB
TypeScript
import dayjs from 'dayjs'
|
|
|
|
import type { LogsBarChartDatum } from '../ProjectHome/ProjectUsage.metrics'
|
|
import {
|
|
computeSuccessAndNonSuccessRates,
|
|
sumErrors,
|
|
sumTotal,
|
|
sumWarnings,
|
|
} from '../ProjectHome/ProjectUsage.metrics'
|
|
|
|
/**
|
|
* Calculates the date range for fetching service health metrics
|
|
* based on the selected interval
|
|
*/
|
|
export const calculateDateRange = (
|
|
interval: '1hr' | '1day' | '7day'
|
|
): { startDate: string; endDate: string } => {
|
|
const now = dayjs()
|
|
const end = now.toISOString()
|
|
let start: string
|
|
|
|
switch (interval) {
|
|
case '1hr':
|
|
start = now.subtract(1, 'hour').toISOString()
|
|
break
|
|
case '1day':
|
|
start = now.subtract(1, 'day').toISOString()
|
|
break
|
|
case '7day':
|
|
start = now.subtract(7, 'day').toISOString()
|
|
break
|
|
default:
|
|
start = now.subtract(1, 'hour').toISOString()
|
|
}
|
|
|
|
return { startDate: start, endDate: end }
|
|
}
|
|
|
|
export type RawChartData = {
|
|
timestamp: string | number
|
|
ok_count?: number | null
|
|
warning_count?: number | null
|
|
error_count?: number | null
|
|
[key: string]: string | number | null | undefined
|
|
}
|
|
|
|
/**
|
|
* Transforms raw chart query results to LogsBarChartDatum format
|
|
*/
|
|
export const transformToBarChartData = (data: RawChartData[]): LogsBarChartDatum[] => {
|
|
return data.map((row) => ({
|
|
timestamp: typeof row.timestamp === 'string' ? row.timestamp : String(row.timestamp),
|
|
ok_count: row.ok_count ?? 0,
|
|
warning_count: row.warning_count ?? 0,
|
|
error_count: row.error_count ?? 0,
|
|
}))
|
|
}
|
|
|
|
/**
|
|
* Calculates health metrics from bar chart data
|
|
*/
|
|
export const calculateHealthMetrics = (eventChartData: LogsBarChartDatum[]) => {
|
|
const total = sumTotal(eventChartData)
|
|
const errorCount = sumErrors(eventChartData)
|
|
const warningCount = sumWarnings(eventChartData)
|
|
const okCount = total - errorCount - warningCount
|
|
const errorRate = total > 0 ? (errorCount / total) * 100 : 0
|
|
const { successRate } = computeSuccessAndNonSuccessRates(total, warningCount, errorCount)
|
|
|
|
return {
|
|
total,
|
|
errorRate,
|
|
successRate,
|
|
errorCount,
|
|
warningCount,
|
|
okCount,
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Calculates aggregated metrics across all services
|
|
*/
|
|
export const calculateAggregatedMetrics = (
|
|
services: {
|
|
total: number
|
|
errorCount: number
|
|
warningCount: number
|
|
}[]
|
|
) => {
|
|
const totalRequests = services.reduce((sum, s) => sum + s.total, 0)
|
|
const totalErrors = services.reduce((sum, s) => sum + s.errorCount, 0)
|
|
const totalWarnings = services.reduce((sum, s) => sum + s.warningCount, 0)
|
|
|
|
const { successRate: overallSuccessRate, nonSuccessRate: overallErrorRate } =
|
|
computeSuccessAndNonSuccessRates(totalRequests, totalWarnings, totalErrors)
|
|
|
|
return {
|
|
totalRequests,
|
|
totalErrors,
|
|
totalWarnings,
|
|
overallErrorRate,
|
|
overallSuccessRate,
|
|
}
|
|
}
|