Diag Engine

Loading...

Embed on your site

Add this snippet to your website:

<script src="https://diag.dariocositore.com/widget.js" data-tenant="YOUR_SLUG"></script>
Total Leads
-
This Month
-
Critical
-
Diagnostics Run
-

Recent Leads

NameContactTierBriefDate
Loading leads...
`; async function loadLeads() { // For now, fetch from D1 via a simple endpoint // In production, this would be a paginated API try { const res = await fetch(`${apiBase}/t/${slug}/leads?token=${encodeURIComponent(token)}`); if (res.ok) { const data = await res.json(); const leads = data.leads || []; const tbody = document.getElementById("leads-body"); if (leads.length === 0) { tbody.innerHTML = 'No leads yet. Embed the widget to start capturing.'; return; } tbody.innerHTML = leads.map(l => ` ${escapeHtml(l.name)} ${escapeHtml(l.contact)} ${(l.tier || 'b').toUpperCase()} ${escapeHtml((l.issue || "").slice(0, 80))} ${escapeHtml((l.created_at || "").slice(0, 10))} `).join(""); document.getElementById("stat-total").textContent = leads.length; const thisMonth = leads.filter(l => (l.created_at || "").startsWith(new Date().toISOString().slice(0, 7))).length; document.getElementById("stat-month").textContent = thisMonth; document.getElementById("stat-critical").textContent = leads.filter(l => l.tier === "tier-a" || l.tier === "a").length; document.getElementById("stat-diags").textContent = leads.length; } } catch (e) { console.error("Failed to load leads", e); } } function escapeHtml(str) { return String(str || "").replace(/&/g, "&").replace(//g, ">"); } loadLeads();