Skip to content

Commit fef2c6f

Browse files
committed
rebuild charts with tb charts
1 parent 7101d9d commit fef2c6f

File tree

10 files changed

+104
-376
lines changed

10 files changed

+104
-376
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
.venv
33
.tinyb
4+
.tb_error.txt
45
.tmp

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@radix-ui/react-separator": "^1.1.1",
2323
"@radix-ui/react-slot": "^1.1.1",
2424
"@radix-ui/react-tooltip": "^1.1.6",
25+
"@tinybirdco/charts": "^0.2.4",
2526
"ai": "^4.0.22",
2627
"class-variance-authority": "^0.7.1",
2728
"clsx": "^2.1.1",

apps/web/pnpm-lock.yaml

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/web/src/components/tools/vercel/dashboard.tsx

Lines changed: 19 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,11 @@ import { useQueryState } from 'nuqs'
44
import { useEffect, useState } from 'react'
55
import { addDays, format } from 'date-fns'
66
import { DateRange } from 'react-day-picker'
7-
import { pipe } from '@/lib/tinybird'
87
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
98
import { TimeRange, type TimeRange as TR } from '@/components/time-range'
109
import MetricCard from '@/components/metric-card'
11-
import { DeploymentsChart, DeploymentsData } from './deployments-chart'
12-
import { DurationChart, DurationData } from './duration-chart'
13-
import { ProjectsChart, ProjectData } from './projects-chart'
14-
import { GitAnalyticsChart, GitData } from './git-analytics-chart'
15-
16-
interface VercelMetrics {
17-
total_deployments: number
18-
success_rate: number
19-
error_rate: number
20-
}
10+
import { VercelDeploymentDuration } from './deployment-duration-ts'
11+
import { VercelDeploymentsOverTime } from './deployments-over-time'
2112

2213
export default function VercelDashboard() {
2314
const [token] = useQueryState('token')
@@ -28,44 +19,13 @@ export default function VercelDashboard() {
2819
})
2920

3021
const [, setIsLoading] = useState(true)
31-
const [metrics, setMetrics] = useState<VercelMetrics>()
32-
const [deploymentsData, setDeploymentsData] = useState<DeploymentsData[]>([])
33-
const [durationData, setDurationData] = useState<DurationData[]>([])
34-
const [projectsData, setProjectsData] = useState<ProjectData[]>([])
35-
const [gitData, setGitData] = useState<GitData[]>([])
3622

