Skip to content

Commit 97a0b3c

Browse files
authored
telemetry: aws_openUrl #3566
Capture metrics for generic URLs.
1 parent 2ca8f7c commit 97a0b3c

File tree

22 files changed

+60
-41
lines changed

22 files changed

+60
-41
lines changed

src/apprunner/wizards/codeRepositoryWizard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
apprunnerCreateServiceDocsUrl,
2323
} from '../../shared/constants'
2424
import { Wizard, WIZARD_BACK } from '../../shared/wizards/wizard'
25+
import { openUrl } from '../../shared/utilities/vsCodeUtils'
2526

2627
const localize = nls.loadMessageBundle()
2728

@@ -149,7 +150,7 @@ export function createConnectionPrompter(client: AppRunnerClient) {
149150
detail: 'Click for documentation on creating a new GitHub connection for App Runner',
150151
data: {} as any,
151152
invalidSelection: true,
152-
onClick: () => vscode.env.openExternal(vscode.Uri.parse(apprunnerConnectionHelpUrl)),
153+
onClick: () => openUrl(vscode.Uri.parse(apprunnerConnectionHelpUrl)),
153154
}
154155

155156
const errorItem = {

src/apprunner/wizards/deploymentButton.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { apprunnerPricingUrl } from '../../shared/constants'
1111
import { PromptSettings } from '../../shared/settings'
1212
import { getIcon } from '../../shared/icons'
1313
import { dontShow } from '../../shared/localizedText'
14+
import { openUrl } from '../../shared/utilities/vsCodeUtils'
1415

1516
const localize = nls.loadMessageBundle()
1617

@@ -41,7 +42,7 @@ async function showDeploymentCostNotification(): Promise<void> {
4142

4243
vscode.window.showInformationMessage(notice, viewPricing, dontShow).then(async button => {
4344
if (button === viewPricing) {
44-
vscode.env.openExternal(pricingUri)
45+
openUrl(pricingUri)
4546
await showDeploymentCostNotification()
4647
} else if (button === dontShow) {
4748
settings.disablePrompt('apprunnerNotifyPricing')

src/auth/credentials/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Timeout, waitTimeout } from '../../shared/utilities/timeoutUtils'
1616
import { fromExtensionManifest } from '../../shared/settings'
1717
import { Profile } from './sharedCredentials'
1818
import { createInputBox, promptUser } from '../../shared/ui/input'
19+
import { openUrl } from '../../shared/utilities/vsCodeUtils'
1920

2021
const credentialsTimeout = 300000 // 5 minutes
2122
const credentialsProgressDelay = 1000
@@ -45,7 +46,7 @@ export function showLoginFailedMessage(credentialsId: string, errMsg: string): v
4546
buttons
4647
).then((selection: string | undefined) => {
4748
if (selection === getHelp) {
48-
vscode.env.openExternal(vscode.Uri.parse(authHelpUrl))
49+
openUrl(vscode.Uri.parse(authHelpUrl))
4950
}
5051
if (selection === editCreds) {
5152
vscode.commands.executeCommand('aws.credentials.edit')

src/auth/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
import { Commands } from '../shared/vscode/commands2'
4242
import { Auth } from './auth'
4343
import { validateIsNewSsoUrl, validateSsoUrlFormat } from './sso/validation'
44+
import { openUrl } from '../shared/utilities/vsCodeUtils'
4445

4546
export async function promptForConnection(auth: Auth, type?: 'iam' | 'sso') {
4647
const resp = await createConnectionPrompter(auth, type).prompt()
@@ -215,7 +216,7 @@ export async function showRegionPrompter(
215216
}
216217

217218
Commands.register('aws.auth.help', async () => {
218-
vscode.env.openExternal(vscode.Uri.parse(authHelpUrl))
219+
openUrl(vscode.Uri.parse(authHelpUrl))
219220
telemetry.aws_help.emit()
220221
})
221222

src/cdk/explorer/rootNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { cdkDocumentationUrl } from '../../shared/constants'
88
import { telemetry } from '../../shared/telemetry/telemetry'
99
import { TreeNode } from '../../shared/treeview/resourceTreeDataProvider'
1010
import { createPlaceholderItem } from '../../shared/treeview/utils'
11-
import { localize } from '../../shared/utilities/vsCodeUtils'
11+
import { localize, openUrl } from '../../shared/utilities/vsCodeUtils'
1212
import { Commands } from '../../shared/vscode/commands2'
1313
import { detectCdkProjects } from './detectCdkProjects'
1414
import { AppNode } from './nodes/appNode'
@@ -50,6 +50,6 @@ export const cdkNode = new CdkRootNode()
5050
export const refreshCdkExplorer = Commands.register('aws.cdk.refresh', cdkNode.refresh.bind(cdkNode))
5151

5252
Commands.register('aws.cdk.viewDocs', () => {
53-
vscode.env.openExternal(vscode.Uri.parse(cdkDocumentationUrl))
53+
openUrl(vscode.Uri.parse(cdkDocumentationUrl))
5454
telemetry.aws_help.emit({ name: 'cdk' })
5555
})

src/codecatalyst/explorer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ConnectedDevEnv, getDevfileLocation, getThisDevEnv } from './model'
1616
import * as codecatalyst from './model'
1717
import { getLogger } from '../shared/logger'
1818
import { Connection, isBuilderIdConnection } from '../auth/connection'
19+
import { openUrl } from '../shared/utilities/vsCodeUtils'
1920

2021
export const getStartedCommand = Commands.register(
2122
'aws.codecatalyst.getStarted',
@@ -28,7 +29,7 @@ export const getStartedCommand = Commands.register(
2829
)
2930

3031
const learnMoreCommand = Commands.register('aws.learnMore', async (docsUrl: vscode.Uri) => {
31-
return vscode.env.openExternal(docsUrl)
32+
return openUrl(docsUrl)
3233
})
3334

3435
// Only used in rare cases on C9

src/codewhisperer/activation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { CodeWhispererCodeCoverageTracker } from './tracker/codewhispererCodeCov
4848
import { AuthUtil } from './util/authUtil'
4949
import { ImportAdderProvider } from './service/importAdderProvider'
5050
import { TelemetryHelper } from './util/telemetryHelper'
51+
import { openUrl } from '../shared/utilities/vsCodeUtils'
5152

5253
const performance = globalThis.performance ?? require('perf_hooks').performance
5354

@@ -96,7 +97,7 @@ export async function activate(context: ExtContext): Promise<void> {
9697
)
9798
.then(async resp => {
9899
if (resp === CodeWhispererConstants.settingsLearnMore) {
99-
vscode.env.openExternal(vscode.Uri.parse(CodeWhispererConstants.learnMoreUri))
100+
openUrl(vscode.Uri.parse(CodeWhispererConstants.learnMoreUri))
100101
}
101102
})
102103
}
@@ -111,7 +112,7 @@ export async function activate(context: ExtContext): Promise<void> {
111112
)
112113
.then(async resp => {
113114
if (resp === CodeWhispererConstants.settingsLearnMore) {
114-
vscode.env.openExternal(vscode.Uri.parse(CodeWhispererConstants.learnMoreUri))
115+
openUrl(vscode.Uri.parse(CodeWhispererConstants.learnMoreUri))
115116
}
116117
})
117118
}

src/codewhisperer/commands/basicCommands.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { ReferenceLogViewProvider } from '../service/referenceLogViewProvider'
1818
import { AuthUtil } from '../util/authUtil'
1919
import { isCloud9 } from '../../shared/extensionUtilities'
2020
import { InlineCompletionService } from '../service/inlineCompletionService'
21+
import { openUrl } from '../../shared/utilities/vsCodeUtils'
2122

2223
export const toggleCodeSuggestions = Commands.declare(
2324
'aws.codeWhisperer.toggleCodeSuggestion',
@@ -64,7 +65,7 @@ export const showReferenceLog = Commands.declare(
6465
)
6566

6667
export const showIntroduction = Commands.declare('aws.codeWhisperer.introduction', () => async () => {
67-
vscode.env.openExternal(vscode.Uri.parse(CodeWhispererConstants.learnMoreUriGeneral))
68+
openUrl(vscode.Uri.parse(CodeWhispererConstants.learnMoreUriGeneral))
6869
})
6970

7071
export const showSecurityScan = Commands.declare(
@@ -116,13 +117,12 @@ export const showSsoSignIn = Commands.declare('aws.codeWhisperer.sso', () => asy
116117

117118
export const showLearnMore = Commands.declare('aws.codeWhisperer.learnMore', () => async () => {
118119
telemetry.ui_click.emit({ elementId: 'cw_learnMore_Cta' })
119-
120-
vscode.env.openExternal(vscode.Uri.parse(CodeWhispererConstants.learnMoreUriGeneral))
120+
openUrl(vscode.Uri.parse(CodeWhispererConstants.learnMoreUriGeneral))
121121
})
122122

123123
// TODO: Use a different URI
124124
export const showFreeTierLimit = Commands.declare('aws.codeWhisperer.freeTierLimit', () => async () => {
125-
vscode.env.openExternal(vscode.Uri.parse(CodeWhispererConstants.learnMoreUri))
125+
openUrl(vscode.Uri.parse(CodeWhispererConstants.learnMoreUri))
126126
})
127127

128128
export const updateReferenceLog = Commands.declare(

src/codewhisperer/commands/startSecurityScan.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { getDirSize } from '../../shared/filesystemUtilities'
3131
import { telemetry } from '../../shared/telemetry/telemetry'
3232
import { TelemetryHelper } from '../util/telemetryHelper'
3333
import { isAwsError } from '../../shared/errors'
34+
import { openUrl } from '../../shared/utilities/vsCodeUtils'
3435

3536
const performance = globalThis.performance ?? require('perf_hooks').performance
3637
const securityScanOutputChannel = vscode.window.createOutputChannel('CodeWhisperer Security Scan Logs')
@@ -284,7 +285,7 @@ export function showScanCompletedNotification(total: number, scannedFiles: Set<s
284285
if (value === CodeWhispererConstants.showScannedFilesMessage) {
285286
vscode.commands.executeCommand(CodeWhispererConstants.codeScanLogsOutputChannelId)
286287
} else if (value === learnMore) {
287-
vscode.env.openExternal(vscode.Uri.parse(CodeWhispererConstants.securityScanLearnMoreUri))
288+
openUrl(vscode.Uri.parse(CodeWhispererConstants.securityScanLearnMoreUri))
288289
}
289290
})
290291
}

src/dynamicResources/activation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ResourceTypeNode } from './explorer/nodes/resourceTypeNode'
1717
import { resourceFileGlobPattern } from './awsResourceManager'
1818
import { Commands } from '../shared/vscode/commands2'
1919
import globals from '../shared/extensionGlobals'
20+
import { openUrl } from '../shared/utilities/vsCodeUtils'
2021

2122
const localize = nls.loadMessageBundle()
2223

@@ -94,7 +95,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
9495
}
9596
}),
9697
Commands.register('aws.resources.viewDocs', async (node: ResourceTypeNode) => {
97-
await vscode.env.openExternal(vscode.Uri.parse(node.metadata.documentation))
98+
await openUrl(vscode.Uri.parse(node.metadata.documentation))
9899
}),
99100
vscode.workspace.onDidChangeTextDocument(textDocumentEvent => {
100101
if (resourceDiagnostics.has(textDocumentEvent.document.uri)) {

0 commit comments

Comments
 (0)