@@ -16,7 +16,7 @@ import { getIcon, codicon } from '../icons'
1616import globals from '../extensionGlobals'
1717import { openUrl } from './vsCodeUtils'
1818import { AmazonQPromptSettings , ToolkitPromptSettings } from '../../shared/settings'
19- import { telemetry } from '../telemetry/telemetry'
19+ import { telemetry , ToolkitShowNotification } from '../telemetry/telemetry'
2020import { vscodeComponent } from '../vscode/commands2'
2121
2222export const messages = {
@@ -35,21 +35,32 @@ export function makeFailedWriteMessage(filename: string): string {
3535 return message
3636}
3737
38- function showMessageWithItems (
39- message : string ,
38+ export function showMessage (
4039 kind : 'info' | 'warn' | 'error' = 'error' ,
40+ message : string ,
4141 items : string [ ] = [ ] ,
42- useModal : boolean = false
43- ) : Thenable < string | undefined > {
44- switch ( kind ) {
45- case 'info' :
46- return vscode . window . showInformationMessage ( message , { modal : useModal } , ...items )
47- case 'warn' :
48- return vscode . window . showWarningMessage ( message , { modal : useModal } , ...items )
49- case 'error' :
50- default :
51- return vscode . window . showErrorMessage ( message , { modal : useModal } , ...items )
42+ options : vscode . MessageOptions & { telemetry ?: boolean } = { } ,
43+ metric : ToolkitShowNotification = {
44+ id : 'unknown' ,
45+ component : 'editor' ,
5246 }
47+ ) : Thenable < string | undefined > {
48+ return telemetry . toolkit_showNotification . run ( async ( span ) => {
49+ span . record ( {
50+ passive : true ,
51+ ...metric ,
52+ } )
53+
54+ switch ( kind ) {
55+ case 'info' :
56+ return vscode . window . showInformationMessage ( message , options , ...items )
57+ case 'warn' :
58+ return vscode . window . showWarningMessage ( message , options , ...items )
59+ case 'error' :
60+ default :
61+ return vscode . window . showErrorMessage ( message , options , ...items )
62+ }
63+ } )
5364}
5465
5566/**
@@ -75,7 +86,7 @@ export async function showMessageWithUrl(
7586 const uri = typeof url === 'string' ? vscode . Uri . parse ( url ) : url
7687 const items = [ ...extraItems , urlItem ]
7788
78- const p = showMessageWithItems ( message , kind , items , useModal )
89+ const p = showMessage ( kind , message , items , { modal : useModal } )
7990 return p . then < string | undefined > ( ( selection ) => {
8091 if ( selection === urlItem ) {
8192 void openUrl ( uri )
@@ -102,7 +113,7 @@ export async function showViewLogsMessage(
102113 const logsItem = localize ( 'AWS.generic.message.viewLogs' , 'View Logs...' )
103114 const items = [ ...extraItems , logsItem ]
104115
105- const p = showMessageWithItems ( message , kind , items )
116+ const p = showMessage ( kind , message , items )
106117 return p . then < string | undefined > ( ( selection ) => {
107118 if ( selection === logsItem ) {
108119 globals . logOutputChannel . show ( true )
0 commit comments