Skip to content

Commit e16237f

Browse files
authored
Merge branch 'aws:master' into master
2 parents 5ec7329 + 643ae10 commit e16237f

File tree

10 files changed

+13
-256
lines changed

10 files changed

+13
-256
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "/review: Invalid file path characters caused some detections to be skipped on Windows"
4+
}

packages/amazonq/test/e2e/amazonq/testGen.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,12 @@ describe('Amazon Q Test Generation', function () {
194194
const viewDiffMessage = chatItems[5]
195195

196196
assert.deepStrictEqual(viewDiffMessage.type, 'answer')
197-
assert.deepStrictEqual(
198-
viewDiffMessage.body,
197+
const expectedEnding =
199198
'Please see the unit tests generated below. Click “View diff” to review the changes in the code editor.'
199+
assert.strictEqual(
200+
viewDiffMessage.body?.includes(expectedEnding),
201+
true,
202+
`View diff message does not contain phrase: ${expectedEnding}`
200203
)
201204
})
202205
})

packages/amazonq/test/unit/codewhisperer/commands/onAcceptance.test.ts

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,8 @@
66
import assert from 'assert'
77
import * as vscode from 'vscode'
88
import * as sinon from 'sinon'
9-
import {
10-
onAcceptance,
11-
AcceptedSuggestionEntry,
12-
session,
13-
CodeWhispererTracker,
14-
RecommendationHandler,
15-
AuthUtil,
16-
} from 'aws-core-vscode/codewhisperer'
9+
import { onAcceptance, AcceptedSuggestionEntry, session, CodeWhispererTracker } from 'aws-core-vscode/codewhisperer'
1710
import { resetCodeWhispererGlobalVariables, createMockTextEditor } from 'aws-core-vscode/test'
18-
import { assertTelemetryCurried } from 'aws-core-vscode/test'
1911

2012
describe('onAcceptance', function () {
2113
describe('onAcceptance', function () {
@@ -68,46 +60,5 @@ describe('onAcceptance', function () {
6860
assert.deepStrictEqual(actualArg.endPosition, new vscode.Position(1, 26))
6961
assert.strictEqual(actualArg.index, 0)
7062
})
71-
72-
it('Should report telemetry that records this user decision event', async function () {
73-
const testStartUrl = 'testStartUrl'
74-
sinon.stub(AuthUtil.instance, 'startUrl').value(testStartUrl)
75-
const mockEditor = createMockTextEditor()
76-
session.requestIdList = ['test']
77-
RecommendationHandler.instance.requestId = 'test'
78-
session.sessionId = 'test'
79-
session.startPos = new vscode.Position(1, 0)
80-
mockEditor.selection = new vscode.Selection(new vscode.Position(1, 0), new vscode.Position(1, 0))
81-
session.recommendations = [{ content: "print('Hello World!')" }]
82-
session.setSuggestionState(0, 'Showed')
83-
session.triggerType = 'OnDemand'
84-
session.setCompletionType(0, session.recommendations[0])
85-
const assertTelemetry = assertTelemetryCurried('codewhisperer_userDecision')
86-
await onAcceptance({
87-
editor: mockEditor,
88-
range: new vscode.Range(new vscode.Position(1, 0), new vscode.Position(1, 21)),
89-
effectiveRange: new vscode.Range(new vscode.Position(1, 0), new vscode.Position(1, 26)),
90-
acceptIndex: 0,
91-
recommendation: "print('Hello World!')",
92-
requestId: '',
93-
sessionId: '',
94-
triggerType: 'OnDemand',
95-
completionType: 'Line',
96-
language: 'python',
97-
references: undefined,
98-
})
99-
assertTelemetry({
100-
codewhispererRequestId: 'test',
101-
codewhispererSessionId: 'test',
102-
codewhispererPaginationProgress: 1,
103-
codewhispererTriggerType: 'OnDemand',
104-
codewhispererSuggestionIndex: 0,
105-
codewhispererSuggestionState: 'Accept',
106-
codewhispererSuggestionReferenceCount: 0,
107-
codewhispererCompletionType: 'Line',
108-
codewhispererLanguage: 'python',
109-
credentialStartUrl: testStartUrl,
110-
})
111-
})
11263
})
11364
})

