Skip to content

Commit 125baf6

Browse files
committed
Fix telemetry recording bug
When someone disables and then re-enables the global telemetry setting, the telemetry recorder needs to be recreated in order to allow it to respond to events again. Also, write the telemetry log item in the same telemetry processor as is used to remove unused fields. This ensures there is no race condition on the order of telemetry processors being run. We always log after fields are removed.
1 parent bbe3b6d commit 125baf6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

extensions/ql-vscode/src/telemetry.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ export class TelemetryListener extends ConfigListener {
6767
* @param e the configuration change event
6868
*/
6969
async handleDidChangeConfiguration(e: ConfigurationChangeEvent): Promise<void> {
70-
if (e.affectsConfiguration('codeQL.telemetry.enableTelemetry')) {
70+
if (
71+
e.affectsConfiguration('codeQL.telemetry.enableTelemetry') ||
72+
e.affectsConfiguration('telemetry.enableTelemetry')
73+
) {
7174
await this.initialize();
7275
}
7376

@@ -115,11 +118,6 @@ export class TelemetryListener extends ConfigListener {
115118
baseDataPropertiesToRemove.forEach(prop => delete baseDataProperties[prop]);
116119
}
117120

118-
return true;
119-
});
120-
121-
// add a telemetry processor to log if requested
122-
client.addTelemetryProcessor((envelope) => {
123121
if (LOG_TELEMETRY.getValue<boolean>()) {
124122
logger.log(`Telemetry: ${JSON.stringify(envelope)}`);
125123
}

0 commit comments

Comments
 (0)