import { defineFrontComponent } from 'twenty-sdk/define'; import React, { useEffect, useState } from 'react'; type SourceStat = { id: string; name: string; slug: string; status: string; totalIngested: number; lastIngestedAt: string | null; }; type LogStat = { status: string; count: number; }; const Dashboard: React.FC = () => { const [sources, setSources] = useState([]); const [logStats, setLogStats] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { const apiUrl = (window as any).__TWENTY_API_URL__ ?? ''; const token = (window as any).__TWENTY_API_TOKEN__ ?? ''; const headers = { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' }; const query = (q: string) => fetch(`${apiUrl}/graphql`, { method: 'POST', headers, body: JSON.stringify({ query: q }) }) .then(r => r.json()); Promise.all([ query(`{ intakeSources(first: 20, orderBy: { lastIngestedAt: DescNullsLast }) { edges { node { id name slug status totalIngested lastIngestedAt } } } }`), query(`{ intakeLogs(first: 200) { edges { node { status } } } }`), ]).then(([srcRes, logRes]) => { setSources((srcRes.data?.intakeSources?.edges ?? []).map((e: any) => e.node)); const counts: Record = {}; for (const e of (logRes.data?.intakeLogs?.edges ?? [])) { counts[e.node.status] = (counts[e.node.status] ?? 0) + 1; } setLogStats(Object.entries(counts).map(([status, count]) => ({ status, count }))); }).finally(() => setLoading(false)); }, []); const statusColor = (s: string) => s === 'ACTIVE' ? '#22c55e' : '#f59e0b'; const logColor = (s: string) => s === 'SUCCESS' ? '#22c55e' : s === 'PARTIAL' ? '#f59e0b' : s === 'FAILED' ? '#ef4444' : '#6b7280'; if (loading) return
Loading...
; const total = logStats.reduce((s, l) => s + l.count, 0); return (

Intake

{sources.length} source{sources.length !== 1 ? 's' : ''} · {total} total ingestions

{/* Log stats */} {logStats.length > 0 && (
{logStats.map(l => (
{l.count}
{l.status}
))}
)} {/* Sources table */} {['Source', 'Slug', 'Status', 'Ingested', 'Last Active'].map(h => ( ))} {sources.map(s => ( ))} {sources.length === 0 && ( )}
{h}
{s.name} {s.slug} {s.status} {s.totalIngested ?? 0} {s.lastIngestedAt ? new Date(s.lastIngestedAt).toLocaleString() : '—'}
No sources yet — use the registration endpoint to add one.
); }; export default defineFrontComponent({ universalIdentifier: '7a3f8b12-c4d9-4e1a-b2f5-8c6d0e9f1a2b', name: 'intake-dashboard', description: 'Intake sources and ingestion statistics', component: Dashboard, });