提交 a48a0cde 编写于 作者: D Dirk Baeumer

Fixes #29862: Add telemetry when the user uses a template to configure the task runner

上级 c08d0606
......@@ -39,6 +39,8 @@ export interface TelemetryEvent {
runner: 'terminal' | 'output';
taskKind: string;
// The command triggered
command: string;
......
......@@ -231,6 +231,7 @@ export interface WorkspaceTaskSource {
kind: 'workspace';
label: string;
config: TaskSourceConfigElement;
customizes?: TaskIdentifier;
}
export interface ExtensionTaskSource {
......@@ -409,6 +410,22 @@ export namespace Task {
return task.defines._key;
}
}
export function getTelemetryKind(task: Task): string {
if (ContributedTask.is(task)) {
return 'extension';
} else if (CustomTask.is(task)) {
if (task._source.customizes) {
return 'workspace>extension';
} else {
return 'workspace';
}
} else if (CompositeTask.is(task)) {
return 'composite';
} else {
return 'unknown';
}
}
}
......
......@@ -106,7 +106,8 @@ abstract class OpenTaskConfigurationAction extends Action {
private messageService: IMessageService, private quickOpenService: IQuickOpenService,
private environmentService: IEnvironmentService,
private configurationResolverService: IConfigurationResolverService,
private extensionService: IExtensionService) {
private extensionService: IExtensionService,
private telemetryService: ITelemetryService) {
super(id, label);
}
......@@ -169,7 +170,13 @@ abstract class OpenTaskConfigurationAction extends Action {
content = content.replace(/(\n)(\t+)/g, (_, s1, s2) => s1 + strings.repeat(' ', s2.length * editorConfig.editor.tabSize));
}
configFileCreated = true;
return this.fileService.createFile(this.contextService.toResource('.vscode/tasks.json'), content); // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return this.fileService.createFile(this.contextService.toResource('.vscode/tasks.json'), content).then((result) => {
this.telemetryService.publicLog(TaskService.TemplateTelemetryEventName, {
templateId: selection.id,
autoDetect: selection.autoDetect
});
return result;
}); // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
});
/* 2.0 version
let content = selection.content;
......@@ -210,10 +217,11 @@ class ConfigureTaskRunnerAction extends OpenTaskConfigurationAction {
@IMessageService messageService: IMessageService, @IQuickOpenService quickOpenService: IQuickOpenService,
@IEnvironmentService environmentService: IEnvironmentService,
@IConfigurationResolverService configurationResolverService: IConfigurationResolverService,
@IExtensionService extensionService) {
@IExtensionService extensionService,
@ITelemetryService telemetryService) {
super(id, label, taskService, configurationService, editorService, fileService, contextService,
outputService, messageService, quickOpenService, environmentService, configurationResolverService,
extensionService);
extensionService, telemetryService);
}
}
......@@ -228,10 +236,11 @@ class ConfigureBuildTaskAction extends OpenTaskConfigurationAction {
@IMessageService messageService: IMessageService, @IQuickOpenService quickOpenService: IQuickOpenService,
@IEnvironmentService environmentService: IEnvironmentService,
@IConfigurationResolverService configurationResolverService: IConfigurationResolverService,
@IExtensionService extensionService) {
@IExtensionService extensionService,
@ITelemetryService telemetryService) {
super(id, label, taskService, configurationService, editorService, fileService, contextService,
outputService, messageService, quickOpenService, environmentService, configurationResolverService,
extensionService);
extensionService, telemetryService);
}
}
......@@ -625,6 +634,7 @@ class TaskService extends EventEmitter implements ITaskService {
private static RanTaskBefore_Key = 'workbench.tasks.ranTaskBefore';
private static CustomizationTelemetryEventName: string = 'taskService.customize';
public static TemplateTelemetryEventName: string = 'taskService.template';
public _serviceBrand: any;
public static SERVICE_ID: string = 'taskService';
......@@ -1589,14 +1599,14 @@ class TaskService extends EventEmitter implements ITaskService {
return new ConfigureTaskRunnerAction(ConfigureTaskRunnerAction.ID, ConfigureTaskRunnerAction.TEXT, this,
this.configurationService, this.editorService, this.fileService, this.contextService,
this.outputService, this.messageService, this.quickOpenService, this.environmentService, this.configurationResolverService,
this.extensionService);
this.extensionService, this.telemetryService);
}
private configureBuildTask(): Action {
return new ConfigureBuildTaskAction(ConfigureBuildTaskAction.ID, ConfigureBuildTaskAction.TEXT, this,
this.configurationService, this.editorService, this.fileService, this.contextService,
this.outputService, this.messageService, this.quickOpenService, this.environmentService, this.configurationResolverService,
this.extensionService);
this.extensionService, this.telemetryService);
}
public beforeShutdown(): boolean | TPromise<boolean> {
......
......@@ -403,6 +403,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem {
let telemetryEvent: TelemetryEvent = {
trigger: trigger,
runner: 'terminal',
taskKind: Task.getTelemetryKind(task),
command: this.getSanitizedCommand(executedCommand),
success: true,
exitCode: summary.exitCode
......@@ -416,6 +417,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem {
let telemetryEvent: TelemetryEvent = {
trigger: trigger,
runner: 'terminal',
taskKind: Task.getTelemetryKind(task),
command: this.getSanitizedCommand(executedCommand),
success: false
};
......
......@@ -139,6 +139,7 @@ export class ProcessTaskSystem extends EventEmitter implements ITaskSystem {
let telemetryEvent: TelemetryEvent = {
trigger: trigger,
runner: 'output',
taskKind: Task.getTelemetryKind(task),
command: 'other',
success: true
};
......
......@@ -1286,7 +1286,7 @@ namespace CustomTask {
export function createCustomTask(contributedTask: Tasks.ContributedTask, configuredProps: Tasks.ConfigurationProperties & { _id: string, _source: Tasks.WorkspaceTaskSource }): Tasks.CustomTask {
let result: Tasks.CustomTask = {
_id: configuredProps._id,
_source: configuredProps._source,
_source: Objects.assign({}, configuredProps._source, { customizes: contributedTask.defines }),
_label: configuredProps.name || contributedTask._label,
type: 'custom',
command: contributedTask.command,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册