@@ -16,8 +16,9 @@ import { getIcon, codicon } from '../icons'
16
16
import globals from '../extensionGlobals'
17
17
import { openUrl } from './vsCodeUtils'
18
18
import { AmazonQPromptSettings , ToolkitPromptSettings } from '../../shared/settings'
19
- import { telemetry } from '../telemetry/telemetry'
19
+ import { telemetry , ToolkitShowNotification } from '../telemetry/telemetry'
20
20
import { vscodeComponent } from '../vscode/commands2'
21
+ import { getTelemetryReasonDesc } from '../errors'
21
22
22
23
export const messages = {
23
24
editCredentials ( icon : boolean ) {
@@ -35,21 +36,31 @@ export function makeFailedWriteMessage(filename: string): string {
35
36
return message
36
37
}
37
38
38
- function showMessageWithItems (
39
- message : string ,
39
+ export function showMessage (
40
40
kind : 'info' | 'warn' | 'error' = 'error' ,
41
+ message : string ,
41
42
items : string [ ] = [ ] ,
42
- useModal : boolean = false
43
+ options : vscode . MessageOptions & { telemetry ?: boolean } = { } ,
44
+ metric : Partial < ToolkitShowNotification > = { }
43
45
) : 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 )
52
- }
46
+ return telemetry . toolkit_showNotification . run ( async ( span ) => {
47
+ span . record ( {
48
+ passive : true ,
49
+ id : 'unknown' ,
50
+ component : 'editor' ,
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
+ } )
53
64
}
54
65
55
66
/**
@@ -75,7 +86,16 @@ export async function showMessageWithUrl(
75
86
const uri = typeof url === 'string' ? vscode . Uri . parse ( url ) : url
76
87
const items = [ ...extraItems , urlItem ]
77
88
78
- const p = showMessageWithItems ( message , kind , items , useModal )
89
+ const p = showMessage (
90
+ kind ,
91
+ message ,
92
+ items ,
93
+ { modal : useModal } ,
94
+ {
95
+ id : 'showMessageWithUrl' ,
96
+ reasonDesc : getTelemetryReasonDesc ( message ) ,
97
+ }
98
+ )
79
99
return p . then < string | undefined > ( ( selection ) => {
80
100
if ( selection === urlItem ) {
81
101
void openUrl ( uri )
@@ -102,7 +122,16 @@ export async function showViewLogsMessage(
102
122
const logsItem = localize ( 'AWS.generic.message.viewLogs' , 'View Logs...' )
103
123
const items = [ ...extraItems , logsItem ]
104
124
105
- const p = showMessageWithItems ( message , kind , items )
125
+ const p = showMessage (
126
+ kind ,
127
+ message ,
128
+ items ,
129
+ { } ,
130
+ {
131
+ id : 'showViewLogsMessage' ,
132
+ reasonDesc : getTelemetryReasonDesc ( message ) ,
133
+ }
134
+ )
106
135
return p . then < string | undefined > ( ( selection ) => {
107
136
if ( selection === logsItem ) {
108
137
globals . logOutputChannel . show ( true )
0 commit comments