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

Method setEnabled

src/telemetry/index.ts:265–285  ·  view source on GitHub ↗

* Persist an explicit user choice (installer toggle or `codegraph * telemetry on|off`). Turning telemetry off also deletes any buffered, * unsent data — off means off.

(enabled: boolean, source: 'installer' | 'cli')

Source from the content-addressed store, hash-verified

263 * unsent data — off means off.
264 */
265 setEnabled(enabled: boolean, source: 'installer' | 'cli'): void {
266 const existing = this.readConfig();
267 this.writeConfig({
268 enabled,
269 machine_id: enabled ? (existing?.enabled && existing.machine_id ? existing.machine_id : randomUUID()) : null,
270 consent_source: source,
271 first_run_notice_shown: true,
272 updated_at: this.now().toISOString(),
273 });
274 if (!enabled) {
275 this.clearPending();
276 try {
277 // Claimed data must not reappear on a later opt-in/crash recovery.
278 for (const name of fs.readdirSync(this.dir)) {
279 if (name === 'telemetry-queue.jsonl' || /^telemetry-queue\.sending\.\d+\.jsonl$/.test(name)) {
280 try { fs.rmSync(path.join(this.dir, name), { force: true }); } catch { /* fail silent */ }
281 }
282 }
283 } catch { /* fail silent */ }
284 }
285 }
286
287 /** True once any consent decision (or the first-run notice) is on disk. */
288 hasStoredChoice(): boolean {

Callers 4

runInstallerWithOptionsFunction · 0.80
mainFunction · 0.80
telemetry.test.tsFile · 0.80

Calls 5

readConfigMethod · 0.95
writeConfigMethod · 0.95
clearPendingMethod · 0.95
randomUUIDFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected