diff --git a/packages/amazonq/.changes/next-release/Bug Fix-0d324321-bddd-4f93-80c4-80978930f157.json b/packages/amazonq/.changes/next-release/Bug Fix-0d324321-bddd-4f93-80c4-80978930f157.json new file mode 100644 index 0000000000..643ff10bb7 --- /dev/null +++ b/packages/amazonq/.changes/next-release/Bug Fix-0d324321-bddd-4f93-80c4-80978930f157.json @@ -0,0 +1,4 @@ +{ + "type": "Bug Fix", + "description": "Amazon Q /dev: include telemetry for workspace usage when generating new files" +} diff --git a/packages/core/src/amazonqFeatureDev/session/sessionState.ts b/packages/core/src/amazonqFeatureDev/session/sessionState.ts index 9c914462ab..72650fdb2f 100644 --- a/packages/core/src/amazonqFeatureDev/session/sessionState.ts +++ b/packages/core/src/amazonqFeatureDev/session/sessionState.ts @@ -56,7 +56,8 @@ function registerNewFiles( fs: VirtualFileSystem, newFileContents: NewFileZipContents[], uploadId: string, - workspaceFolders: CurrentWsFolders + workspaceFolders: CurrentWsFolders, + conversationId: string ): NewFileInfo[] { const result: NewFileInfo[] = [] const workspaceFolderPrefixes = getWorkspaceFoldersByPrefixes(workspaceFolders) @@ -70,6 +71,11 @@ function registerNewFiles( workspaceFolderPrefixes === undefined ? '' : zipFilePath.substring(0, zipFilePath.indexOf(path.sep)) const folder = workspaceFolderPrefixes === undefined ? workspaceFolders[0] : workspaceFolderPrefixes[prefix] if (folder === undefined) { + telemetry.amazonq_trackScenarioCountUsage.emit({ + amazonqConversationId: conversationId, + credentialStartUrl: AuthUtil.instance.startUrl, + scenarioType: 'wsOrphanedDocuments', + }) getLogger().error(`No workspace folder found for file: ${zipFilePath} and prefix: ${prefix}`) continue } @@ -161,7 +167,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 { @@ -348,7 +360,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', diff --git a/packages/core/src/shared/telemetry/vscodeTelemetry.json b/packages/core/src/shared/telemetry/vscodeTelemetry.json index fffeec357b..a4624c5775 100644 --- a/packages/core/src/shared/telemetry/vscodeTelemetry.json +++ b/packages/core/src/shared/telemetry/vscodeTelemetry.json @@ -315,6 +315,12 @@ "name": "totalFiles", "type": "int", "description": "The total number of files being sent to Amazon Q" + }, + { + "name": "scenarioType", + "type": "string", + "allowedValues": ["wsOrphanedDocuments"], + "description": "Scenarios to count in telemetry" } ], "metrics": [ @@ -939,6 +945,25 @@ } ] }, + { + "name": "amazonq_trackScenarioCountUsage", + "description": "Count how many times a scenario is reached.", + "unit": "Count", + "metadata": [ + { + "type": "amazonqConversationId", + "required": true + }, + { + "type": "credentialStartUrl", + "required": false + }, + { + "type": "scenarioType", + "required": true + } + ] + }, { "name": "amazonq_approachThumbsUp", "description": "User clicked on the thumbs up button, to mention that they are satisfied",