Skip to content

Commit 5cf0615

Browse files
authored
codeWhisperer: fix for auto-enable suggestion on window reload and changes in Telemetry events (#3870)
* CW: Fix auto-enable suggestion on window reload * Telemetry changes in serviceInvocation and userTriggerDecision events
1 parent 5bfe471 commit 5cf0615

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/codewhisperer/commands/basicCommands.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { openUrl } from '../../shared/utilities/vsCodeUtils'
2222
import { CodeWhispererCommandDeclarations } from '../commands/gettingStartedPageCommands'
2323
import { getIcon } from '../../shared/icons'
2424
import { localize } from '../../shared/utilities/vsCodeUtils'
25-
import { PromptSettings } from '../../shared/settings'
2625

2726
export const toggleCodeSuggestions = Commands.declare(
2827
'aws.codeWhisperer.toggleCodeSuggestion',
@@ -57,14 +56,6 @@ export const enableCodeSuggestions = Commands.declare(
5756
await set(CodeWhispererConstants.autoTriggerEnabledKey, true, context.extensionContext.globalState)
5857
await vscode.commands.executeCommand('setContext', 'CODEWHISPERER_ENABLED', true)
5958
await vscode.commands.executeCommand('aws.codeWhisperer.refresh')
60-
const prompts = PromptSettings.instance
61-
62-
const shouldShow = await prompts.isPromptEnabled('codeWhispererNewWelcomeMessage')
63-
//If user login old or new, If welcome message is not shown then open the Getting Started Page after this mark it as SHOWN.
64-
if (shouldShow) {
65-
vscode.commands.executeCommand('aws.codeWhisperer.gettingStarted', createGettingStartedNode())
66-
prompts.update('codeWhispererNewWelcomeMessage', true)
67-
}
6859
if (!isCloud9()) {
6960
await vscode.commands.executeCommand('aws.codeWhisperer.refreshStatusBar')
7061
}

src/codewhisperer/service/recommendationHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ export class RecommendationHandler {
309309
latency,
310310
session.startPos.line,
311311
session.language,
312+
session.taskType,
312313
reason,
313314
session.requestContext.supplementalMetadata
314315
)

src/codewhisperer/util/authUtil.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,17 @@ export class AuthUtil {
7272
vscode.commands.executeCommand('aws.codeWhisperer.refreshStatusBar'),
7373
vscode.commands.executeCommand('aws.codeWhisperer.updateReferenceLog'),
7474
])
75-
75+
const prompts = PromptSettings.instance
76+
77+
const shouldShow = await prompts.isPromptEnabled('codeWhispererNewWelcomeMessage')
78+
// To check valid connection
79+
if (this.isValidEnterpriseSsoInUse() || (this.isBuilderIdInUse() && !this.isConnectionExpired())) {
80+
//If user login old or new, If welcome message is not shown then open the Getting Started Page after this mark it as SHOWN.
81+
if (shouldShow) {
82+
vscode.commands.executeCommand('aws.codeWhisperer.gettingStarted')
83+
prompts.update('codeWhispererNewWelcomeMessage', true)
84+
}
85+
}
7686
await vscode.commands.executeCommand('setContext', 'CODEWHISPERER_ENABLED', this.isConnected())
7787
})
7888
}

src/codewhisperer/util/telemetryHelper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { runtimeLanguageContext } from './runtimeLanguageContext'
88
import { codeWhispererClient as client, RecommendationsList } from '../client/codewhisperer'
99
import { LicenseUtil } from './licenseUtil'
1010
import {
11+
CodewhispererGettingStartedTask,
1112
CodewhispererLanguage,
1213
CodewhispererPreviousSuggestionState,
1314
CodewhispererServiceInvocation,
@@ -86,6 +87,7 @@ export class TelemetryHelper {
8687
duration: number | undefined,
8788
lineNumber: number | undefined,
8889
language: CodewhispererLanguage,
90+
taskType: CodewhispererGettingStartedTask | undefined,
8991
reason: string,
9092
supplementalContextMetadata?: Omit<CodeWhispererSupplementalContext, 'supplementalContextItems'> | undefined
9193
) {
@@ -100,6 +102,7 @@ export class TelemetryHelper {
100102
codewhispererLineNumber: lineNumber || 0,
101103
codewhispererCursorOffset: this.cursorOffset || 0,
102104
codewhispererLanguage: language,
105+
CodewhispererGettingStartedTask: taskType,
103106
reason: reason ? reason.substring(0, 200) : undefined,
104107
credentialStartUrl: AuthUtil.instance.startUrl,
105108
codewhispererImportRecommendationEnabled: CodeWhispererSettings.instance.isImportRecommendationEnabled(),
@@ -245,6 +248,7 @@ export class TelemetryHelper {
245248
credentialStartUrl: events[0].credentialStartUrl,
246249
codewhispererCompletionType: this.getAggregatedCompletionType(events),
247250
codewhispererLanguage: events[0].codewhispererLanguage,
251+
codewhispererGettingStartedTask: session.taskType,
248252
codewhispererTriggerType: events[0].codewhispererTriggerType,
249253
codewhispererSuggestionCount: events.length,
250254
codewhispererAutomatedTriggerType: serviceInvocation.codewhispererAutomatedTriggerType,
@@ -288,7 +292,7 @@ export class TelemetryHelper {
288292
credentialStartUrl: this.sessionDecisions[0].credentialStartUrl,
289293
codewhispererCompletionType: aggregatedCompletionType,
290294
codewhispererLanguage: language,
291-
codewhispererGettingStartedTask: this.sessionDecisions[0].codewhispererGettingStartedTask,
295+
codewhispererGettingStartedTask: session.taskType,
292296
codewhispererTriggerType: this.sessionDecisions[0].codewhispererTriggerType,
293297
codewhispererSuggestionCount: this.sessionDecisions
294298
.map(e => e.codewhispererSuggestionCount)

0 commit comments

Comments
 (0)