fix: live cold email stats from CRM in dashboard update

- update-launch-dashboard.py now queries the CRM webhook for real pipeline counts
- Goals (Cold Emails Sent, Active Contacts, CRM Contacts) update daily at 03:00
- Campaign cards (Cold Mail, Influencer) rebuilt from operations.json dynamically
- CRM contacts badge in header updates from live data
- All probe functions replaced with actual CRM query
This commit is contained in:
Oliver
2026-06-17 05:51:37 -03:00
parent 87273a901f
commit 396105cda8
3 changed files with 88 additions and 102 deletions
+48 -70
View File
@@ -693,7 +693,7 @@
<div class="badge-row">
<span class="badge live">● Site Live</span>
<span class="badge warn">● Prelaunch</span>
<span class="badge info">139 CRM Contacts</span>
<span class="badge info" id="crm-badge">0 CRM Contacts</span>
</div>
<div class="updated" id="brief-updated">Last updated: &mdash;</div>
</div>
@@ -878,67 +878,24 @@
<script>
/* ════════ DATA ════════ */
const goals = [
{ id: 'active-contacts', label: 'Active Contacts', current: 1, target: 60, note: 'CRM Cold → Won (88 on Hold excluded)' },
{ id: 'subscriptions', label: 'Subscriptions', current: 0, target: 50, note: 'Paying customers' },
{ id: 'influencers', label: 'Influencers', current: 0, target: 20, note: 'YT creators & affiliates' },
{ id: 'visitors', label: 'Page Visitors', current: 9, target: 10000, unit: '/mo', note: '9 unique visitors in first 2 days (Plausible)' },
{ id: 'outreach-sent', label: 'Cold Emails Sent', current: 0, target: 100, note: 'First touch sent' },
{ id: 'crm-contacts', label: 'CRM Contacts', current: 139, target: 200, note: '89 original + 50 backlink targets' },
/* Campaign label templates — labels stay here, values come from JSON */
const CAMPAIGN_LABELS = [
{ l: '✉ Cold Mail', status: 'draft', metricLabels: ['Drafted', 'Sent', 'Replied'] },
{ l: '🎙 Influencer', status: 'paused', metricLabels: ['Identified', 'Contacted', 'Onboarded'] },
{ l: '🔗 LinkedIn', status: 'draft', metricLabels: ['Connections', 'Outreach', 'Replied'] },
];
const campaigns = [
{
label: '✉ Cold Mail', status: 'draft',
metrics: [{ v: 0, l: 'Drafted' }, { v: 0, l: 'Sent' }, { v: 0, l: 'Replied' }],
items: [
{ t: 'Coupons ready: friends950, creator950', ok: true },
{ t: 'Template signed as Mark', ok: true },
{ t: 'No contacts with real emails yet', ok: false },
]
},
{
label: '🎙 Influencer', status: 'paused',
metrics: [{ v: 60, l: 'Identified' }, { v: 0, l: 'Contacted' }, { v: 0, l: 'Onboarded' }],
items: [
{ t: '60 YT creators on Hold', ok: true },
{ t: 'Need business emails for top 20', ok: false },
{ t: 'Affiliate program TBD', ok: false },
]
},
{
label: '🔗 LinkedIn', status: 'draft',
metrics: [{ v: 0, l: 'Connections' }, { v: 0, l: 'Outreach' }, { v: 0, l: 'Replied' }],
items: [
{ t: 'No outreach started', ok: false },
{ t: 'Company page TBD', ok: false },
{ t: 'No content strategy defined', ok: false },
]
},
{
label: '🌐 SEO & Traffic', status: 'draft',
metrics: [{ v: 9, l: 'Visitors/mo' }, { v: 0, l: 'Blog Posts' }, { v: 50, l: 'Backlink Targets' }],
items: [
{ t: 'Plausible analytics live with 7 custom events — 9 visitors, 37 pageviews', ok: true },
{ t: '50 backlink targets in CRM (strategy=Backlink outreach)', ok: true },
{ t: 'Need Google Search Console submission', ok: false },
{ t: 'Need blog posts (guest posts + own content)', ok: false },
{ t: 'Need directory submissions: Product Hunt, BetaList, G2 + 12 more', ok: false },
]
},
{
label: '🔗 Backlinks', status: 'draft',
metrics: [{ v: 50, l: 'Collected' }, { v: 0, l: 'Ref Domains' }, { v: 0, l: 'Guest Posts' }],
target: { links: 10, domains: 5, posts: 3 },
items: [
{ t: '50 backlink targets sourced — 15 AI directories, 15 blogs, 20 YT/newsletters', ok: true },
{ t: 'All 50 in CRM with strategy=Backlink outreach (Hold stage)', ok: true },
{ t: 'Need directory submissions (Product Hunt, BetaList, G2 + 12 more)', ok: false },
{ t: 'Need guest post pitches to 15 tech blogs', ok: false },
]
}
const goals = [
{ id: 'active-contacts', label: 'Active Contacts', current: 0, target: 60, note: 'Loading...' },
{ id: 'subscriptions', label: 'Subscriptions', current: 0, target: 50, note: 'Loading...' },
{ id: 'influencers', label: 'Influencers', current: 0, target: 20, note: 'Loading...' },
{ id: 'visitors', label: 'Page Visitors', current: 0, target: 10000, unit: '/mo', note: 'Loading...' },
{ id: 'outreach-sent', label: 'Cold Emails Sent', current: 0, target: 100, note: 'Loading...' },
{ id: 'crm-contacts', label: 'CRM Contacts', current: 0, target: 200, note: 'Loading...' },
];
let campaigns = []; // populated from operations.json via fetchLiveData
/* Top 5 needs — 2 done after Oliver's last update */
const NEEDS = [
{ id: "n1", text: "Business emails for top 20 YouTube creators — blocking cold email outreach", done: false },
@@ -1033,18 +990,29 @@
}
function renderCampaigns() {
document.getElementById('campaign-grid').innerHTML = campaigns.map(c => {
const st = c.status === 'active' ? '<span class="status-tag active">● Active</span>'
: c.status === 'paused' ? '<span class="status-tag paused">● Paused</span>'
: '<span class="status-tag draft">Draft</span>';
return `<div class="campaign-card">
<h3>${c.label} ${st}</h3>
<div class="stat-row">${c.metrics.map(m => `<div class="stat-item"><div class="stat-num">${m.v}</div><div class="stat-label">${m.l}</div></div>`).join('')}</div>
${c.target ? `<div style="font-size:10px;color:var(--text-muted);margin-bottom:6px;">Target: ${c.target.links} quality links, ${c.target.domains} referring domains, ${c.target.posts} guest posts</div>` : ''}
<ul>${c.items.map(i => `<li><span class="dot ${i.ok ? 'green' : 'red'}"></span>${i.t}</li>`).join('')}</ul>
</div>`;
}).join('');
}
const src = campaigns.length > 0 ? campaigns : [];
const grid = document.getElementById('campaign-grid');
grid.innerHTML = src.map((c, idx) => {
const tpl = CAMPAIGN_LABELS[idx] || {};
const label = tpl.l || 'Campaign';
const st = c.status || tpl.status || 'draft';
const statusTag = st === 'active' ? '<span class="status-tag active">● Active</span>'
: st === 'paused' ? '<span class="status-tag paused">● Paused</span>'
: '<span class="status-tag draft">Draft</span>';
const metrics = c.metrics || [0, 0, 0];
const labels = tpl.metricLabels || ['', '', ''];
return `<div class="campaign-card">
<h3>${label} ${statusTag}</h3>
<div class="stat-row">${metrics.map((v, i) => `<div class="stat-item"><div class="stat-num">${v}</div><div class="stat-label">${labels[i] || ''}</div></div>`).join('')}</div>
${c.target ? `<div style="font-size:10px;color:var(--text-muted);margin-bottom:6px;">Target: ${c.target.links} quality links, ${c.target.domains} referring domains, ${c.target.posts} guest posts</div>` : ''}
<ul>${(c.items || []).map(i => `<li><span class="dot ${i.ok ? 'green' : 'red'}"></span>${i.t}</li>`).join('')}</ul>
</div>`;
}).join('');
// Fallback if no JSON data loaded
if (!grid.innerHTML) {
grid.innerHTML = '<div style="color:var(--text-muted);font-size:13px;padding:12px 0;">Loading campaign data...</div>';
}
}
/* ── Needs (checkboxes) ── */
function getNeeds() {
@@ -1246,6 +1214,16 @@
if (d.updated) document.getElementById('brief-updated').textContent = 'Last updated: ' + d.updated;
if (d.goals) d.goals.forEach((g, i) => { if (goals[i]) { goals[i].current = g.current; goals[i].note = g.note || goals[i].note; } });
renderGoals();
// Load campaigns from operations.json
if (d.campaigns && d.campaigns.length > 0) {
campaigns = d.campaigns;
renderCampaigns();
}
// Update CRM badge
const badge = document.getElementById('crm-badge');
if (badge && d.comms && d.comms.crm) {
badge.innerHTML = `${d.comms.crm.total} CRM Contacts`;
}
} catch { /* defaults */ }
}