ENG-296 - Add telemetry for followup questions (#2661)

* initial

* added quantity

* task.options_ignored

* cleanup

* cleanup

* changeset

* Much neater

* cleanup
This commit is contained in:
canvrno authored and GitHub committed 2025-04-05 00:23:01 -05:00
1 parent 59dca4f55c
commit 075d82fb90
3 files changed
+53

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@cline/extension": patch
---
Telemetry added for when users click AI-generated options/questions, or if they ignore them. Also tracks the number of options that were displayed.
+10
View File
@@ -2649,6 +2649,9 @@ export class Task {
})
}
// Store the number of options for telemetry
const options = parsePartialArrayString(optionsRaw || "[]")
const { text, images } = await this.ask("followup", JSON.stringify(sharedMessage), false)
// Check if options contains the text response
@@ -2662,9 +2665,11 @@ export class Task {
selected: text,
} satisfies ClineAskQuestion)
await this.saveClineMessagesAndUpdateHistory()
telemetryService.captureOptionSelected(this.taskId, options.length, "act")
}
} else {
// Option not selected, send user feedback
telemetryService.captureOptionsIgnored(this.taskId, options.length, "act")
await this.say("user_feedback", text ?? "", images)
}
@@ -2705,6 +2710,9 @@ export class Task {
// })
// }
// Store the number of options for telemetry
const options = parsePartialArrayString(optionsRaw || "[]")
this.isAwaitingPlanResponse = true
let { text, images } = await this.ask("plan_mode_respond", JSON.stringify(sharedMessage), false)
this.isAwaitingPlanResponse = false
@@ -2725,10 +2733,12 @@ export class Task {
selected: text,
} satisfies ClinePlanModeResponse)
await this.saveClineMessagesAndUpdateHistory()
telemetryService.captureOptionSelected(this.taskId, options.length, "plan")
}
} else {
// Option not selected, send user feedback
if (text || images?.length) {
telemetryService.captureOptionsIgnored(this.taskId, options.length, "plan")
await this.say("user_feedback", text ?? "", images)
}
}
@@ -28,6 +28,10 @@ class PostHogClient {
TOKEN_USAGE: "task.tokens",
// Tracks switches between plan and act modes
MODE_SWITCH: "task.mode",
// Tracks when users select an option from AI-generated followup questions
OPTION_SELECTED: "task.option_selected",
// Tracks when users type a custom response instead of selecting an option from AI-generated followup questions
OPTIONS_IGNORED: "task.options_ignored",
// Tracks usage of the git-based checkpoint system (shadow_git_initialized, commit_created, branch_created, branch_deleted_active, branch_deleted_inactive, restored)
CHECKPOINT_USED: "task.checkpoint_used",
// Tracks when tools (like file operations, commands) are used
@@ -457,6 +461,40 @@ class PostHogClient {
})
}
/**
* Records when a user selects an option from AI-generated followup questions
* @param taskId Unique identifier for the task
* @param qty The quantity of options that were presented
* @param mode The mode in which the option was selected ("plan" or "act")
*/
public captureOptionSelected(taskId: string, qty: number, mode: "plan" | "act") {
this.capture({
event: PostHogClient.EVENTS.TASK.OPTION_SELECTED,
properties: {
taskId,
qty,
mode,
},
})
}
/**
* Records when a user types a custom response instead of selecting one of the AI-generated followup questions
* @param taskId Unique identifier for the task
* @param qty The quantity of options that were presented
* @param mode The mode in which the custom response was provided ("plan" or "act")
*/
public captureOptionsIgnored(taskId: string, qty: number, mode: "plan" | "act") {
this.capture({
event: PostHogClient.EVENTS.TASK.OPTIONS_IGNORED,
properties: {
taskId,
qty,
mode,
},
})
}
public isTelemetryEnabled(): boolean {
return this.telemetryEnabled
}