aboutsummaryrefslogtreecommitdiff
path: root/api/debug/dashboard.php
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-10-23 14:39:30 +0200
committerAgando <roduccomm@gmail.com>2026-10-23 14:39:30 +0200
commit97f55bf200c74a1b8ca0068ff70cbfeda77916cf (patch)
treef27fdfda0031d716bdc3717301eb2e250dbda9f8 /api/debug/dashboard.php
parent3bbaa9df177fcab2ee9dd04857d16d92c4812780 (diff)
fix(newos4-debug): idempotent ingest, admin-gated reads, honest counts (v4.6.52-53)
Root cause: _syncToBackend() re-sent the whole error DB with cumulative counts every 300s, and ingest.php did count += client count per batch. 33 real signatures had accumulated 116,696 "occurrences" (one self-referential row alone: 46,133). Backend - ingest.php: per-(session,hash) synced map, adds only the delta, resets prev when the client count shrank (cleared localStorage), caps delta at 5000, bounds synced at 500 hashes and sessions at 200, normalises timestamps to +00:00, 30-day retention that also purges dropped hashes from every synced map, returns `accepted` (entries) next to `ingested` (occurrences). - stats.php/dashboard.php: total_errors = occurrences, unique_errors = signatures, last-ingest card. The two numbers were inconsistent by ~3,500x. - health.php: reports self_referential count and status=degraded instead of ok. - Pruned live data: 33 -> 23 records, 116,696 -> 58,759 occurrences, max cluster 110,226 -> 52,387 (archive kept in data/debug/archive/). - nginx: stats/errors/clusters/dashboard/agent-replies now behind auth_request /_wx11_admin_auth (302 without a session); ingest/report/health stay public for telemetry. Verified: reads 302, ingest 200, report 400. Client - module-debug-supervisor.js: sends only hashes whose count changed (persisted webx11_debug_synced), records synced counts only after success, stops auto-filing aborts/timeouts and debug-pipeline requests as bug reports (2 of the last 5 reports were "user aborted a request"). Verified with a scratch php -S copy: same batch POSTed 3x -> count stays 5; count=99999 -> clamped to 1000; retention dropped 10 legacy rows.
Diffstat (limited to 'api/debug/dashboard.php')
-rw-r--r--api/debug/dashboard.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/api/debug/dashboard.php b/api/debug/dashboard.php
index c235ec0..74ba3af 100644
--- a/api/debug/dashboard.php
+++ b/api/debug/dashboard.php
@@ -5,7 +5,9 @@ header('Content-Type: text/html; charset=utf-8');
$errors = load_json(ERRORS_FILE);
$sessions = load_json(SESSIONS_FILE);
-$totalErrors = count($errors);
+$uniqueErrors = count($errors);
+$totalOccurrences = array_sum(array_map(fn($e) => (int)($e['count'] ?? 1), $errors));
+$lastIngest = $errors ? max(array_column($errors, 'ingested_at')) : null;
$totalSessions = count($sessions);
$byType = [];
$bySeverity = [];
@@ -91,8 +93,10 @@ if ($lastSync): ?>
<div class="grid">
<div class="card">
- <h3>Total Errors</h3>
- <div class="stat-value <?= $totalErrors > 0 ? 'error' : 'ok' ?>"><?= $totalErrors ?></div>
+ <h3>Total Occurrences</h3>
+ <div class="stat-value <?= $totalOccurrences > 0 ? 'error' : 'ok' ?>"><?= $totalOccurrences ?></div>
+ <div class="muted" style="font-size:.75em;color:var(--muted)"><?= $uniqueErrors ?> unique signatures</div>
+ <div class="muted" style="font-size:.75em;color:var(--muted)">last ingest: <?= $lastIngest ? htmlspecialchars($lastIngest) : '—' ?></div>
</div>
<div class="card">
<h3>Sessions</h3>