packages/amazonq/test/unit/codewhisperer/commands/onInlineAcceptance.test.ts

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import assert from 'assert'
77
import * as vscode from 'vscode'
88
import * as sinon from 'sinon'
99
import { resetCodeWhispererGlobalVariables, createMockTextEditor } from 'aws-core-vscode/test'
10-
import { assertTelemetryCurried } from 'aws-core-vscode/test'
11-
import { onInlineAcceptance, RecommendationHandler, AuthUtil, session } from 'aws-core-vscode/codewhisperer'
12-
import { globals } from 'aws-core-vscode/shared'
13-
import { extensionVersion } from 'aws-core-vscode/shared'
10+
import { onInlineAcceptance, RecommendationHandler, session } from 'aws-core-vscode/codewhisperer'
1411

1512
describe('onInlineAcceptance', function () {
1613
describe('onInlineAcceptance', function () {
@@ -42,51 +39,5 @@ describe('onInlineAcceptance', function () {
4239
})
4340
assert.ok(spy.calledWith())
4441
})
45-
46-
it('Should report telemetry that records this user decision event', async function () {
47-
await globals.globalState.update('CODEWHISPERER_USER_GROUP', {
48-
version: extensionVersion,
49-
})
50-
51-
const testStartUrl = 'testStartUrl'
52-
sinon.stub(AuthUtil.instance, 'startUrl').value(testStartUrl)
53-
const mockEditor = createMockTextEditor()
54-
session.requestIdList = ['test']
55-
RecommendationHandler.instance.requestId = 'test'
56-
session.requestIdList = ['test']
57-
session.sessionId = 'test'
58-
session.startPos = new vscode.Position(1, 0)
59-
mockEditor.selection = new vscode.Selection(new vscode.Position(1, 0), new vscode.Position(1, 0))
60-
session.recommendations = [{ content: "print('Hello World!')" }]
61-
session.setSuggestionState(0, 'Showed')
62-
session.triggerType = 'OnDemand'
63-
session.setCompletionType(0, session.recommendations[0])
64-
const assertTelemetry = assertTelemetryCurried('codewhisperer_userDecision')
65-
await onInlineAcceptance({
66-
editor: mockEditor,
67-
range: new vscode.Range(new vscode.Position(1, 0), new vscode.Position(1, 21)),
68-
effectiveRange: new vscode.Range(new vscode.Position(1, 0), new vscode.Position(1, 21)),
69-
acceptIndex: 0,
70-
recommendation: "print('Hello World!')",
71-
requestId: '',
72-
sessionId: '',
73-
triggerType: 'OnDemand',
74-
completionType: 'Line',
75-
language: 'python',
76-
references: undefined,
77-
})
78-
assertTelemetry({
79-
codewhispererRequestId: 'test',
80-
codewhispererSessionId: 'test',
81-
codewhispererPaginationProgress: 1,
82-
codewhispererTriggerType: 'OnDemand',
83-
codewhispererSuggestionIndex: 0,
84-
codewhispererSuggestionState: 'Accept',
85-
codewhispererSuggestionReferenceCount: 0,
86-
codewhispererCompletionType: 'Line',
87-
codewhispererLanguage: 'python',
88-
credentialStartUrl: testStartUrl,
89-
})
90-
})
9142
})
9243
})

packages/amazonq/test/unit/codewhisperer/service/recommendationHandler.test.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -150,41 +150,6 @@ describe('recommendationHandler', function () {
150150
codewhispererSupplementalContextLength: 100,
151151
})
152152
})
153-
154-
it('should call telemetry function that records a Empty userDecision event', async function () {
155-
const mockServerResult = {
156-
recommendations: [],
157-
nextToken: '',
158-
$response: {
159-
requestId: 'test_request_empty',
160-
httpResponse: {
161-
headers: {
162-
'x-amzn-sessionid': 'test_request_empty',
163-
},
164-
},
165-
},
166-
}
167-
const handler = new RecommendationHandler()
168-
sinon.stub(handler, 'getServerResponse').resolves(mockServerResult)
169-
sinon.stub(performance, 'now').returns(0.0)
170-
session.startPos = new vscode.Position(1, 0)
171-
session.requestIdList = ['test_request_empty']
172-
session.startCursorOffset = 2
173-
await handler.getRecommendations(mockClient, mockEditor, 'AutoTrigger', config, 'Enter')
174-
const assertTelemetry = assertTelemetryCurried('codewhisperer_userDecision')
175-
assertTelemetry({
176-
codewhispererRequestId: 'test_request_empty',
177-
codewhispererSessionId: 'test_request_empty',
178-
codewhispererPaginationProgress: 0,
179-
codewhispererTriggerType: 'AutoTrigger',
180-
codewhispererSuggestionIndex: -1,
181-
codewhispererSuggestionState: 'Empty',
182-
codewhispererSuggestionReferenceCount: 0,
183-
codewhispererCompletionType: 'Line',
184-
codewhispererLanguage: 'python',
185-
credentialStartUrl: testStartUrl,
186-
})
187-
})
188153
})
189154

