MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / recordUsage

Method recordUsage

src/telemetry/index.ts:295–311  ·  view source on GitHub ↗

Recheck shared consent, then increment in memory; no network or writes.

(kind: UsageKind, name: string, ok: boolean, client?: ClientInfo)

Source from the content-addressed store, hash-verified

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 {

Callers 6

serveLocallyFunction · 0.80
handleToolsCallMethod · 0.80
mainFunction · 0.80
gateFunction · 0.80
telemetry.test.tsFile · 0.80

Calls 6

isEnabledMethod · 0.95
utcDayMethod · 0.95
ensureExitHookMethod · 0.95
countKeyFunction · 0.85
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected