11import { Anthropic } from "@anthropic-ai/sdk"
22import axios from "axios"
3- import fs from "fs/promises"
4- import os from "os"
53import crypto from "crypto"
64import { execa } from "execa"
5+ import fs from "fs/promises"
6+ import os from "os"
77import pWaitFor from "p-wait-for"
88import * as path from "path"
99import * as vscode from "vscode"
@@ -13,26 +13,25 @@ import { openFile, openImage } from "../../integrations/misc/open-file"
1313import { selectImages } from "../../integrations/misc/process-images"
1414import { getTheme } from "../../integrations/theme/getTheme"
1515import WorkspaceTracker from "../../integrations/workspace/WorkspaceTracker"
16- import { McpHub } from "../../services/mcp/McpHub"
17- import { McpDownloadResponse , McpMarketplaceCatalog , McpMarketplaceItem , McpServer } from "../../shared/mcp"
1816import { FirebaseAuthManager , UserInfo } from "../../services/auth/FirebaseAuthManager"
17+ import { McpHub } from "../../services/mcp/McpHub"
1918import { ApiProvider , ModelInfo } from "../../shared/api"
2019import { findLast } from "../../shared/array"
20+ import { AutoApprovalSettings , DEFAULT_AUTO_APPROVAL_SETTINGS } from "../../shared/AutoApprovalSettings"
21+ import { BrowserSettings , DEFAULT_BROWSER_SETTINGS } from "../../shared/BrowserSettings"
22+ import { ChatContent } from "../../shared/ChatContent"
23+ import { ChatSettings , DEFAULT_CHAT_SETTINGS } from "../../shared/ChatSettings"
2124import { ExtensionMessage , ExtensionState , Platform } from "../../shared/ExtensionMessage"
2225import { HistoryItem } from "../../shared/HistoryItem"
26+ import { McpDownloadResponse , McpMarketplaceCatalog , McpServer } from "../../shared/mcp"
2327import { ClineCheckpointRestore , WebviewMessage } from "../../shared/WebviewMessage"
2428import { fileExistsAtPath } from "../../utils/fs"
29+ import { searchCommits } from "../../utils/git"
2530import { Cline } from "../Cline"
2631import { openMention } from "../mentions"
2732import { getNonce } from "./getNonce"
2833import { getUri } from "./getUri"
29- import { AutoApprovalSettings , DEFAULT_AUTO_APPROVAL_SETTINGS } from "../../shared/AutoApprovalSettings"
30- import { BrowserSettings , DEFAULT_BROWSER_SETTINGS } from "../../shared/BrowserSettings"
31- import { ChatSettings , DEFAULT_CHAT_SETTINGS } from "../../shared/ChatSettings"
32- import { DIFF_VIEW_URI_SCHEME } from "../../integrations/editor/DiffViewProvider"
33- import { searchCommits } from "../../utils/git"
34- import { ChatContent } from "../../shared/ChatContent"
35- import { getShell } from "../../utils/shell"
34+ import { telemetryService } from "../../services/telemetry/TelemetryService"
3635
3736/*
3837https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
@@ -280,6 +279,16 @@ export class ClineProvider implements vscode.WebviewViewProvider {
280279 task ,
281280 images ,
282281 )
282+
283+ // New task started
284+ if ( telemetryService . isTelemetryEnabled ( ) ) {
285+ telemetryService . capture ( {
286+ event : "New task started" ,
287+ properties : {
288+ apiProvider : apiConfiguration . apiProvider ,
289+ } ,
290+ } )
291+ }
283292 }
284293
285294 async initClineWithHistoryItem ( historyItem : HistoryItem ) {
@@ -829,6 +838,21 @@ export class ClineProvider implements vscode.WebviewViewProvider {
829838 )
830839 break
831840 }
841+ // telemetry
842+ case "openTelemetrySettings" : {
843+ await vscode . commands . executeCommand (
844+ "workbench.action.openSettings" ,
845+ "@ext:saoudrizwan.claude-dev cline.telemetryOptIn" ,
846+ )
847+ break
848+ }
849+ case "telemetryOptIn" : {
850+ if ( message . bool !== undefined ) {
851+ await vscode . workspace . getConfiguration ( "cline" ) . update ( "enableTelemetry" , message . bool , true )
852+ await this . postStateToWebview ( )
853+ }
854+ break
855+ }
832856 // Add more switch case statements here as more webview message commands
833857 // are created within the webview context (i.e. inside media/main.js)
834858 }
@@ -1594,6 +1618,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
15941618 userInfo,
15951619 authToken,
15961620 mcpMarketplaceEnabled,
1621+ telemetryOptIn,
15971622 } = await this . getState ( )
15981623
15991624 return {
@@ -1613,6 +1638,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
16131638 isLoggedIn : ! ! authToken ,
16141639 userInfo,
16151640 mcpMarketplaceEnabled,
1641+ telemetryOptIn,
16161642 }
16171643 }
16181644
@@ -1791,6 +1817,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
17911817 . get ( "reasoningEffort" , "medium" )
17921818
17931819 const mcpMarketplaceEnabled = vscode . workspace . getConfiguration ( "cline" ) . get < boolean > ( "mcpMarketplace.enabled" , true )
1820+ const telemetryOptIn = vscode . workspace . getConfiguration ( "cline" ) . get < boolean | null > ( "enableTelemetry" , null )
17941821
17951822 return {
17961823 apiConfiguration : {
@@ -1847,6 +1874,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
18471874 previousModeModelId,
18481875 previousModeModelInfo,
18491876 mcpMarketplaceEnabled,
1877+ telemetryOptIn,
18501878 }
18511879 }
18521880
0 commit comments