Skip to content

Commit 9151dce

Browse files
committed
correct the logic to send the telemetry
1 parent ca2c128 commit 9151dce

File tree

1 file changed

+78
-27
lines changed
  • plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller

1 file changed

+78
-27
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

Lines changed: 78 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -690,33 +690,6 @@ class CodeTestChatController(
690690
buildZipFileBytes = session.srcZipFileSize,
691691
requestId = session.startTestGenerationRequestId
692692
)
693-
} else {
694-
AmazonqTelemetry.unitTestGeneration(
695-
count = session.iteration.toLong() - 1,
696-
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
697-
hasUserPromptSupplied = session.hasUserPromptSupplied,
698-
isSupportedLanguage = true,
699-
credentialStartUrl = getStartUrl(project = context.project),
700-
jobGroup = session.testGenerationJobGroupName,
701-
jobId = session.testGenerationJob,
702-
acceptedCount = session.numberOfUnitTestCasesGenerated?.toLong(),
703-
generatedCount = session.numberOfUnitTestCasesGenerated?.toLong(),
704-
acceptedLinesCount = session.linesOfCodeGenerated?.toLong(),
705-
generatedLinesCount = session.linesOfCodeGenerated?.toLong(),
706-
acceptedCharactersCount = session.charsOfCodeGenerated?.toLong(),
707-
generatedCharactersCount = session.charsOfCodeGenerated?.toLong(),
708-
result = if (buildResult) {
709-
MetricResult.Succeeded
710-
} else {
711-
MetricResult.Failed
712-
},
713-
perfClientLatency = session.latencyOfTestGeneration,
714-
isCodeBlockSelected = session.isCodeBlockSelected,
715-
artifactsUploadDuration = session.artifactUploadDuration,
716-
buildZipFileBytes = session.srcZipFileSize,
717-
requestId = session.startTestGenerationRequestId,
718-
update = session.updateBuildCommands,
719-
)
720693
}
721694

722695
codeTestChatHelper.addAnswer(
@@ -826,6 +799,32 @@ class CodeTestChatController(
826799
codeTestChatHelper.updateUI(
827800
promptInputPlaceholder = message("testgen.placeholder.newtab")
828801
)
802+
AmazonqTelemetry.unitTestGeneration(
803+
count = session.iteration.toLong() - 1,
804+
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
805+
hasUserPromptSupplied = session.hasUserPromptSupplied,
806+
isSupportedLanguage = true,
807+
credentialStartUrl = getStartUrl(project = context.project),
808+
jobGroup = session.testGenerationJobGroupName,
809+
jobId = session.testGenerationJob,
810+
acceptedCount = session.numberOfUnitTestCasesGenerated?.toLong(),
811+
generatedCount = session.numberOfUnitTestCasesGenerated?.toLong(),
812+
acceptedLinesCount = session.linesOfCodeGenerated?.toLong(),
813+
generatedLinesCount = session.linesOfCodeGenerated?.toLong(),
814+
acceptedCharactersCount = session.charsOfCodeGenerated?.toLong(),
815+
generatedCharactersCount = session.charsOfCodeGenerated?.toLong(),
816+
result = if (buildResult) {
817+
MetricResult.Succeeded
818+
} else {
819+
MetricResult.Failed
820+
},
821+
perfClientLatency = session.latencyOfTestGeneration,
822+
isCodeBlockSelected = session.isCodeBlockSelected,
823+
artifactsUploadDuration = session.artifactUploadDuration,
824+
buildZipFileBytes = session.srcZipFileSize,
825+
requestId = session.startTestGenerationRequestId,
826+
update = session.updateBuildCommands,
827+
)
829828
}
830829
}
831830

@@ -955,6 +954,32 @@ class CodeTestChatController(
955954
canBeVoted = false
956955
)
957956
)
957+
AmazonqTelemetry.unitTestGeneration(
958+
count = session.iteration.toLong() - 1,
959+
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
960+
hasUserPromptSupplied = session.hasUserPromptSupplied,
961+
isSupportedLanguage = true,
962+
credentialStartUrl = getStartUrl(project = context.project),
963+
jobGroup = session.testGenerationJobGroupName,
964+
jobId = session.testGenerationJob,
965+
acceptedCount = session.numberOfUnitTestCasesGenerated?.toLong(),
966+
generatedCount = session.numberOfUnitTestCasesGenerated?.toLong(),
967+
acceptedLinesCount = session.linesOfCodeGenerated?.toLong(),
968+
generatedLinesCount = session.linesOfCodeGenerated?.toLong(),
969+
acceptedCharactersCount = session.charsOfCodeGenerated?.toLong(),
970+
generatedCharactersCount = session.charsOfCodeGenerated?.toLong(),
971+
result = if (buildResult) {
972+
MetricResult.Succeeded
973+
} else {
974+
MetricResult.Failed
975+
},
976+
perfClientLatency = session.latencyOfTestGeneration,
977+
isCodeBlockSelected = session.isCodeBlockSelected,
978+
artifactsUploadDuration = session.artifactUploadDuration,
979+
buildZipFileBytes = session.srcZipFileSize,
980+
requestId = session.startTestGenerationRequestId,
981+
update = session.updateBuildCommands,
982+
)
958983
sessionCleanUp(message.tabId)
959984
}
960985
"utg_proceed", "utg_build_and_execute" -> {
@@ -1006,6 +1031,32 @@ class CodeTestChatController(
10061031
)
10071032
)
10081033
buildResult = true
1034+
AmazonqTelemetry.unitTestGeneration(
1035+
count = session.iteration.toLong() - 1,
1036+
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
1037+
hasUserPromptSupplied = session.hasUserPromptSupplied,
1038+
isSupportedLanguage = true,
1039+
credentialStartUrl = getStartUrl(project = context.project),
1040+
jobGroup = session.testGenerationJobGroupName,
1041+
jobId = session.testGenerationJob,
1042+
acceptedCount = session.numberOfUnitTestCasesGenerated?.toLong(),
1043+
generatedCount = session.numberOfUnitTestCasesGenerated?.toLong(),
1044+
acceptedLinesCount = session.linesOfCodeGenerated?.toLong(),
1045+
generatedLinesCount = session.linesOfCodeGenerated?.toLong(),
1046+
acceptedCharactersCount = session.charsOfCodeGenerated?.toLong(),
1047+
generatedCharactersCount = session.charsOfCodeGenerated?.toLong(),
1048+
result = if (buildResult) {
1049+
MetricResult.Succeeded
1050+
} else {
1051+
MetricResult.Failed
1052+
},
1053+
perfClientLatency = session.latencyOfTestGeneration,
1054+
isCodeBlockSelected = session.isCodeBlockSelected,
1055+
artifactsUploadDuration = session.artifactUploadDuration,
1056+
buildZipFileBytes = session.srcZipFileSize,
1057+
requestId = session.startTestGenerationRequestId,
1058+
update = session.updateBuildCommands,
1059+
)
10091060
sessionCleanUp(message.tabId)
10101061
return
10111062
}

0 commit comments

Comments
 (0)