-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX (Extension) @W-16733527@ Additional telemetry for apex guru #139
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,16 @@ export async function activate(context: vscode.ExtensionContext): Promise<vscode | |
outputChannel: outputChannel | ||
}); | ||
}); | ||
context.subscriptions.push(runApexGuruOnSelectedFile, runApexGuruOnCurrentFile); | ||
const insertApexGuruSuggestions = vscode.commands.registerCommand(Constants.COMMAND_INCLUDE_APEX_GURU_SUGGESTIONS, async (document: vscode.TextDocument, position: vscode.Position, suggestedCode: string) => { | ||
const edit = new vscode.WorkspaceEdit(); | ||
edit.insert(document.uri, position, suggestedCode); | ||
await vscode.workspace.applyEdit(edit); | ||
TelemetryService.sendCommandEvent(Constants.TELEM_SUCCESSFUL_APEX_GURU_FILE_ANALYSIS, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New telemetry to get number of times users used the suggestions ApexGuru provided, along with the number of lines that were included. |
||
executedCommand: Constants.COMMAND_INCLUDE_APEX_GURU_SUGGESTIONS, | ||
lines: suggestedCode.split('\n').length.toString() | ||
}); | ||
}) | ||
context.subscriptions.push(runApexGuruOnSelectedFile, runApexGuruOnCurrentFile, insertApexGuruSuggestions); | ||
} | ||
|
||
if (SettingsManager.getSfgeDeltaRunsEnabled()) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,14 +111,14 @@ export class _ApexGuruFixGenerator extends FixGenerator { | |
|
||
const action = new vscode.CodeAction(messages.fixer.fixWithApexGuruSuggestions, vscode.CodeActionKind.QuickFix); | ||
action.diagnostics = [this.diagnostic]; | ||
|
||
const edit = new vscode.WorkspaceEdit(); | ||
const range = this.diagnostic.range; // Assuming the range is the location of the existing code in the document | ||
const diagnosticStartLine = new vscode.Position(range.start.line, range.start.character); | ||
edit.insert(document.uri, diagnosticStartLine, suggestedCode + '\n'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I do this, there is no way to get the telemetry on how many times users clicked on the "include apex guru suggestions" quick-fix. I had to to make this a command and add it to the action and I can report telemetry on that command. |
||
|
||
// Assign the edit to the action | ||
action.edit = edit; | ||
|
||
action.command = { | ||
title: 'Apply ApexGuru Fix', | ||
command: Constants.COMMAND_INCLUDE_APEX_GURU_SUGGESTIONS, | ||
arguments: [document, diagnosticStartLine, suggestedCode + '\n'] | ||
} | ||
|
||
return action; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
violationsWithSuggestedCodeCount
to matchviolationsCount
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! that sounds better. I'll rename it.