diff options
Diffstat (limited to 'src/vs/platform/extensionManagement/common/abstractExtensionManagementService.ts')
-rw-r--r-- | src/vs/platform/extensionManagement/common/abstractExtensionManagementService.ts | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/vs/platform/extensionManagement/common/abstractExtensionManagementService.ts b/src/vs/platform/extensionManagement/common/abstractExtensionManagementService.ts index 574a72fa436..81fa42981c2 100644 --- a/src/vs/platform/extensionManagement/common/abstractExtensionManagementService.ts +++ b/src/vs/platform/extensionManagement/common/abstractExtensionManagementService.ts @@ -6,7 +6,7 @@ import { isNonEmptyArray } from 'vs/base/common/arrays'; import { Barrier, CancelablePromise, createCancelablePromise } from 'vs/base/common/async'; import { CancellationToken } from 'vs/base/common/cancellation'; -import { canceled, getErrorMessage } from 'vs/base/common/errors'; +import { CancellationError, getErrorMessage } from 'vs/base/common/errors'; import { Emitter, Event } from 'vs/base/common/event'; import { Disposable, toDisposable } from 'vs/base/common/lifecycle'; import { isWeb } from 'vs/base/common/platform'; @@ -91,7 +91,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl const compatible = await this.checkAndGetCompatibleVersion(extension, !options.installGivenVersion, !!options.installPreReleaseVersion); return await this.installExtension(compatible.manifest, compatible.extension, options); } catch (error) { - reportTelemetry(this.telemetryService, 'extensionGallery:install', getGalleryExtensionTelemetryData(extension), undefined, error); + reportTelemetry(this.telemetryService, 'extensionGallery:install', { extensionData: getGalleryExtensionTelemetryData(extension), error }); this.logService.error(`Failed to install extension.`, extension.identifier.id); this.logService.error(error); throw toExtensionManagementError(error); @@ -216,7 +216,12 @@ export abstract class AbstractExtensionManagementService extends Disposable impl const local = await task.run(); await this.joinAllSettled(this.participants.map(participant => participant.postInstall(local, task.source, options, CancellationToken.None))); if (!URI.isUri(task.source)) { - reportTelemetry(this.telemetryService, task.operation === InstallOperation.Update ? 'extensionGallery:update' : 'extensionGallery:install', getGalleryExtensionTelemetryData(task.source), new Date().getTime() - startTime, undefined); + const isUpdate = task.operation === InstallOperation.Update; + reportTelemetry(this.telemetryService, isUpdate ? 'extensionGallery:update' : 'extensionGallery:install', { + extensionData: getGalleryExtensionTelemetryData(task.source), + duration: new Date().getTime() - startTime, + durationSinceUpdate: isUpdate ? undefined : new Date().getTime() - task.source.lastUpdated + }); // In web, report extension install statistics explicitly. In Desktop, statistics are automatically updated while downloading the VSIX. if (isWeb && task.operation !== InstallOperation.Update) { try { @@ -227,7 +232,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl installResults.push({ local, identifier: task.identifier, operation: task.operation, source: task.source }); } catch (error) { if (!URI.isUri(task.source)) { - reportTelemetry(this.telemetryService, task.operation === InstallOperation.Update ? 'extensionGallery:update' : 'extensionGallery:install', getGalleryExtensionTelemetryData(task.source), new Date().getTime() - startTime, error); + reportTelemetry(this.telemetryService, task.operation === InstallOperation.Update ? 'extensionGallery:update' : 'extensionGallery:install', { extensionData: getGalleryExtensionTelemetryData(task.source), duration: new Date().getTime() - startTime, error }); } this.logService.error('Error while installing the extension:', task.identifier.id); throw error; @@ -433,7 +438,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl } else { this.logService.info('Successfully uninstalled extension:', extension.identifier.id); } - reportTelemetry(this.telemetryService, 'extensionGallery:uninstall', getLocalExtensionTelemetryData(extension), undefined, error); + reportTelemetry(this.telemetryService, 'extensionGallery:uninstall', { extensionData: getLocalExtensionTelemetryData(extension), error }); this._onDidUninstallExtension.fire({ identifier: extension.identifier, error: error?.code }); }; @@ -611,12 +616,13 @@ function toExtensionManagementError(error: Error): ExtensionManagementError { return e; } -export function reportTelemetry(telemetryService: ITelemetryService, eventName: string, extensionData: any, duration?: number, error?: Error): void { +export function reportTelemetry(telemetryService: ITelemetryService, eventName: string, { extensionData, duration, error, durationSinceUpdate }: { extensionData: any; duration?: number; durationSinceUpdate?: number; error?: Error }): void { const errorcode = error ? error instanceof ExtensionManagementError ? error.code : ExtensionManagementErrorCode.Internal : undefined; /* __GDPR__ "extensionGallery:install" : { "success": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }, "duration" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }, + "durationSinceUpdate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, "errorcode": { "classification": "CallstackOrException", "purpose": "PerformanceAndHealth" }, "recommendationReason": { "retiredFromVersion": "1.23.0", "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, "${include}": [ @@ -644,7 +650,7 @@ export function reportTelemetry(telemetryService: ITelemetryService, eventName: ] } */ - telemetryService.publicLogError(eventName, { ...extensionData, success: !error, duration, errorcode }); + telemetryService.publicLog(eventName, { ...extensionData, success: !error, duration, errorcode, durationSinceUpdate }); } export abstract class AbstractExtensionTask<T> { @@ -671,7 +677,7 @@ export abstract class AbstractExtensionTask<T> { return new Promise((c, e) => { const disposable = token.onCancellationRequested(() => { disposable.dispose(); - e(canceled()); + e(new CancellationError()); }); }); }); |