diff --git a/src/common.ts b/src/common.ts index 7f831af7..d972bc71 100644 --- a/src/common.ts +++ b/src/common.ts @@ -12,7 +12,7 @@ import "./utils/path" // necessary to have access to String.prototype.toPosix import { HostProvider } from "@/hosts/host-provider" import { FileContextTracker } from "./core/context/context-tracking/FileContextTracker" -import { telemetryService } from "./services/posthog/PostHogClientProvider" +// import { telemetryService } from "./services/posthog/PostHogClientProvider" import { ShowMessageType } from "./shared/proto/host/window" import { getLatestAnnouncementId } from "./utils/announcements" /** @@ -51,7 +51,7 @@ export async function initialize(context: vscode.ExtensionContext): Promise 0) { - console.log("+++++++++++++++++++++nonToolMessages.length+++++++++++++++++++++++++", nonToolMessages.length) openAiMessages.push({ role: "user", - // content: nonToolMessages.slice(-6).map((part) => { content: nonToolMessages.map((part) => { if (part.type === "image") { return { @@ -93,12 +91,7 @@ export function convertToOpenAiMessages( }, } } - // return { type: "text", text: part.text } - console.log( - "+++++++++++++++++++++nonToolMessage.text.length+++++++++++++++++++++++++", - part.text.length, - ) - return { type: "text", text: part.text.substring(0, 6000) } + return { type: "text", text: part.text } }), }) } diff --git a/src/core/api/transform/openai-format.ts.bk b/src/core/api/transform/openai-format.ts.bk deleted file mode 100644 index 19c2f005..00000000 --- a/src/core/api/transform/openai-format.ts.bk +++ /dev/null @@ -1,208 +0,0 @@ -import { Anthropic } from "@anthropic-ai/sdk" -import OpenAI from "openai" - -export function convertToOpenAiMessages( - anthropicMessages: Anthropic.Messages.MessageParam[], -): OpenAI.Chat.ChatCompletionMessageParam[] { - const openAiMessages: OpenAI.Chat.ChatCompletionMessageParam[] = [] - - for (const anthropicMessage of anthropicMessages) { - if (typeof anthropicMessage.content === "string") { - openAiMessages.push({ - role: anthropicMessage.role, - content: anthropicMessage.content, - }) - } else { - // image_url.url is base64 encoded image data - // ensure it contains the content-type of the image: data:image/png;base64, - /* - { role: "user", content: "" | { type: "text", text: string } | { type: "image_url", image_url: { url: string } } }, - // content required unless tool_calls is present - { role: "assistant", content?: "" | null, tool_calls?: [{ id: "", function: { name: "", arguments: "" }, type: "function" }] }, - { role: "tool", tool_call_id: "", content: ""} - */ - if (anthropicMessage.role === "user") { - const { nonToolMessages, toolMessages } = anthropicMessage.content.reduce<{ - nonToolMessages: (Anthropic.TextBlockParam | Anthropic.ImageBlockParam)[] - toolMessages: Anthropic.ToolResultBlockParam[] - }>( - (acc, part) => { - if (part.type === "tool_result") { - acc.toolMessages.push(part) - } else if (part.type === "text" || part.type === "image") { - acc.nonToolMessages.push(part) - } // user cannot send tool_use messages - return acc - }, - { nonToolMessages: [], toolMessages: [] }, - ) - - // Process tool result messages FIRST since they must follow the tool use messages - const toolResultImages: Anthropic.Messages.ImageBlockParam[] = [] - toolMessages.forEach((toolMessage) => { - // The Anthropic SDK allows tool results to be a string or an array of text and image blocks, enabling rich and structured content. In contrast, the OpenAI SDK only supports tool results as a single string, so we map the Anthropic tool result parts into one concatenated string to maintain compatibility. - let content: string - if (typeof toolMessage.content === "string") { - content = toolMessage.content - } else { - content = - toolMessage.content - ?.map((part) => { - if (part.type === "image") { - toolResultImages.push(part) - return "(see following user message for image)" - } - return part.text - }) - .join("\n") ?? "" - } - openAiMessages.push({ - role: "tool", - tool_call_id: toolMessage.tool_use_id, - content: content, - }) - }) - - // If tool results contain images, send as a separate user message - // I ran into an issue where if I gave feedback for one of many tool uses, the request would fail. - // "Messages following `tool_use` blocks must begin with a matching number of `tool_result` blocks." - // Therefore we need to send these images after the tool result messages - // NOTE: it's actually okay to have multiple user messages in a row, the model will treat them as a continuation of the same input (this way works better than combining them into one message, since the tool result specifically mentions (see following user message for image) - // UPDATE v2.0: we don't use tools anymore, but if we did it's important to note that the openrouter prompt caching mechanism requires one user message at a time, so we would need to add these images to the user content array instead. - // if (toolResultImages.length > 0) { - // openAiMessages.push({ - // role: "user", - // content: toolResultImages.map((part) => ({ - // type: "image_url", - // image_url: { url: `data:${part.source.media_type};base64,${part.source.data}` }, - // })), - // }) - // } - - // Process non-tool messages - if (nonToolMessages.length > 0) { - openAiMessages.push({ - role: "user", - content: nonToolMessages.map((part) => { - if (part.type === "image") { - return { - type: "image_url", - image_url: { - url: `data:${part.source.media_type};base64,${part.source.data}`, - }, - } - } - return { type: "text", text: part.text.substring(0, 500) } - }), - }) - } - } else if (anthropicMessage.role === "assistant") { - const { nonToolMessages, toolMessages } = anthropicMessage.content.reduce<{ - nonToolMessages: (Anthropic.TextBlockParam | Anthropic.ImageBlockParam)[] - toolMessages: Anthropic.ToolUseBlockParam[] - }>( - (acc, part) => { - if (part.type === "tool_use") { - acc.toolMessages.push(part) - } else if (part.type === "text" || part.type === "image") { - acc.nonToolMessages.push(part) - } // assistant cannot send tool_result messages - return acc - }, - { nonToolMessages: [], toolMessages: [] }, - ) - - // Process non-tool messages - let content: string | undefined - if (nonToolMessages.length > 0) { - content = nonToolMessages - .map((part) => { - if (part.type === "image") { - return "" // impossible as the assistant cannot send images - } - return part.text - }) - .join("\n") - } - - // Process tool use messages - const tool_calls: OpenAI.Chat.ChatCompletionMessageToolCall[] = toolMessages.map((toolMessage) => ({ - id: toolMessage.id, - type: "function", - function: { - name: toolMessage.name, - // json string - arguments: JSON.stringify(toolMessage.input), - }, - })) - - openAiMessages.push({ - role: "assistant", - content, - // Cannot be an empty array. API expects an array with minimum length 1, and will respond with an error if it's empty - tool_calls: tool_calls.length > 0 ? tool_calls : undefined, - }) - } - } - } - - return openAiMessages -} - -// Convert OpenAI response to Anthropic format -export function convertToAnthropicMessage(completion: OpenAI.Chat.Completions.ChatCompletion): Anthropic.Messages.Message { - const openAiMessage = completion.choices[0].message - const anthropicMessage: Anthropic.Messages.Message = { - id: completion.id, - type: "message", - role: openAiMessage.role, // always "assistant" - content: [ - { - type: "text", - text: openAiMessage.content || "", - citations: null, - }, - ], - model: completion.model, - stop_reason: (() => { - switch (completion.choices[0].finish_reason) { - case "stop": - return "end_turn" - case "length": - return "max_tokens" - case "tool_calls": - return "tool_use" - case "content_filter": // Anthropic doesn't have an exact equivalent - default: - return null - } - })(), - stop_sequence: null, // which custom stop_sequence was generated, if any (not applicable if you don't use stop_sequence) - usage: { - input_tokens: completion.usage?.prompt_tokens || 0, - output_tokens: completion.usage?.completion_tokens || 0, - cache_creation_input_tokens: null, - cache_read_input_tokens: null, - }, - } - - if (openAiMessage.tool_calls && openAiMessage.tool_calls.length > 0) { - anthropicMessage.content.push( - ...openAiMessage.tool_calls.map((toolCall): Anthropic.ToolUseBlock => { - let parsedInput = {} - try { - parsedInput = JSON.parse(toolCall.function.arguments || "{}") - } catch (error) { - console.error("Failed to parse tool arguments:", error) - } - return { - type: "tool_use", - id: toolCall.id, - name: toolCall.function.name, - input: parsedInput, - } - }), - ) - } - return anthropicMessage -} diff --git a/src/core/controller/task/taskFeedback.ts b/src/core/controller/task/taskFeedback.ts index 729b8a3e..a24d6fe4 100644 --- a/src/core/controller/task/taskFeedback.ts +++ b/src/core/controller/task/taskFeedback.ts @@ -1,4 +1,4 @@ -import { telemetryService } from "@services/posthog/PostHogClientProvider" +// import { telemetryService } from "@services/posthog/PostHogClientProvider" import { Empty, StringRequest } from "@shared/proto/cline/common" import { Controller } from ".." @@ -16,7 +16,8 @@ export async function taskFeedback(controller: Controller, request: StringReques try { if (controller.task?.ulid) { - telemetryService.captureTaskFeedback(controller.task.ulid, request.value as any) + console.log(controller.task.ulid, request.value as any) + // telemetryService.captureTaskFeedback(controller.task.ulid, request.value as any) } else { console.warn("taskFeedback: No active task to receive feedback") } diff --git a/src/core/controller/ui/openWalkthrough.ts b/src/core/controller/ui/openWalkthrough.ts index 457724ca..49fb2eab 100644 --- a/src/core/controller/ui/openWalkthrough.ts +++ b/src/core/controller/ui/openWalkthrough.ts @@ -1,4 +1,4 @@ -import { telemetryService } from "@services/posthog/PostHogClientProvider" +// import { telemetryService } from "@services/posthog/PostHogClientProvider" import type { EmptyRequest } from "@shared/proto/cline/common" import { Empty } from "@shared/proto/cline/common" import * as vscode from "vscode" @@ -13,7 +13,7 @@ import type { Controller } from "../index" export async function openWalkthrough(_controller: Controller, _request: EmptyRequest): Promise { try { await vscode.commands.executeCommand("workbench.action.openWalkthrough", "saoudrizwan.claude-dev#ClineWalkthrough") - telemetryService.captureButtonClick("webview_openWalkthrough") + // telemetryService.captureButtonClick("webview_openWalkthrough") return Empty.create({}) } catch (error) { console.error(`Failed to open walkthrough: ${error}`) diff --git a/src/core/task/index.ts b/src/core/task/index.ts index 12d67e2f..7e95bd6c 100644 --- a/src/core/task/index.ts +++ b/src/core/task/index.ts @@ -43,7 +43,7 @@ import { UrlContentFetcher } from "@services/browser/UrlContentFetcher" import { listFiles } from "@services/glob/list-files" import { Logger } from "@services/logging/Logger" import { McpHub } from "@services/mcp/McpHub" -import { telemetryService } from "@services/posthog/PostHogClientProvider" +// import { telemetryService } from "@services/posthog/PostHogClientProvider" import { AutoApprovalSettings } from "@shared/AutoApprovalSettings" import { ApiConfiguration } from "@shared/api" import { findLast, findLastIndex } from "@shared/array" @@ -333,13 +333,14 @@ export class Task { } // initialize telemetry - if (historyItem) { - // Open task from history - telemetryService.captureTaskRestarted(this.ulid, currentProvider) - } else { - // New task started - telemetryService.captureTaskCreated(this.ulid, currentProvider) - } + // if (historyItem) { + // // Open task from history + // console.log(this.ulid, currentProvider) + // // telemetryService.captureTaskRestarted(this.ulid, currentProvider) + // } else { + // // New task started + // telemetryService.captureTaskCreated(this.ulid, currentProvider) + // } this.toolExecutor = new ToolExecutor( this.controller.context, @@ -387,7 +388,7 @@ export class Task { public updateUseAutoCondense(useAutoCondense: boolean): void { // Track the setting change with current task and model context - telemetryService.captureAutoCondenseToggle(this.ulid, useAutoCondense, this.api.getModel().id) + // telemetryService.captureAutoCondenseToggle(this.ulid, useAutoCondense, this.api.getModel().id) this.useAutoCondense = useAutoCondense } @@ -2253,13 +2254,13 @@ export class Task { content: userContent, }) - telemetryService.captureConversationTurnEvent(this.ulid, providerId, model.id, "user") + // telemetryService.captureConversationTurnEvent(this.ulid, providerId, model.id, "user") - // Capture task initialization timing telemetry for the first API request - if (isFirstRequest) { - const durationMs = Math.round(performance.now() - this.taskInitializationStartTime) - telemetryService.captureTaskInitialization(this.ulid, this.taskId, durationMs, this.enableCheckpoints) - } + // // Capture task initialization timing telemetry for the first API request + // if (isFirstRequest) { + // const durationMs = Math.round(performance.now() - this.taskInitializationStartTime) + // telemetryService.captureTaskInitialization(this.ulid, this.taskId, durationMs, this.enableCheckpoints) + // } // since we sent off a placeholder api_req_started message to update the webview while waiting to actually start the API request (to load potential details for example), we need to update the text of that message const lastApiReqIndex = findLastIndex(this.messageStateHandler.getClineMessages(), (m) => m.say === "api_req_started") @@ -2324,13 +2325,13 @@ export class Task { }) await this.messageStateHandler.saveClineMessagesAndUpdateHistory() - telemetryService.captureConversationTurnEvent(this.ulid, providerId, this.api.getModel().id, "assistant", { - tokensIn: inputTokens, - tokensOut: outputTokens, - cacheWriteTokens, - cacheReadTokens, - totalCost, - }) + // telemetryService.captureConversationTurnEvent(this.ulid, providerId, this.api.getModel().id, "assistant", { + // tokensIn: inputTokens, + // tokensOut: outputTokens, + // cacheWriteTokens, + // cacheReadTokens, + // totalCost, + // }) // signals to provider that it can retrieve the saved messages from disk, as abortTask can not be awaited on in nature this.taskState.didFinishAbortingStream = true @@ -2495,13 +2496,13 @@ export class Task { // need to save assistant responses to file before proceeding to tool use since user can exit at any moment and we wouldn't be able to save the assistant's response let didEndLoop = false if (assistantMessage.length > 0) { - telemetryService.captureConversationTurnEvent(this.ulid, providerId, model.id, "assistant", { - tokensIn: inputTokens, - tokensOut: outputTokens, - cacheWriteTokens, - cacheReadTokens, - totalCost, - }) + // telemetryService.captureConversationTurnEvent(this.ulid, providerId, model.id, "assistant", { + // tokensIn: inputTokens, + // tokensOut: outputTokens, + // cacheWriteTokens, + // cacheReadTokens, + // totalCost, + // }) await this.messageStateHandler.addToApiConversationHistory({ role: "assistant", diff --git a/src/core/task/tools/handlers/AskFollowupQuestionToolHandler.ts b/src/core/task/tools/handlers/AskFollowupQuestionToolHandler.ts index 563c2f32..399328e5 100644 --- a/src/core/task/tools/handlers/AskFollowupQuestionToolHandler.ts +++ b/src/core/task/tools/handlers/AskFollowupQuestionToolHandler.ts @@ -1,6 +1,6 @@ import { processFilesIntoText } from "@integrations/misc/extract-text" import { showSystemNotification } from "@integrations/notifications" -import { telemetryService } from "@services/posthog/PostHogClientProvider" +// import { telemetryService } from "@services/posthog/PostHogClientProvider" import { findLast, parsePartialArrayString } from "@shared/array" import { ClineAsk, ClineAskQuestion } from "@shared/ExtensionMessage" import { ToolUse, ToolUseName } from "../../../assistant-message" @@ -72,7 +72,7 @@ export class AskFollowupQuestionToolHandler implements IToolHandler, IPartialBlo // Check if options contains the text response if (optionsRaw && text && options.includes(text)) { - telemetryService.captureOptionSelected(config.ulid, options.length, "act") + // telemetryService.captureOptionSelected(config.ulid, options.length, "act") // Valid option selected, update last followup message with selected option const clineMessages = config.messageState.getClineMessages() @@ -86,7 +86,7 @@ export class AskFollowupQuestionToolHandler implements IToolHandler, IPartialBlo } } else { // Option not selected, send user feedback - telemetryService.captureOptionsIgnored(config.ulid, options.length, "act") + // telemetryService.captureOptionsIgnored(config.ulid, options.length, "act") await config.callbacks.say("user_feedback", text ?? "", images, followupFiles) } diff --git a/src/core/task/tools/handlers/SearchFilesToolHandler.ts b/src/core/task/tools/handlers/SearchFilesToolHandler.ts index 7059c321..afce767e 100644 --- a/src/core/task/tools/handlers/SearchFilesToolHandler.ts +++ b/src/core/task/tools/handlers/SearchFilesToolHandler.ts @@ -1,5 +1,5 @@ import type { ToolUse } from "@core/assistant-message" -import { telemetryService } from "@services/posthog/PostHogClientProvider" +// import { telemetryService } from "@services/posthog/PostHogClientProvider" import { regexSearchFiles } from "@services/ripgrep" import { getReadablePath, isLocatedInWorkspace } from "@utils/path" import * as path from "path" @@ -103,7 +103,7 @@ export class SearchFilesToolHandler implements IFullyManagedTool { config.taskState.consecutiveAutoApprovedRequestsCount++ // Capture telemetry - telemetryService.captureToolUsage(config.ulid, block.name, config.api.getModel().id, true, true) + // telemetryService.captureToolUsage(config.ulid, block.name, config.api.getModel().id, true, true) } else { // Manual approval flow const notificationMessage = `Cline wants to search files for ${regex}` @@ -123,10 +123,10 @@ export class SearchFilesToolHandler implements IFullyManagedTool { if (response !== "yesButtonClicked") { // Handle rejection config.taskState.didRejectTool = true - telemetryService.captureToolUsage(config.ulid, block.name, config.api.getModel().id, false, false) + // telemetryService.captureToolUsage(config.ulid, block.name, config.api.getModel().id, false, false) return "The user denied this operation." } else { - telemetryService.captureToolUsage(config.ulid, block.name, config.api.getModel().id, false, true) + // telemetryService.captureToolUsage(config.ulid, block.name, config.api.getModel().id, false, true) } } diff --git a/src/core/task/tools/handlers/SummarizeTaskHandler.ts b/src/core/task/tools/handlers/SummarizeTaskHandler.ts index 2d15833a..497cc087 100644 --- a/src/core/task/tools/handlers/SummarizeTaskHandler.ts +++ b/src/core/task/tools/handlers/SummarizeTaskHandler.ts @@ -2,7 +2,7 @@ import type { ToolUse } from "@core/assistant-message" import { continuationPrompt } from "@core/prompts/contextManagement" import { formatResponse } from "@core/prompts/responses" import { ensureTaskDirectoryExists } from "@core/storage/disk" -import { telemetryService } from "@services/posthog/PostHogClientProvider" +// import { telemetryService } from "@services/posthog/PostHogClientProvider" import { ClineSayTool } from "@shared/ExtensionMessage" import type { ToolResponse } from "../../index" import type { IPartialBlockHandler, IToolHandler } from "../ToolExecutorCoordinator" @@ -74,14 +74,14 @@ export class SummarizeTaskHandler implements IToolHandler, IPartialBlockHandler config.taskState.lastAutoCompactTriggerIndex, ) - if (telemetryData) { - telemetryService.captureSummarizeTask( - config.ulid, - config.api.getModel().id, - telemetryData.tokensUsed, - telemetryData.maxContextWindow, - ) - } + // if (telemetryData) { + // telemetryService.captureSummarizeTask( + // config.ulid, + // config.api.getModel().id, + // telemetryData.tokensUsed, + // telemetryData.maxContextWindow, + // ) + // } return toolResult } catch (error) { diff --git a/src/integrations/checkpoints/CheckpointGitOperations.ts b/src/integrations/checkpoints/CheckpointGitOperations.ts index 15d12489..21f0acbe 100644 --- a/src/integrations/checkpoints/CheckpointGitOperations.ts +++ b/src/integrations/checkpoints/CheckpointGitOperations.ts @@ -3,7 +3,7 @@ import fs from "fs/promises" import { globby } from "globby" import * as path from "path" import simpleGit, { type SimpleGit } from "simple-git" -import { telemetryService } from "@/services/posthog/PostHogClientProvider" +// import { telemetryService } from "@/services/posthog/PostHogClientProvider" import { getLfsPatterns, writeExcludesFile } from "./CheckpointExclusions" interface CheckpointAddResult { @@ -100,7 +100,7 @@ export class GitOperations { await git.commit("initial commit", { "--allow-empty": null }) const durationMs = Math.round(performance.now() - startTime) - telemetryService.captureCheckpointUsage(taskId, "shadow_git_initialized", durationMs) + // telemetryService.captureCheckpointUsage(taskId, "shadow_git_initialized", durationMs) console.warn(`Shadow git initialization completed`) diff --git a/src/integrations/checkpoints/CheckpointTracker.ts b/src/integrations/checkpoints/CheckpointTracker.ts index 57953295..622edb7d 100644 --- a/src/integrations/checkpoints/CheckpointTracker.ts +++ b/src/integrations/checkpoints/CheckpointTracker.ts @@ -1,4 +1,4 @@ -import { telemetryService } from "@services/posthog/PostHogClientProvider" +// import { telemetryService } from "@services/posthog/PostHogClientProvider" import fs from "fs/promises" import * as path from "path" import simpleGit from "simple-git" @@ -124,7 +124,7 @@ class CheckpointTracker { await newTracker.gitOperations.initShadowGit(gitPath, workingDir, taskId) const durationMs = Math.round(performance.now() - startTime) - telemetryService.captureCheckpointUsage(taskId, "shadow_git_initialized", durationMs) + // telemetryService.captureCheckpointUsage(taskId, "shadow_git_initialized", durationMs) return newTracker } catch (error) { @@ -184,7 +184,7 @@ class CheckpointTracker { console.warn(`Checkpoint commit created: `, commitHash) const durationMs = Math.round(performance.now() - startTime) - telemetryService.captureCheckpointUsage(this.taskId, "commit_created", durationMs) + // telemetryService.captureCheckpointUsage(this.taskId, "commit_created", durationMs) return commitHash } catch (error) { @@ -260,7 +260,7 @@ class CheckpointTracker { console.debug(`Successfully reset to checkpoint: ${commitHash}`) const durationMs = Math.round(performance.now() - startTime) - telemetryService.captureCheckpointUsage(this.taskId, "restored", durationMs) + // telemetryService.captureCheckpointUsage(this.taskId, "restored", durationMs) } /** @@ -338,7 +338,7 @@ class CheckpointTracker { } const durationMs = Math.round(performance.now() - startTime) - telemetryService.captureCheckpointUsage(this.taskId, "diff_generated", durationMs) + // telemetryService.captureCheckpointUsage(this.taskId, "diff_generated", durationMs) return result } @@ -367,7 +367,7 @@ class CheckpointTracker { const diffSummary = await git.diffSummary([diffRange]) const durationMs = Math.round(performance.now() - startTime) - telemetryService.captureCheckpointUsage(this.taskId, "diff_generated", durationMs) + // telemetryService.captureCheckpointUsage(this.taskId, "diff_generated", durationMs) return diffSummary.files.length } diff --git a/src/services/auth/AuthService.ts b/src/services/auth/AuthService.ts index 36ac02da..f16abfa6 100644 --- a/src/services/auth/AuthService.ts +++ b/src/services/auth/AuthService.ts @@ -1,4 +1,4 @@ -import { featureFlagsService, telemetryService } from "@services/posthog/PostHogClientProvider" +// import { featureFlagsService, telemetryService } from "@services/posthog/PostHogClientProvider" import { AuthState, UserInfo } from "@shared/proto/cline/account" import { type EmptyRequest, String } from "@shared/proto/cline/common" import { clineEnvConfig } from "@/config" @@ -322,12 +322,12 @@ export class AuthService { // Identify the user in telemetry if available // Fetch the feature flags for the user - if (this._clineAuthInfo?.userInfo?.id) { - telemetryService.identifyAccount(this._clineAuthInfo.userInfo) - for (const flag of Object.values(FEATURE_FLAGS)) { - await featureFlagsService?.isFeatureFlagEnabled(flag) - } - } + // if (this._clineAuthInfo?.userInfo?.id) { + // telemetryService.identifyAccount(this._clineAuthInfo.userInfo) + // for (const flag of Object.values(FEATURE_FLAGS)) { + // await featureFlagsService?.isFeatureFlagEnabled(flag) + // } + // } // Update the state in the webview if (controller) { diff --git a/src/services/browser/BrowserSession.ts b/src/services/browser/BrowserSession.ts index 7ff25f78..3b139293 100644 --- a/src/services/browser/BrowserSession.ts +++ b/src/services/browser/BrowserSession.ts @@ -15,7 +15,7 @@ import PCR from "puppeteer-chromium-resolver" import type { ConsoleMessage, ScreenshotOptions } from "puppeteer-core" import { Browser, connect, launch, Page, TimeoutError } from "puppeteer-core" import * as vscode from "vscode" -import { telemetryService } from "@/services/posthog/PostHogClientProvider" +// import { telemetryService } from "@/services/posthog/PostHogClientProvider" import { discoverChromeInstances, isPortOpen, testBrowserConnection } from "./BrowserDiscovery" interface PCRStats { @@ -209,26 +209,26 @@ export class BrowserSession { // Don't create a new page here, as we'll create it in launchRemoteBrowser // Send telemetry for browser tool start - if (this.ulid) { - telemetryService.captureBrowserToolStart(this.ulid, this.browserSettings) - } + // if (this.ulid) { + // telemetryService.captureBrowserToolStart(this.ulid, this.browserSettings) + // } return } catch (error) { console.error("Failed to launch remote browser, falling back to local mode:", error) // Capture error telemetry - if (this.ulid) { - telemetryService.captureBrowserError( - this.ulid, - "remote_browser_launch_error", - error instanceof Error ? error.message : String(error), - { - isRemote: true, - remoteBrowserHost: this.browserSettings.remoteBrowserHost, - }, - ) - } + // if (this.ulid) { + // telemetryService.captureBrowserError( + // this.ulid, + // "remote_browser_launch_error", + // error instanceof Error ? error.message : String(error), + // { + // isRemote: true, + // remoteBrowserHost: this.browserSettings.remoteBrowserHost, + // }, + // ) + // } await this.launchLocalBrowser() } @@ -240,9 +240,9 @@ export class BrowserSession { this.page = await this.browser?.newPage() // Send telemetry for browser tool start - if (this.ulid) { - telemetryService.captureBrowserToolStart(this.ulid, this.browserSettings) - } + // if (this.ulid) { + // // telemetryService.captureBrowserToolStart(this.ulid, this.browserSettings) + // } } async launchLocalBrowser() { @@ -299,17 +299,17 @@ export class BrowserSession { console.log(`Failed to connect using cached endpoint: ${error}`) // Capture error telemetry - if (this.ulid) { - telemetryService.captureBrowserError( - this.ulid, - "cached_endpoint_connection_error", - error instanceof Error ? error.message : String(error), - { - isRemote: true, - endpoint: browserWSEndpoint, - }, - ) - } + // if (this.ulid) { + // telemetryService.captureBrowserError( + // this.ulid, + // "cached_endpoint_connection_error", + // error instanceof Error ? error.message : String(error), + // { + // isRemote: true, + // endpoint: browserWSEndpoint, + // }, + // ) + // } // Clear the cached endpoint since it's no longer valid this.cachedWebSocketEndpoint = undefined @@ -351,17 +351,17 @@ export class BrowserSession { console.log(`Failed to connect to remote browser: ${error}`) // Capture error telemetry - if (this.ulid) { - telemetryService.captureBrowserError( - this.ulid, - "remote_host_connection_error", - error instanceof Error ? error.message : String(error), - { - isRemote: true, - remoteBrowserHost, - }, - ) - } + // if (this.ulid) { + // telemetryService.captureBrowserError( + // this.ulid, + // "remote_host_connection_error", + // error instanceof Error ? error.message : String(error), + // { + // isRemote: true, + // remoteBrowserHost, + // }, + // ) + // } } } @@ -374,14 +374,14 @@ export class BrowserSession { async closeBrowser(): Promise { if (this.browser || this.page) { // Send telemetry for browser tool end if we have a task ID and session was started - if (this.ulid && this.sessionStartTime > 0) { - const sessionDuration = Date.now() - this.sessionStartTime - telemetryService.captureBrowserToolEnd(this.ulid, { - actionCount: this.browserActions.length, - duration: sessionDuration, - actions: this.browserActions, - }) - } + // if (this.ulid && this.sessionStartTime > 0) { + // const sessionDuration = Date.now() - this.sessionStartTime + // telemetryService.captureBrowserToolEnd(this.ulid, { + // actionCount: this.browserActions.length, + // duration: sessionDuration, + // actions: this.browserActions, + // }) + // } if (this.isConnectedToRemote && this.browser) { // Close the page/tab first if it exists @@ -446,12 +446,12 @@ export class BrowserSession { logs.push(`[Error] ${errorMessage}`) // Capture error telemetry - if (this.ulid) { - telemetryService.captureBrowserError(this.ulid, "browser_action_error", errorMessage, { - isRemote: this.isConnectedToRemote, - action: this.browserActions[this.browserActions.length - 1], - }) - } + // if (this.ulid) { + // telemetryService.captureBrowserError(this.ulid, "browser_action_error", errorMessage, { + // isRemote: this.isConnectedToRemote, + // action: this.browserActions[this.browserActions.length - 1], + // }) + // } } } @@ -491,12 +491,12 @@ export class BrowserSession { if (!screenshotBase64) { // Capture error telemetry - if (this.ulid) { - telemetryService.captureBrowserError(this.ulid, "screenshot_error", "Failed to take screenshot", { - isRemote: this.isConnectedToRemote, - action: this.browserActions[this.browserActions.length - 1], - }) - } + // if (this.ulid) { + // telemetryService.captureBrowserError(this.ulid, "screenshot_error", "Failed to take screenshot", { + // isRemote: this.isConnectedToRemote, + // action: this.browserActions[this.browserActions.length - 1], + // }) + // } throw new Error("Failed to take screenshot.") } diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index 0371611b..e26df142 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -33,7 +33,7 @@ import ReconnectingEventSource from "reconnecting-eventsource" import * as vscode from "vscode" import { z } from "zod" import { HostProvider } from "@/hosts/host-provider" -import { TelemetryService } from "@/services/posthog/telemetry/TelemetryService" +// import { TelemetryService } from "@/services/posthog/telemetry/TelemetryService" import { ShowMessageType } from "@/shared/proto/host/window" import { DEFAULT_REQUEST_TIMEOUT_MS } from "./constants" import { BaseConfigSchema, McpSettingsSchema, ServerConfigSchema } from "./schemas" @@ -42,7 +42,7 @@ export class McpHub { getMcpServersPath: () => Promise private getSettingsDirectoryPath: () => Promise private clientVersion: string - private telemetryService?: TelemetryService + // private telemetryService?: TelemetryService private disposables: vscode.Disposable[] = [] private settingsWatcher?: FSWatcher @@ -65,12 +65,12 @@ export class McpHub { getMcpServersPath: () => Promise, getSettingsDirectoryPath: () => Promise, clientVersion: string, - telemetryService?: TelemetryService, + // telemetryService?: TelemetryService, ) { this.getMcpServersPath = getMcpServersPath this.getSettingsDirectoryPath = getSettingsDirectoryPath this.clientVersion = clientVersion - this.telemetryService = telemetryService + // this.telemetryService = telemetryService this.watchMcpSettingsFile() this.initializeMcpServers() } @@ -839,14 +839,14 @@ export class McpHub { console.error(`Failed to parse timeout configuration for server ${serverName}: ${error}`) } - this.telemetryService?.captureMcpToolCall( - ulid, - serverName, - toolName, - "started", - undefined, - toolArguments ? Object.keys(toolArguments) : undefined, - ) + // this.telemetryService?.captureMcpToolCall( + // ulid, + // serverName, + // toolName, + // "started", + // undefined, + // toolArguments ? Object.keys(toolArguments) : undefined, + // ) try { const result = await connection.client.request( @@ -863,28 +863,28 @@ export class McpHub { }, ) - this.telemetryService?.captureMcpToolCall( - ulid, - serverName, - toolName, - "success", - undefined, - toolArguments ? Object.keys(toolArguments) : undefined, - ) + // this.telemetryService?.captureMcpToolCall( + // ulid, + // serverName, + // toolName, + // "success", + // undefined, + // toolArguments ? Object.keys(toolArguments) : undefined, + // ) return { ...result, content: result.content ?? [], } } catch (error) { - this.telemetryService?.captureMcpToolCall( - ulid, - serverName, - toolName, - "error", - error instanceof Error ? error.message : String(error), - toolArguments ? Object.keys(toolArguments) : undefined, - ) + // this.telemetryService?.captureMcpToolCall( + // ulid, + // serverName, + // toolName, + // "error", + // error instanceof Error ? error.message : String(error), + // toolArguments ? Object.keys(toolArguments) : undefined, + // ) throw error } } diff --git a/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx b/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx index 874c17fb..b834b63f 100644 --- a/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx +++ b/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx @@ -2,7 +2,6 @@ import { VSCodeCheckbox, VSCodeLink } from "@vscode/webview-ui-toolkit/react" import { useExtensionState } from "@/context/ExtensionStateContext" import PreferredLanguageSetting from "../PreferredLanguageSetting" import Section from "../Section" -import { updateSetting } from "../utils/settingsHandlers" interface GeneralSettingsSectionProps { renderSectionHeader: (tabId: string) => JSX.Element | null @@ -16,19 +15,10 @@ const GeneralSettingsSection = ({ renderSectionHeader }: GeneralSettingsSectionP {renderSectionHeader("general")}
-
- { - const checked = e.target.checked === true - updateSetting("telemetrySetting", checked ? "enabled" : "disabled") - }}> - 允许匿名错误和使用情况报告 - +

本插件不会搜集和传输任何用户信息

- 通过发送使用数据和错误报告来帮助改进 Cline。我们绝不会发送任何代码、提示或个人信息。请参阅我们的{" "} + 选择使用胜算云 API Router 功能的用户。请参阅我们的{" "} 使用条款 {" "}