Skip to content

Commit f896178

Browse files
authored
fix(codewhisperer): remove hardcoded telemetry metric #4098
1 parent cce77a2 commit f896178

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/codewhisperer/commands/startSecurityScan.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export async function startSecurityScan(
183183
codeScanTelemetryEntry.codewhispererCodeScanTotalIssues = total
184184
codeScanTelemetryEntry.codewhispererCodeScanIssuesWithFixes = withFixes
185185
throwIfCancelled()
186-
getLogger().verbose(`Security scan totally found ${total} issues.`)
186+
getLogger().verbose(`Security scan totally found ${total} issues. ${withFixes} of them have fixes.`)
187187
if (isCloud9()) {
188188
securityPanelViewProvider.addLines(securityRecommendationCollection, editor)
189189
vscode.commands.executeCommand('workbench.view.extension.aws-codewhisperer-security-panel')
@@ -235,8 +235,7 @@ export async function emitCodeScanTelemetry(editor: vscode.TextEditor, codeScanT
235235
)
236236
codeScanTelemetryEntry.codewhispererCodeScanProjectBytes = projectSize
237237
}
238-
// TODO: should be removed. Added this to pass tests
239-
telemetry.codewhisperer_securityScan.emit({ ...codeScanTelemetryEntry, codewhispererCodeScanIssuesWithFixes: 1 })
238+
telemetry.codewhisperer_securityScan.emit(codeScanTelemetryEntry)
240239
}
241240

242241
export function errorPromptHelper(error: Error) {

src/test/codewhisperer/commands/startSecurityScan.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { FakeExtensionContext } from '../../fakeExtensionContext'
1414
import * as diagnosticsProvider from '../../../codewhisperer/service/diagnosticsProvider'
1515
import { getTestWorkspaceFolder } from '../../../testInteg/integrationTestsUtilities'
1616
import { join } from 'path'
17-
import { closeAllEditors } from '../../testUtil'
17+
import { assertTelemetry, closeAllEditors } from '../../testUtil'
1818
import { stub } from '../../utilities/stubber'
1919
import { HttpResponse } from 'aws-sdk'
2020
import { getTestWindow } from '../../shared/vscode/window'
@@ -27,6 +27,7 @@ import {
2727
stopScanMessage,
2828
} from '../../../codewhisperer/models/constants'
2929
import * as model from '../../../codewhisperer/models/model'
30+
import { CodewhispererSecurityScan } from '../../../shared/telemetry/telemetry.gen'
3031

3132
const mockCreateCodeScanResponse = {
3233
$response: {
@@ -265,5 +266,11 @@ describe('startSecurityScan', function () {
265266
extensionContext
266267
)
267268
assert.ok(commandSpy.calledWith(codeScanLogsOutputChannelId))
269+
assertTelemetry('codewhisperer_securityScan', {
270+
codewhispererLanguage: 'python',
271+
codewhispererCodeScanTotalIssues: 1,
272+
codewhispererCodeScanIssuesWithFixes: 0,
273+
codewhispererCodeScanLines: 188,
274+
} as CodewhispererSecurityScan)
268275
})
269276
})

0 commit comments

Comments
 (0)