startup - convert workspacestats to workbench contribution
This commit is contained in:
parent
8e97fef6f3
commit
6b30ade4ea
|
@ -169,6 +169,7 @@ export interface IWindowService {
|
|||
|
||||
onDidChangeFocus: Event<boolean>;
|
||||
|
||||
getConfiguration(): IWindowConfiguration;
|
||||
getCurrentWindowId(): number;
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import Event, { filterEvent, mapEvent, anyEvent } from 'vs/base/common/event';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { remote } from 'electron';
|
||||
import { IRecentlyOpened } from 'vs/platform/history/common/history';
|
||||
import { ICommandAction } from 'vs/platform/actions/common/actions';
|
||||
|
@ -23,6 +23,7 @@ export class WindowService implements IWindowService {
|
|||
|
||||
constructor(
|
||||
private windowId: number,
|
||||
private configuration: IWindowConfiguration,
|
||||
@IWindowsService private windowsService: IWindowsService
|
||||
) {
|
||||
const onThisWindowFocus = mapEvent(filterEvent(windowsService.onWindowFocus, id => id === windowId), _ => true);
|
||||
|
@ -34,6 +35,10 @@ export class WindowService implements IWindowService {
|
|||
return this.windowId;
|
||||
}
|
||||
|
||||
getConfiguration(): IWindowConfiguration {
|
||||
return this.configuration;
|
||||
}
|
||||
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
options.windowId = this.windowId;
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import ErrorTelemetry from 'vs/platform/telemetry/browser/errorTelemetry';
|
|||
import { ElectronWindow } from 'vs/workbench/electron-browser/window';
|
||||
import { resolveWorkbenchCommonProperties, getOrCreateMachineId } from 'vs/platform/telemetry/node/workbenchCommonProperties';
|
||||
import { machineIdIpcChannel } from 'vs/platform/telemetry/node/commonProperties';
|
||||
import { WorkspaceStats } from 'vs/workbench/services/telemetry/node/workspaceStats';
|
||||
import { IWindowsService, IWindowService, IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { WindowService } from 'vs/platform/windows/electron-browser/windowService';
|
||||
import { MessageService } from 'vs/workbench/services/message/electron-browser/messageService';
|
||||
|
@ -249,11 +248,6 @@ export class WorkbenchShell {
|
|||
this.telemetryService.publicLog('startupTime', this.timerService.startupMetrics);
|
||||
});
|
||||
|
||||
// Telemetry: workspace tags
|
||||
const workspaceStats: WorkspaceStats = <WorkspaceStats>this.workbench.getInstantiationService().createInstance(WorkspaceStats);
|
||||
workspaceStats.reportWorkspaceTags(this.configuration);
|
||||
workspaceStats.reportCloudStats();
|
||||
|
||||
// Root Warning
|
||||
if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) {
|
||||
this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'."));
|
||||
|
@ -285,7 +279,7 @@ export class WorkbenchShell {
|
|||
this.broadcastService = new BroadcastService(currentWindow.id);
|
||||
serviceCollection.set(IBroadcastService, this.broadcastService);
|
||||
|
||||
serviceCollection.set(IWindowService, new SyncDescriptor(WindowService, currentWindow.id));
|
||||
serviceCollection.set(IWindowService, new SyncDescriptor(WindowService, currentWindow.id, this.configuration));
|
||||
|
||||
const sharedProcess = (<IWindowsService>serviceCollection.get(IWindowsService)).whenSharedProcessReady()
|
||||
.then(() => connectNet(this.environmentService.sharedIPCHandle, `window:${currentWindow.id}`));
|
||||
|
|
14
src/vs/workbench/parts/stats/node/stats.contribution.ts
Normal file
14
src/vs/workbench/parts/stats/node/stats.contribution.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { WorkspaceStatsReporter } from 'vs/workbench/parts/stats/node/workspaceStats';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
|
||||
// Register Workspace Stats Contribution
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStatsReporter, LifecyclePhase.Running);
|
|
@ -13,7 +13,9 @@ import { IFileService, IFileStat } from 'vs/platform/files/common/files';
|
|||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowConfiguration, IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
const SshProtocolMatcher = /^([^@:]+@)?([^:]+):/;
|
||||
const SshUrlMatcher = /^([^@:]+@)?([^:]+):(.+)$/;
|
||||
|
@ -131,7 +133,7 @@ export function getHashedRemotes(text: string): string[] {
|
|||
});
|
||||
}
|
||||
|
||||
export class WorkspaceStats {
|
||||
class WorkspaceStats {
|
||||
constructor(
|
||||
@IFileService private fileService: IFileService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
|
@ -414,3 +416,24 @@ export class WorkspaceStats {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Telemetry: workspace tags
|
||||
export class WorkspaceStatsReporter implements IWorkbenchContribution {
|
||||
|
||||
constructor(
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IWindowService private windowService: IWindowService
|
||||
) {
|
||||
this.reportWorkspaceStats();
|
||||
}
|
||||
|
||||
public getId(): string {
|
||||
return 'vs.backup.backupModelTracker';
|
||||
}
|
||||
|
||||
private reportWorkspaceStats(): void {
|
||||
const workspaceStats: WorkspaceStats = this.instantiationService.createInstance(WorkspaceStats);
|
||||
workspaceStats.reportWorkspaceTags(this.windowService.getConfiguration());
|
||||
workspaceStats.reportCloudStats();
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import * as crypto from 'crypto';
|
||||
import { getDomainsOfRemotes, getRemotes, getHashedRemotes } from 'vs/workbench/services/telemetry/node/workspaceStats';
|
||||
import { getDomainsOfRemotes, getRemotes, getHashedRemotes } from 'vs/workbench/parts/stats/node/workspaceStats';
|
||||
|
||||
function hash(value: string): string {
|
||||
return crypto.createHash('sha1').update(value.toString()).digest('hex');
|
|
@ -46,7 +46,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
|
|||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowsService, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { RawTextSource, IRawTextSource } from 'vs/editor/common/model/textSource';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
@ -890,6 +890,10 @@ export class TestWindowService implements IWindowService {
|
|||
return TPromise.as(false);
|
||||
}
|
||||
|
||||
getConfiguration(): IWindowConfiguration {
|
||||
return Object.create(null);
|
||||
}
|
||||
|
||||
getCurrentWindowId(): number {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@ import 'vs/workbench/parts/files/browser/files.contribution';
|
|||
|
||||
import 'vs/workbench/parts/backup/common/backup.contribution';
|
||||
|
||||
import 'vs/workbench/parts/stats/node/stats.contribution';
|
||||
|
||||
import 'vs/workbench/parts/search/browser/search.contribution';
|
||||
import 'vs/workbench/parts/search/browser/searchViewlet'; // can be packaged separately
|
||||
import 'vs/workbench/parts/search/browser/openAnythingHandler'; // can be packaged separately
|
||||
|
|
|
@ -421,7 +421,7 @@
|
|||
},
|
||||
{
|
||||
"target": "{**/**.test.ts,**/test/**}",
|
||||
"restrictions": "{**/vs/**,assert,sinon}"
|
||||
"restrictions": "{**/vs/**,assert,sinon,crypto}"
|
||||
},
|
||||
{
|
||||
"target": "**/{common,browser,workbench}/**",
|
||||
|
|
Loading…
Reference in a new issue