Wait for telemetryReporter to complete dispose before deactivating extensions

This commit is contained in:
Ramya Achutha Rao
2018-02-06 15:49:25 -08:00
parent 153ffd21e6
commit 3b075ee291
3 changed files with 23 additions and 10 deletions

View File

@@ -55,13 +55,14 @@ interface JSONSchemaSettings {
schema?: any;
}
let telemetryReporter: TelemetryReporter;
export function activate(context: ExtensionContext) {
let toDispose = context.subscriptions;
let packageInfo = getPackageInfo(context);
let telemetryReporter: TelemetryReporter = packageInfo && new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
toDispose.push(telemetryReporter);
telemetryReporter = packageInfo && new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
// The server is implemented in node
let serverModule = context.asAbsolutePath(path.join('server', 'out', 'jsonServerMain.js'));
@@ -169,6 +170,10 @@ export function activate(context: ExtensionContext) {
languages.setLanguageConfiguration('jsonc', languageConfiguration);
}
export function deactivate(): Promise<any> {
return telemetryReporter ? telemetryReporter.dispose() : Promise.resolve(null);
}
function getSchemaAssociation(context: ExtensionContext): ISchemaAssociations {
let associations: ISchemaAssociations = {};
extensions.all.forEach(extension => {