diff --git a/src/vs/editor/browser/standalone/standaloneCodeEditor.ts b/src/vs/editor/browser/standalone/standaloneCodeEditor.ts index a61d0df31a1..206ec9cd9e2 100644 --- a/src/vs/editor/browser/standalone/standaloneCodeEditor.ts +++ b/src/vs/editor/browser/standalone/standaloneCodeEditor.ts @@ -19,7 +19,7 @@ import {AbstractKeybindingService} from 'vs/platform/keybinding/browser/keybindi import {ICommandHandler, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybindingService'; import {IMarkerService} from 'vs/platform/markers/common/markers'; import {Registry} from 'vs/platform/platform'; -import {RemoteTelemetryServiceHelper} from 'vs/platform/telemetry/common/abstractRemoteTelemetryService'; +import {RemoteTelemetryServiceHelper} from 'vs/platform/telemetry/common/remoteTelemetryService'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {DefaultConfig} from 'vs/editor/common/config/defaultConfig'; import {IActionDescriptor, ICodeEditorWidgetCreationOptions, IDiffEditorOptions, IModel} from 'vs/editor/common/editorCommon'; diff --git a/src/vs/editor/common/worker/editorWorkerServer.ts b/src/vs/editor/common/worker/editorWorkerServer.ts index 86bda9ace86..c5334971509 100644 --- a/src/vs/editor/common/worker/editorWorkerServer.ts +++ b/src/vs/editor/common/worker/editorWorkerServer.ts @@ -17,7 +17,7 @@ import {IExtensionDescription} from 'vs/platform/extensions/common/extensions'; import {createInstantiationService} from 'vs/platform/instantiation/common/instantiationService'; import {SecondaryMarkerService} from 'vs/platform/markers/common/markerService'; import {BaseRequestService} from 'vs/platform/request/common/baseRequestService'; -import {WorkerTelemetryService} from 'vs/platform/telemetry/common/workerTelemetryService'; +import {RemoteTelemetryService} from 'vs/platform/telemetry/common/remoteTelemetryService'; import {WorkerThreadService} from 'vs/platform/thread/common/workerThreadService'; import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/baseWorkspaceContextService'; import {IWorkspace} from 'vs/platform/workspace/common/workspace'; @@ -93,7 +93,7 @@ export class EditorWorkerServer { this.threadService = new WorkerThreadService(mainThread.getRemoteCom()); this.threadService.setInstantiationService(createInstantiationService({ threadService: this.threadService })); - var telemetryServiceInstance = new WorkerTelemetryService(this.threadService); + var telemetryServiceInstance = new RemoteTelemetryService('workerTelemetry', this.threadService); var resourceService = new ResourceService(); var markerService = new SecondaryMarkerService(this.threadService); diff --git a/src/vs/platform/telemetry/common/abstractRemoteTelemetryService.ts b/src/vs/platform/telemetry/common/abstractRemoteTelemetryService.ts deleted file mode 100644 index 981e85bc45a..00000000000 --- a/src/vs/platform/telemetry/common/abstractRemoteTelemetryService.ts +++ /dev/null @@ -1,58 +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 { TPromise } from 'vs/base/common/winjs.base'; -import AbstractTelemetryService = require('vs/platform/telemetry/common/abstractTelemetryService'); -import {ITelemetryService, ITelemetryInfo, ITelemetryAppender} from 'vs/platform/telemetry/common/telemetry'; -import {Remotable, IThreadService} from 'vs/platform/thread/common/thread'; -import {IDisposable} from 'vs/base/common/lifecycle'; -/** - * Helper always instantiated in the main process to receive telemetry events from remote telemetry services - */ -@Remotable.MainContext('RemoteTelemetryServiceHelper') -export class RemoteTelemetryServiceHelper { - - private _telemetryService: ITelemetryService; - - constructor( @ITelemetryService telemetryService: ITelemetryService) { - this._telemetryService = telemetryService; - } - - public _handleRemoteTelemetryEvent(eventName: string, data?: any): void { - this._telemetryService.publicLog(eventName, data); - } - - public getTelemetryInfo(): TPromise { - return this._telemetryService.getTelemetryInfo(); - } -} - -/** - * Base class for remote telemetry services (instantiated in extension host or in web workers) - */ -export class AbstractRemoteTelemetryService extends AbstractTelemetryService.AbstractTelemetryService implements ITelemetryService { - - private _proxy: RemoteTelemetryServiceHelper; - - constructor(threadService: IThreadService) { - // Log all events including public, since they will be forwarded to the main which will do the real filtering - super(); - this._proxy = threadService.getRemotable(RemoteTelemetryServiceHelper); - } - - getTelemetryInfo(): TPromise { - return this._proxy.getTelemetryInfo(); - } - - public addTelemetryAppender(appender: ITelemetryAppender): IDisposable { - throw new Error('Telemetry appenders are not supported in this execution envirnoment'); - } - - protected handleEvent(eventName: string, data?: any): void { - this._proxy._handleRemoteTelemetryEvent(eventName, data); - } -} - diff --git a/src/vs/platform/telemetry/common/remoteTelemetryService.ts b/src/vs/platform/telemetry/common/remoteTelemetryService.ts new file mode 100644 index 00000000000..dc4c293b5fa --- /dev/null +++ b/src/vs/platform/telemetry/common/remoteTelemetryService.ts @@ -0,0 +1,62 @@ +/*--------------------------------------------------------------------------------------------- + * 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 {Remotable, IThreadService} from 'vs/platform/thread/common/thread'; + +/** + * Helper always instantiated in the main process to receive telemetry events from remote telemetry services + */ +@Remotable.MainContext('RemoteTelemetryServiceHelper') +export class RemoteTelemetryServiceHelper { + + private _telemetryService: ITelemetryService; + + constructor( @ITelemetryService telemetryService: ITelemetryService) { + this._telemetryService = telemetryService; + } + + public $publicLog(eventName: string, data?: any): void { + this._telemetryService.publicLog(eventName, data); + } + + public $getTelemetryInfo(): TPromise { + return this._telemetryService.getTelemetryInfo(); + } +} + +export class RemoteTelemetryService implements ITelemetryService { + + serviceId: any; + + private _name: string; + private _proxy: RemoteTelemetryServiceHelper; + + constructor(name: string, threadService: IThreadService) { + this._name = name; + this._proxy = threadService.getRemotable(RemoteTelemetryServiceHelper); + } + + getTelemetryInfo(): TPromise { + return this._proxy.$getTelemetryInfo(); + } + + publicLog(eventName: string, data?: any): void { + data = data || Object.create(null); + data[this._name] = true; + this._proxy.$publicLog(eventName, data); + } + + timedPublicLog(): any { + throw notImplemented(); + } + + addTelemetryAppender(): any { + throw notImplemented(); + } +} diff --git a/src/vs/platform/telemetry/common/telemetry.ts b/src/vs/platform/telemetry/common/telemetry.ts index 3ed58633bfa..4f4dd6d9dd3 100644 --- a/src/vs/platform/telemetry/common/telemetry.ts +++ b/src/vs/platform/telemetry/common/telemetry.ts @@ -20,7 +20,7 @@ export interface ITelemetryInfo { instanceId: string; } -export interface ITelemetryService extends IDisposable { +export interface ITelemetryService { serviceId: ServiceIdentifier; /** @@ -53,7 +53,6 @@ export const NullTelemetryService: ITelemetryService = { timedPublicLog(name: string, data?: any): ITimerEvent { return nullEvent; }, publicLog(eventName: string, data?: any): void { }, addTelemetryAppender(appender): IDisposable { return { dispose() { } }; }, - dispose(): void { }, getTelemetryInfo(): TPromise { return TPromise.as({ instanceId: 'someValue.instanceId', diff --git a/src/vs/platform/telemetry/common/workerTelemetryService.ts b/src/vs/platform/telemetry/common/workerTelemetryService.ts deleted file mode 100644 index 7293e74cdf1..00000000000 --- a/src/vs/platform/telemetry/common/workerTelemetryService.ts +++ /dev/null @@ -1,16 +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 {AbstractRemoteTelemetryService} from 'vs/platform/telemetry/common/abstractRemoteTelemetryService'; - -export class WorkerTelemetryService extends AbstractRemoteTelemetryService { - - protected handleEvent(eventName: string, data?: any): void { - data = data || {}; - data['workerTelemetry'] = true; - super.handleEvent(eventName, data); - } -} \ No newline at end of file diff --git a/src/vs/workbench/api/node/extHostTelemetry.ts b/src/vs/workbench/api/node/extHostTelemetry.ts deleted file mode 100644 index dfa918c8fe8..00000000000 --- a/src/vs/workbench/api/node/extHostTelemetry.ts +++ /dev/null @@ -1,16 +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 {AbstractRemoteTelemetryService} from 'vs/platform/telemetry/common/abstractRemoteTelemetryService'; - -export class ExtHostTelemetryService extends AbstractRemoteTelemetryService { - - protected handleEvent(eventName: string, data?: any): void { - data = data || {}; - data['pluginHostTelemetry'] = true; - super.handleEvent(eventName, data); - } -} \ No newline at end of file diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 86d110f62a0..b9ddf0477ce 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -55,7 +55,7 @@ import {MainThreadFileSystemEventService} from 'vs/workbench/api/node/extHostFil import {MainThreadQuickOpen} from 'vs/workbench/api/node/extHostQuickOpen'; import {MainThreadStatusBar} from 'vs/workbench/api/node/extHostStatusBar'; import {MainThreadCommands} from 'vs/workbench/api/node/extHostCommands'; -import {RemoteTelemetryServiceHelper} from 'vs/platform/telemetry/common/abstractRemoteTelemetryService'; +import {RemoteTelemetryServiceHelper} from 'vs/platform/telemetry/common/remoteTelemetryService'; import {MainThreadDiagnostics} from 'vs/workbench/api/node/extHostDiagnostics'; import {MainThreadOutputService} from 'vs/workbench/api/node/extHostOutputService'; import {MainThreadMessageService} from 'vs/workbench/api/node/extHostMessageService'; diff --git a/src/vs/workbench/node/extensionHostMain.ts b/src/vs/workbench/node/extensionHostMain.ts index ac9da614f25..3257fb2a4bb 100644 --- a/src/vs/workbench/node/extensionHostMain.ts +++ b/src/vs/workbench/node/extensionHostMain.ts @@ -22,7 +22,7 @@ import {IInstantiationService } from 'vs/platform/instantiation/common/instantia import InstantiationService = require('vs/platform/instantiation/common/instantiationService'); import {ExtHostExtensionService} from 'vs/platform/extensions/common/nativeExtensionService'; import {ExtHostThreadService} from 'vs/platform/thread/common/extHostThreadService'; -import {ExtHostTelemetryService} from 'vs/workbench/api/node/extHostTelemetry'; +import {RemoteTelemetryService} from 'vs/platform/telemetry/common/remoteTelemetryService'; import {BaseRequestService} from 'vs/platform/request/common/baseRequestService'; import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/baseWorkspaceContextService'; import {ModeServiceImpl} from 'vs/editor/common/services/modeServiceImpl'; @@ -59,20 +59,20 @@ export function createServices(remoteCom: IMainProcessExtHostIPC, initData: IIni let contextService = new BaseWorkspaceContextService(initData.contextService.workspace, initData.contextService.configuration, initData.contextService.options); let threadService = new ExtHostThreadService(remoteCom); threadService.setInstantiationService(InstantiationService.createInstantiationService({ threadService: threadService })); - let telemetryService = new ExtHostTelemetryService(threadService); + let telemetryService = new RemoteTelemetryService('pluginHostTelemetry', threadService); let requestService = new BaseRequestService(contextService, telemetryService); let modelService = threadService.getRemotable(ExtHostModelService); let extensionService = new ExtHostExtensionService(threadService, telemetryService); let modeService = new ModeServiceImpl(threadService, extensionService); let _services: any = { - contextService: contextService, - requestService: requestService, - modelService: modelService, - threadService: threadService, - modeService: modeService, - extensionService: extensionService, - telemetryService: telemetryService + contextService, + requestService, + modelService, + threadService, + modeService, + extensionService, + telemetryService }; let instantiationService = InstantiationService.createInstantiationService(_services); threadService.setInstantiationService(instantiationService);