Spaces:
Sleeping
Sleeping
File size: 3,770 Bytes
b6ba491 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Mindstack Dashboard</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body { font-family: sans-serif; background: #0f0f1a; color: #e0e0e0; margin: 0; padding: 20px; }
h1 { color: #a78bfa; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin: 24px 0; }
.card { background: #1e1e2e; border-radius: 12px; padding: 20px; text-align: center; }
.card .val { font-size: 2rem; font-weight: bold; color: #a78bfa; }
.card .lbl { font-size: 0.85rem; color: #888; margin-top: 4px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
canvas { background: #1e1e2e; border-radius: 12px; padding: 16px; }
@media(max-width:600px){ .charts { grid-template-columns: 1fr; } }
</style>
</head>
<body>
<h1>π Mindstack Tracker</h1>
<div class="grid">
<div class="card"><div class="val" id="sessions">β</div><div class="lbl">Sessions</div></div>
<div class="card"><div class="val" id="events">β</div><div class="lbl">Events</div></div>
<div class="card"><div class="val" id="taux_achat">β</div><div class="lbl">Taux achat</div></div>
<div class="card"><div class="val" id="revenu">β</div><div class="lbl">Revenu total</div></div>
<div class="card"><div class="val" id="scroll">β</div><div class="lbl">Scroll moyen</div></div>
<div class="card"><div class="val" id="temps">β</div><div class="lbl">Temps moyen</div></div>
</div>
<div class="charts">
<canvas id="abChart"></canvas>
<canvas id="srcChart"></canvas>
<canvas id="hourlyChart" style="grid-column: span 2"></canvas>
</div>
<script>
const COLORS = ["#a78bfa","#34d399","#f472b6","#60a5fa","#fbbf24"];
async function load() {
const r = await fetch("/stats");
const d = await r.json();
document.getElementById("sessions").textContent = d.total_sessions;
document.getElementById("events").textContent = d.total_events;
document.getElementById("taux_achat").textContent = d.taux_achat + "%";
document.getElementById("revenu").textContent = d.revenu_total + "β¬";
document.getElementById("scroll").textContent = d.scroll_moyen + "%";
document.getElementById("temps").textContent = d.temps_moyen_s + "s";
// A/B Chart
new Chart(document.getElementById("abChart"), {
type: "bar",
data: {
labels: Object.keys(d.ab_taux_conv),
datasets: [{
label: "Taux conversion % par variant",
data: Object.values(d.ab_taux_conv),
backgroundColor: COLORS
}]
},
options: { plugins: { legend: { labels: { color: "#e0e0e0" } } }, scales: { x: { ticks: { color: "#e0e0e0" } }, y: { ticks: { color: "#e0e0e0" } } } }
});
// Source Chart
new Chart(document.getElementById("srcChart"), {
type: "doughnut",
data: {
labels: Object.keys(d.src_distribution),
datasets: [{ data: Object.values(d.src_distribution), backgroundColor: COLORS }]
},
options: { plugins: { legend: { labels: { color: "#e0e0e0" } }, title: { display: true, text: "Sources", color: "#e0e0e0" } } }
});
// Hourly Chart
new Chart(document.getElementById("hourlyChart"), {
type: "line",
data: {
labels: d.hourly.map(h => h.h),
datasets: [{
label: "Events / heure",
data: d.hourly.map(h => h.n),
borderColor: "#a78bfa",
backgroundColor: "rgba(167,139,250,0.1)",
fill: true,
tension: 0.3
}]
},
options: { plugins: { legend: { labels: { color: "#e0e0e0" } } }, scales: { x: { ticks: { color: "#888", maxTicksLimit: 12 } }, y: { ticks: { color: "#e0e0e0" } } } }
});
}
load();
setInterval(load, 30000); // refresh toutes les 30s
</script>
</body>
</html>
|