blind-monkeys / templates /analytics.html
deanpowers's picture
Sync workspace source: rank tracker module + routes, Grid DB admin page, flaskfactory AI probe + analytics zone, nav.js v16 Blog pill, template refresh
c8c30b4
Raw History Blame Contribute Delete
19.6 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Analytics β€” Blind Monkeys</title>
<link rel="stylesheet" href="/css/nav.css?v=4">
<style>
* { box-sizing: border-box; }
body { background: #0d1117; color: #e6edf3; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; margin: 0; }
.page-content { max-width: 1100px; margin: 0 auto; padding: 32px 20px; }
h1 { font-size: 24px; margin: 0 0 4px; }
.sub { color: #8b949e; font-size: 14px; margin-bottom: 24px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: #1e2329; border: 2px solid #30363d; border-radius: 12px; padding: 18px; }
.stat .t { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #f0b90b; margin-bottom: 8px; }
.stat .v { font-size: 26px; font-weight: 700; font-family: 'SF Mono', Monaco, monospace; }
.stat .d { font-size: 12px; color: #8b949e; margin-top: 6px; }
.pos { color: #4ade80; } .neg { color: #f87171; } .mut { color: #8b949e; }
.card { background: #1e2329; border: 2px solid #30363d; border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.card h2 { font-size: 14px; color: #f0b90b; margin: 0 0 16px; letter-spacing: 1px; text-transform: uppercase; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 8px; color: #8b949e; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #30363d; }
td { padding: 12px 8px; border-bottom: 1px solid #21262d; font-size: 14px; }
tr:last-child td { border-bottom: none; }
.mono { font-family: 'SF Mono', Monaco, monospace; }
.empty { color: #8b949e; font-size: 14px; padding: 16px 0; text-align: center; }
.more { display: inline-block; padding: 10px 22px; background: #f0b90b; color: #0d1117; border-radius: 8px; font-weight: 700; font-size: 14px; text-decoration: none; }
.more:hover { opacity: 0.85; }
</style>
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
</head>
<body>
<nav class="nav-bar">
<div class="nav-brand">πŸ™ˆ Blind Monkeys</div>
<div class="nav-links">
<a href="/settings/" class="nav-link">βš™οΈ Settings</a>
<a href="/profile/" class="nav-link">πŸ‘€ Profile</a>
<a href="/logout" class="nav-link">πŸšͺ Logout</a>
</div>
</nav>
<div class="page-content">
<div class="breadcrumbs"><a href="/">Home</a><span class="bc-sep">β€Ί</span><span class="bc-current">Analytics</span></div>
<h1>πŸ“ˆ Analytics</h1>
<div class="card">
<h2 style="color:#f0b90b;font-size:20px;font-weight:700;margin:0 0 14px;">Cloudflare β€” Unique Visitors (Last 7 Days)</h2>
<div style="color:#8b949e;font-size:12px;margin:0 0 12px;">⚠️ Counts unique IP + browser combinations β€” includes bots, crawlers, and scanners, not just humans. True human-visitor counts will arrive once Cloudflare Web Analytics is enabled.</div>
<div id="cf-charts" style="color:#8b949e;font-size:14px;">Loading…</div>
</div>
<div class="card">
<h2 style="color:#f0b90b;font-size:20px;font-weight:700;margin:0 0 14px;">Google PageSpeed Scores (Mobile)</h2>
<div style="color:#8b949e;font-size:12px;margin:0 0 12px;">Mobile performance score (0–100) for each site, refreshed every 12 hours. Green is 95 or better; anything below 95 shows in red.</div>
<div id="psi-scores" style="color:#8b949e;font-size:14px;">Loading…</div>
</div>
<div class="card">
<h2 style="color:#f0b90b;font-size:20px;font-weight:700;margin:0 0 14px;">Search Engine &amp; Bot Crawlers (Last 7 Days)</h2>
<div id="crawler-charts" style="color:#8b949e;font-size:14px;">Loading…</div>
</div>
<div class="card">
<h2 style="color:#f0b90b;font-size:20px;font-weight:700;margin:0 0 14px;">Keyword Rankings (DuckDuckGo β€” Daily)</h2>
<div style="color:#8b949e;font-size:12px;margin:0 0 12px;">Where our domains appear for brand and discovery terms. Checked daily; β–²/β–Ό is the 1-day change. DuckDuckGo (Bing-powered) is a free approximation β€” Google blocks datacenter crawlers.</div>
<div id="rank-charts" style="color:#8b949e;font-size:14px;">Loading…</div>
</div>
<div class="card">
<h2 style="color:#f0b90b;font-size:20px;font-weight:700;margin:0 0 14px;">AI Visibility β€” Do LLMs Know Blind Monkeys?</h2>
<div style="color:#8b949e;font-size:12px;margin:0 0 12px;">Each major AI assistant is asked daily what it knows about blindmonkeys.org. β€œKnows us” means its answer mentioned Blind Monkeys.</div>
<div id="ai-visibility" style="color:#8b949e;font-size:14px;">Loading…</div>
</div>
<div class="card">
<h2 style="color:#f0b90b;font-size:20px;font-weight:700;margin:0 0 14px;">AI Visibility β€” Do LLMs Know the Zojax Sites?</h2>
<div style="color:#8b949e;font-size:12px;margin:0 0 12px;">The same assistants are asked daily about the zojax.com family of sites. βœ” = verified with site-specific facts, ⚠ = mentioned, ✘ = no real mention.</div>
<div id="ai-visibility-zojax" style="color:#8b949e;font-size:14px;">Loading…</div>
</div>
</div>
<script src="/css/nav.js?v=16"></script>
<script>
(function () {
Promise.all([
fetch('/api/whoami').then(function (r) { return r.json(); }).catch(function () { return {}; }),
fetch('/api/cf-visitors').then(function (r) { return r.json(); })
]).then(function (results) {
var whoami = results[0] || {};
var isAdmin = whoami.role === 'admin';
var zones = results[1];
var host = document.getElementById('cf-charts');
if (!host) return;
if (!zones || !zones.length) { host.textContent = 'No data available.'; return; }
host.innerHTML = '';
zones.forEach(function (z) {
var days = z.days || [];
var card = document.createElement('div');
card.style.cssText = 'margin-bottom:28px;';
var title = document.createElement('div');
title.style.cssText = 'color:#f0b90b;font-size:14px;font-weight:700;margin:0 0 8px;';
title.textContent = z.zone + (z.zone === 'zojax.com' ? ' (www, ai, wordpress, pardot, salesforce)' : '');
if (isAdmin) {
var cfLink = document.createElement('a');
cfLink.href = 'https://dash.cloudflare.com/7a86249a25c2a428499dedef7d15bde9/' + z.zone;
cfLink.target = '_blank';
cfLink.rel = 'noopener noreferrer';
cfLink.style.cssText = 'color:#f0b90b;text-decoration:none;font-size:11px;font-weight:400;margin-left:10px;';
cfLink.textContent = 'Open in Cloudflare β†’';
title.appendChild(cfLink);
}
card.appendChild(title);
if (!days.length) {
var empty = document.createElement('div');
empty.style.cssText = 'color:#8b949e;font-size:13px;';
empty.textContent = z.error ? ('Error: ' + z.error) : 'No visitor data.';
card.appendChild(empty);
host.appendChild(card);
return;
}
var max = Math.max.apply(null, days.map(function (d) { return d.uniques; })) || 1;
var W = 560, H = 150, bw = W / days.length;
var svg = '<svg viewBox="0 0 ' + W + ' ' + (H + 24) + '" width="100%" style="max-width:560px;display:block;">';
days.forEach(function (d, i) {
var h = Math.round(d.uniques / max * (H - 20));
var x = i * bw + 4, y = H - h;
svg += '<rect x="' + x + '" y="' + y + '" width="' + (bw - 8) + '" height="' + Math.max(h, 2) + '" rx="3" fill="#f0b90b"><title>' + d.date + ': ' + d.uniques + ' visitors \u00b7 ' + d.requests + ' requests</title></rect>';
svg += '<text x="' + (x + (bw - 8) / 2) + '" y="' + (y - 5) + '" text-anchor="middle" font-size="10" fill="#8b949e">' + d.uniques + '</text>';
svg += '<text x="' + (x + (bw - 8) / 2) + '" y="' + (H + 16) + '" text-anchor="middle" font-size="10" fill="#8b949e">' + d.date.slice(5) + '</text>';
});
svg += '</svg>';
var wrap = document.createElement('div');
wrap.innerHTML = svg;
card.appendChild(wrap);
var sum = document.createElement('div');
sum.style.cssText = 'color:#8b949e;font-size:12px;margin-top:6px;';
var tu = (z.total_uniques != null) ? Number(z.total_uniques).toLocaleString() : null;
var tr = (z.total_requests != null) ? Number(z.total_requests).toLocaleString() : null;
sum.textContent = tu ? ('7-day total: ' + tu + ' unique visitors' + (tr ? (' \u00b7 ' + tr + ' requests') : '') + ' (each visitor counted once, not once per day)') : 'Unique visitors per day';
card.appendChild(sum);
host.appendChild(card);
});
}).catch(function () {
var host = document.getElementById('cf-charts');
if (host) host.textContent = 'Could not load visitor data.';
});
})();
(function loadPsi() {
fetch('/api/psi-scores').then(function (r) { return r.json(); }).then(function (d) {
var host = document.getElementById('psi-scores');
if (!host) return;
var scores = d.scores || {};
var urls = Object.keys(scores);
if (d.status === 'refreshing' || !urls.length) {
host.textContent = (d.status === 'refreshing')
? 'Measuring page speed for all sites β€” this takes about two minutes on first load. Revisit or reload shortly…'
: 'No scores yet β€” will appear after the next refresh.';
if (d.status === 'refreshing') setTimeout(loadPsi, 20000);
return;
}
host.innerHTML = '';
var tbl = document.createElement('table');
tbl.style.cssText = 'width:100%;';
tbl.innerHTML = '<tr><th>Site</th><th>Score</th><th>LCP</th><th>TBT</th><th>CLS</th></tr>';
urls.forEach(function (u) {
var s = scores[u];
var tr = document.createElement('tr');
var sc = s.score;
var col = sc >= 95 ? 'pos' : 'neg';
tr.innerHTML = '<td><a href="' + u + '" style="color:#58a6ff;text-decoration:none;">' + u.replace('https://', '').replace(/\/$/, '') + '</a></td>'
+ '<td class="' + col + '" style="font-weight:700;font-size:18px;">' + (sc != null ? sc : 'β€”') + '</td>'
+ '<td class="mut">' + (s.lcp || 'β€”') + '</td>'
+ '<td class="mut">' + (s.tbt || 'β€”') + '</td>'
+ '<td class="mut">' + (s.cls || 'β€”') + '</td>';
tbl.appendChild(tr);
});
host.appendChild(tbl);
if (d.ts) {
var ago = Math.round((Date.now() / 1000 - d.ts) / 3600);
var foot = document.createElement('div');
foot.style.cssText = 'color:#8b949e;font-size:12px;margin-top:6px;';
foot.textContent = 'Last measured ' + (ago < 1 ? 'less than an hour' : ago + 'h') + ' ago (mobile, Google PageSpeed Insights).';
host.appendChild(foot);
}
}).catch(function () {
var host = document.getElementById('psi-scores');
if (host) host.textContent = 'Could not load PageSpeed scores.';
});
})();
(function () {
fetch('/api/ai-visibility').then(function (r) { return r.json(); }).then(function (data) {
var host = document.getElementById('ai-visibility');
if (!host) return;
var rows = (data && data.summary) || [];
if (!rows.length) { host.textContent = 'No data yet β€” the visibility scan will run on its next cron cycle.'; return; }
host.innerHTML = '';
var tbl = document.createElement('table');
tbl.style.cssText = 'width:100%;';
tbl.innerHTML = '<tr><th>AI Engine</th><th>Knows Us</th><th>Last Checked</th><th>First Mentioned</th><th>What It Said</th></tr>';
rows.forEach(function (e) {
var tr = document.createElement('tr');
var knows;
if (e.verified === true) knows = '<span class="pos">βœ” Yes</span>';
else if (e.mentioned === true) knows = '<span style="color:#f0b90b;">⚠ Mentioned</span>';
else if (e.mentioned === false) knows = '<span class="neg">✘ No</span>';
else knows = e.configured ? '<span class="mut">error</span>' : '<span class="mut">not configured</span>';
var quote = e.quote
? '<span style="color:#c9d1d9;">β€œ' + e.quote.replace(/&/g, '&amp;').replace(/</g, '&lt;').slice(0, 240) + '…”</span>'
: (e.error ? '<span class="mut">' + e.error.slice(0, 80) + '</span>' : '<span class="mut">β€”</span>');
var checked = e.checked_at ? e.checked_at.slice(0, 10) : 'β€”';
var first = e.first_seen ? e.first_seen.slice(0, 10) : 'β€”';
tr.innerHTML = '<td>' + e.engine_name + '</td><td>' + knows + '</td><td style="color:#8b949e;">' + checked + '</td><td style="color:#8b949e;">' + first + '</td><td style="font-size:13px;">' + quote + '</td>';
tbl.appendChild(tr);
});
host.appendChild(tbl);
}).catch(function () {
var host = document.getElementById('ai-visibility');
if (host) host.textContent = 'Could not load AI visibility data.';
});
})();
(function () {
fetch('/api/ai-visibility').then(function (r) { return r.json(); }).then(function (data) {
var host = document.getElementById('ai-visibility-zojax');
if (!host) return;
var rows = (data && data.summary) || [];
var withSites = rows.filter(function (e) { return e.sites && (e.sites.zojax || e.sites.django_zojax || e.sites.zojax_family || e.sites.flaskfactory); });
if (!withSites.length) { host.textContent = 'No Zojax-site probe data yet β€” the next visibility scan will collect it.'; return; }
host.innerHTML = '';
var tbl = document.createElement('table');
tbl.style.cssText = 'width:100%;';
tbl.innerHTML = '<tr><th>AI Engine</th><th>zojax.com</th><th>django.zojax.com</th><th>ai / wp / sf / pardot subdomains</th><th>flaskfactory.ai</th></tr>';
function cell(st) {
if (!st || st.mentioned === null || st.mentioned === undefined) return '<span class="mut">β€”</span>';
if (st.verified) return '<span class="pos">βœ” Yes</span>';
if (st.mentioned) return '<span style="color:#f0b90b;">⚠ Mentioned</span>';
return '<span class="neg">✘ No</span>';
}
rows.forEach(function (e) {
var tr = document.createElement('tr');
var s = e.sites || {};
tr.innerHTML = '<td>' + e.engine_name + '</td><td>' + cell(s.zojax) + '</td><td>' + cell(s.django_zojax) + '</td><td>' + cell(s.zojax_family) + '</td><td>' + cell(s.flaskfactory) + '</td>';
tbl.appendChild(tr);
});
host.appendChild(tbl);
}).catch(function () {
var host = document.getElementById('ai-visibility-zojax');
if (host) host.textContent = 'Could not load AI visibility data.';
});
})();
(function () {
fetch('/api/crawler-activity').then(function (r) { return r.json(); }).then(function (zones) {
var host = document.getElementById('crawler-charts');
if (!host) return;
if (!zones || !zones.length) { host.textContent = 'No data available.'; return; }
host.innerHTML = '';
zones.forEach(function (z) {
var card = document.createElement('div');
card.style.cssText = 'margin-bottom:28px;';
var title = document.createElement('div');
title.style.cssText = 'color:#f0b90b;font-size:14px;font-weight:700;margin:0 0 8px;';
title.textContent = z.zone;
card.appendChild(title);
if (!z.bots || !z.bots.length) {
var empty = document.createElement('div');
empty.style.cssText = 'color:#8b949e;font-size:13px;';
empty.textContent = z.error ? ('Error: ' + z.error) : 'No crawler visits detected in the last 7 days.';
card.appendChild(empty);
host.appendChild(card);
return;
}
var tbl = document.createElement('table');
tbl.style.cssText = 'width:100%;';
tbl.innerHTML = '<tr><th>Crawler</th><th style="text-align:right;">7-Day Hits</th><th>Daily Activity</th><th>Last Seen</th></tr>';
z.bots.forEach(function (b) {
var max = Math.max.apply(null, b.days) || 1;
var bars = '';
b.days.forEach(function (v, i) {
var h = Math.max(Math.round(v / max * 22), v ? 3 : 1);
bars += '<rect x="' + (i * 16) + '" y="' + (26 - h) + '" width="12" height="' + h + '" rx="2" fill="' + (i === 6 ? '#f0b90b' : '#8b949e') + '"><title>' + v + ' requests</title></rect>';
});
var lastSeen = -1;
b.days.forEach(function (v, i) { if (v > 0) lastSeen = i; });
var lastTxt = lastSeen === 6 ? 'Today' : (lastSeen >= 0 ? (6 - lastSeen) + ' days ago' : '\u2014');
var tr = document.createElement('tr');
tr.innerHTML = '<td>' + b.name + '</td>' +
'<td style="text-align:right;" class="mono">' + b.total.toLocaleString() + '</td>' +
'<td><svg viewBox="0 0 112 26" width="112" height="26">' + bars + '</svg></td>' +
'<td style="color:#8b949e;">' + lastTxt + '</td>';
tbl.appendChild(tr);
});
card.appendChild(tbl);
host.appendChild(card);
});
}).catch(function () {
var host = document.getElementById('crawler-charts');
if (host) host.textContent = 'Could not load crawler data.';
});
})();
(function () {
fetch('/api/rank-positions').then(function (r) { return r.json(); }).then(function (data) {
var host = document.getElementById('rank-charts');
if (!host) return;
var kws = (data && data.keywords) || [];
if (!kws.length) { host.textContent = 'No rank data yet β€” the next daily check will collect it.'; return; }
var tbl = document.createElement('table');
tbl.style.cssText = 'width:100%;';
tbl.innerHTML = '<tr><th>Keyword</th><th>Domain</th><th style="text-align:right;">Position</th><th style="text-align:right;">1-Day</th></tr>';
kws.forEach(function (k) {
(k.rows || []).forEach(function (row) {
var pos = row.position ? ('#' + row.position) : 'β€”';
var chg = '';
if (typeof row.change === 'number') {
if (row.change > 0) chg = '<span style="color:#3fb950;">β–²' + row.change + '</span>';
else if (row.change < 0) chg = '<span style="color:#f85149;">β–Ό' + (-row.change) + '</span>';
else chg = '=';
}
var tr = document.createElement('tr');
tr.innerHTML = '<td>' + k.keyword + '</td><td>' + row.domain + '</td><td style="text-align:right;">' + pos + '</td><td style="text-align:right;">' + chg + '</td>';
tbl.appendChild(tr);
});
});
host.innerHTML = '';
host.appendChild(tbl);
}).catch(function () {
var host = document.getElementById('rank-charts');
if (host) host.textContent = 'Could not load rank data.';
});
})();
</script>
</body>
</html>