Skip to content

Commit b4b7512

Browse files
authored
Improve Cline accounts support telemetry (cline#5242)
* fixed linter rule and added identified telemtry stuff * Updated the error handling * fixed error handling
1 parent e08c656 commit b4b7512

File tree

5 files changed

+41
-9
lines changed

5 files changed

+41
-9
lines changed

docs/more-info/telemetry.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ title: "Telemetry"
44

55
### Overview
66

7-
To help make Cline better for everyone, we collect anonymous usage data that helps us understand how developers are using our open-source AI coding agent. This feedback loop is crucial for improving Cline's capabilities and user experience.
7+
To help make Cline better for everyone, we collect usage data that helps us understand how developers are using our open-source AI coding agent. This feedback loop is crucial for improving Cline's capabilities and user experience.
88

99
We use PostHog, an open-source analytics platform, for data collection and analysis. Our telemetry implementation is fully transparent - you can review the [source code](https://github.com/cline/cline/blob/main/src/services/posthog/telemetry/TelemetryService.ts) to see exactly what we track.
1010

1111
### Tracking Policy
1212

13-
Privacy is our priority. All collected data is anonymized before being sent to PostHog, with no personally identifiable information (PII) included. Your code, prompts, and conversation content always remain private and are never collected.
13+
Privacy is our priority. By default, all collected data is anonymized. If you log in with a Cline account, your telemetry data will be associated with your account to help us improve the product and provide better support when you encounter issues. Your code, prompts, and conversation content always remain private and are never collected.
1414

1515
### What We Track
1616

17-
We collect basic anonymous usage data including:
17+
We collect basic usage data including:
1818

1919
**Task Interactions:** When tasks start and finish, conversation flow (without content)\
2020
**Mode and Tool Usage:** Switches between plan/act modes, which tools are being used\
@@ -28,7 +28,7 @@ For complete transparency, you can inspect our [telemetry implementation](https:
2828

2929
Telemetry in Cline is entirely optional:
3030

31-
- When you update or install our VS Code extension, you'll see a message about our anonymous telemetry
31+
- When you update or install our VS Code extension, you'll see a message about our telemetry
3232
- You can change your preference anytime in settings
3333

3434
Cline also respects VS Code's global telemetry settings. If you've disabled telemetry at the VS Code level, Cline's telemetry will automatically be disabled as well.

src/services/auth/AuthService.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { clineEnvConfig } from "@/config"
33
import { Controller } from "@/core/controller"
44
import { getRequestRegistry, type StreamingResponseHandler } from "@/core/controller/grpc-handler"
55
import { storeSecret } from "@/core/storage/state"
6+
import { telemetryService } from "@services/posthog/telemetry/TelemetryService"
67
import { AuthState, UserInfo } from "@shared/proto/cline/account"
78
import { type EmptyRequest, String } from "@shared/proto/cline/common"
89
import { FirebaseAuthProvider } from "./providers/FirebaseAuthProvider"
@@ -230,6 +231,10 @@ export class AuthService {
230231
this._clineAuthInfo = await this._provider.provider.signIn(this._context, token, provider)
231232
this._authenticated = true
232233

234+
if (this._clineAuthInfo) {
235+
telemetryService.identifyAccount(this._clineAuthInfo.userInfo)
236+
}
237+
233238
await this.sendAuthStatusUpdate()
234239
// return this._clineAuthInfo
235240
} catch (error) {
@@ -259,6 +264,7 @@ export class AuthService {
259264
this._clineAuthInfo = await this._provider.provider.retrieveClineAuthInfo(this._context)
260265
if (this._clineAuthInfo) {
261266
this._authenticated = true
267+
telemetryService.identifyAccount(this._clineAuthInfo.userInfo)
262268
await this.sendAuthStatusUpdate()
263269
} else {
264270
console.warn("No user found after restoring auth token")

src/services/posthog/telemetry/TelemetryService.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { TaskFeedbackType } from "@shared/WebviewMessage"
66
import type { BrowserSettings } from "@shared/BrowserSettings"
77
import { posthogClientProvider } from "../PostHogClientProvider"
88
import { Mode } from "@/shared/storage/types"
9+
import { ClineAccountUserInfo } from "@/services/auth/AuthService"
910

1011
/**
1112
* TelemetryService handles telemetry event tracking for the Cline extension
@@ -211,6 +212,31 @@ class TelemetryService {
211212
}
212213
}
213214

215+
/**
216+
* Identifies the accounts user
217+
* @param userInfo The user's information
218+
*/
219+
public identifyAccount(userInfo: ClineAccountUserInfo) {
220+
if (!this.telemetryEnabled) {
221+
return
222+
}
223+
224+
if (!this.client) {
225+
console.warn("Telemetry client is not initialized. Skipping identifyAccount.")
226+
return
227+
}
228+
229+
this.client.identify({
230+
distinctId: userInfo.id,
231+
properties: {
232+
uuid: userInfo.id,
233+
email: userInfo.email,
234+
name: userInfo.displayName,
235+
...this.addProperties({}),
236+
},
237+
})
238+
}
239+
214240
// Task events
215241
/**
216242
* Records when a new task/conversation is started

webview-ui/src/components/common/TelemetryBanner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ const TelemetryBanner = () => {
7777
(and access experimental features)
7878
</i>
7979
<div style={{ marginTop: 4 }}>
80-
Cline collects anonymous error and usage data to help us fix bugs and improve the extension. No code, prompts,
81-
or personal information is ever sent.
80+
Cline collects error and usage data to help us fix bugs and improve the extension. No code, prompts, or
81+
personal information is ever sent.
8282
<div style={{ marginTop: 4 }}>
8383
You can turn this setting off in{" "}
8484
<VSCodeLink href="#" onClick={handleOpenSettings}>

webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ const GeneralSettingsSection = ({ renderSectionHeader }: GeneralSettingsSectionP
2525
const checked = e.target.checked === true
2626
updateSetting("telemetrySetting", checked ? "enabled" : "disabled")
2727
}}>
28-
Allow anonymous error and usage reporting
28+
Allow error and usage reporting
2929
</VSCodeCheckbox>
3030
<p className="text-xs mt-[5px] text-[var(--vscode-descriptionForeground)]">
31-
Help improve Cline by sending anonymous usage data and error reports. No code, prompts, or personal
32-
information are ever sent. See our{" "}
31+
Help improve Cline by sending usage data and error reports. No code, prompts, or personal information are
32+
ever sent. See our{" "}
3333
<VSCodeLink href="https://docs.cline.bot/more-info/telemetry" className="text-inherit">
3434
telemetry overview
3535
</VSCodeLink>{" "}

0 commit comments

Comments
 (0)