Skip to content

Commit ca16e97

Browse files
committed
PR feedback
1 parent a97a7df commit ca16e97

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

packages/telemetry/src/TelemetryService.ts

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

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

510
/**
611
* TelemetryService wrapper class that defers initialization.
@@ -231,7 +236,7 @@ export class TelemetryService {
231236
* @param previousSetting The previous telemetry setting
232237
* @param newSetting The new telemetry setting
233238
*/
234-
public captureTelemetrySettingsChanged(previousSetting: string, newSetting: string): void {
239+
public captureTelemetrySettingsChanged(previousSetting: TelemetrySetting, newSetting: TelemetrySetting): void {
235240
this.captureEvent(TelemetryEventName.TELEMETRY_SETTINGS_CHANGED, {
236241
previousSetting,
237242
newSetting,

packages/types/src/telemetry.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,17 @@ export const rooCodeTelemetryEventSchema = z.discriminatedUnion("type", [
200200
TelemetryEventName.TAB_SHOWN,
201201
TelemetryEventName.MODE_SETTINGS_CHANGED,
202202
TelemetryEventName.CUSTOM_MODE_CREATED,
203-
TelemetryEventName.TELEMETRY_SETTINGS_CHANGED,
204203
]),
205204
properties: telemetryPropertiesSchema,
206205
}),
206+
z.object({
207+
type: z.literal(TelemetryEventName.TELEMETRY_SETTINGS_CHANGED),
208+
properties: z.object({
209+
...telemetryPropertiesSchema.shape,
210+
previousSetting: telemetrySettingsSchema,
211+
newSetting: telemetrySettingsSchema,
212+
}),
213+
}),
207214
z.object({
208215
type: z.literal(TelemetryEventName.TASK_MESSAGE),
209216
properties: z.object({

src/core/webview/webviewMessageHandler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,10 +2304,11 @@ export const webviewMessageHandler = async (
23042304
if (wasPreviouslyOptedIn && !isOptedIn && TelemetryService.hasInstance()) {
23052305
TelemetryService.instance.captureTelemetrySettingsChanged(previousSetting, telemetrySetting)
23062306
}
2307-
23082307
// Update the telemetry state
23092308
await updateGlobalState("telemetrySetting", telemetrySetting)
2310-
TelemetryService.instance.updateTelemetryState(isOptedIn)
2309+
if (TelemetryService.hasInstance()) {
2310+
TelemetryService.instance.updateTelemetryState(isOptedIn)
2311+
}
23112312

23122313
// If turning telemetry ON, fire event AFTER enabling
23132314
if (!wasPreviouslyOptedIn && isOptedIn && TelemetryService.hasInstance()) {

0 commit comments

Comments
 (0)