-
Notifications
You must be signed in to change notification settings - Fork 737
telemetry(amazonq chat): numberOfCodeBlocks #4761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
ee9f69c
a804eeb
a3332e4
cbe5a6d
de8bf7a
a54c03b
451e48e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "type": "Feature", | ||
| "description": "Amazon Q Chat: Added metric parameters to recordAddMessage telemetry event." | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ import { OnboardingPageInteraction } from '../../../../amazonq/onboardingPage/mo | |
| import { FeatureAuthState } from '../../../../codewhisperer/util/authUtil' | ||
| import { AuthFollowUpType, expiredText, enableQText, reauthenticateText } from '../../../../amazonq/auth/model' | ||
| import { userGuideURL } from '../../../../amazonq/webview/ui/texts/constants' | ||
| import { marked } from 'marked' | ||
|
|
||
| export type StaticTextResponseType = 'quick-action-help' | 'onboarding-help' | 'transform' | 'help' | ||
|
|
||
|
|
@@ -88,6 +89,21 @@ export class Messenger { | |
| ) | ||
| ) | ||
| } | ||
|
|
||
| public async countTotalNumberOfCodeBlocks(message: string): Promise<number> { | ||
| if (message === undefined) { | ||
| return 0 | ||
| } | ||
|
|
||
| // To Convert Markdown text to HTML using marked library | ||
| const html = await marked(message) | ||
|
|
||
| // Count the number of <pre> tags in the HTML to find the total number of code blocks | ||
| const totalNumberOfCodeBlocks = (html.match(/<pre>/g) || []).length | ||
|
||
|
|
||
| return totalNumberOfCodeBlocks | ||
| } | ||
|
|
||
| public async sendAIResponse( | ||
| response: GenerateAssistantResponseCommandOutput, | ||
| session: ChatSession, | ||
|
|
@@ -214,7 +230,7 @@ export class Messenger { | |
| relatedSuggestions = [] | ||
| this.telemetryHelper.recordMessageResponseError(triggerPayload, tabID, statusCode ?? 0) | ||
| }) | ||
| .finally(() => { | ||
| .finally(async () => { | ||
| if (relatedSuggestions.length !== 0) { | ||
| this.dispatcher.sendChatMessage( | ||
| new ChatMessage( | ||
|
|
@@ -264,6 +280,7 @@ export class Messenger { | |
| messageID, | ||
| responseCode, | ||
| codeReferenceCount: codeReference.length, | ||
| totalNumberOfCodeBlocksInResponse: await this.countTotalNumberOfCodeBlocks(message), | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.