Skip to content

Commit 022d858

Browse files
telemetry(auth): emit metric when Auth webview loaded
Problem: The inital problem is that when we focused chat, it returned succeeded even though it didn't have any idea if the UI was actually rendered to the user. Solution: This new solution will have the UI emit a telemetry metric once per session that indicates when the UI has loaded. It will also distinguish between the login and reauth page. The metric is `webview_load` and the `webviewName` field will distinguish between login and reauth NOTE: When Q chat itself has its UI ready we already emit a `webview_load` metric. So use all of these metrics to determine what the user actually saw Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 969f1ec commit 022d858

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

packages/core/src/login/webview/vue/backend.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ export abstract class CommonAuthWebview extends VueWebview {
6161
return globals.regionProvider.getRegions().reverse()
6262
}
6363

64+
private didCall: { login: boolean; reauth: boolean } = { login: false, reauth: false }
65+
public setUiReady(state: 'login' | 'reauth') {
66+
// Prevent telemetry spam, since showing/hiding chat triggers this each time.
67+
// So only emit once.
68+
if (this.didCall[state]) {
69+
return
70+
}
71+
72+
telemetry.webview_load.emit({
73+
passive: true,
74+
webviewName: state,
75+
result: 'Succeeded',
76+
})
77+
this.didCall[state] = true
78+
}
79+
6480
/**
6581
* This wraps the execution of the given setupFunc() and handles common errors from the SSO setup process.
6682
*

packages/core/src/login/webview/vue/login.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ export default defineComponent({
368368
// Pre-select the first available login option
369369
await this.preselectLoginOption()
370370
await this.handleUrlInput() // validate the default startUrl
371+
372+
await client.setUiReady('login')
371373
},
372374
methods: {
373375
toggleItemSelection(itemId: number) {

packages/core/src/login/webview/vue/reauthenticate.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ export default defineComponent({
127127
128128
this.doShow = true
129129
},
130+
async mounted() {
131+
await client.setUiReady('reauth')
132+
},
130133
methods: {
131134
async reauthenticate() {
132135
client.emitUiClick('auth_reauthenticate')

0 commit comments

Comments
 (0)