@@ -36,21 +36,24 @@ export function makeFailedWriteMessage(filename: string): string {
3636 return message
3737}
3838
39+ /**
40+ * Shows a message and emits a `toolkit_showNotification` metric (if and only if the user
41+ * confirms/dismisses the dialog!) capturing the result.
42+ *
43+ * @param kind Kind of message to show
44+ * @param message Message text
45+ * @param items Buttons
46+ * @returns Promise that resolves when a button is clicked or the message is dismissed, and returns
47+ * the selected button text.
48+ */
3949export function showMessage (
4050 kind : 'info' | 'warn' | 'error' = 'error' ,
4151 message : string ,
4252 items : string [ ] = [ ] ,
4353 options : vscode . MessageOptions & { telemetry ?: boolean } = { } ,
4454 metric : Partial < ToolkitShowNotification > = { }
4555) : Thenable < string | undefined > {
46- return telemetry . toolkit_showNotification . run ( async ( span ) => {
47- span . record ( {
48- passive : true ,
49- id : 'unknown' ,
50- component : 'editor' ,
51- ...metric ,
52- } )
53-
56+ function showMsg ( ) {
5457 switch ( kind ) {
5558 case 'info' :
5659 return vscode . window . showInformationMessage ( message , options , ...items )
@@ -60,6 +63,24 @@ export function showMessage(
6063 default :
6164 return vscode . window . showErrorMessage ( message , options , ...items )
6265 }
66+ }
67+
68+ // NOTE: this does not emit telemetry (or logs) until the user confirms/dismisses the message!
69+ // That includes vscode's "Do Not Disturb" mode: when a message is "shown" in DND mode, it is
70+ // neither confirmed nor dismissed until the user opens the messages list and interacts with it!
71+ return telemetry . toolkit_showNotification . run ( async ( span ) => {
72+ span . record ( {
73+ passive : true ,
74+ id : 'unknown' ,
75+ component : 'editor' ,
76+ ...metric ,
77+ } )
78+
79+ return showMsg ( ) . then ( ( result ) => {
80+ span . record ( { userChoice : result } as any )
81+
82+ return result
83+ } )
6384 } )
6485}
6586
@@ -108,7 +129,6 @@ export async function showMessageWithUrl(
108129 * Shows a non-modal message with a "View Logs" button.
109130 *
110131 * @param message Message text
111- * @param window Window
112132 * @param kind Kind of message to show
113133 * @param extraItems Extra buttons shown _before_ the "View Logs" button
114134 * @returns Promise that resolves when a button is clicked or the message is
@@ -146,7 +166,6 @@ export async function showViewLogsMessage(
146166 * @param prompt the message to show.
147167 * @param confirm the confirmation button text.
148168 * @param cancel the cancel button text.
149- * @param window the window.
150169 */
151170export async function showConfirmationMessage ( {
152171 prompt,
0 commit comments