Skip to content

Commit de470fe

Browse files
committed
chore: fix doc telemetry changes fail CI issue
1 parent 75ec079 commit de470fe

File tree

1 file changed

+10
-7
lines changed
  • plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/session

1 file changed

+10
-7
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/session/DocSession.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class DocSession(val tabID: String, val project: Project) {
5050
var task: String = ""
5151
val proxyClient: AmazonQCodeGenerateClient
5252
val amazonQCodeGenService: AmazonQCodeGenService
53-
private var _reportedChanges = mutableMapOf<String, String>()
53+
private val _reportedChanges = mutableMapOf<String, String>()
5454

5555
// retry session state vars
5656
private var codegenRetries: Int
@@ -161,7 +161,7 @@ class DocSession(val tabID: String, val project: Project) {
161161
} else {
162162
val sourceContent = reportedChange
163163
?: VfsUtil.findRelativeFile(filePath.zipFilePath, context.selectedSourceFolder)?.content()
164-
?: ""
164+
.orEmpty()
165165
val diffMetrics = getDiffMetrics(sourceContent, content)
166166
totalAddedLines += diffMetrics.insertedLines
167167
totalAddedChars += diffMetrics.insertedCharacters
@@ -188,7 +188,7 @@ class DocSession(val tabID: String, val project: Project) {
188188
totalAddedLines += content.split('\n').size
189189
} else {
190190
val existingFileContent = VfsUtil.findRelativeFile(filePath.zipFilePath, context.selectedSourceFolder)?.content()
191-
val diffMetrics = getDiffMetrics(existingFileContent ?: "", content)
191+
val diffMetrics = getDiffMetrics(existingFileContent.orEmpty(), content)
192192
totalAddedLines += diffMetrics.insertedLines
193193
totalAddedChars += diffMetrics.insertedCharacters
194194
}
@@ -277,10 +277,13 @@ class DocSession(val tabID: String, val project: Project) {
277277
) {
278278
val sendDocTelemetryEventResponse: SendTelemetryEventResponse
279279
try {
280-
when {
281-
generationEvent != null -> sendDocTelemetryEventResponse = proxyClient.sendDocTelemetryEvent(generationEvent, null)
282-
acceptanceEvent != null -> sendDocTelemetryEventResponse = proxyClient.sendDocTelemetryEvent(null, acceptanceEvent)
283-
else -> throw IllegalArgumentException("Either generation or acceptance event must be provided")
280+
sendDocTelemetryEventResponse = when {
281+
generationEvent != null -> proxyClient.sendDocTelemetryEvent(generationEvent, null)
282+
acceptanceEvent != null -> proxyClient.sendDocTelemetryEvent(null, acceptanceEvent)
283+
else -> {
284+
logger.warn("Neither generation nor acceptance event was provided")
285+
return
286+
}
284287
}
285288
val requestId = sendDocTelemetryEventResponse.responseMetadata().requestId()
286289
logger.debug {

0 commit comments

Comments
 (0)