@@ -11,6 +11,13 @@ import { VercelDeploymentDuration } from './deployment-duration-ts'
1111import { VercelDeploymentsOverTime } from './deployments-over-time'
1212import { GitAnalytics } from './git-analytics'
1313import { VercelProjects } from './project-stats'
14+ import { pipe } from '@/lib/tinybird'
15+
16+ interface VercelMetrics {
17+ total_deployments : number
18+ success_rate : number
19+ error_rate : number
20+ }
1421
1522export default function VercelDashboard ( ) {
1623 const [ token ] = useQueryState ( 'token' )
@@ -19,15 +26,28 @@ export default function VercelDashboard() {
1926 from : addDays ( new Date ( ) , - 7 ) ,
2027 to : new Date ( )
2128 } )
29+ const [ metrics , setMetrics ] = useState < VercelMetrics > ( )
2230
2331 const [ , setIsLoading ] = useState ( true )
2432
2533 useEffect ( ( ) => {
2634 async function fetchData ( ) {
2735 if ( ! token ) return
2836
37+ const params = {
38+ time_range : timeRange ,
39+ ...( dateRange ?. from && { date_from : format ( dateRange . from , 'yyyy-MM-dd HH:mm:ss' ) } ) ,
40+ ...( dateRange ?. to && { date_to : format ( dateRange . to , 'yyyy-MM-dd 23:59:59' ) } )
41+ }
42+
2943 try {
3044 setIsLoading ( true )
45+ const [
46+ metricsResult ,
47+ ] = await Promise . all ( [
48+ pipe < { data : VercelMetrics [ ] } > ( token , 'vercel_deployment_metrics' , params ) ,
49+ ] )
50+ setMetrics ( metricsResult ?. data ?. [ 0 ] )
3151 } catch ( error ) {
3252 console . error ( 'Failed to fetch data:' , error )
3353 } finally {
@@ -51,22 +71,18 @@ export default function VercelDashboard() {
5171 </ div >
5272
5373 { /* Metrics Row */ }
54- < div className = "grid gap-4 md:grid-cols-4 " >
74+ < div className = "grid gap-4 md:grid-cols-3 " >
5575 < MetricCard
5676 title = "Total Deployments"
57- value = { 'N/A' }
77+ value = { metrics ?. total_deployments ?? 'N/A' }
5878 />
5979 < MetricCard
6080 title = "Success Rate"
61- value = { 'N/A' }
62- />
63- < MetricCard
64- title = "Average Deploy Time"
65- value = { 'N/A' }
81+ value = { metrics ?. success_rate ?? 'N/A' }
6682 />
6783 < MetricCard
6884 title = "Error Rate"
69- value = { 'N/A' }
85+ value = { metrics ?. error_rate ?? 'N/A' }
7086 />
7187 </ div >
7288
0 commit comments