Skip to content

Commit b0b9a66

Browse files
Now we can check git out
* Added checkpoint telemetry * changeset * Update src/services/telemetry/TelemetryService.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
1 parent 6033d22 commit b0b9a66

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.changeset/quick-rings-eat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": patch
3+
---
4+
5+
Checkpoints Telemetry

src/integrations/checkpoints/CheckpointGitOperations.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { globby } from "globby"
33
import * as path from "path"
44
import simpleGit, { SimpleGit } from "simple-git"
55
import { HistoryItem } from "../../shared/HistoryItem"
6+
import { telemetryService } from "../../services/telemetry/TelemetryService"
67
import { fileExistsAtPath } from "../../utils/fs"
78
import { getLfsPatterns, writeExcludesFile } from "./CheckpointExclusions"
89
import { getWorkingDirectory, hashWorkingDir } from "./CheckpointUtils"
@@ -272,6 +273,14 @@ export class GitOperations {
272273
if (branches.all.includes(branchName)) {
273274
console.info(`Found branch ${branchName} to delete`)
274275
await GitOperations.deleteBranchForGit(git, branchName)
276+
277+
// Determine if the task is active based on whether we had to use the stored worktree path
278+
const isTaskActive = !historyItem.shadowGitConfigWorkTree
279+
telemetryService.captureCheckpointUsage(
280+
taskId,
281+
isTaskActive ? "branch_deleted_active" : "branch_deleted_inactive",
282+
)
283+
275284
return
276285
}
277286
console.warn(`Branch ${branchName} not found in branch-per-task repository`)
@@ -356,6 +365,7 @@ export class GitOperations {
356365
if (!branches.all.includes(branchName)) {
357366
console.info(`Creating new task branch: ${branchName}`)
358367
await git.checkoutLocalBranch(branchName)
368+
telemetryService.captureCheckpointUsage(taskId, "branch_created")
359369
} else {
360370
console.info(`Switching to existing task branch: ${branchName}`)
361371
await git.checkout(branchName)

src/integrations/checkpoints/CheckpointTracker.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from "path"
33
import simpleGit from "simple-git"
44
import * as vscode from "vscode"
55
import { HistoryItem } from "../../shared/HistoryItem"
6+
import { telemetryService } from "../../services/telemetry/TelemetryService"
67
import { GitOperations } from "./CheckpointGitOperations"
78
import { getShadowGitPath, hashWorkingDir, getWorkingDirectory } from "./CheckpointUtils"
89

@@ -113,7 +114,11 @@ class CheckpointTracker {
113114
// Branch-per-task structure
114115
const gitPath = await getShadowGitPath(newTracker.globalStoragePath, newTracker.taskId, newTracker.cwdHash)
115116
await newTracker.gitOperations.initShadowGit(gitPath, workingDir)
117+
118+
telemetryService.captureCheckpointUsage(taskId, "shadow_git_initialized")
119+
116120
await newTracker.gitOperations.switchToTaskBranch(newTracker.taskId, gitPath)
121+
117122
return newTracker
118123
} catch (error) {
119124
console.error("Failed to create CheckpointTracker:", error)
@@ -168,6 +173,7 @@ class CheckpointTracker {
168173
})
169174
const commitHash = result.commit || ""
170175
console.warn(`Checkpoint commit created.`)
176+
telemetryService.captureCheckpointUsage(this.taskId, "commit_created")
171177
return commitHash
172178
} catch (error) {
173179
console.error("Failed to create checkpoint:", {
@@ -241,6 +247,7 @@ class CheckpointTracker {
241247
await this.gitOperations.switchToTaskBranch(this.taskId, gitPath)
242248
await git.reset(["--hard", commitHash]) // Hard reset to target commit
243249
console.debug(`Successfully reset to checkpoint: ${commitHash}`)
250+
telemetryService.captureCheckpointUsage(this.taskId, "restored")
244251
}
245252

246253
/**

src/services/telemetry/TelemetryService.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PostHogClient {
2323
TOKEN_USAGE: "task.tokens",
2424
// Tracks switches between plan and act modes
2525
MODE_SWITCH: "task.mode",
26-
// Tracks usage of the git-based checkpoint system (create/restore/delete)
26+
// Tracks usage of the git-based checkpoint system (shadow_git_initialized, commit_created, branch_created, branch_deleted_active, branch_deleted_inactive, restored)
2727
CHECKPOINT_USED: "task.checkpoint_used",
2828
// Tracks when tools (like file operations, commands) are used
2929
TOOL_USED: "task.tool_used",
@@ -249,9 +249,18 @@ class PostHogClient {
249249
/**
250250
* Records interactions with the git-based checkpoint system
251251
* @param taskId Unique identifier for the task
252-
* @param action The type of checkpoint action (created/restored/deleted)
252+
* @param action The type of checkpoint action
253253
*/
254-
public captureCheckpointUsage(taskId: string, action: "created" | "restored" | "deleted") {
254+
public captureCheckpointUsage(
255+
taskId: string,
256+
action:
257+
| "shadow_git_initialized"
258+
| "commit_created"
259+
| "branch_created"
260+
| "branch_deleted_active"
261+
| "branch_deleted_inactive"
262+
| "restored",
263+
) {
255264
this.capture({
256265
event: PostHogClient.EVENTS.TASK.CHECKPOINT_USED,
257266
properties: {

0 commit comments

Comments
 (0)