* Resolution order (first match wins) — keep in sync with TELEMETRY.md: * DO_NOT_TRACK=1 > CODEGRAPH_TELEMETRY=0|1 > stored config > default on.
()
| 233 | * DO_NOT_TRACK=1 > CODEGRAPH_TELEMETRY=0|1 > stored config > default on. |
| 234 | */ |
| 235 | getStatus(): TelemetryStatus { |
| 236 | const config = this.readConfig(); |
| 237 | const machineId = config?.machine_id ?? null; |
| 238 | const dnt = this.env.DO_NOT_TRACK; |
| 239 | if (dnt !== undefined && dnt !== '' && dnt !== '0' && dnt.toLowerCase() !== 'false') { |
| 240 | this.clearPending(); |
| 241 | return { enabled: false, decidedBy: 'DO_NOT_TRACK', machineId, configPath: this.configPath }; |
| 242 | } |
| 243 | const forced = this.env.CODEGRAPH_TELEMETRY; |
| 244 | if (forced !== undefined && forced !== '') { |
| 245 | const on = forced !== '0' && forced.toLowerCase() !== 'false'; |
| 246 | if (!on) this.clearPending(); |
| 247 | return { enabled: on, decidedBy: 'CODEGRAPH_TELEMETRY', machineId, configPath: this.configPath }; |
| 248 | } |
| 249 | if (config) { |
| 250 | if (!config.enabled) this.clearPending(); |
| 251 | return { enabled: config.enabled, decidedBy: 'config', machineId, configPath: this.configPath }; |
| 252 | } |
| 253 | return { enabled: true, decidedBy: 'default', machineId, configPath: this.configPath }; |
| 254 | } |
| 255 | |
| 256 | isEnabled(): boolean { |
| 257 | return this.getStatus().enabled; |
no test coverage detected