Skip to content

Commit cf5c567

Browse files
authored
fix(telemetry): do not throttle named events from commands #3032
Problem: * Telemetry package is outdated * Events emitted from commands are throttled by default, but this isn't desirable for 'named' events * Only affects certain CodeCatalyst commands Solution: * Update package * Skip throttling when commands have a telemetry name * Test coverage was added for this
1 parent d44be74 commit cf5c567

File tree

10 files changed

+123
-105
lines changed

10 files changed

+123
-105
lines changed

package-lock.json

Lines changed: 66 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3499,7 +3499,7 @@
34993499
"report": "nyc report --reporter=html --reporter=json"
35003500
},
35013501
"devDependencies": {
3502-
"@aws-toolkits/telemetry": "^1.0.80",
3502+
"@aws-toolkits/telemetry": "^1.0.82",
35033503
"@cspotcode/source-map-support": "^0.8.1",
35043504
"@sinonjs/fake-timers": "^8.1.0",
35053505
"@types/adm-zip": "^0.4.34",

src/codecatalyst/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const localize = nls.loadMessageBundle()
1010

1111
import * as vscode from 'vscode'
1212
import { selectCodeCatalystResource } from './wizards/selectResource'
13-
import { openCodeCatalystUrl } from './utils'
13+
import { openCodeCatalystUrl, recordSource } from './utils'
1414
import { CodeCatalystAuthenticationProvider } from './auth'
1515
import { Commands } from '../shared/vscode/commands2'
1616
import { CodeCatalystClient, CodeCatalystResource, createClient } from '../shared/clients/codecatalystClient'
@@ -236,7 +236,7 @@ export class CodeCatalystCommands {
236236
// need to be careful of mapping explosion so this granular data would either need
237237
// to be flattened or we restrict the names to a pre-determined set
238238
if (id === undefined) {
239-
telemetry.codecatalyst_connect.record({ source: 'CommandPalette' })
239+
recordSource('CommandPalette')
240240
}
241241

242242
return this.withClient(openDevEnv, devenv, targetPath)

src/codecatalyst/reconnect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { showViewLogsMessage } from '../shared/utilities/messages'
1515
import { CodeCatalystAuthenticationProvider } from './auth'
1616
import { getCodeCatalystDevEnvId } from '../shared/vscode/env'
1717
import globals from '../shared/extensionGlobals'
18-
import { telemetry } from '../shared/telemetry/telemetry'
18+
import { recordSource } from './utils'
1919

2020
const localize = nls.loadMessageBundle()
2121

@@ -223,7 +223,7 @@ async function openReconnectedDevEnv(
223223
project: { name: devenv.projectName },
224224
}
225225

226-
telemetry.codecatalyst_connect.record({ source: 'Reconnect' })
226+
recordSource('Reconnect')
227227
await codeCatalystConnectCommand.execute(client, identifier, devenv.previousVscodeWorkspace)
228228

229229
// When we only have 1 devenv to watch we might as well close the local vscode instance

src/codecatalyst/uriHandlers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import * as vscode from 'vscode'
77
import { SearchParams, UriHandler } from '../shared/vscode/uriHandler'
88
import { getCodeCatalystConfig } from '../shared/clients/codecatalystClient'
99
import { CodeCatalystCommands } from './commands'
10-
import { telemetry } from '../shared/telemetry/telemetry'
10+
import { recordSource } from './utils'
1111

1212
export function register(
1313
handler: UriHandler,
1414
commands: Pick<typeof CodeCatalystCommands.declared, 'cloneRepo' | 'openDevEnv'>
1515
) {
1616
async function cloneHandler(params: ReturnType<typeof parseCloneParams>) {
17-
telemetry.codecatalyst_localClone.record({ source: 'UriHandler' })
17+
recordSource('UriHandler')
1818

1919
if (params.url.authority.endsWith(getCodeCatalystConfig().gitHostname)) {
2020
await commands.cloneRepo.execute(params.url)
@@ -24,7 +24,7 @@ export function register(
2424
}
2525

2626
async function connectHandler(params: ReturnType<typeof parseConnectParams | typeof parseConnectParamsOld>) {
27-
telemetry.codecatalyst_connect.record({ source: 'UriHandler' })
27+
recordSource('UriHandler')
2828

2929
await commands.openDevEnv.execute({
3030
id: params.devEnvironmentId,

src/codecatalyst/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Ides } from 'aws-sdk/clients/codecatalyst'
77
import * as vscode from 'vscode'
88
import { CodeCatalystResource, getCodeCatalystConfig } from '../shared/clients/codecatalystClient'
99
import { pushIf } from '../shared/utilities/collectionUtils'
10+
import { telemetry } from '../shared/telemetry/telemetry'
1011

1112
/**
1213
* Builds a web URL from the given CodeCatalyst object.
@@ -54,3 +55,9 @@ export function openCodeCatalystUrl(o: CodeCatalystResource) {
5455
export function isCodeCatalystVSCode(ides: Ides | undefined): boolean {
5556
return ides !== undefined && ides.findIndex(ide => ide.name === 'VSCode') !== -1
5657
}
58+
59+
export function recordSource(source: 'Webview' | 'UriHandler' | 'Reconnect' | 'CommandPalette') {
60+
// TODO: add `source` (or something similar) as a base component to events
61+
telemetry.codecatalyst_connect.record({ source } as any)
62+
telemetry.codecatalyst_localClone.record({ source } as any)
63+
}

src/codecatalyst/vue/create/backend.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { CancellationError } from '../../../shared/utilities/timeoutUtils'
3131
import { isCloud9 } from '../../../shared/extensionUtilities'
3232
import { telemetry } from '../../../shared/telemetry/telemetry'
3333
import { isNonNullable } from '../../../shared/utilities/tsUtils'
34+
import { recordSource } from '../../utils'
3435

3536
interface LinkedResponse {
3637
readonly type: 'linked'
@@ -141,7 +142,7 @@ export class CodeCatalystCreateWebview extends VueWebview {
141142
}
142143
})()
143144

144-
telemetry.codecatalyst_connect.record({ source: 'Webview' })
145+
recordSource('Webview')
145146
telemetry.codecatalyst_createDevEnvironment.record({ codecatalyst_createDevEnvironmentRepoType: source.type })
146147

147148
this.onComplete(devenv)

src/shared/telemetry/vscodeTelemetry.json

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@
3131
"name": "cli",
3232
"type": "string",
3333
"description": "Installed CLI"
34-
},
35-
{
36-
"name": "codecatalyst_createDevEnvironmentRepoType",
37-
"type": "string",
38-
"description": "Type of Git repository provided to the Code Catalyst workspace create wizard",
39-
"allowedValues": ["linked", "none"]
40-
},
41-
{
42-
"name": "codecatalyst_updateDevEnvironmentLocationType",
43-
"type": "string",
44-
"description": "Locality of the Code Catalyst update workspace request (i.e., from the thin client or the local IDE instance)",
45-
"allowedValues": ["remote", "local"]
46-
},
47-
{
48-
"name": "userId",
49-
"type": "string",
50-
"description": "Opaque AWS ID identifier"
5134
}
5235
],
5336
"metrics": [
@@ -256,42 +239,6 @@
256239
{
257240
"name": "sam_openConfigUi",
258241
"description": "Called after opening the SAM Config UI"
259-
},
260-
{
261-
"name": "codecatalyst_createDevEnvironment",
262-
"description": "Create a Code Catalyst DevEnv",
263-
"metadata": [
264-
{ "type": "result" },
265-
{ "type": "userId" },
266-
{
267-
"type": "codecatalyst_createDevEnvironmentRepoType",
268-
"required": false
269-
}
270-
]
271-
},
272-
{
273-
"name": "codecatalyst_updateDevEnvironmentSettings",
274-
"description": "Update properties of a Code Catalyst development environment",
275-
"metadata": [
276-
{ "type": "result" },
277-
{ "type": "userId" },
278-
{ "type": "codecatalyst_updateDevEnvironmentLocationType" }
279-
]
280-
},
281-
{
282-
"name": "codecatalyst_updateDevfile",
283-
"description": "Trigger a devfile update on a Code Catalyst development environment",
284-
"metadata": [{ "type": "result" }, { "type": "userId" }]
285-
},
286-
{
287-
"name": "codecatalyst_localClone",
288-
"description": "Clone a Code Catalyst code repository locally",
289-
"metadata": [{ "type": "result" }, { "type": "userId" }, { "type": "source", "required": false }]
290-
},
291-
{
292-
"name": "codecatalyst_connect",
293-
"description": "Connect to a Code Catalyst development environment",
294-
"metadata": [{ "type": "result" }, { "type": "userId" }, { "type": "source", "required": false }]
295242
}
296243
]
297244
}

0 commit comments

Comments
 (0)