Skip to content

Commit 9b01578

Browse files
committed
Make it clear that we don't capture messages in default telemetry
1 parent 580f6d1 commit 9b01578

File tree

3 files changed

+40
-26
lines changed

3 files changed

+40
-26
lines changed

packages/cloud/src/CloudService.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as vscode from "vscode"
22
import EventEmitter from "events"
33

4-
import type { CloudUserInfo } from "@roo-code/types"
4+
import type { CloudUserInfo, TelemetryEvent } from "@roo-code/types"
55
import { TelemetryService } from "@roo-code/telemetry"
66

77
import { AuthService, type AuthServiceEvents } from "./AuthService"
@@ -117,6 +117,13 @@ export class CloudService extends EventEmitter<CloudServiceEvents> {
117117
return this.settingsService!.getAllowList()
118118
}
119119

120+
// TelemetryClient
121+
122+
public captureEvent(event: TelemetryEvent): void {
123+
this.ensureInitialized()
124+
this.telemetryClient!.capture(event)
125+
}
126+
120127
// Lifecycle
121128

122129
public dispose(): void {
@@ -165,4 +172,8 @@ export class CloudService extends EventEmitter<CloudServiceEvents> {
165172
this._instance = null
166173
}
167174
}
175+
176+
static isEnabled(): boolean {
177+
return !!this._instance?.isAuthenticated()
178+
}
168179
}

packages/telemetry/src/TelemetryService.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { ZodError } from "zod"
22

3-
import {
4-
type TelemetryClient,
5-
type TelemetryPropertiesProvider,
6-
type ClineMessage,
7-
TelemetryEventName,
8-
} from "@roo-code/types"
3+
import { type TelemetryClient, type TelemetryPropertiesProvider, TelemetryEventName } from "@roo-code/types"
94

105
/**
116
* TelemetryService wrapper class that defers initialization.
@@ -77,10 +72,6 @@ export class TelemetryService {
7772
this.captureEvent(TelemetryEventName.TASK_COMPLETED, { taskId })
7873
}
7974

80-
public captureTaskMessage(taskId: string, message: ClineMessage): void {
81-
this.captureEvent(TelemetryEventName.TASK_MESSAGE, { taskId, message })
82-
}
83-
8475
public captureConversationMessage(taskId: string, source: "user" | "assistant"): void {
8576
this.captureEvent(TelemetryEventName.TASK_CONVERSATION_MESSAGE, { taskId, source })
8677
}

src/core/task/Task.ts

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ import delay from "delay"
88
import pWaitFor from "p-wait-for"
99
import { serializeError } from "serialize-error"
1010

11-
import type {
12-
ProviderSettings,
13-
TokenUsage,
14-
ToolUsage,
15-
ToolName,
16-
ContextCondense,
17-
ClineAsk,
18-
ClineMessage,
19-
ClineSay,
20-
ToolProgressStatus,
21-
HistoryItem,
11+
import {
12+
type ProviderSettings,
13+
type TokenUsage,
14+
type ToolUsage,
15+
type ToolName,
16+
type ContextCondense,
17+
type ClineAsk,
18+
type ClineMessage,
19+
type ClineSay,
20+
type ToolProgressStatus,
21+
type HistoryItem,
22+
TelemetryEventName,
2223
} from "@roo-code/types"
2324
import { TelemetryService } from "@roo-code/telemetry"
25+
import { CloudService } from "@roo-code/cloud"
2426

2527
// api
2628
import { ApiHandler, ApiHandlerCreateMessageMetadata, buildApiHandler } from "../../api"
@@ -322,8 +324,13 @@ export class Task extends EventEmitter<ClineEvents> {
322324
this.emit("message", { action: "created", message })
323325
await this.saveClineMessages()
324326

325-
if (message.partial !== true) {
326-
TelemetryService.instance.captureTaskMessage(this.taskId, message)
327+
const shouldCaptureMessage = message.partial !== true && CloudService.isEnabled()
328+
329+
if (shouldCaptureMessage) {
330+
CloudService.instance.captureEvent({
331+
event: TelemetryEventName.TASK_MESSAGE,
332+
properties: { taskId: this.taskId, message },
333+
})
327334
}
328335
}
329336

@@ -336,8 +343,13 @@ export class Task extends EventEmitter<ClineEvents> {
336343
await this.providerRef.deref()?.postMessageToWebview({ type: "partialMessage", partialMessage })
337344
this.emit("message", { action: "updated", message: partialMessage })
338345

339-
if (partialMessage.partial !== true) {
340-
TelemetryService.instance.captureTaskMessage(this.taskId, partialMessage)
346+
const shouldCaptureMessage = partialMessage.partial !== true && CloudService.isEnabled()
347+
348+
if (shouldCaptureMessage) {
349+
CloudService.instance.captureEvent({
350+
event: TelemetryEventName.TASK_MESSAGE,
351+
properties: { taskId: this.taskId, message: partialMessage },
352+
})
341353
}
342354
}
343355

0 commit comments

Comments
 (0)