From 8aa430710aae642e958fa3bb8bc551b5f5742df6 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 18 Aug 2016 15:24:09 +0200 Subject: [PATCH] add vsix download telemetry timer data related to #10180 --- .../common/extensionTelemetry.ts | 30 +++++++++++++++++++ .../node/extensionGalleryService.ts | 4 +++ .../extensionsWorkbenchService.ts | 19 ++---------- 3 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 src/vs/platform/extensionManagement/common/extensionTelemetry.ts diff --git a/src/vs/platform/extensionManagement/common/extensionTelemetry.ts b/src/vs/platform/extensionManagement/common/extensionTelemetry.ts new file mode 100644 index 00000000000..b112fa7d75f --- /dev/null +++ b/src/vs/platform/extensionManagement/common/extensionTelemetry.ts @@ -0,0 +1,30 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import { ILocalExtension, IGalleryExtension } from 'vs/platform/extensionManagement/common/extensionManagement'; + +export function getLocalExtensionTelemetryData(extension: ILocalExtension): any { + return { + id: `${ extension.manifest.publisher }.${ extension.manifest.name }`, + name: extension.manifest.name, + galleryId: extension.metadata ? extension.metadata.id : null, + publisherId: extension.metadata ? extension.metadata.publisherId : null, + publisherName: extension.manifest.publisher, + publisherDisplayName: extension.metadata ? extension.metadata.publisherDisplayName : null + }; +} + +export function getGalleryExtensionTelemetryData(extension: IGalleryExtension): any { + return { + id: `${ extension.publisher }.${ extension.name }`, + name: extension.name, + galleryId: extension.id, + publisherId: extension.publisherId, + publisherName: extension.publisher, + publisherDisplayName: extension.publisherDisplayName + }; +} \ No newline at end of file diff --git a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts index 2c01d130461..66b270cc79c 100644 --- a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts +++ b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts @@ -8,6 +8,7 @@ import { tmpdir } from 'os'; import * as path from 'path'; import { TPromise } from 'vs/base/common/winjs.base'; import { IGalleryExtension, IExtensionGalleryService, IQueryOptions, SortBy, SortOrder, IExtensionManifest } from 'vs/platform/extensionManagement/common/extensionManagement'; +import { getGalleryExtensionTelemetryData } from 'vs/platform/extensionManagement/common/extensionTelemetry'; import { isUndefined } from 'vs/base/common/types'; import { assign, getOrDefault } from 'vs/base/common/objects'; import { IRequestService } from 'vs/platform/request/common/request'; @@ -339,10 +340,13 @@ export class ExtensionGalleryService implements IExtensionGalleryService { return this.getLastValidExtensionVersion(rawExtension, rawExtension.versions).then(rawVersion => { const url = `${ getAssetSource(rawVersion.files, AssetType.VSIX) }?install=true`; const zipPath = path.join(tmpdir(), extension.id); + const data = getGalleryExtensionTelemetryData(extension); + const timer = this.telemetryService.timedPublicLog('galleryService:downloadVSIX', data); return this.getCommonHeaders() .then(headers => this._getAsset({ url, headers })) .then(context => download(zipPath, context)) + .then(() => timer.stop()) .then(() => zipPath); }); }); diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts index 3bcd3338121..39d1d045958 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts @@ -15,6 +15,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IPager, mapPager, singlePagePager } from 'vs/base/common/paging'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IExtensionManagementService, IExtensionGalleryService, IExtensionTipsService, ILocalExtension, IGalleryExtension, IQueryOptions } from 'vs/platform/extensionManagement/common/extensionManagement'; +import { getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData } from 'vs/platform/extensionManagement/common/extensionTelemetry'; import * as semver from 'semver'; import * as path from 'path'; import URI from 'vs/base/common/uri'; @@ -120,23 +121,9 @@ class Extension implements IExtension { const { local, gallery } = this; if (gallery) { - return { - id: `${ gallery.publisher }.${ gallery.name }`, - name: gallery.name, - galleryId: gallery.id, - publisherId: gallery.publisherId, - publisherName: gallery.publisher, - publisherDisplayName: gallery.publisherDisplayName - }; + return getGalleryExtensionTelemetryData(gallery); } else { - return { - id: `${ local.manifest.publisher }.${ local.manifest.name }`, - name: local.manifest.name, - galleryId: local.metadata ? local.metadata.id : null, - publisherId: local.metadata ? local.metadata.publisherId : null, - publisherName: local.manifest.publisher, - publisherDisplayName: local.metadata ? local.metadata.publisherDisplayName : null - }; + return getLocalExtensionTelemetryData(local); } } }