Skip to content

Commit 20204ce

Browse files
authored
fix(amazonq): do not include plan generation and code generation durations in createUpload telemetry event for /dev (#4462)
1 parent cb108eb commit 20204ce

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/session/PrepareCodeGenerationState.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class PrepareCodeGenerationState(
3636
var result: Result = Result.Succeeded
3737
var failureReason: String? = null
3838
var zipFileLength: Long? = null
39+
val nextState: SessionState
3940
try {
4041
val repoZipResult = config.repoContext.getProjectZip()
4142
val zipFileChecksum = repoZipResult.checksum
@@ -49,10 +50,11 @@ class PrepareCodeGenerationState(
4950
)
5051

5152
uploadArtifactToS3(uploadUrlResponse.uploadUrl(), fileToUpload, zipFileChecksum, zipFileLength, uploadUrlResponse.kmsKeyArn())
53+
deleteUploadArtifact(fileToUpload)
5254

5355
this.uploadId = uploadUrlResponse.uploadId()
5456

55-
val nextState = CodeGenerationState(
57+
nextState = CodeGenerationState(
5658
tabID = this.tabID,
5759
approach = "", // No approach needed,
5860
config = this.config,
@@ -61,9 +63,6 @@ class PrepareCodeGenerationState(
6163
repositorySize = zipFileLength.toDouble(),
6264
messenger = messenger
6365
)
64-
deleteUploadArtifact(fileToUpload)
65-
66-
return nextState.interact(action)
6766
} catch (e: Exception) {
6867
result = Result.Failed
6968
failureReason = e.javaClass.simpleName
@@ -80,5 +79,7 @@ class PrepareCodeGenerationState(
8079
credentialStartUrl = getStartUrl(config.featureDevService.project)
8180
)
8281
}
82+
// It is essential to interact with the next state outside of try-catch block for the telemetry to capture events for the states separately
83+
return nextState.interact(action)
8384
}
8485
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/session/PrepareRefinementState.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class PrepareRefinementState(
2424
var result: Result = Result.Succeeded
2525
var failureReason: String? = null
2626
var zipFileLength: Long? = null
27+
val nextState: SessionState
2728
try {
2829
val repoZipResult = config.repoContext.getProjectZip()
2930
val zipFileChecksum = repoZipResult.checksum
@@ -37,11 +38,9 @@ class PrepareRefinementState(
3738
)
3839

3940
uploadArtifactToS3(uploadUrlResponse.uploadUrl(), fileToUpload, zipFileChecksum, zipFileLength, uploadUrlResponse.kmsKeyArn())
40-
4141
deleteUploadArtifact(fileToUpload)
4242

43-
val nextState = RefinementState(approach, tabID, config, uploadUrlResponse.uploadId(), 0)
44-
return nextState.interact(action)
43+
nextState = RefinementState(approach, tabID, config, uploadUrlResponse.uploadId(), 0)
4544
} catch (e: Exception) {
4645
result = Result.Failed
4746
failureReason = e.javaClass.simpleName
@@ -58,5 +57,7 @@ class PrepareRefinementState(
5857
credentialStartUrl = getStartUrl(config.featureDevService.project)
5958
)
6059
}
60+
// It is essential to interact with the next state outside of try-catch block for the telemetry to capture events for the states separately
61+
return nextState.interact(action)
6162
}
6263
}

0 commit comments

Comments
 (0)