提交 12d000ec 编写于 作者: C Christof Marti

Run experiment with default viewlet shown/hidden (fixes #12414)

上级 f279a631
......@@ -6,6 +6,7 @@
import {TPromise} from 'vs/base/common/winjs.base';
import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
import {IStorageService} from 'vs/platform/storage/common/storage';
export const ITelemetryService = createDecorator<ITelemetryService>('telemetryService');
......@@ -15,6 +16,10 @@ export interface ITelemetryInfo {
instanceId: string;
}
export interface ITelemetryExperiments {
showDefaultViewlet: boolean;
}
export interface ITelemetryService {
_serviceBrand: any;
......@@ -28,10 +33,17 @@ export interface ITelemetryService {
getTelemetryInfo(): TPromise<ITelemetryInfo>;
isOptedIn: boolean;
getExperiments(): ITelemetryExperiments;
}
export const NullTelemetryService: ITelemetryService = {
export const defaultExperiments: ITelemetryExperiments = {
showDefaultViewlet: false
};
export const NullTelemetryService = {
_serviceBrand: undefined,
_experiments: defaultExperiments,
publicLog(eventName: string, data?: any) {
return TPromise.as<void>(null);
},
......@@ -42,9 +54,25 @@ export const NullTelemetryService: ITelemetryService = {
sessionId: 'someValue.sessionId',
machineId: 'someValue.machineId'
});
},
getExperiments(): ITelemetryExperiments {
return this._experiments;
}
};
export function loadExperiments(storageService: IStorageService): ITelemetryExperiments {
const key = 'experiments.randomness';
let valueString = storageService.get(key);
if (!valueString) {
valueString = Math.random().toString();
storageService.store(key, valueString);
}
const value = parseFloat(valueString);
return {
showDefaultViewlet: value < 0.5
};
}
export interface ITelemetryAppender {
log(eventName: string, data: any): void;
}
......
......@@ -7,7 +7,7 @@
import {localize} from 'vs/nls';
import {escapeRegExpCharacters} from 'vs/base/common/strings';
import {ITelemetryService, ITelemetryAppender, ITelemetryInfo} from 'vs/platform/telemetry/common/telemetry';
import {ITelemetryService, ITelemetryAppender, ITelemetryInfo, ITelemetryExperiments, defaultExperiments} from 'vs/platform/telemetry/common/telemetry';
import {optional} from 'vs/platform/instantiation/common/instantiation';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IConfigurationRegistry, Extensions} from 'vs/platform/configuration/common/configurationRegistry';
......@@ -21,6 +21,7 @@ export interface ITelemetryServiceConfig {
commonProperties?: TPromise<{ [name: string]: any }>;
piiPaths?: string[];
userOptIn?: boolean;
experiments?: ITelemetryExperiments;
}
export class TelemetryService implements ITelemetryService {
......@@ -34,6 +35,7 @@ export class TelemetryService implements ITelemetryService {
private _commonProperties: TPromise<{ [name: string]: any; }>;
private _piiPaths: string[];
private _userOptIn: boolean;
private _experiments: ITelemetryExperiments;
private _disposables: IDisposable[] = [];
private _cleanupPatterns: [RegExp, string][] = [];
......@@ -46,6 +48,7 @@ export class TelemetryService implements ITelemetryService {
this._commonProperties = config.commonProperties || TPromise.as({});
this._piiPaths = config.piiPaths || [];
this._userOptIn = typeof config.userOptIn === 'undefined' ? true : config.userOptIn;
this._experiments = config.experiments || defaultExperiments;
// static cleanup patterns for:
// #1 `file:///DANGEROUS/PATH/resources/app/Useful/Information`
......@@ -76,6 +79,10 @@ export class TelemetryService implements ITelemetryService {
return this._userOptIn;
}
getExperiments(): ITelemetryExperiments {
return this._experiments;
}
getTelemetryInfo(): TPromise<ITelemetryInfo> {
return this._commonProperties.then(values => {
// well known properties
......
......@@ -6,7 +6,7 @@
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 {ITelemetryService, ITelemetryInfo, ITelemetryExperiments} from 'vs/platform/telemetry/common/telemetry';
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
import {MainContext, MainThreadTelemetryShape} from './extHost.protocol';
......@@ -26,6 +26,10 @@ export class RemoteTelemetryService implements ITelemetryService {
throw notImplemented();
}
getExperiments(): ITelemetryExperiments {
throw notImplemented();
}
getTelemetryInfo(): TPromise<ITelemetryInfo> {
return this._proxy.$getTelemetryInfo();
}
......
......@@ -22,7 +22,7 @@ import {ContextViewService} from 'vs/platform/contextview/browser/contextViewSer
import timer = require('vs/base/common/timer');
import {Workbench} from 'vs/workbench/electron-browser/workbench';
import {Storage, inMemoryLocalStorageInstance} from 'vs/workbench/common/storage';
import {ITelemetryService, NullTelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {ITelemetryService, NullTelemetryService, loadExperiments} from 'vs/platform/telemetry/common/telemetry';
import {ITelemetryAppenderChannel, TelemetryAppenderClient} from 'vs/platform/telemetry/common/telemetryIpc';
import {TelemetryService, ITelemetryServiceConfig} from 'vs/platform/telemetry/common/telemetryService';
import {IdleMonitor, UserStatus} from 'vs/platform/telemetry/browser/idleMonitor';
......@@ -197,7 +197,8 @@ export class WorkbenchShell {
emptyWorkbench: !this.contextService.getWorkspace(),
customKeybindingsCount,
theme: this.themeService.getColorTheme(),
language: platform.language
language: platform.language,
experiments: this.telemetryService.getExperiments()
});
const workspaceStats: WorkspaceStats = <WorkspaceStats>this.workbench.getInstantiationService().createInstance(WorkspaceStats);
......@@ -249,7 +250,8 @@ export class WorkbenchShell {
const config: ITelemetryServiceConfig = {
appender: new TelemetryAppenderClient(channel),
commonProperties: resolveWorkbenchCommonProperties(this.storageService, commit, version),
piiPaths: [this.environmentService.appRoot, this.environmentService.extensionsPath]
piiPaths: [this.environmentService.appRoot, this.environmentService.extensionsPath],
experiments: loadExperiments(this.storageService)
};
const telemetryService = instantiationService.createInstance(TelemetryService, config);
......@@ -266,6 +268,7 @@ export class WorkbenchShell {
disposables.add(telemetryService, errorTelemetry, listener, idleMonitor);
} else {
NullTelemetryService._experiments = loadExperiments(this.storageService);
this.telemetryService = NullTelemetryService;
}
......
......@@ -73,6 +73,7 @@ import {IMenuService} from 'vs/platform/actions/common/actions';
import {MenuService} from 'vs/platform/actions/common/menuService';
import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
import {IEnvironmentService} from 'vs/platform/environment/common/environment';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
export const MessagesVisibleContext = new RawContextKey<boolean>('globalMessageVisible', false);
export const EditorsVisibleContext = new RawContextKey<boolean>('editorIsOpen', false);
......@@ -154,6 +155,7 @@ export class Workbench implements IPartService {
@ILifecycleService private lifecycleService: ILifecycleService,
@IMessageService private messageService: IMessageService,
@IThreadService private threadService: IThreadService,
@ITelemetryService private telemetryService: ITelemetryService,
@IEnvironmentService private environmentService: IEnvironmentService
) {
this.container = container;
......@@ -418,7 +420,7 @@ export class Workbench implements IPartService {
// Sidebar visibility
this.sideBarHidden = this.storageService.getBoolean(Workbench.sidebarHiddenSettingKey, StorageScope.WORKSPACE, false);
if (!this.contextService.getWorkspace()) {
this.sideBarHidden = true; // we hide sidebar in single-file-mode
this.sideBarHidden = !this.telemetryService.getExperiments().showDefaultViewlet;
}
const viewletRegistry = (<ViewletRegistry>Registry.as(ViewletExtensions.Viewlets));
......
......@@ -11,7 +11,7 @@ import {WorkspaceContextService, IWorkspaceContextService} from 'vs/platform/wor
import {createSyncDescriptor} from 'vs/platform/instantiation/common/descriptors';
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
import {ISearchService} from 'vs/platform/search/common/search';
import {ITelemetryService, ITelemetryInfo} from 'vs/platform/telemetry/common/telemetry';
import {ITelemetryService, ITelemetryInfo, ITelemetryExperiments, defaultExperiments} from 'vs/platform/telemetry/common/telemetry';
import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/services/untitled/common/untitledEditorService';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import * as minimist from 'minimist';
......@@ -156,4 +156,8 @@ class TestTelemetryService implements ITelemetryService {
machineId: 'someValue.machineId'
});
}
public getExperiments(): ITelemetryExperiments {
return defaultExperiments;
}
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册