3723
useEffect(() => {
3824
async function fetchData() {
3925
if (!token) return
4026

41-
const params = {
42-
time_range: timeRange,
43-
...(dateRange?.from && { date_from: format(dateRange.from, 'yyyy-MM-dd HH:mm:ss') }),
44-
...(dateRange?.to && { date_to: format(dateRange.to, 'yyyy-MM-dd 23:59:59') })
45-
}
46-
4727
try {
4828
setIsLoading(true)
49-
const [
50-
metricsResult,
51-
deploymentsResult,
52-
durationResult,
53-
projectsResult,
54-
gitAnalyticsResult,
55-
56-
] = await Promise.all([
57-
pipe<{ data: VercelMetrics[] }>(token, 'vercel_deployment_metrics', params),
58-
pipe<{ data: DeploymentsData[] }>(token, 'vercel_deployments_over_time', params),
59-
pipe<{ data: DurationData[] }>(token, 'vercel_deployment_duration', params),
60-
pipe<{ data: ProjectData[] }>(token, 'vercel_project_stats', params),
61-
pipe<{ data: GitData[] }>(token, 'vercel_git_analytics', params)
62-
])
63-
64-
setMetrics(metricsResult?.data?.[0])
65-
setDeploymentsData(deploymentsResult?.data ?? [])
66-
setDurationData(durationResult?.data ?? [])
67-
setProjectsData(projectsResult?.data ?? [])
68-
setGitData(gitAnalyticsResult?.data ?? [])
6929
} catch (error) {
7030
console.error('Failed to fetch data:', error)
7131
} finally {
@@ -90,19 +50,19 @@ export default function VercelDashboard() {
9050
<div className="grid gap-4 md:grid-cols-4">
9151
<MetricCard
9252
title="Total Deployments"
93-
value={metrics?.total_deployments ?? 'N/A'}
53+
value={'N/A'}
9454
/>
9555
<MetricCard
9656
title="Success Rate"
97-
value={metrics?.success_rate ? `${metrics.success_rate}%` : 'N/A'}
57+
value={'N/A'}
9858
/>
9959
<MetricCard
10060
title="Average Deploy Time"
101-
value={durationData.length > 0 ? `${Math.round(durationData.reduce((acc, curr) => acc + curr.avg_duration, 0) / durationData.length)}s` : 'N/A'}
61+
value={'N/A'}
10262
/>
10363
<MetricCard
10464
title="Error Rate"
105-
value={metrics?.error_rate ? `${metrics.error_rate}%` : 'N/A'}
65+
value={'N/A'}
10666
/>
10767
</div>
10868

@@ -113,9 +73,11 @@ export default function VercelDashboard() {
11373
<CardTitle>Deployments Over Time</CardTitle>
11474
</CardHeader>
11575
<CardContent>
116-
<DeploymentsChart
117-
data={deploymentsData}
118-
timeRange={timeRange}
76+
{/* Deployments Over Time chart */}
77+
<VercelDeploymentsOverTime
78+
time_range={timeRange}
79+
date_from={dateRange.from ? format(dateRange.from, 'yyyy-MM-dd HH:mm:ss') : undefined}
80+
date_to={dateRange.to ? format(dateRange.to, 'yyyy-MM-dd HH:mm:ss') : undefined}
11981
/>
12082
</CardContent>
12183
</Card>
@@ -125,23 +87,23 @@ export default function VercelDashboard() {
12587
<CardTitle>Deploy Duration</CardTitle>
12688
</CardHeader>
12789
<CardContent>
128-
<DurationChart
129-
data={durationData}
130-
timeRange={timeRange} />
90+
{/* Deploy Duration chart */}
91+
<VercelDeploymentDuration
92+
time_range={timeRange}
93+
date_from={dateRange.from ? format(dateRange.from, 'yyyy-MM-dd HH:mm:ss') : undefined}
94+
date_to={dateRange.to ? format(dateRange.to, 'yyyy-MM-dd HH:mm:ss') : undefined}
95+
/>
13196
</CardContent>
13297
</Card>
13398
</div>
13499

135-
{/* Tables and Additional Charts */}
136100
<div className="grid gap-4 md:grid-cols-2">
137101
<Card>
138102
<CardHeader>
139103
<CardTitle>Top Projects</CardTitle>
140104
</CardHeader>
141105
<CardContent>
142-
<ProjectsChart
143-
data={projectsData}
144-
/>
106+
{/* Top Projects table */}
145107
</CardContent>
146108
</Card>
147109

@@ -150,9 +112,7 @@ export default function VercelDashboard() {
150112
<CardTitle>Git Analytics</CardTitle>
151113
</CardHeader>
152114
<CardContent>
153-
<GitAnalyticsChart
154-
data={gitData}
155-
/>
115+
{/* Git Analytics chart */}
156116
</CardContent>
157117
</Card>
158118
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use client'
2+
3+
import { LineChart } from '@tinybirdco/charts'
4+
5+
export function VercelDeploymentDuration(params: {
6+
date_from?: string
7+
date_to?: string
8+
time_range?: string
9+
}) {
10+
return (
11+
<LineChart
12+
endpoint="https://api.tinybird.co/v0/pipes/vercel_deployment_duration.json"
13+
token = "p.eyJ1IjogIjdjNjJiZGRjLWQ3MDItNDBiMy04YTc5LTdkYWQ4ODZmN2FhYiIsICJpZCI6ICIwYWYxMDYzMi1iMTdhLTQzMWEtYjlkOS0wZjdlZWU1M2I3ODMiLCAiaG9zdCI6ICJldV9zaGFyZWQifQ.EUq1kGyKew75WAzACmSmPLjfjDI0F5Jj0DXQAQSqhD8"
14+
index="period"
15+
categories={['avg_duration', 'p95_duration']}
16+
colorPalette={['#27F795', '#008060', '#0EB1B9', '#9263AF', '#5A6FC0', '#86BFDB', '#FFC145', '#FF6B6C', '#DC82C8', '#FFC0F1']}
17+
stacked={true}
18+
title="Vercel Deployment Duration"
19+
height="500px"
20+
params={params}
21+
/>
22+
)
23+
}

apps/web/src/components/tools/vercel/deployments-chart.tsx

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)