mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
have MainThreadTelemetry instead of fake telemetry service
This commit is contained in:
@@ -43,7 +43,6 @@ import EditorCommon = require('vs/editor/common/editorCommon');
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionService';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import * as vscode from 'vscode';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
@@ -74,10 +73,11 @@ function proposedApiFunction<T>(extension: IExtensionDescription, fn: T): T {
|
||||
export function createApiFactory(
|
||||
initData: IInitData,
|
||||
threadService: ExtHostThreadService,
|
||||
extensionService: ExtHostExtensionService,
|
||||
telemetryService: ITelemetryService
|
||||
extensionService: ExtHostExtensionService
|
||||
): IExtensionApiFactory {
|
||||
|
||||
const mainThreadTelemetry = threadService.get(MainContext.MainThreadTelemetry);
|
||||
|
||||
// Addressable instances
|
||||
const extHostHeapService = threadService.set(ExtHostContext.ExtHostHeapService, new ExtHostHeapService());
|
||||
const extHostDocumentsAndEditors = threadService.set(ExtHostContext.ExtHostDocumentsAndEditors, new ExtHostDocumentsAndEditors(threadService));
|
||||
@@ -140,7 +140,7 @@ export function createApiFactory(
|
||||
return undefined;
|
||||
}
|
||||
this._seen.add(apiName);
|
||||
return telemetryService.publicLog('apiUsage', {
|
||||
return mainThreadTelemetry.$publicLog('apiUsage', {
|
||||
name: apiName,
|
||||
extension: extension.id
|
||||
});
|
||||
@@ -475,7 +475,7 @@ export function createApiFactory(
|
||||
return extHostSCM.inputBox;
|
||||
},
|
||||
createSourceControl(id: string, label: string) {
|
||||
telemetryService.publicLog('registerSCMProvider', {
|
||||
mainThreadTelemetry.$publicLog('registerSCMProvider', {
|
||||
extensionId: extension.id,
|
||||
providerId: id,
|
||||
providerLabel: label
|
||||
|
||||
@@ -288,7 +288,6 @@ export interface MainThreadStorageShape extends IDisposable {
|
||||
|
||||
export interface MainThreadTelemetryShape extends IDisposable {
|
||||
$publicLog(eventName: string, data?: any): void;
|
||||
$getTelemetryInfo(): TPromise<ITelemetryInfo>;
|
||||
}
|
||||
|
||||
export interface MainThreadWorkspaceShape extends IDisposable {
|
||||
|
||||
@@ -12,9 +12,8 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/node/extensionDescriptionRegistry';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtHostStorage } from 'vs/workbench/api/node/extHostStorage';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { createApiFactory, initializeExtensionApi } from 'vs/workbench/api/node/extHost.api.impl';
|
||||
import { MainContext, MainThreadExtensionServiceShape, IWorkspaceData, IEnvironment, IInitData, ExtHostExtensionServiceShape } from './extHost.protocol';
|
||||
import { MainContext, MainThreadExtensionServiceShape, IWorkspaceData, IEnvironment, IInitData, ExtHostExtensionServiceShape, MainThreadTelemetryShape } from './extHost.protocol';
|
||||
import { IExtensionMemento, ExtensionsActivator, ActivatedExtension, IExtensionAPI, IExtensionContext, EmptyExtension, IExtensionModule } from 'vs/workbench/api/node/extHostExtensionActivator';
|
||||
import { Barrier } from 'vs/workbench/services/extensions/node/barrier';
|
||||
import { ExtHostThreadService } from 'vs/workbench/services/thread/node/extHostThreadService';
|
||||
@@ -112,7 +111,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
private readonly _barrier: Barrier;
|
||||
private readonly _registry: ExtensionDescriptionRegistry;
|
||||
private readonly _threadService: ExtHostThreadService;
|
||||
private readonly _telemetryService: ITelemetryService;
|
||||
private readonly _mainThreadTelemetry: MainThreadTelemetryShape;
|
||||
private readonly _storage: ExtHostStorage;
|
||||
private readonly _storagePath: ExtensionStoragePath;
|
||||
private readonly _proxy: MainThreadExtensionServiceShape;
|
||||
@@ -121,18 +120,18 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
/**
|
||||
* This class is constructed manually because it is a service, so it doesn't use any ctor injection
|
||||
*/
|
||||
constructor(initData: IInitData, threadService: ExtHostThreadService, telemetryService: ITelemetryService) {
|
||||
constructor(initData: IInitData, threadService: ExtHostThreadService) {
|
||||
this._barrier = new Barrier();
|
||||
this._registry = new ExtensionDescriptionRegistry(initData.extensions);
|
||||
this._threadService = threadService;
|
||||
this._telemetryService = telemetryService;
|
||||
this._mainThreadTelemetry = threadService.get(MainContext.MainThreadTelemetry);
|
||||
this._storage = new ExtHostStorage(threadService);
|
||||
this._storagePath = new ExtensionStoragePath(initData.workspace, initData.environment);
|
||||
this._proxy = this._threadService.get(MainContext.MainThreadExtensionService);
|
||||
this._activator = null;
|
||||
|
||||
// initialize API first (i.e. do not release barrier until the API is initialized)
|
||||
const apiFactory = createApiFactory(initData, threadService, this, this._telemetryService);
|
||||
const apiFactory = createApiFactory(initData, threadService, this);
|
||||
|
||||
initializeExtensionApi(this, apiFactory).then(() => {
|
||||
|
||||
@@ -281,7 +280,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
|
||||
private _doActivateExtension(extensionDescription: IExtensionDescription): TPromise<ActivatedExtension> {
|
||||
let event = getTelemetryActivationEvent(extensionDescription);
|
||||
this._telemetryService.publicLog('activatePlugin', event);
|
||||
this._mainThreadTelemetry.$publicLog('activatePlugin', event);
|
||||
if (!extensionDescription.main) {
|
||||
// Treat the extension as being empty => NOT AN ERROR CASE
|
||||
return TPromise.as(new EmptyExtension());
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { notImplemented } from 'vs/base/common/errors';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { MainContext, MainThreadTelemetryShape, IMainContext } from './extHost.protocol';
|
||||
|
||||
export class RemoteTelemetryService implements ITelemetryService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private _name: string;
|
||||
private _proxy: MainThreadTelemetryShape;
|
||||
|
||||
constructor(name: string, mainContext: IMainContext) {
|
||||
this._name = name;
|
||||
this._proxy = mainContext.get(MainContext.MainThreadTelemetry);
|
||||
}
|
||||
|
||||
get isOptedIn(): boolean {
|
||||
throw notImplemented();
|
||||
}
|
||||
|
||||
getTelemetryInfo(): TPromise<ITelemetryInfo> {
|
||||
return this._proxy.$getTelemetryInfo();
|
||||
}
|
||||
|
||||
publicLog(eventName: string, data?: any): TPromise<void> {
|
||||
data = data || Object.create(null);
|
||||
data[this._name] = true;
|
||||
this._proxy.$publicLog(eventName, data);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
timedPublicLog(): any {
|
||||
throw notImplemented();
|
||||
}
|
||||
|
||||
addTelemetryAppender(): any {
|
||||
throw notImplemented();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user