()
| 81 | } |
| 82 | |
| 83 | private async flush() { |
| 84 | if (this.buffer.length === 0) return; |
| 85 | const events = [...this.buffer]; |
| 86 | this.buffer = []; |
| 87 | |
| 88 | try { |
| 89 | // POST to console backend error endpoint |
| 90 | await fetch("/api/errors", { |
| 91 | method: "POST", |
| 92 | headers: { "Content-Type": "application/json" }, |
| 93 | body: JSON.stringify({ events }), |
| 94 | }); |
| 95 | } catch { |
| 96 | // If reporting fails, put events back (up to a limit) |
| 97 | if (this.buffer.length < 100) { |
| 98 | this.buffer.unshift(...events); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | startPeriodicFlush(intervalMs = 30_000) { |
| 104 | this.flushInterval = window.setInterval(() => this.flush(), intervalMs); |
no outgoing calls
no test coverage detected