Skip to content

Commit

Permalink
Telemetry: Fix hasV2Event often being included as an event property (
Browse files Browse the repository at this point in the history
  • Loading branch information
umpox authored Mar 15, 2024
1 parent 0b259fc commit 21d9298
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 69 deletions.
17 changes: 11 additions & 6 deletions vscode/src/chat/chat-view/SidebarViewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,17 @@ export class SidebarViewController implements vscode.WebviewViewProvider {
async (token, endpoint) => {
closeAuthProgressIndicator()
const authStatus = await this.authProvider.auth(endpoint, token)
telemetryService.log('CodyVSCodeExtension:auth:fromTokenReceiver', {
type: 'callback',
from: 'web',
success: Boolean(authStatus?.isLoggedIn),
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:auth:fromTokenReceiver',
{
type: 'callback',
from: 'web',
success: Boolean(authStatus?.isLoggedIn),
},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent(
'cody.auth.fromTokenReceiver.web',
'succeeded',
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/commands/GhostHintDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class GhostHintDecorator implements vscode.Disposable {
}

private _fireDisplayEvent(): void {
telemetryService.log('CodyVSCodeExtension:ghostText:visible', { hasV2Event: true })
telemetryService.log('CodyVSCodeExtension:ghostText:visible', {}, { hasV2Event: true })
telemetryRecorder.recordEvent('cody.ghostText', 'visible')
}

Expand Down
15 changes: 10 additions & 5 deletions vscode/src/edit/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,16 @@ export class EditProvider {
}

if (!isMessageInProgress) {
telemetryService.log('CodyVSCodeExtension:fixupResponse:hasCode', {
...countCode(response),
source: this.config.task.source,
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixupResponse:hasCode',
{
...countCode(response),
source: this.config.task.source,
},
{
hasV2Event: true,
}
)
const endpoint = this.config.authProvider?.getAuthStatus()?.endpoint
const responseText = endpoint && isDotCom(endpoint) ? response : undefined
telemetryRecorder.recordEvent('cody.fixup.response', 'hasCode', {
Expand Down
114 changes: 79 additions & 35 deletions vscode/src/non-stop/FixupController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,58 +50,93 @@ export class FixupController
this._disposables.push(
vscode.workspace.registerTextDocumentContentProvider('cody-fixup', this.contentStore),
vscode.commands.registerCommand('cody.fixup.codelens.cancel', id => {
telemetryService.log('CodyVSCodeExtension:fixup:codeLens:clicked', {
op: 'cancel',
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixup:codeLens:clicked',
{
op: 'cancel',
},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.fixup.codeLens', 'cancel')
return this.cancel(id)
}),
vscode.commands.registerCommand('cody.fixup.codelens.diff', id => {
telemetryService.log('CodyVSCodeExtension:fixup:codeLens:clicked', {
op: 'diff',
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixup:codeLens:clicked',
{
op: 'diff',
},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.fixup.codeLens', 'diff')
return this.diff(id)
}),
vscode.commands.registerCommand('cody.fixup.codelens.retry', async id => {
telemetryService.log('CodyVSCodeExtension:fixup:codeLens:clicked', {
op: 'regenerate',
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixup:codeLens:clicked',
{
op: 'regenerate',
},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.fixup.codeLens', 'retry')
return this.retry(id)
}),
vscode.commands.registerCommand('cody.fixup.codelens.undo', id => {
telemetryService.log('CodyVSCodeExtension:fixup:codeLens:clicked', {
op: 'undo',
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixup:codeLens:clicked',
{
op: 'undo',
},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.fixup.codeLens', 'undo')
return this.undo(id)
}),
vscode.commands.registerCommand('cody.fixup.codelens.accept', id => {
telemetryService.log('CodyVSCodeExtension:fixup:codeLens:clicked', {
op: 'accept',
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixup:codeLens:clicked',
{
op: 'accept',
},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.fixup.codeLens', 'accept')
return this.accept(id)
}),
vscode.commands.registerCommand('cody.fixup.codelens.error', id => {
telemetryService.log('CodyVSCodeExtension:fixup:codeLens:clicked', {
op: 'show_error',
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixup:codeLens:clicked',
{
op: 'show_error',
},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.fixup.codeLens', 'showError')
return this.showError(id)
}),
vscode.commands.registerCommand('cody.fixup.codelens.skip-formatting', id => {
telemetryService.log('CodyVSCodeExtension:fixup:codeLens:clicked', {
op: 'skip_formatting',
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixup:codeLens:clicked',
{
op: 'skip_formatting',
},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.fixup.codeLens', 'skipFormatting')
return this.skipFormatting(id)
}),
Expand Down Expand Up @@ -301,10 +336,15 @@ export class FixupController
private scheduleRespin(task: FixupTask): void {
const MAX_SPIN_COUNT_PER_TASK = 5
if (task.spinCount >= MAX_SPIN_COUNT_PER_TASK) {
telemetryService.log('CodyVSCodeExtension:fixup:respin', {
count: task.spinCount,
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixup:respin',
{
count: task.spinCount,
},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.fixup.respin', 'scheduled', {
metadata: { spinCount: task.spinCount },
})
Expand Down Expand Up @@ -737,9 +777,13 @@ export class FixupController
})

if (!editOk) {
telemetryService.log('CodyVSCodeExtension:fixup:revert:failed', {
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:fixup:revert:failed',
{},
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.fixup.revert', 'failed')
return
}
Expand Down
36 changes: 23 additions & 13 deletions vscode/src/services/AuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ export class AuthProvider {
public async signinMenu(type?: 'enterprise' | 'dotcom' | 'token', uri?: string): Promise<void> {
const mode = this.authStatus.isLoggedIn ? 'switch' : 'signin'
logDebug('AuthProvider:signinMenu', mode)
telemetryService.log('CodyVSCodeExtension:login:clicked', { hasV2Event: true })
telemetryService.log('CodyVSCodeExtension:login:clicked', {}, { hasV2Event: true })
telemetryRecorder.recordEvent('cody.auth.login', 'clicked')
const item = await AuthMenu(mode, this.endpointHistory)
if (!item) {
return
}
const menuID = type || item?.id
telemetryService.log('CodyVSCodeExtension:auth:selectSigninMenu', { menuID, hasV2Event: true })
telemetryService.log(
'CodyVSCodeExtension:auth:selectSigninMenu',
{ menuID },
{ hasV2Event: true }
)
telemetryRecorder.recordEvent('cody.auth.signin.menu', 'clicked', {
privateMetadata: { menuID },
})
Expand Down Expand Up @@ -132,10 +136,13 @@ export class AuthProvider {
return
}
const authState = await this.auth(instanceUrl, accessToken)
telemetryService.log('CodyVSCodeExtension:auth:fromToken', {
success: Boolean(authState?.isLoggedIn),
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:auth:fromToken',
{
success: Boolean(authState?.isLoggedIn),
},
{ hasV2Event: true }
)
telemetryRecorder.recordEvent('cody.auth.signin.token', 'clicked', {
metadata: {
success: authState?.isLoggedIn ? 1 : 0,
Expand All @@ -145,7 +152,7 @@ export class AuthProvider {
}

public async signoutMenu(): Promise<void> {
telemetryService.log('CodyVSCodeExtension:logout:clicked', { hasV2Event: true })
telemetryService.log('CodyVSCodeExtension:logout:clicked', {}, { hasV2Event: true })
telemetryRecorder.recordEvent('cody.auth.logout', 'clicked')
const { endpoint } = this.getAuthStatus()

Expand Down Expand Up @@ -363,12 +370,15 @@ export class AuthProvider {
return
}
const authState = await this.auth(endpoint, token, customHeaders)
telemetryService.log('CodyVSCodeExtension:auth:fromCallback', {
type: 'callback',
from: 'web',
success: Boolean(authState?.isLoggedIn),
hasV2Event: true,
})
telemetryService.log(
'CodyVSCodeExtension:auth:fromCallback',
{
type: 'callback',
from: 'web',
success: Boolean(authState?.isLoggedIn),
},
{ hasV2Event: true }
)
telemetryRecorder.recordEvent('cody.auth.fromCallback.web', 'succeeded', {
metadata: {
success: authState?.isLoggedIn ? 1 : 0,
Expand Down
23 changes: 14 additions & 9 deletions vscode/src/services/utils/codeblock-action-tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function setLastStoredCode(
const op = eventName.includes('copy') ? 'copy' : eventName.startsWith('insert') ? 'insert' : 'save'
const args = { op, charCount, lineCount, source, requestID }

telemetryService.log(`CodyVSCodeExtension:${eventName}:clicked`, { args, hasV2Event: true })
telemetryService.log(`CodyVSCodeExtension:${eventName}:clicked`, { args }, { hasV2Event: true })
telemetryRecorder.recordEvent(`cody.${eventName}`, 'clicked', {
metadata: {
lineCount,
Expand Down Expand Up @@ -135,14 +135,19 @@ export async function onTextDocumentChange(newCode: string): Promise<void> {
const op = 'paste'
const eventType = 'keyDown'
// e.g.'CodyVSCodeExtension:keyDown:Paste:clicked'
telemetryService.log(`CodyVSCodeExtension:${eventType}:Paste:clicked`, {
op,
lineCount,
charCount,
source,
requestID,
hasV2Event: true,
})
telemetryService.log(
`CodyVSCodeExtension:${eventType}:Paste:clicked`,
{
op,
lineCount,
charCount,
source,
requestID,
},
{
hasV2Event: true,
}
)

telemetryRecorder.recordEvent(`cody.${eventType}`, 'paste', {
metadata: {
Expand Down

0 comments on commit 21d9298

Please sign in to comment.