Add telemetry on TS refactoring usage

Needed to understand which type of refactorings are most used so we can decided which bugs to prioritize and which new refactoring areas to invest in
This commit is contained in:
Matt Bierner
2018-06-29 17:13:49 -07:00
parent dd9ef41d5c
commit 2f0b9394bc
2 changed files with 21 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ import { Command, CommandManager } from '../utils/commandManager';
import { VersionDependentRegistration } from '../utils/dependentRegistration';
import * as typeConverters from '../utils/typeConverters';
import FormattingOptionsManager from './fileConfigurationManager';
import TelemetryReporter from '../utils/telemetry';
class ApplyRefactoringCommand implements Command {
@@ -18,7 +19,8 @@ class ApplyRefactoringCommand implements Command {
public readonly id = ApplyRefactoringCommand.ID;
constructor(
private readonly client: ITypeScriptServiceClient
private readonly client: ITypeScriptServiceClient,
private readonly telemetryReporter: TelemetryReporter
) { }
public async execute(
@@ -28,6 +30,18 @@ class ApplyRefactoringCommand implements Command {
action: string,
range: vscode.Range
): Promise<boolean> {
/* __GDPR__
"refactor.execute" : {
"action" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
"${include}": [
"${TypeScriptCommonProperties}"
]
}
*/
this.telemetryReporter.logTelemetry('refactor.execute', {
action: action
});
const args: Proto.GetEditsForRefactorRequestArgs = {
...typeConverters.Range.toFileRangeRequestArgs(file, range),
refactor,
@@ -97,9 +111,10 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
constructor(
private readonly client: ITypeScriptServiceClient,
private readonly formattingOptionsManager: FormattingOptionsManager,
commandManager: CommandManager
commandManager: CommandManager,
telemetryReporter: TelemetryReporter
) {
const doRefactoringCommand = commandManager.register(new ApplyRefactoringCommand(this.client));
const doRefactoringCommand = commandManager.register(new ApplyRefactoringCommand(this.client, telemetryReporter));
commandManager.register(new SelectRefactorCommand(doRefactoringCommand));
}
@@ -204,10 +219,11 @@ export function register(
client: ITypeScriptServiceClient,
formattingOptionsManager: FormattingOptionsManager,
commandManager: CommandManager,
telemetryReporter: TelemetryReporter,
) {
return new VersionDependentRegistration(client, API.v240, () => {
return vscode.languages.registerCodeActionsProvider(selector,
new TypeScriptRefactorProvider(client, formattingOptionsManager, commandManager),
new TypeScriptRefactorProvider(client, formattingOptionsManager, commandManager, telemetryReporter),
TypeScriptRefactorProvider.metadata);
});
}

View File

@@ -86,7 +86,7 @@ export default class LanguageProvider {
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/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.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));
this.disposables.push((await import('./features/referencesCodeLens')).register(selector, this.description.id, this.client, cachedResponse));
this.disposables.push((await import('./features/rename')).register(selector, this.client));