Skip to content

Commit 9c08d04

Browse files
committed
Add telemetry for checkpoint save/restore/diff
1 parent 85775ce commit 9c08d04

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/core/Cline.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3798,6 +3798,8 @@ export class Cline {
37983798
return
37993799
}
38003800

3801+
telemetryService.captureCheckpointDiffed(this.taskId)
3802+
38013803
if (!previousCommitHash && mode === "checkpoint") {
38023804
const previousCheckpoint = this.clineMessages
38033805
.filter(({ say }) => say === "checkpoint_saved")
@@ -3849,6 +3851,8 @@ export class Cline {
38493851
return
38503852
}
38513853

3854+
telemetryService.captureCheckpointCreated(this.taskId)
3855+
38523856
// Start the checkpoint process in the background.
38533857
service.saveCheckpoint(`Task: ${this.taskId}, Time: ${Date.now()}`).catch((err) => {
38543858
console.error("[Cline#checkpointSave] caught unexpected error, disabling checkpoints", err)
@@ -3880,6 +3884,8 @@ export class Cline {
38803884
try {
38813885
await service.restoreCheckpoint(commitHash)
38823886

3887+
telemetryService.captureCheckpointRestored(this.taskId)
3888+
38833889
await this.providerRef.deref()?.postMessageToWebview({ type: "currentCheckpointUpdated", text: commitHash })
38843890

38853891
if (mode === "restore") {

src/services/telemetry/TelemetryService.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class PostHogClient {
2222
CONVERSATION_MESSAGE: "Conversation Message",
2323
MODE_SWITCH: "Mode Switched",
2424
TOOL_USED: "Tool Used",
25+
CHECKPOINT_CREATED: "Checkpoint Created",
26+
CHECKPOINT_RESTORED: "Checkpoint Restored",
27+
CHECKPOINT_DIFFED: "Checkpoint Diffed",
2528
},
2629
}
2730

@@ -246,6 +249,18 @@ class TelemetryService {
246249
})
247250
}
248251

252+
public captureCheckpointCreated(taskId: string): void {
253+
this.captureEvent(PostHogClient.EVENTS.TASK.CHECKPOINT_CREATED, { taskId })
254+
}
255+
256+
public captureCheckpointDiffed(taskId: string): void {
257+
this.captureEvent(PostHogClient.EVENTS.TASK.CHECKPOINT_DIFFED, { taskId })
258+
}
259+
260+
public captureCheckpointRestored(taskId: string): void {
261+
this.captureEvent(PostHogClient.EVENTS.TASK.CHECKPOINT_RESTORED, { taskId })
262+
}
263+
249264
/**
250265
* Checks if telemetry is currently enabled
251266
* @returns Whether telemetry is enabled

0 commit comments

Comments
 (0)