190155
describe('isValidResponse', function () {

packages/amazonq/test/unit/codewhisperer/util/telemetryHelper.test.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -282,41 +282,4 @@ describe('telemetryHelper', function () {
282282
assert.strictEqual(actual, 'Empty')
283283
})
284284
})
285-
286-
describe('recordUserDecisionTelemetry', function () {
287-
beforeEach(async function () {
288-
await resetCodeWhispererGlobalVariables()
289-
})
290-
291-
it('Should call telemetry record for each recommendations with proper arguments', async function () {
292-
const telemetryHelper = new TelemetryHelper()
293-
const response = [{ content: "print('Hello')" }]
294-
const requestIdList = ['test_x', 'test_x', 'test_y']
295-
const sessionId = 'test_x'
296-
session.triggerType = 'AutoTrigger'
297-
const assertTelemetry = assertTelemetryCurried('codewhisperer_userDecision')
298-
const suggestionState = new Map<number, string>([[0, 'Showed']])
299-
const completionTypes = new Map<number, CodewhispererCompletionType>([[0, 'Line']])
300-
telemetryHelper.recordUserDecisionTelemetry(
301-
requestIdList,
302-
sessionId,
303-
response,
304-
0,
305-
0,
306-
completionTypes,
307-
suggestionState
308-
)
309-
assertTelemetry({
310-
codewhispererRequestId: 'test_x',
311-
codewhispererSessionId: 'test_x',
312-
codewhispererPaginationProgress: 0,
313-
codewhispererTriggerType: 'AutoTrigger',
314-
codewhispererSuggestionIndex: 0,
315-
codewhispererSuggestionState: 'Accept',
316-
codewhispererSuggestionReferenceCount: 0,
317-
codewhispererCompletionType: 'Line',
318-
codewhispererLanguage: 'python',
319-
})
320-
})
321-
})
322285
})

