* Resolution order (first match wins) — keep in sync with TELEMETRY.md: * DO_NOT_TRACK=1 > CODEGRAPH_TELEMETRY=0|1 > stored config > default on.
()
| 185 | * DO_NOT_TRACK=1 > CODEGRAPH_TELEMETRY=0|1 > stored config > default on. |
| 186 | */ |
| 187 | getStatus(): TelemetryStatus { |
| 188 | const config = this.readConfig(); |
| 189 | const machineId = config?.machine_id ?? null; |
| 190 | const dnt = this.env.DO_NOT_TRACK; |
| 191 | if (dnt !== undefined && dnt !== '' && dnt !== '0' && dnt.toLowerCase() !== 'false') { |
| 192 | return { enabled: false, decidedBy: 'DO_NOT_TRACK', machineId, configPath: this.configPath }; |
| 193 | } |
| 194 | const forced = this.env.CODEGRAPH_TELEMETRY; |
| 195 | if (forced !== undefined && forced !== '') { |
| 196 | const on = forced !== '0' && forced.toLowerCase() !== 'false'; |
| 197 | return { enabled: on, decidedBy: 'CODEGRAPH_TELEMETRY', machineId, configPath: this.configPath }; |
| 198 | } |
| 199 | if (config) { |
| 200 | return { enabled: config.enabled, decidedBy: 'config', machineId, configPath: this.configPath }; |
| 201 | } |
| 202 | return { enabled: true, decidedBy: 'default', machineId, configPath: this.configPath }; |
| 203 | } |
| 204 | |
| 205 | isEnabled(): boolean { |
| 206 | return this.getStatus().enabled; |
no test coverage detected