Skip to content

Commit bfcec27

Browse files
authored
Merge pull request #4457 from leigaol/q_startUrl
AmazonQ: Add start url to more telemetry events of Amazon Q
2 parents b05213b + b335770 commit bfcec27

File tree

6 files changed

+152
-5
lines changed

6 files changed

+152
-5
lines changed

packages/toolkit/src/amazonqFeatureDev/controllers/chat/controller.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { featureName } from '../../constants'
1818
import { ChatSessionStorage } from '../../storages/chatSession'
1919
import { FollowUpTypes, SessionStatePhase } from '../../types'
2020
import { Messenger } from './messenger/messenger'
21-
import { getChatAuthState } from '../../../codewhisperer/util/authUtil'
21+
import { AuthUtil, getChatAuthState } from '../../../codewhisperer/util/authUtil'
2222
import { AuthController } from '../../../amazonq/auth/controller'
2323
import { getLogger } from '../../../shared/logger'
2424
import { submitFeedback } from '../../../feedback/vue/submitFeedback'
@@ -117,12 +117,14 @@ export class FeatureDevController {
117117
amazonqConversationId: session?.conversationId,
118118
value: 1,
119119
result: 'Succeeded',
120+
credentialStartUrl: AuthUtil.instance.startUrl,
120121
})
121122
} else if (vote === 'downvote') {
122123
telemetry.amazonq_approachThumbsDown.emit({
123124
amazonqConversationId: session?.conversationId,
124125
value: 1,
125126
result: 'Succeeded',
127+
credentialStartUrl: AuthUtil.instance.startUrl,
126128
})
127129
}
128130
break
@@ -358,6 +360,7 @@ export class FeatureDevController {
358360
amazonqConversationId: session.conversationId,
359361
enabled: true,
360362
result: 'Succeeded',
363+
credentialStartUrl: AuthUtil.instance.startUrl,
361364
})
362365

363366
if (message.deleted) {
@@ -421,6 +424,7 @@ export class FeatureDevController {
421424
amazonqConversationId: session.conversationId,
422425
amazonqEndOfTheConversationLatency: performance.now() - session.telemetry.sessionStartTime,
423426
result: 'Succeeded',
427+
credentialStartUrl: AuthUtil.instance.startUrl,
424428
})
425429

426430
// Old session for the tab is ending, delete it so we can create a new one for the message id

packages/toolkit/src/amazonqFeatureDev/session/session.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { approachRetryLimit } from '../limits'
1313
import { SessionConfig } from './sessionConfigFactory'
1414
import { telemetry } from '../../shared/telemetry/telemetry'
1515
import { TelemetryHelper } from '../util/telemetryHelper'
16+
import { AuthUtil } from '../../codewhisperer/util/authUtil'
1617

1718
export class Session {
1819
private _state?: SessionState | Omit<SessionState, 'uploadId'>
@@ -55,6 +56,7 @@ export class Session {
5556
amazonqConversationId: this.conversationId,
5657
value: 1,
5758
result: 'Succeeded',
59+
credentialStartUrl: AuthUtil.instance.startUrl,
5860
})
5961