packages/core/src/codewhisperer/util/telemetryHelper.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -161,25 +161,6 @@ export class TelemetryHelper {
161161
) {
162162
const selectedCustomization = getSelectedCustomization()
163163

164-
telemetry.codewhisperer_userDecision.emit({
165-
codewhispererCompletionType: 'Line',
166-
codewhispererGettingStartedTask: session.taskType,
167-
codewhispererLanguage: language,
168-
codewhispererPaginationProgress: paginationIndex,
169-
codewhispererRequestId: requestIdList[0],
170-
codewhispererSessionId: sessionId ? sessionId : undefined,
171-
codewhispererSuggestionIndex: -1,
172-
codewhispererSuggestionState: 'Empty',
173-
codewhispererSuggestionReferenceCount: 0,
174-
codewhispererSuggestionReferences: undefined,
175-
codewhispererSupplementalContextIsUtg: supplementalContextMetadata?.isUtg,
176-
codewhispererSupplementalContextLength: supplementalContextMetadata?.contentsLength,
177-
codewhispererSupplementalContextTimeout: supplementalContextMetadata?.isProcessTimeout,
178-
codewhispererTriggerType: session.triggerType,
179-
credentialStartUrl: AuthUtil.instance.startUrl,
180-
traceId: this.traceId,
181-
})
182-
183164
telemetry.codewhisperer_userTriggerDecision.emit({
184165
codewhispererAutomatedTriggerType: session.autoTriggerType,
185166
codewhispererClassifierResult: this.classifierResult,
@@ -300,7 +281,6 @@ export class TelemetryHelper {
300281
credentialStartUrl: AuthUtil.instance.startUrl,
301282
traceId: this.traceId,
302283
}
303-
telemetry.codewhisperer_userDecision.emit(event)
304284
events.push(event)
305285
}
306286

packages/core/src/codewhisperer/util/zipUtil.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { FeatureUseCase } from '../models/constants'
2424
import { ChildProcess, ChildProcessOptions } from '../../shared/utilities/processUtils'
2525
import { ProjectZipError } from '../../amazonqTest/error'
2626
import { removeAnsi } from '../../shared/utilities/textUtilities'
27+
import { normalize } from '../../shared/utilities/pathUtils'
2728

2829
export interface ZipMetadata {
2930
rootDir: string
@@ -123,7 +124,7 @@ export class ZipUtil {
123124
zip.addFile(zipEntryPath, Buffer.from(content, 'utf-8'))
124125

125126
if (scope === CodeWhispererConstants.CodeAnalysisScope.FILE_ON_DEMAND) {
126-
const gitDiffContent = `+++ b/${path.normalize(zipEntryPath)}` // Sending file path in payload for LLM code review
127+
const gitDiffContent = `+++ b/${normalize(zipEntryPath)}` // Sending file path in payload for LLM code review
127128
zip.addFile(ZipConstants.codeDiffFilePath, Buffer.from(gitDiffContent, 'utf-8'))
128129
}
129130
} else {

packages/core/src/shared/telemetry/exemptMetrics.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const validationExemptMetrics: Set<string> = new Set([
2525
'codeTransform_jobStatusChanged',
2626
'codeTransform_logApiError',
2727
'codeTransform_logApiLatency',
28-
'codewhisperer_userDecision',
2928
'codewhisperer_codeScanIssueHover',
3029
'codewhisperer_codePercentage',
3130
'codewhisperer_userModification',

packages/core/src/shared/telemetry/vscodeTelemetry.json

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,6 @@
228228
"name": "executedCount",
229229
"type": "int",
230230
"description": "The number of executed operations"
231-
},
232-
{
233-
"name": "amazonqUploadIntent",
234-
"type": "string",
235-
"description": "The intent of the upload",
236-
"allowedValues": [
237-
"TRANSFORMATION",
238-
"TASK_ASSIST_PLANNING",
239-
"AUTOMATIC_FILE_SECURITY_SCAN",
240-
"FULL_PROJECT_SECURITY_SCAN"
241-
]
242231
}
243232
],
244233
"metrics": [
@@ -885,27 +874,6 @@
885874
}
886875
]
887876
},
888-
{
889-
"name": "amazonq_createUpload",
890-
"description": "Captures createUploadUrl invocation process",
891-
"metadata": [
892-
{
893-
"type": "amazonqConversationId"
894-
},
895-
{
896-
"type": "amazonqRepositorySize",
897-
"required": false
898-
},
899-
{
900-
"type": "amazonqUploadIntent",
901-
"required": false
902-
},
903-
{
904-
"type": "credentialStartUrl",
905-
"required": false
906-
}
907-
]
908-
},
909877
{
910878
"name": "ide_editCodeFile",
911879
"description": "User opened a code file with the given file extension. Client should DEDUPLICATE this metric (ideally hourly/daily). AWS-specific files should (also) emit `file_editAwsFile`.",
@@ -1158,34 +1126,6 @@
11581126
{
11591127
"name": "docdb_addRegion",
11601128
"description": "User clicked on add region command"
1161-
},
1162-
{
1163-
"name": "codewhisperer_codeScanIssueDetected",
1164-
"description": "Called when a code scan issue is returned from the service",
1165-
"metadata": [
1166-
{
1167-
"type": "autoDetected",
1168-
"required": false
1169-
},
1170-
{
1171-
"type": "codewhispererCodeScanJobId",
1172-
"required": false
1173-
},
1174-
{
1175-
"type": "detectorId"
1176-
},
1177-
{
1178-
"type": "findingId"
1179-
},
1180-
{
1181-
"type": "includesFix",
1182-
"required": false
1183-
},
1184-
{
1185-
"type": "ruleId",
1186-
"required": false
1187-
}
1188-
]
11891129
}
11901130
]
11911131
}

0 commit comments

Comments
 (0)