提交 6d66c8bb 编写于 作者: C Christof Marti

Show commands for new users the first day after installation (#15547)

上级 32b4fdb3
......@@ -12,6 +12,7 @@ import URI from 'vs/base/common/uri';
import { ConfigurationSource, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
export const ITelemetryService = createDecorator<ITelemetryService>('telemetryService');
......@@ -22,7 +23,7 @@ export interface ITelemetryInfo {
}
export interface ITelemetryExperiments {
showFirstSessionWatermark: boolean;
showNewUserWatermark: boolean;
openUntitledFile: boolean;
}
......@@ -44,7 +45,7 @@ export interface ITelemetryService {
}
export const defaultExperiments: ITelemetryExperiments = {
showFirstSessionWatermark: false,
showNewUserWatermark: false,
openUntitledFile: true
};
......@@ -67,7 +68,7 @@ export const NullTelemetryService = {
}
};
export function loadExperiments(storageService: IStorageService, configurationService: IConfigurationService): ITelemetryExperiments {
export function loadExperiments(contextService: IWorkspaceContextService, storageService: IStorageService, configurationService: IConfigurationService): ITelemetryExperiments {
const key = 'experiments.randomness';
let valueString = storageService.get(key);
......@@ -77,19 +78,19 @@ export function loadExperiments(storageService: IStorageService, configurationSe
}
const random1 = parseFloat(valueString);
let [random2, showFirstSessionWatermark] = splitRandom(random1);
let [random2, showNewUserWatermark] = splitRandom(random1);
let [, openUntitledFile] = splitRandom(random2);
// is the user a first time user?
let isNewSession = storageService.get('telemetry.lastSessionDate') ? false : true;
if (!isNewSession) {
// for returning users we fall back to the default configuration for the sidebar and the initially opened, empty editor
showFirstSessionWatermark = defaultExperiments.showFirstSessionWatermark;
const newUserDuration = 24 * 60 * 60 * 1000;
const firstSessionDate = storageService.get('telemetry.firstSessionDate');
const isNewUser = !firstSessionDate || Date.now() - Date.parse(firstSessionDate) < newUserDuration;
if (!isNewUser || !!contextService.getWorkspace()) {
showNewUserWatermark = defaultExperiments.showNewUserWatermark;
openUntitledFile = defaultExperiments.openUntitledFile;
}
return applyOverrides(configurationService, {
showFirstSessionWatermark,
showNewUserWatermark,
openUntitledFile
});
}
......
......@@ -335,7 +335,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, this.configurationService)
experiments: loadExperiments(this.contextService, this.storageService, this.configurationService)
};
const telemetryService = instantiationService.createInstance(TelemetryService, config);
......@@ -352,7 +352,7 @@ export class WorkbenchShell {
disposables.add(telemetryService, errorTelemetry, listener, idleMonitor);
} else {
NullTelemetryService._experiments = loadExperiments(this.storageService, this.configurationService);
NullTelemetryService._experiments = loadExperiments(this.contextService, this.storageService, this.configurationService);
this.telemetryService = NullTelemetryService;
}
......
......@@ -99,7 +99,7 @@ const openGlobalKeybindings: WatermarkEntry = {
ids: [OpenGlobalKeybindingsAction.ID]
};
const firstSessionEntries = [
const newUserEntries = [
showCommands,
selectTheme,
selectKeymap,
......@@ -158,9 +158,8 @@ export class WatermarkContribution implements IWorkbenchContribution {
const box = $(watermark)
.div({ 'class': 'watermark-box' });
const folder = !!this.contextService.getWorkspace();
const firstSession = this.telemetryService.getExperiments().showFirstSessionWatermark &&
!this.storageService.get('telemetry.lastSessionDate');
const selected = (folder ? folderEntries : firstSession ? firstSessionEntries : noFolderEntries)
const newUser = this.telemetryService.getExperiments().showNewUserWatermark;
const selected = (newUser ? newUserEntries : (folder ? folderEntries : noFolderEntries))
.filter(entry => !('mac' in entry) || entry.mac === isMacintosh);
const update = () => {
const builder = $(box);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册