6062
this.messenger.sendAsyncEventProgress(this.tabID, true, undefined)
@@ -72,7 +74,7 @@ export class Session {
7274

7375
await telemetry.amazonq_startConversationInvoke.run(async span => {
7476
this._conversationId = await this.proxyClient.createConversation()
75-
span.record({ amazonqConversationId: this._conversationId })
77+
span.record({ amazonqConversationId: this._conversationId, credentialStartUrl: AuthUtil.instance.startUrl })
7678
})
7779

7880
this._state = new PrepareRefinementState(

packages/toolkit/src/amazonqFeatureDev/session/sessionState.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { SessionState, SessionStateAction, SessionStateConfig, SessionStateInter
1212
import { prepareRepoData } from '../util/files'
1313
import { uploadCode } from '../util/upload'
1414
import { encodeHTML } from '../../shared/utilities/textUtilities'
15+
import { AuthUtil } from '../../codewhisperer/util/authUtil'
1516

1617
export class ConversationNotStartedState implements Omit<SessionState, 'uploadId'> {
1718
public tokenSource: vscode.CancellationTokenSource
@@ -35,7 +36,10 @@ export class PrepareRefinementState implements Omit<SessionState, 'uploadId'> {
3536
}
3637
async interact(action: SessionStateAction): Promise<SessionStateInteraction> {
3738
const uploadId = await telemetry.amazonq_createUpload.run(async span => {
38-
span.record({ amazonqConversationId: this.config.conversationId })
39+
span.record({
40+
amazonqConversationId: this.config.conversationId,
41+
credentialStartUrl: AuthUtil.instance.startUrl,
42+
})
3943
const { zipFileBuffer, zipFileChecksum } = await prepareRepoData(
4044
this.config.sourceRoot,
4145
action.telemetry,
@@ -77,7 +81,10 @@ export class RefinementState implements SessionState {
7781
async interact(action: SessionStateAction): Promise<SessionStateInteraction> {
7882
return telemetry.amazonq_approachInvoke.run(async span => {
7983
try {
80-
span.record({ amazonqConversationId: this.conversationId })
84+
span.record({
85+
amazonqConversationId: this.conversationId,
86+
credentialStartUrl: AuthUtil.instance.startUrl,
87+
})
8188
action.telemetry.setGenerateApproachIteration(this.currentIteration)
8289
action.telemetry.setGenerateApproachLastInvocationTime()
8390
if (!action.msg) {

packages/toolkit/src/codewhisperer/tracker/codewhispererTracker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export class CodeWhispererTracker {
105105
cwsprChatConversationId: suggestion.conversationID,
106106
cwsprChatMessageId: suggestion.messageID,
107107
cwsprChatModificationPercentage: percentage ? percentage : 0,
108+
credentialStartUrl: AuthUtil.instance.startUrl,
108109
}
109110

110111
telemetry.amazonq_modifyCode.emit(event)

packages/toolkit/src/codewhispererChat/controllers/chat/telemetryHelper.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ export function logSendTelemetryEventFailure(error: any) {
5050
}
5151

5252
export function recordTelemetryChatRunCommand(type: CwsprChatCommandType, command?: string) {
53-
telemetry.amazonq_runCommand.emit({ cwsprChatCommandType: type, cwsprChatCommandName: command })
53+
telemetry.amazonq_runCommand.emit({
54+
cwsprChatCommandType: type,
55+
cwsprChatCommandName: command,
56+
credentialStartUrl: AuthUtil.instance.startUrl,
57+
})
5458
}
5559

5660
export class CWCTelemetryHelper {
@@ -293,6 +297,7 @@ export class CWCTelemetryHelper {
293297
cwsprChatUserIntent: telemetryUserIntent,
294298
cwsprChatHasCodeSnippet: triggerPayload.codeSelection && !triggerPayload.codeSelection.isEmpty,
295299
cwsprChatProgrammingLanguage: triggerPayload.fileLanguage,
300+
credentialStartUrl: AuthUtil.instance.startUrl,
296301
})
297302
}
298303

@@ -319,6 +324,7 @@ export class CWCTelemetryHelper {
319324
cwsprChatRequestLength: triggerPayload.message?.length ?? 0,
320325
cwsprChatResponseLength: message.messageLength,
321326
cwsprChatConversationType: 'Chat',
327+
credentialStartUrl: AuthUtil.instance.startUrl,
322328
}
323329

324330
telemetry.amazonq_addMessage.emit(event)
@@ -360,6 +366,7 @@ export class CWCTelemetryHelper {
360366
cwsprChatResponseCode: responseCode,
361367
cwsprChatRequestLength: triggerPayload.message?.length ?? 0,
362368
cwsprChatConversationType: 'Chat',
369+
credentialStartUrl: AuthUtil.instance.startUrl,
363370
})
364371
}
365372

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

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,132 @@
861861
{
862862
"type": "cwsprChatCommandName",
863863
"required": false
864+
},
865+
{
866+
"type": "credentialStartUrl",
867+
"required": false
868+
}
869+
]
870+
},
871+
{
872+
"name": "amazonq_codeGenerationThumbsUp",
873+
"description": "User clicked on the thumbs up button to say that they are unsatisfied",
874+
"unit": "Count",
875+
"metadata": [
876+
{ "type": "amazonqConversationId" },
877+
{
878+
"type": "credentialStartUrl",
879+
"required": false
880+
}
881+
]
882+
},
883+
{
884+
"name": "amazonq_codeGenerationThumbsDown",
885+
"description": "User clicked on the thumbs down button to say that they are unsatisfied",
886+
"unit": "Count",
887+
"metadata": [
888+
{ "type": "amazonqConversationId" },
889+
{
890+
"type": "credentialStartUrl",
891+
"required": false
892+
}
893+
]
894+
},
895+
{
896+
"name": "amazonq_approachThumbsUp",
897+
"description": "User clicked on the thumbs up button, to mention that they are satisfied",
898+
"unit": "Count",
899+
"metadata": [
900+
{ "type": "amazonqConversationId" },
901+
{
902+
"type": "credentialStartUrl",
903+
"required": false
904+
}
905+
]
906+
},
907+
{
908+
"name": "amazonq_approachThumbsDown",
909+
"description": "User clicked on the thumbs down button to say that they are unsatisfied",
910+
"unit": "Count",
911+
"metadata": [
912+
{ "type": "amazonqConversationId" },
913+
{
914+
"type": "credentialStartUrl",
915+
"required": false
916+
}
917+
]
918+
},
919+
{
920+
"name": "amazonq_isReviewedChanges",
921+
"description": "User reviewed changes",
922+
"passive": true,
923+
"metadata": [
924+
{ "type": "enabled" },
925+
{ "type": "amazonqConversationId" },
926+
{
927+
"type": "credentialStartUrl",
928+
"required": false
929+
}
930+
]
931+
},
932+
933+
{
934+
"name": "amazonq_startChat",
935+
"description": "Number of times the user have triggered /dev and started the chat",
936+
"unit": "Count",
937+
"metadata": [
938+
{ "type": "amazonqConversationId" },
939+
{
940+
"type": "credentialStartUrl",
941+
"required": false
942+
}
943+
]
944+
},
945+
{
946+
"name": "amazonq_endChat",
947+
"description": "Captures end of the conversation with amazonq /dev",
948+
"metadata": [
949+
{ "type": "amazonqConversationId" },
950+
{ "type": "amazonqEndOfTheConversationLatency", "required": false },
951+
{
952+
"type": "credentialStartUrl",
953+
"required": false
954+
}
955+
]
956+
},
957+
{
958+
"name": "amazonq_approachInvoke",
959+
"description": "Captures Approach generation process",
960+
"metadata": [
961+
{ "type": "amazonqConversationId" },
962+
{ "type": "amazonqGenerateApproachIteration" },
963+
{ "type": "amazonqGenerateApproachLatency" },
964+
{
965+
"type": "credentialStartUrl",
966+
"required": false
967+
}
968+
]
969+
},
970+
{
971+
"name": "amazonq_startConversationInvoke",
972+
"description": "Captures startConversation invocation process",
973+
"metadata": [
974+
{ "type": "amazonqConversationId", "required": false },
975+
{
976+
"type": "credentialStartUrl",
977+
"required": false
978+
}
979+
]
980+
},
981+
{
982+
"name": "amazonq_createUpload",
983+
"description": "Captures createUploadUrl invocation process",
984+
"metadata": [
985+
{ "type": "amazonqConversationId" },
986+
{ "type": "amazonqRepositorySize", "required": false },
987+
{
988+
"type": "credentialStartUrl",
989+
"required": false
864990
}
865991
]
866992
}

0 commit comments

Comments
 (0)