Add telemetry on organize imports

This is needed to understand if users are running this action and how we can improve discoverablity
This commit is contained in:
Matt Bierner
2018-07-16 13:00:25 -07:00
parent cbcafcc284
commit f5c36f4bb8
2 changed files with 19 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ import { Command, CommandManager } from '../utils/commandManager';
import { VersionDependentRegistration } from '../utils/dependentRegistration';
import * as typeconverts from '../utils/typeConverters';
import FileConfigurationManager from './fileConfigurationManager';
import TelemetryReporter from '../utils/telemetry';
const localize = nls.loadMessageBundle();
@@ -22,10 +23,20 @@ class OrganizeImportsCommand implements Command {
public readonly id = OrganizeImportsCommand.Id;
constructor(
private readonly client: ITypeScriptServiceClient
private readonly client: ITypeScriptServiceClient,
private readonly telemetryReporter: TelemetryReporter,
) { }
public async execute(file: string): Promise<boolean> {
/* __GDPR__
"organizeImports.execute" : {
"${include}": [
"${TypeScriptCommonProperties}"
]
}
*/
this.telemetryReporter.logTelemetry('organizeImports.execute', {});
const args: Proto.OrganizeImportsRequestArgs = {
scope: {
type: 'file',
@@ -49,8 +60,10 @@ export class OrganizeImportsCodeActionProvider implements vscode.CodeActionProvi
private readonly client: ITypeScriptServiceClient,
commandManager: CommandManager,
private readonly fileConfigManager: FileConfigurationManager,
telemetryReporter: TelemetryReporter,
) {
commandManager.register(new OrganizeImportsCommand(client));
commandManager.register(new OrganizeImportsCommand(client, telemetryReporter));
}
public readonly metadata: vscode.CodeActionProviderMetadata = {
@@ -82,10 +95,11 @@ export function register(
selector: vscode.DocumentSelector,
client: ITypeScriptServiceClient,
commandManager: CommandManager,
fileConfigurationManager: FileConfigurationManager
fileConfigurationManager: FileConfigurationManager,
telemetryReporter: TelemetryReporter,
) {
return new VersionDependentRegistration(client, API.v280, () => {
const organizeImportsProvider = new OrganizeImportsCodeActionProvider(client, commandManager, fileConfigurationManager);
const organizeImportsProvider = new OrganizeImportsCodeActionProvider(client, commandManager, fileConfigurationManager, telemetryReporter);
return vscode.languages.registerCodeActionsProvider(selector,
organizeImportsProvider,
organizeImportsProvider.metadata);

View File

@@ -84,7 +84,7 @@ export default class LanguageProvider {
this.disposables.push((await import('./features/implementations')).register(selector, this.client));
this.disposables.push((await import('./features/implementationsCodeLens')).register(selector, this.description.id, this.client, cachedResponse));
this.disposables.push((await import('./features/jsDocCompletions')).register(selector, this.client, this.commandManager));
this.disposables.push((await import('./features/organizeImports')).register(selector, this.client, this.commandManager, this.fileConfigurationManager));
this.disposables.push((await import('./features/organizeImports')).register(selector, this.client, this.commandManager, this.fileConfigurationManager, this.telemetryReporter));
this.disposables.push((await import('./features/quickFix')).register(selector, this.client, this.fileConfigurationManager, this.commandManager, this.diagnosticsManager, this.telemetryReporter));
this.disposables.push((await import('./features/refactor')).register(selector, this.client, this.fileConfigurationManager, this.commandManager, this.telemetryReporter));
this.disposables.push((await import('./features/references')).register(selector, this.client));