Skip to content

Commit b856029

Browse files
authored
CodeWhisperer: Getting Started UX #3861
Problem User can see Getting Started UX Even without Login Solution Fixed the problem and now user can see the Getting Started UX only if user is logged in. Made Telemetry changes to capture user clicks in getting started UX.
1 parent b378ac5 commit b856029

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

src/codewhisperer/commands/gettingStartedPageCommands.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ import * as vscode from 'vscode'
66
import { CommandDeclarations, Commands } from '../../shared/vscode/commands2'
77
import { showCodeWhispererWebview, CodeWhispererSource } from '../vue/backend'
88
import { telemetry } from '../../shared/telemetry/telemetry'
9+
import { PromptSettings } from '../../shared/settings'
910
/**
1011
* The methods with backend logic for the Codewhisperer Getting Started Page commands.
1112
*/
1213
export class CodeWhispererCommandBackend {
1314
constructor(private readonly extContext: vscode.ExtensionContext) {}
14-
public showGettingStartedPage(source: CodeWhispererSource) {
15-
telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_ButtonClick', passive: true })
15+
public async showGettingStartedPage(source: CodeWhispererSource) {
16+
const prompts = PromptSettings.instance
17+
//To check the condition If the user has already seen the welcome message
18+
if (!(await prompts.isPromptEnabled('codeWhispererNewWelcomeMessage'))) {
19+
telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_ButtonClick', passive: true })
20+
}
1621
return showCodeWhispererWebview(this.extContext, source)
1722
}
1823
}

src/codewhisperer/service/recommendationHandler.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,19 @@ export class RecommendationHandler {
135135
}
136136
}
137137

138-
async getTaskTypeFromEditorFileName(fileName: string): Promise<CodewhispererGettingStartedTask> {
139-
if (fileName.startsWith('CodeWhisperer_generate_suggestion')) {
138+
async getTaskTypeFromEditorFileName(filePath: string): Promise<CodewhispererGettingStartedTask | undefined> {
139+
if (filePath.includes('CodeWhisperer_generate_suggestion')) {
140140
return 'autoTrigger'
141-
} else if (fileName.startsWith('CodeWhisperer_manual_invoke')) {
141+
} else if (filePath.includes('CodeWhisperer_manual_invoke')) {
142142
return 'manualTrigger'
143-
} else if (fileName.startsWith('CodeWhisperer_use_comments')) {
143+
} else if (filePath.includes('CodeWhisperer_use_comments')) {
144144
return 'commentAsPrompt'
145-
} else if (fileName.startsWith('CodeWhisperer_navigate_suggestions')) {
145+
} else if (filePath.includes('CodeWhisperer_navigate_suggestions')) {
146146
return 'navigation'
147-
} else {
147+
} else if (filePath.includes('Generate_unit_tests')) {
148148
return 'unitTest'
149+
} else {
150+
return undefined
149151
}
150152
}
151153

src/codewhisperer/util/authUtil.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ export class AuthUtil {
7272
vscode.commands.executeCommand('aws.codeWhisperer.refreshStatusBar'),
7373
vscode.commands.executeCommand('aws.codeWhisperer.updateReferenceLog'),
7474
])
75-
await vscode.commands.executeCommand('aws.codeWhisperer.enableCodeSuggestions')
75+
// To check valid connection
76+
if (this.isValidEnterpriseSsoInUse() || (this.isBuilderIdInUse() && !this.isConnectionExpired())) {
77+
await vscode.commands.executeCommand('aws.codeWhisperer.enableCodeSuggestions')
78+
}
7679
await vscode.commands.executeCommand('setContext', 'CODEWHISPERER_ENABLED', this.isConnected())
7780
})
7881
}

src/codewhisperer/util/codeWhispererSession.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CodeWhispererSession {
2626
supplementalMetadata: Omit<CodeWhispererSupplementalContext, 'supplementalContextItems'> | undefined
2727
} = { request: {} as any, supplementalMetadata: {} as any }
2828
language: CodewhispererLanguage = 'java'
29-
taskType: CodewhispererGettingStartedTask = 'autoTrigger'
29+
taskType: CodewhispererGettingStartedTask | undefined
3030
// Various states of recommendations
3131
recommendations: Recommendation[] = []
3232
suggestionStates = new Map<number, string>()

src/codewhisperer/vue/backend.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import globals from '../../shared/extensionGlobals'
1313
import { telemetry, CodewhispererLanguage, CodewhispererGettingStartedTask } from '../../shared/telemetry/telemetry'
1414
import { FileSystemCommon } from '../../srcShared/fs'
1515
import { getLogger } from '../../shared/logger'
16+
import { PromptSettings } from '../../shared/settings'
1617
export type OSType = 'Mac' | 'RestOfOS'
1718
export class CodeWhispererWebview extends VueWebview {
1819
public readonly id = 'CodeWhispererWebview'
@@ -156,5 +157,12 @@ export async function showCodeWhispererWebview(
156157
subscriptions = undefined
157158
}),
158159
]
160+
const prompts = PromptSettings.instance
161+
//To check the condition If the user has already seen the welcome message
162+
if (await prompts.isPromptEnabled('codeWhispererNewWelcomeMessage')) {
163+
telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_PageOpen', passive: true })
164+
} else {
165+
telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_PageOpen', passive: false })
166+
}
159167
}
160168
}

src/codewhisperer/vue/root.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ import Shortcuts from './shortcuts.vue'
8181
import ScanCode from './scanCode.vue'
8282
import GenerateSuggestionTab from './genSuggestionTab.vue'
8383
import Workshop from './workshop.vue'
84-
import { CodeWhispererWebview } from './backend'
85-
import { WebviewClientFactory } from '../../webviews/client'
86-
87-
const client = WebviewClientFactory.create<CodeWhispererWebview>()
8884
8985
export default defineComponent({
9086
name: 'Getting_Started',
@@ -101,10 +97,6 @@ export default defineComponent({
10197
active: parseInt(sessionStorage.getItem('active') || '0'),
10298
}
10399
},
104-
//The created hook runs before the templates and Virtual DOM have been mounted or rendered
105-
created() {
106-
client.emitUiClick('codewhisperer_Learn_PageOpen')
107-
},
108100
mounted() {
109101
/*
110102
We use Session Storage here because we need to store the the first time signin user and Existing first time signin state globally. According to this we need to display the banner.

0 commit comments

Comments
 (0)