Skip to content

Commit 2ef9a42

Browse files
arangatangLeonardo Araneda Freccero
andauthored
Q CodeTransform: Emit projectId telemetry when starting new transformation. (#4543)
* Q CodeTransform: Emit projectId telemetry when starting new transformation. * Update package-lock.json * Format and move string to constant. --------- Co-authored-by: Leonardo Araneda Freccero <araneda@amazon.com>
1 parent bdccdaa commit 2ef9a42

File tree

7 files changed

+29
-10
lines changed

7 files changed

+29
-10
lines changed

package-lock.json

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

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4242,7 +4242,7 @@
42424242
},
42434243
"devDependencies": {
42444244
"@aws-sdk/types": "^3.13.1",
4245-
"@aws-toolkits/telemetry": "^1.0.193",
4245+
"@aws-toolkits/telemetry": "^1.0.196",
42464246
"@aws/fully-qualified-names": "^2.1.4",
42474247
"@cspotcode/source-map-support": "^0.8.1",
42484248
"@sinonjs/fake-timers": "^10.0.2",

packages/core/src/amazonqGumby/telemetry/codeTransformTelemetry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import * as CodeWhispererConstants from '../../codewhisperer/models/constants'
1616
import { codeTransformTelemetryState } from './codeTransformTelemetryState'
1717
import { MetadataResult } from '../../shared/telemetry/telemetryClient'
1818

19+
export const telemetryUndefined = 'undefined'
20+
1921
export enum CancelActionPositions {
2022
ApiError = 'apiError',
2123
LoadingPanel = 'loadingPanelStopButton',

packages/core/src/auth/secondaryAuth.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,12 @@ export class SecondaryAuth<T extends Connection = Connection> {
159159
public get isConnectionExpired() {
160160
if (this.activeConnection) {
161161
getLogger().info(
162-
indent(`secondaryAuth connection id = ${this.activeConnection.id}
162+
indent(
163+
`secondaryAuth connection id = ${this.activeConnection.id}
163164
secondaryAuth connection status = ${this.auth.getConnectionState(this.activeConnection)}`,
164-
4, true)
165+
4,
166+
true
167+
)
165168
)
166169
}
167170
return !!this.activeConnection && this.auth.getConnectionState(this.activeConnection) === 'invalid'

packages/core/src/auth/sso/ssoAccessTokenProvider.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ export class SsoAccessTokenProvider {
8787
public async getToken(): Promise<SsoToken | undefined> {
8888
const data = await this.cache.token.load(this.tokenCacheKey)
8989
getLogger().info(
90-
indent(`current client registration id=${data?.registration?.clientId},
90+
indent(
91+
`current client registration id=${data?.registration?.clientId},
9192
expires at ${data?.registration?.expiresAt},
92-
key = ${this.tokenCacheKey}`, 4, true)
93+
key = ${this.tokenCacheKey}`,
94+
4,
95+
true
96+
)
9397
)
9498
if (!data || !isExpired(data.token)) {
9599
return data?.token

packages/core/src/codewhisperer/commands/startTransformByQ.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { QuickPickItem } from 'vscode'
2828
import { MultiStepInputFlowController } from '../../shared//multiStepInputFlowController'
2929
import path from 'path'
3030
import { sleep } from '../../shared/utilities/timeoutUtils'
31-
import { encodeHTML } from '../../shared/utilities/textUtilities'
31+
import { encodeHTML, getStringHash } from '../../shared/utilities/textUtilities'
3232
import {
3333
CodeTransformJavaSourceVersionsAllowed,
3434
CodeTransformJavaTargetVersionsAllowed,
@@ -41,6 +41,7 @@ import {
4141
CancelActionPositions,
4242
JDKToTelemetryValue,
4343
calculateTotalLatency,
44+
telemetryUndefined,
4445
} from '../../amazonqGumby/telemetry/codeTransformTelemetry'
4546
import { MetadataResult } from '../../shared/telemetry/telemetryClient'
4647

@@ -93,6 +94,7 @@ async function collectInput(validProjects: Map<vscode.QuickPickItem, JDKVersion
9394
transformByQState.getTargetJDKVersion()
9495
) as CodeTransformJavaTargetVersionsAllowed,
9596
result: MetadataResult.Fail,
97+
codeTransformProjectId: getStringHash(state.project.label),
9698
})
9799
await vscode.window.showErrorMessage(CodeWhispererConstants.unsupportedJavaVersionSelectedMessage, {
98100
modal: true,
@@ -442,6 +444,12 @@ export async function setTransformationToRunningState(userInputState: UserInputS
442444

443445
codeTransformTelemetryState.setStartTime()
444446

447+
const projectPath = userInputState.project?.label
448+
let projectId = telemetryUndefined
449+
if (projectPath !== undefined) {
450+
projectId = getStringHash(projectPath)
451+
}
452+
445453
telemetry.codeTransform_jobStartedCompleteFromPopupDialog.emit({
446454
codeTransformSessionId: codeTransformTelemetryState.getSessionId(),
447455
codeTransformJavaSourceVersionsAllowed: JDKToTelemetryValue(
@@ -450,6 +458,7 @@ export async function setTransformationToRunningState(userInputState: UserInputS
450458
codeTransformJavaTargetVersionsAllowed: JDKToTelemetryValue(
451459
transformByQState.getTargetJDKVersion()
452460
) as CodeTransformJavaTargetVersionsAllowed,
461+
codeTransformProjectId: projectId,
453462
result: MetadataResult.Pass,
454463
})
455464

packages/core/src/codewhisperer/service/transformByQHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ export async function pollTransformationJob(jobId: string, validStates: string[]
845845
codeTransformJobId: jobId,
846846
codeTransformStatus: status,
847847
result: MetadataResult.Pass,
848+
codeTransformPreviousStatus: transformByQState.getPolledJobStatus(),
848849
})
849850
}
850851
transformByQState.setPolledJobStatus(status)

0 commit comments

Comments
 (0)