Skip to content

Commit aec21bb

Browse files
authored
Capturing telemetry events for write to file failures (RooCodeInc#2527)
* added telemetry to track diff edit failures * changeset
1 parent 931279c commit aec21bb

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

.changeset/dirty-rice-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
added telemetry to track replace_in_file tool failures

src/core/Cline.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,16 @@ export class Cline {
17481748
)
17491749
} catch (error) {
17501750
await this.say("diff_error", relPath)
1751+
1752+
// Extract error type from error message if possible, or use a generic type
1753+
const errorType =
1754+
error instanceof Error && error.message.includes("does not match anything")
1755+
? "search_not_found"
1756+
: "other_diff_error"
1757+
1758+
// Add telemetry for diff edit failure
1759+
telemetryService.captureDiffEditFailure(this.taskId, errorType)
1760+
17511761
pushToolResult(
17521762
formatResponse.toolError(
17531763
`${(error as Error)?.message}\n\n` +

src/services/telemetry/TelemetryService.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class PostHogClient {
3232
HISTORICAL_LOADED: "task.historical_loaded",
3333
// Tracks when the retry button is clicked for failed operations
3434
RETRY_CLICKED: "task.retry_clicked",
35+
// Tracks when a diff edit (replace_in_file) operation fails
36+
DIFF_EDIT_FAILED: "task.diff_edit_failed",
3537
},
3638
// UI interaction events for tracking user engagement
3739
UI: {
@@ -377,6 +379,21 @@ class PostHogClient {
377379
})
378380
}
379381

382+
/**
383+
* Records when a diff edit (replace_in_file) operation fails
384+
* @param taskId Unique identifier for the task
385+
* @param errorType Type of error that occurred (e.g., "search_not_found", "invalid_format")
386+
*/
387+
public captureDiffEditFailure(taskId: string, errorType?: string) {
388+
this.capture({
389+
event: PostHogClient.EVENTS.TASK.DIFF_EDIT_FAILED,
390+
properties: {
391+
taskId,
392+
errorType,
393+
},
394+
})
395+
}
396+
380397
/**
381398
* Records when a different model is selected for use
382399
* @param model Name of the selected model

0 commit comments

Comments
 (0)