Recheck shared consent, then increment in memory; no network or writes.
(kind: UsageKind, name: string, ok: boolean, client?: ClientInfo)
| 293 | |
| 294 | /** Recheck shared consent, then increment in memory; no network or writes. */ |
| 295 | recordUsage(kind: UsageKind, name: string, ok: boolean, client?: ClientInfo): void { |
| 296 | if (!this.isEnabled()) return; |
| 297 | const fresh: CountLine = { v: SCHEMA_VERSION, d: this.utcDay(), k: kind, n: name.slice(0, 64), c: 1, e: ok ? 0 : 1 }; |
| 298 | const cn = client?.name?.slice(0, 64); |
| 299 | const cv = client?.version?.slice(0, 32); |
| 300 | if (cn) fresh.cn = cn; |
| 301 | if (cv) fresh.cv = cv; |
| 302 | const key = countKey(fresh); |
| 303 | const line = this.counts.get(key); |
| 304 | if (line) { |
| 305 | line.c += 1; |
| 306 | if (!ok) line.e += 1; |
| 307 | } else { |
| 308 | this.counts.set(key, fresh); |
| 309 | } |
| 310 | this.ensureExitHook(); |
| 311 | } |
| 312 | |
| 313 | /** install / index / uninstall — buffered like everything else. */ |
| 314 | recordLifecycle(event: LifecycleEvent, props: Record<string, unknown>): void { |
no test coverage detected