// Server errors (5xx responses) in the last 24 hours, for the Hub heartbeat. In memory per // process: a restart starts again from zero, which is fine for spotting a spike. const WINDOW_MS = 24 * 60 * 60 * 1000; const MAX_KEPT = 10000; let times = []; function recordError(now = Date.now()) { times.push(now); if (times.length > MAX_KEPT) times = times.slice(-MAX_KEPT); } function countLast24h(now = Date.now()) { times = times.filter(t => now - t < WINDOW_MS); return times.length; } module.exports = { recordError, countLast24h };