Capture telemetry for usage of code actions (#2650)

This commit is contained in:
Matt Rubens 2025-04-15 10:37:48 -04:00 committed by GitHub
parent afbf174e19
commit 31fd6e1470
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View file

@ -3,6 +3,7 @@ import * as vscode from "vscode"
import { ACTION_NAMES, COMMAND_IDS } from "../core/CodeActionProvider"
import { EditorUtils } from "../core/EditorUtils"
import { ClineProvider } from "../core/webview/ClineProvider"
import { telemetryService } from "../services/telemetry/TelemetryService"
export const registerCodeActions = (context: vscode.ExtensionContext) => {
registerCodeActionPair(

View file

@ -269,6 +269,9 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
promptType: keyof typeof ACTION_NAMES,
params: Record<string, string | any[]>,
): Promise<void> {
// Capture telemetry for code action usage
telemetryService.captureCodeActionUsed(promptType)
const visibleProvider = await ClineProvider.getInstance()
if (!visibleProvider) {
@ -302,6 +305,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
promptType: "TERMINAL_ADD_TO_CONTEXT" | "TERMINAL_FIX" | "TERMINAL_EXPLAIN",
params: Record<string, string | any[]>,
): Promise<void> {
// Capture telemetry for terminal action usage
telemetryService.captureCodeActionUsed(promptType)
const visibleProvider = await ClineProvider.getInstance()
if (!visibleProvider) {
return

View file

@ -27,6 +27,7 @@ class PostHogClient {
CHECKPOINT_CREATED: "Checkpoint Created",
CHECKPOINT_RESTORED: "Checkpoint Restored",
CHECKPOINT_DIFFED: "Checkpoint Diffed",
CODE_ACTION_USED: "Code Action Used",
},
ERRORS: {
SCHEMA_VALIDATION_ERROR: "Schema Validation Error",
@ -268,6 +269,12 @@ class TelemetryService {
this.captureEvent(PostHogClient.EVENTS.TASK.CHECKPOINT_RESTORED, { taskId })
}
public captureCodeActionUsed(actionType: string): void {
this.captureEvent(PostHogClient.EVENTS.TASK.CODE_ACTION_USED, {
actionType,
})
}
public captureSchemaValidationError({ schemaName, error }: { schemaName: string; error: ZodError }): void {
this.captureEvent(PostHogClient.EVENTS.ERRORS.SCHEMA_VALIDATION_ERROR, {
schemaName,