mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
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:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user