removed context manipulate; removed telemetry.
This commit is contained in:
1 parent
36636c83c2
commit
bce624a76e
16 files changed
+160
-396
No files matched your search
+2
-2
@@ -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<Webv
|
||||
|
||||
await showVersionUpdateAnnouncement(context)
|
||||
|
||||
telemetryService.captureExtensionActivated()
|
||||
// telemetryService.captureExtensionActivated()
|
||||
|
||||
return sidebarWebview
|
||||
}
|
||||
|
||||
@@ -60,8 +60,6 @@ export class ShengSuanYunHandler implements ApiHandler {
|
||||
this.options.thinkingBudgetTokens,
|
||||
)
|
||||
|
||||
let didOutputUsage: boolean = false
|
||||
let lastChunk: any = {}
|
||||
for await (const chunk of stream) {
|
||||
// openrouter returns an error object instead of the openai sdk throwing an error
|
||||
if ("error" in chunk) {
|
||||
@@ -75,8 +73,6 @@ export class ShengSuanYunHandler implements ApiHandler {
|
||||
console.error("shengSuanYun stream chunk:", chunk)
|
||||
continue
|
||||
}
|
||||
|
||||
lastChunk = chunk
|
||||
// console.log(JSON.stringify(chunk, null, 2))
|
||||
|
||||
const choice = chunk.choices?.[0]
|
||||
@@ -117,7 +113,7 @@ export class ShengSuanYunHandler implements ApiHandler {
|
||||
reasoning: delta.reasoning,
|
||||
}
|
||||
}
|
||||
if (!didOutputUsage && chunk.usage) {
|
||||
if (chunk.usage) {
|
||||
const input = (chunk.usage.prompt_tokens || 0) - (chunk.usage.prompt_tokens_details?.cached_tokens || 0)
|
||||
const output = chunk.usage.completion_tokens || 0
|
||||
// @ts-ignore-next-line
|
||||
@@ -132,17 +128,8 @@ export class ShengSuanYunHandler implements ApiHandler {
|
||||
outputTokens: output,
|
||||
totalCost: cost ? cost : (input / 1000000) * inputPrice + (output / 1000000) * outputPrice,
|
||||
}
|
||||
didOutputUsage = true
|
||||
}
|
||||
}
|
||||
// Fallback to generation endpoint if usage chunk not returned ; NotImplemented yet
|
||||
if (!didOutputUsage) {
|
||||
console.log("ShengSuanYunHandler.createMessage -- lastChunk without usage", JSON.stringify(lastChunk, null, 2))
|
||||
// const apiStreamUsage = await this.getApiStreamUsage()
|
||||
// if (apiStreamUsage) {
|
||||
// yield apiStreamUsage
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
getModel(): { id: string; info: ModelInfo } {
|
||||
|
||||
@@ -80,10 +80,8 @@ export function convertToOpenAiMessages(
|
||||
|
||||
// Process non-tool messages
|
||||
if (nonToolMessages.length > 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 }
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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<Empty> {
|
||||
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}`)
|
||||
|
||||
+30
-29
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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`)
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<BrowserActionResult> {
|
||||
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.")
|
||||
}
|
||||
|
||||
|
||||
+28
-28
@@ -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<string>
|
||||
private getSettingsDirectoryPath: () => Promise<string>
|
||||
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<string>,
|
||||
getSettingsDirectoryPath: () => Promise<string>,
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")}
|
||||
<Section>
|
||||
<PreferredLanguageSetting />
|
||||
|
||||
<div className="mb-[5px]">
|
||||
<VSCodeCheckbox
|
||||
checked={telemetrySetting !== "disabled"}
|
||||
className="mb-[5px]"
|
||||
onChange={(e: any) => {
|
||||
const checked = e.target.checked === true
|
||||
updateSetting("telemetrySetting", checked ? "enabled" : "disabled")
|
||||
}}>
|
||||
允许匿名错误和使用情况报告
|
||||
</VSCodeCheckbox>
|
||||
<h2 className="block mb-1 text-sm font-medium">本插件不会搜集和传输任何用户信息</h2>
|
||||
<p className="text-xs mt-[5px] text-[var(--vscode-descriptionForeground)]">
|
||||
通过发送使用数据和错误报告来帮助改进 Cline。我们绝不会发送任何代码、提示或个人信息。请参阅我们的{" "}
|
||||
选择使用胜算云 API Router 功能的用户。请参阅我们的{" "}
|
||||
<VSCodeLink className="text-inherit" href="https://docs.router.shengsuanyun.com/terms-of-service">
|
||||
使用条款
|
||||
</VSCodeLink>{" "}
|
||||
|
||||
Reference in new issue
Block a user