Skip to content

Commit

Permalink
Merge master into feature/q-dev-ux
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-toolkit-automation authored Oct 9, 2024
2 parents 7173ddd + d697f44 commit dfbb8e5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "Amazon Q /dev: include telemetry for workspace usage when generating new files"
}
25 changes: 22 additions & 3 deletions packages/core/src/amazonqFeatureDev/session/sessionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function registerNewFiles(
fs: VirtualFileSystem,
newFileContents: NewFileZipContents[],
uploadId: string,
workspaceFolders: CurrentWsFolders
workspaceFolders: CurrentWsFolders,
conversationId: string
): NewFileInfo[] {
const result: NewFileInfo[] = []
const workspaceFolderPrefixes = getWorkspaceFoldersByPrefixes(workspaceFolders)
Expand All @@ -81,6 +82,12 @@ function registerNewFiles(
Object.values(workspaceFolderPrefixes).find((val) => val.index === 0)?.name ?? ''
]
if (folder === undefined) {
telemetry.toolkit_trackScenario.emit({
count: 1,
amazonqConversationId: conversationId,
credentialStartUrl: AuthUtil.instance.startUrl,
scenario: 'wsOrphanedDocuments',
})
getLogger().error(`No workspace folder found for file: ${zipFilePath} and prefix: ${prefix}`)
continue
}
Expand Down Expand Up @@ -174,7 +181,13 @@ abstract class CodeGenBase {
case CodeGenerationStatus.COMPLETE: {
const { newFileContents, deletedFiles, references } =
await this.config.proxyClient.exportResultArchive(this.conversationId)
const newFileInfo = registerNewFiles(fs, newFileContents, this.uploadId, workspaceFolders)
const newFileInfo = registerNewFiles(
fs,
newFileContents,
this.uploadId,
workspaceFolders,
this.conversationId
)
telemetry.setNumberOfFilesGenerated(newFileInfo.length)

return {
Expand Down Expand Up @@ -378,7 +391,13 @@ export class MockCodeGenState implements SessionState {
zipFilePath: f.zipFilePath,
fileContent: f.fileContent,
}))
this.filePaths = registerNewFiles(action.fs, newFileContents, this.uploadId, this.config.workspaceFolders)
this.filePaths = registerNewFiles(
action.fs,
newFileContents,
this.uploadId,
this.config.workspaceFolders,
this.conversationId
)
this.deletedFiles = [
{
zipFilePath: 'src/this-file-should-be-deleted.ts',
Expand Down

0 comments on commit dfbb8e5

Please sign in to comment.