Skip to content

Commit addc4fb

Browse files
committed
telemetry(messages): maybeShowMinVscodeWarning
1 parent d697f44 commit addc4fb

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

packages/core/src/shared/extensionStartup.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { fs } from '../shared/fs/fs'
1414
import { getIdeProperties, getIdeType, isAmazonQ, isCloud9, isCn, productName } from './extensionUtilities'
1515
import * as localizedText from './localizedText'
1616
import { AmazonQPromptSettings, ToolkitPromptSettings } from './settings'
17+
import { showMessage } from './utilities/messages'
1718

1819
const localize = nls.loadMessageBundle()
1920

@@ -27,19 +28,17 @@ export async function maybeShowMinVscodeWarning(minVscode: string) {
2728
}
2829
const updateButton = `Update ${vscode.env.appName}`
2930
if (getIdeType() === 'vscode' && semver.lt(vscode.version, minVscode)) {
30-
void vscode.window
31-
.showWarningMessage(
32-
`${productName()} will soon require VS Code ${minVscode} or newer. The currently running version ${vscode.version} will no longer receive updates.`,
33-
updateButton,
34-
localizedText.dontShow
35-
)
36-
.then(async (resp) => {
37-
if (resp === updateButton) {
38-
await vscode.commands.executeCommand('update.checkForUpdate')
39-
} else if (resp === localizedText.dontShow) {
40-
void settings.disablePrompt('minIdeVersion')
41-
}
42-
})
31+
void showMessage(
32+
'warn',
33+
`${productName()} will soon require VS Code ${minVscode} or newer. The currently running version ${vscode.version} will no longer receive updates.`,
34+
[updateButton, localizedText.dontShow]
35+
).then(async (resp) => {
36+
if (resp === updateButton) {
37+
await vscode.commands.executeCommand('update.checkForUpdate')
38+
} else if (resp === localizedText.dontShow) {
39+
void settings.disablePrompt('minIdeVersion')
40+
}
41+
})
4342
}
4443
}
4544

packages/core/src/shared/utilities/messages.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,25 @@ 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
42+
options: vscode.MessageOptions & { telemetry?: boolean } = {}
4343
): 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-
}
44+
return telemetry.toolkit_showNotification.run(async (span) => {
45+
span.record({ passive: true })
46+
47+
switch (kind) {
48+
case 'info':
49+
return vscode.window.showInformationMessage(message, options, ...items)
50+
case 'warn':
51+
return vscode.window.showWarningMessage(message, options, ...items)
52+
case 'error':
53+
default:
54+
return vscode.window.showErrorMessage(message, options, ...items)
55+
}
56+
})
5357
}
5458

5559
/**
@@ -75,7 +79,7 @@ export async function showMessageWithUrl(
7579
const uri = typeof url === 'string' ? vscode.Uri.parse(url) : url
7680
const items = [...extraItems, urlItem]
7781

78-
const p = showMessageWithItems(message, kind, items, useModal)
82+
const p = showMessage(kind, message, items, { modal: useModal })
7983
return p.then<string | undefined>((selection) => {
8084
if (selection === urlItem) {
8185
void openUrl(uri)
@@ -102,7 +106,7 @@ export async function showViewLogsMessage(
102106
const logsItem = localize('AWS.generic.message.viewLogs', 'View Logs...')
103107
const items = [...extraItems, logsItem]
104108

105-
const p = showMessageWithItems(message, kind, items)
109+
const p = showMessage(kind, message, items)
106110
return p.then<string | undefined>((selection) => {
107111
if (selection === logsItem) {
108112
globals.logOutputChannel.show(true)

0 commit comments

Comments
 (0)