sending the diagnostics on handle exit

This commit is contained in:
Aiday Marlen Kyzy
2023-08-17 14:35:27 +02:00
parent 614bfb3d33
commit 0d4db5ffc4
2 changed files with 37 additions and 19 deletions

View File

@@ -149,12 +149,40 @@ class DiagnosticSettings {
}
}
class DiagnosticsTelemetryManager {
private _diagnosticCodes: number[] = [];
constructor(private readonly _telemetryReporter: TelemetryReporter) { }
public addDiagnosticCodes(codes: number[]) {
this._diagnosticCodes.push(...codes);
this._diagnosticCodes.sort();
}
public sendDiagnosticsCodesTelemetry(): void {
/* __GDPR__
"typescript.diagnostics" : {
"owner": "@aiday-mar",
"diagnosticCodes" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
"${include}": [
"${TypeScriptCommonProperties}"
]
}
*/
this._telemetryReporter.logTelemetry('typescript.diagnostics', {
diagnoticCodes: this._diagnosticCodes.join(', ')
});
this._diagnosticCodes = [];
}
}
export class DiagnosticsManager extends Disposable {
private readonly _diagnostics: ResourceMap<FileDiagnostics>;
private readonly _settings = new DiagnosticSettings();
private readonly _currentDiagnostics: vscode.DiagnosticCollection;
private readonly _pendingUpdates: ResourceMap<any>;
private readonly _diagnosticsTelemetryManager: DiagnosticsTelemetryManager;
private readonly _updateDelay = 50;
constructor(
@@ -167,6 +195,7 @@ export class DiagnosticsManager extends Disposable {
this._pendingUpdates = new ResourceMap<any>(undefined, { onCaseInsensitiveFileSystem });
this._currentDiagnostics = this._register(vscode.languages.createDiagnosticCollection(owner));
this._diagnosticsTelemetryManager = new DiagnosticsTelemetryManager(telemetryReporter);
this._register(vscode.workspace.onDidOpenTextDocument((document) => {
const diagnostics = this.getDiagnostics(document.uri);
const diagnoticCodes = diagnostics.reduce(function (result: number[], d: vscode.Diagnostic) {
@@ -177,22 +206,15 @@ export class DiagnosticsManager extends Disposable {
result.push(Number(code.value));
}
return result;
}, []).sort();
/* __GDPR__
"typescript.diagnostics" : {
"owner": "@aiday-mar",
"diagnosticCodes" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
"${include}": [
"${TypeScriptCommonProperties}"
]
}
*/
telemetryReporter.logTelemetry('typescript.diagnostics', {
diagnoticCodes: diagnoticCodes.join(', ')
});
}, []);
this._diagnosticsTelemetryManager.addDiagnosticCodes(diagnoticCodes);
}));
}
public sendDiagnosticsCodesTelemetry(): void {
this._diagnosticsTelemetryManager.sendDiagnosticsCodesTelemetry();
}
public override dispose() {
super.dispose();

View File

@@ -456,7 +456,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
*/
this.logTelemetry('tsserver.exitWithCode', { code: code ?? undefined, signal: signal ?? undefined });
this.diagnosticsManager.sendDiagnosticsCodesTelemetry();
if (this.token !== mytoken) {
// this is coming from an old process
@@ -468,9 +468,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
this.serviceExited(!this.isRestarting);
this.isRestarting = false;
// TODO: on handle exit, we need to send the typescript errors that we have accumulated
console.log('on handle exit');
});
handle.onEvent(event => this.dispatchEvent(event));
@@ -582,7 +579,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
};
}
// TODO: service exited will close the client service, is this the one that we need to monitor?
private serviceExited(restart: boolean): void {
this.loadingIndicator.reset();