From 83ac7b4e03b561b3010e65d9a4eae3a4aeee30dd Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Fri, 18 Aug 2017 08:34:35 -0700 Subject: [PATCH] Deploy to Azure quick link experiment --- .../platform/telemetry/common/experiments.ts | 61 ++++++++++++------- src/vs/workbench/electron-browser/shell.ts | 9 ++- .../electron-browser/vs_code_welcome_page.ts | 1 + .../page/electron-browser/welcomePage.ts | 8 +++ 4 files changed, 54 insertions(+), 25 deletions(-) diff --git a/src/vs/platform/telemetry/common/experiments.ts b/src/vs/platform/telemetry/common/experiments.ts index b338b4518db..36961817a48 100644 --- a/src/vs/platform/telemetry/common/experiments.ts +++ b/src/vs/platform/telemetry/common/experiments.ts @@ -6,31 +6,46 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IStorageService } from 'vs/platform/storage/common/storage'; -import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; +import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -export interface ITelemetryExperiments { +export interface IExperiments { + deployToAzureQuickLink: boolean; } -const defaultExperiments: ITelemetryExperiments = { -}; +export const IExperimentService = createDecorator('experimentService'); -export function loadExperiments(accessor?: ServicesAccessor): ITelemetryExperiments { +export interface IExperimentService { - // shortcut since there are currently no experiments (should introduce separate service to load only once) - if (!accessor) { - return {}; + _serviceBrand: any; + + getExperiments(): IExperiments; +} + +export class ExperimentService implements IExperimentService { + + _serviceBrand: any; + + private experiments: IExperiments; + + constructor( + @IStorageService private storageService: IStorageService, + @IConfigurationService private configurationService: IConfigurationService, + ) { } + + getExperiments() { + if (!this.experiments) { + this.experiments = loadExperiments(this.storageService, this.configurationService); + } + return this.experiments; } - - const storageService = accessor.get(IStorageService); - const configurationService = accessor.get(IConfigurationService); - - let { - } = splitExperimentsRandomness(storageService); - - return applyOverrides(defaultExperiments, configurationService); } -function applyOverrides(experiments: ITelemetryExperiments, configurationService: IConfigurationService): ITelemetryExperiments { +function loadExperiments(storageService: IStorageService, configurationService: IConfigurationService): IExperiments { + const experiments = splitExperimentsRandomness(storageService); + return applyOverrides(experiments, configurationService); +} + +function applyOverrides(experiments: IExperiments, configurationService: IConfigurationService): IExperiments { const experimentsConfig = getExperimentsOverrides(configurationService); Object.keys(experiments).forEach(key => { if (key in experimentsConfig) { @@ -40,14 +55,14 @@ function applyOverrides(experiments: ITelemetryExperiments, configurationService return experiments; } -function splitExperimentsRandomness(storageService: IStorageService): ITelemetryExperiments { +function splitExperimentsRandomness(storageService: IStorageService): IExperiments { const random1 = getExperimentsRandomness(storageService); const [random2, /* showTaskDocumentation */] = splitRandom(random1); - const [random3, /* openUntitledFile */] = splitRandom(random2); - const [random4, /* mergeQuickLinks */] = splitRandom(random3); - // tslint:disable-next-line:no-unused-variable (https://github.com/Microsoft/TypeScript/issues/16628) - const [random5, /* enableWelcomePage */] = splitRandom(random4); + const [/* random3 */, deployToAzureQuickLink] = splitRandom(random2); + // const [random4, /* mergeQuickLinks */] = splitRandom(random3); + // const [random5, /* enableWelcomePage */] = splitRandom(random4); return { + deployToAzureQuickLink }; } @@ -68,7 +83,7 @@ function splitRandom(random: number): [number, boolean] { return [scaled - i, i === 1]; } -function getExperimentsOverrides(configurationService: IConfigurationService): ITelemetryExperiments { +function getExperimentsOverrides(configurationService: IConfigurationService): IExperiments { const config: any = configurationService.getConfiguration('telemetry'); return config && config.experiments || {}; } diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 0870ae8b268..593ee95af9c 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -23,7 +23,7 @@ import { ContextViewService } from 'vs/platform/contextview/browser/contextViewS import { Workbench, IWorkbenchStartedInfo } from 'vs/workbench/electron-browser/workbench'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { NullTelemetryService, configurationTelemetry, lifecycleTelemetry } from 'vs/platform/telemetry/common/telemetryUtils'; -import { loadExperiments } from 'vs/platform/telemetry/common/experiments'; +import { IExperimentService, ExperimentService } from 'vs/platform/telemetry/common/experiments'; 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'; @@ -117,6 +117,7 @@ export class WorkbenchShell { private configurationService: IConfigurationService; private contextService: IWorkspaceContextService; private telemetryService: ITelemetryService; + private experimentService: IExperimentService; private extensionService: ExtensionService; private broadcastService: IBroadcastService; private timerService: ITimerService; @@ -208,7 +209,7 @@ export class WorkbenchShell { customKeybindingsCount: info.customKeybindingsCount, theme: this.themeService.getColorTheme().id, language: platform.language, - experiments: loadExperiments(), + experiments: this.experimentService.getExperiments(), pinnedViewlets: info.pinnedViewlets, restoredViewlet: info.restoredViewlet, restoredEditors: info.restoredEditors.length, @@ -263,6 +264,10 @@ export class WorkbenchShell { restoreFontInfo(this.storageService); readFontInfo(BareFontInfo.createFromRawSettings(this.configurationService.getConfiguration('editor'), browser.getZoomLevel())); + // Experiments + this.experimentService = instantiationService.createInstance(ExperimentService); + serviceCollection.set(IExperimentService, this.experimentService); + // Telemetry this.sendMachineIdToMain(this.storageService); if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !!product.enableTelemetry) { diff --git a/src/vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page.ts b/src/vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page.ts index 926d92f29b3..ecd1e174fd9 100644 --- a/src/vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page.ts +++ b/src/vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page.ts @@ -69,6 +69,7 @@ export default () => ` diff --git a/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts b/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts index 7264d548e85..530d3e2012b 100644 --- a/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts +++ b/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts @@ -23,6 +23,7 @@ import { IConfigurationEditingService, ConfigurationTarget } from 'vs/workbench/ import { localize } from 'vs/nls'; import { Action } from 'vs/base/common/actions'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IExperimentService } from 'vs/platform/telemetry/common/experiments'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { Schemas } from 'vs/base/common/network'; import { IBackupFileService } from 'vs/workbench/services/backup/common/backup'; @@ -194,6 +195,7 @@ class WelcomePage { @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, @ILifecycleService lifecycleService: ILifecycleService, @IThemeService private themeService: IThemeService, + @IExperimentService private experimentService: IExperimentService, @ITelemetryService private telemetryService: ITelemetryService ) { this.disposables.push(lifecycleService.onShutdown(() => this.dispose())); @@ -313,6 +315,12 @@ class WelcomePage { } }; })); + + if (this.experimentService.getExperiments().deployToAzureQuickLink) { + container.querySelector('.showInterfaceOverview').remove(); + } else { + container.querySelector('.deployToAzure').remove(); + } } private addExtensionList(container: HTMLElement, listSelector: string, suggestions: ExtensionSuggestion[], strings: Strings) {