Telemetry for title button clicks (#3108)

This commit is contained in:
Matt Rubens 2025-05-01 23:11:32 -04:00 committed by GitHub
parent be387fa948
commit 2d8beb2ed0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View file

@ -3,6 +3,7 @@ import delay from "delay"
import { ClineProvider } from "../core/webview/ClineProvider"
import { ContextProxy } from "../core/config/ContextProxy"
import { telemetryService } from "../services/telemetry/TelemetryService"
import { registerHumanRelayCallback, unregisterHumanRelayCallback, handleHumanRelayResponse } from "./humanRelay"
import { handleNewTask } from "./handleTask"
@ -71,6 +72,8 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
return
}
telemetryService.captureTitleButtonClicked("plus")
await visibleProvider.removeClineFromStack()
await visibleProvider.postStateToWebview()
await visibleProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
@ -82,6 +85,8 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
return
}
telemetryService.captureTitleButtonClicked("mcp")
visibleProvider.postMessageToWebview({ type: "action", action: "mcpButtonClicked" })
},
"roo-cline.promptsButtonClicked": () => {
@ -91,9 +96,15 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
return
}
telemetryService.captureTitleButtonClicked("prompts")
visibleProvider.postMessageToWebview({ type: "action", action: "promptsButtonClicked" })
},
"roo-cline.popoutButtonClicked": () => openClineInNewTab({ context, outputChannel }),
"roo-cline.popoutButtonClicked": () => {
telemetryService.captureTitleButtonClicked("popout")
return openClineInNewTab({ context, outputChannel })
},
"roo-cline.openInNewTab": () => openClineInNewTab({ context, outputChannel }),
"roo-cline.settingsButtonClicked": () => {
const visibleProvider = getVisibleProviderOrLog(outputChannel)
@ -102,6 +113,8 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
return
}
telemetryService.captureTitleButtonClicked("settings")
visibleProvider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" })
},
"roo-cline.historyButtonClicked": () => {
@ -111,9 +124,13 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
return
}
telemetryService.captureTitleButtonClicked("history")
visibleProvider.postMessageToWebview({ type: "action", action: "historyButtonClicked" })
},
"roo-cline.helpButtonClicked": () => {
telemetryService.captureTitleButtonClicked("help")
vscode.env.openExternal(vscode.Uri.parse("https://docs.roocode.com"))
},
"roo-cline.showHumanRelayDialog": (params: { requestId: string; promptText: string }) => {

View file

@ -145,6 +145,14 @@ class TelemetryService {
this.captureEvent(PostHogClient.EVENTS.ERRORS.CONSECUTIVE_MISTAKE_ERROR, { taskId })
}
/**
* Captures a title button click event
* @param button The button that was clicked
*/
public captureTitleButtonClicked(button: string): void {
this.captureEvent("Title Button Clicked", { button })
}
/**
* Checks if telemetry is currently enabled
* @returns Whether telemetry is enabled