MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / shouldReport

Function shouldReport

src/services/log-report.ts:14–26  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

12const DEDUP_WINDOW_MS = 10_000
13
14function shouldReport(key: string): boolean {
15 const now = Date.now()
16 const last = recent.get(key)
17 if (last !== undefined && now - last < DEDUP_WINDOW_MS) return false
18 recent.set(key, now)
19 // Bound the map so it can't grow without limit.
20 if (recent.size > 100) {
21 for (const [k, t] of recent) {
22 if (now - t >= DEDUP_WINDOW_MS) recent.delete(k)
23 }
24 }
25 return true
26}
27
28export function reportError(message: string, stack?: string): void {
29 if (!message) return

Callers 1

reportErrorFunction · 0.85

Calls 4

setMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65
nowMethod · 0.45

Tested by

no test coverage detected