(payload: TelemetryEvent)
| 63 | |
| 64 | /** Fire-and-forget log. Never throws. */ |
| 65 | export function logTelemetry(payload: TelemetryEvent): void { |
| 66 | if (isDisabled()) return; |
| 67 | const enriched = { ...payload, ts: new Date().toISOString() }; |
| 68 | ensureDir() |
| 69 | .then(() => fs.appendFile(telemetryFile(), JSON.stringify(enriched) + '\n', 'utf8')) |
| 70 | .catch(() => { |
| 71 | // Telemetry must never crash the caller. If the disk is full or perms |
| 72 | // are wrong, swallow silently — there's nothing useful to do here. |
| 73 | }); |
| 74 | } |
| 75 | |
| 76 | /** Test-only: reset cached state. */ |
| 77 | export function _resetTelemetryCache(): void { |
no test coverage detected