From 590209ca76ae0a557df83a1d7f50d0cf69c6d66a Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Tue, 15 Apr 2025 00:07:54 -0400 Subject: [PATCH] Add telemetry for diff errors --- src/core/tools/applyDiffTool.ts | 4 ++++ src/services/telemetry/TelemetryService.ts | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/core/tools/applyDiffTool.ts b/src/core/tools/applyDiffTool.ts index 92fe94632df..2f68480e58d 100644 --- a/src/core/tools/applyDiffTool.ts +++ b/src/core/tools/applyDiffTool.ts @@ -10,6 +10,7 @@ import { addLineNumbers } from "../../integrations/misc/extract-text" import path from "path" import fs from "fs/promises" import { RecordSource } from "../context-tracking/FileContextTrackerTypes" +import { telemetryService } from "../../services/telemetry/TelemetryService" export async function applyDiffTool( cline: Cline, @@ -88,6 +89,9 @@ export async function applyDiffTool( const currentCount = (cline.consecutiveMistakeCountForApplyDiff.get(relPath) || 0) + 1 cline.consecutiveMistakeCountForApplyDiff.set(relPath, currentCount) let formattedError = "" + + telemetryService.captureDiffApplicationError(cline.taskId) + if (diffResult.failParts && diffResult.failParts.length > 0) { for (const failPart of diffResult.failParts) { if (failPart.success) { diff --git a/src/services/telemetry/TelemetryService.ts b/src/services/telemetry/TelemetryService.ts index 30145c6b98b..f80749bdb70 100644 --- a/src/services/telemetry/TelemetryService.ts +++ b/src/services/telemetry/TelemetryService.ts @@ -30,6 +30,7 @@ class PostHogClient { }, ERRORS: { SCHEMA_VALIDATION_ERROR: "Schema Validation Error", + DIFF_APPLICATION_ERROR: "Diff Application Error", }, } @@ -274,6 +275,12 @@ class TelemetryService { }) } + public captureDiffApplicationError(taskId: string): void { + this.captureEvent(PostHogClient.EVENTS.ERRORS.DIFF_APPLICATION_ERROR, { + taskId, + }) + } + /** * Checks if telemetry is currently enabled * @returns Whether telemetry is enabled