提交 e94e0089 编写于 作者: C Christof Marti

#12534: Enable overrides for testing

上级 a8894fbf
......@@ -5,6 +5,7 @@
'use strict';
import {TPromise} from 'vs/base/common/winjs.base';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
import {IStorageService} from 'vs/platform/storage/common/storage';
......@@ -64,7 +65,7 @@ export const NullTelemetryService = {
}
};
export function loadExperiments(storageService: IStorageService): ITelemetryExperiments {
export function loadExperiments(storageService: IStorageService, configurationService: IConfigurationService): ITelemetryExperiments {
const key = 'experiments.randomness';
let valueString = storageService.get(key);
if (!valueString) {
......@@ -75,11 +76,22 @@ export function loadExperiments(storageService: IStorageService): ITelemetryExpe
const [random1, showDefaultViewlet] = splitRandom(random0);
const [random2, showCommandsWatermark] = splitRandom(random1);
const [, openUntitledFile] = splitRandom(random2);
return {
return applyOverrides(configurationService, {
showDefaultViewlet,
showCommandsWatermark,
openUntitledFile
};
});
}
export function applyOverrides(configurationService: IConfigurationService, experiments: ITelemetryExperiments): ITelemetryExperiments {
const config: any = configurationService.getConfiguration('telemetry');
const experimentsConfig = config && config.experiments || {};
Object.keys(experiments).forEach(key => {
if (key in experimentsConfig) {
experiments[key] = experimentsConfig[key];
}
});
return experiments;
}
function splitRandom(random: number): [number, boolean] {
......
......@@ -257,7 +257,7 @@ export class WorkbenchShell {
appender: new TelemetryAppenderClient(channel),
commonProperties: resolveWorkbenchCommonProperties(this.storageService, commit, version),
piiPaths: [this.environmentService.appRoot, this.environmentService.extensionsPath],
experiments: loadExperiments(this.storageService)
experiments: loadExperiments(this.storageService, this.configurationService)
};
const telemetryService = instantiationService.createInstance(TelemetryService, config);
......@@ -274,7 +274,7 @@ export class WorkbenchShell {
disposables.add(telemetryService, errorTelemetry, listener, idleMonitor);
} else {
NullTelemetryService._experiments = loadExperiments(this.storageService);
NullTelemetryService._experiments = loadExperiments(this.storageService, this.configurationService);
this.telemetryService = NullTelemetryService;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册