diff --git a/CHANGELOG.md b/CHANGELOG.md index aa3ade33e..a823d1896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - New error message in UI when net new scan is done on an invalid repository. Net new scans only work on Git. - Clear in Memory cache when branch is changed. - Added Clear Persisted Cache command. +- Add support for ai fix feedback analytic when pressing apply on a fix. ## [2.18.2] - Update Language Server Protocol version to 15. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 879704451..382ef7b3b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,13 +25,15 @@ Code changes require extension reload when run in debug. ## Run tests and debug - Unit tests - - Run `npm run test:unit` for a single execution, `npm run test:unit:watch` to watch for changes. - Make sure to re-run the command to pick up new files, if new `**.test.ts` is added. - Integration tests - Run `npm run test:integration`. +- Run Lint + - npm `npm run lint` + You can debug tests via VS Code debugger, selecting "Extension Unit Tests" or "Extension Integration Tests" respectively. ## Analytics, experimentation and error reporting diff --git a/src/snyk/common/constants/commands.ts b/src/snyk/common/constants/commands.ts index ab6bdc05a..ae2aca170 100644 --- a/src/snyk/common/constants/commands.ts +++ b/src/snyk/common/constants/commands.ts @@ -25,6 +25,7 @@ export const SNYK_WORKSPACE_SCAN_COMMAND = 'snyk.workspace.scan'; export const SNYK_TRUST_WORKSPACE_FOLDERS_COMMAND = 'snyk.trustWorkspaceFolders'; export const SNYK_GET_ACTIVE_USER = 'snyk.getActiveUser'; export const SNYK_CODE_FIX_DIFFS_COMMAND = 'snyk.code.fixDiffs'; +export const SNYK_CODE_SUBMIT_FIX_FEEDBACK = 'snyk.code.submitFixFeedback'; export const SNYK_FEATURE_FLAG_COMMAND = 'snyk.getFeatureFlagStatus'; export const SNYK_CLEAR_CACHE_COMMAND = 'snyk.clearCache'; export const SNYK_CLEAR_PERSISTED_CACHE_COMMAND = 'snyk.clearPersistedCache'; diff --git a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts index f7465562a..30beb4d22 100644 --- a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts +++ b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts @@ -6,6 +6,7 @@ import * as vscode from 'vscode'; import { SNYK_CODE_FIX_DIFFS_COMMAND, SNYK_GENERATE_ISSUE_DESCRIPTION, + SNYK_CODE_SUBMIT_FIX_FEEDBACK, SNYK_IGNORE_ISSUE_COMMAND, SNYK_OPEN_BROWSER_COMMAND, SNYK_OPEN_LOCAL_COMMAND, @@ -273,7 +274,7 @@ export class CodeSuggestionWebviewProvider } case 'applyGitDiff': { - const { patch, filePath } = message.args; + const { patch, filePath, fixId } = message.args; const fileContent = readFileSync(filePath, 'utf8'); const patchedContent = applyPatch(fileContent, patch); @@ -300,6 +301,11 @@ export class CodeSuggestionWebviewProvider this.highlightAddedCode(filePath, patch); this.setupCloseOnSave(filePath); + try { + await vscode.commands.executeCommand(SNYK_CODE_SUBMIT_FIX_FEEDBACK, fixId, 'FIX_APPLIED'); + } catch (e) { + throw new Error('Error in submit fix feedback'); + } break; } diff --git a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts index a9fae44c0..05f124324 100644 --- a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts +++ b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScriptLS.ts @@ -87,6 +87,7 @@ args: { patch: string; filePath: string; + fixId: string; }; }; @@ -244,10 +245,11 @@ const diffSuggestion = suggestion.diffs[diffSelectedIndex]; const filePath = suggestion.filePath; const patch = diffSuggestion.unifiedDiffsPerFile[filePath]; + const fixId = suggestion.id; const message: ApplyGitDiffMessage = { type: 'applyGitDiff', - args: { filePath, patch }, + args: { filePath, patch, fixId }, }; sendMessage(message); } diff --git a/src/snyk/snykCode/views/suggestion/types.ts b/src/snyk/snykCode/views/suggestion/types.ts index b814679c1..6c89d6379 100644 --- a/src/snyk/snykCode/views/suggestion/types.ts +++ b/src/snyk/snykCode/views/suggestion/types.ts @@ -64,6 +64,7 @@ export type ApplyGitDiffMessage = { args: { patch: string; filePath: string; + fixId: string; }; };