add vsix download telemetry timer data

related to #10180
This commit is contained in:
Joao Moreno 2016-08-18 15:24:09 +02:00
parent 231bad3fbb
commit 8aa430710a
3 changed files with 37 additions and 16 deletions

View file

@ -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
};
}

View file

@ -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);
});
});

View file

@ -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);
}
}
}