Skip to content

Commit e94e260

Browse files
feat(settings): emit telemetry for chat font size changes (#157)
The chat font size change/reset handlers now emit telemetry like the other UI settings handlers in this file (ui_settings_chat_font_size_changed with the value, and ui_settings_chat_font_size_reset). Covered by UISettings spec.
1 parent a046159 commit e94e260

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

webview-ui/src/components/settings/UISettings.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ export const UISettings = ({
5757

5858
const handleChatFontSizeChange = (value: number) => {
5959
setCachedStateField("chatFontSize", value)
60+
61+
// Track telemetry event
62+
telemetryClient.capture("ui_settings_chat_font_size_changed", {
63+
value,
64+
})
6065
}
6166

6267
const handleChatFontSizeReset = () => {
6368
setCachedStateField("chatFontSize", undefined)
69+
70+
// Track telemetry event
71+
telemetryClient.capture("ui_settings_chat_font_size_reset")
6472
}
6573

6674
return (

webview-ui/src/components/settings/__tests__/UISettings.spec.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { render, fireEvent, waitFor } from "@testing-library/react"
22
import { describe, it, expect, vi } from "vitest"
33
import { UISettings } from "../UISettings"
4+
import { telemetryClient } from "@/utils/TelemetryClient"
5+
6+
vi.mock("@/utils/TelemetryClient", () => ({
7+
telemetryClient: { capture: vi.fn() },
8+
}))
49

510
describe("UISettings", () => {
611
const defaultProps = {
@@ -66,6 +71,7 @@ describe("UISettings", () => {
6671
fireEvent.keyDown(slider, { key: "ArrowRight" })
6772

6873
expect(setCachedStateField).toHaveBeenCalledWith("chatFontSize", 15)
74+
expect(telemetryClient.capture).toHaveBeenCalledWith("ui_settings_chat_font_size_changed", { value: 15 })
6975
})
7076

7177
it("disables reset when unset and clears the value on reset", () => {
@@ -85,6 +91,7 @@ describe("UISettings", () => {
8591

8692
fireEvent.click(resetSet)
8793
expect(setCachedStateField).toHaveBeenCalledWith("chatFontSize", undefined)
94+
expect(telemetryClient.capture).toHaveBeenCalledWith("ui_settings_chat_font_size_reset")
8895
})
8996
})
9097
})

0 commit comments

Comments
 (0)