Skip to content

Commit 451d328

Browse files
committed
feat: track slash command usage via UI clicks instead of text detection
- Remove detectSlashCommands utility and its usage from Task.ts - Add telemetry tracking to SlashCommandsList for popover clicks - Add telemetry tracking to ChatTextArea for context menu selections - Track both mode switches and custom commands with appropriate types - Delete unused slashCommandDetection.ts and its tests
1 parent eed6a84 commit 451d328

File tree

5 files changed

+22
-270
lines changed

5 files changed

+22
-270
lines changed

src/core/task/Task.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ import {
2929
import { TelemetryService } from "@roo-code/telemetry"
3030
import { CloudService } from "@roo-code/cloud"
3131

32-
// utils
33-
import { detectSlashCommands } from "../../utils/slashCommandDetection"
34-
3532
// api
3633
import { ApiHandler, ApiHandlerCreateMessageMetadata, buildApiHandler } from "../../api"
3734
import { ApiStream } from "../../api/transform/stream"
@@ -717,14 +714,6 @@ export class Task extends EventEmitter<ClineEvents> {
717714
this.askResponse = askResponse
718715
this.askResponseText = text
719716
this.askResponseImages = images
720-
721-
// Detect and track slash command usage
722-
if (askResponse === "messageResponse" && text && TelemetryService.hasInstance()) {
723-
const slashCommands = detectSlashCommands(text)
724-
for (const command of slashCommands) {
725-
TelemetryService.instance.captureSlashCommandUsed(this.taskId, command.type, command.commandName)
726-
}
727-
}
728717
}
729718

730719
async handleTerminalOperation(terminalOperation: "continue" | "abort") {

src/utils/__tests__/slashCommandDetection.spec.ts

Lines changed: 0 additions & 191 deletions
This file was deleted.

src/utils/slashCommandDetection.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
} from "@src/utils/context-mentions"
2121
import { convertToMentionPath } from "@/utils/path-mentions"
2222
import { StandardTooltip } from "@/components/ui"
23+
import { telemetryClient } from "@/utils/TelemetryClient"
24+
import { TelemetryEventName } from "@roo-code/types"
2325

2426
import Thumbnails from "../common/Thumbnails"
2527
import ModeSelector from "./ModeSelector"
@@ -294,6 +296,12 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
294296
}
295297

296298
if (type === ContextMenuOptionType.Mode && value) {
299+
// Track telemetry for mode selection from context menu
300+
telemetryClient.capture(TelemetryEventName.SLASH_COMMAND_USED, {
301+
commandType: "mode",
302+
commandName: value,
303+
})
304+
297305
// Handle mode selection.
298306
setMode(value)
299307
setInputValue("")
@@ -303,6 +311,12 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
303311
}
304312

305313
if (type === ContextMenuOptionType.Command && value) {
314+
// Track telemetry for slash command usage from context menu
315+
telemetryClient.capture(TelemetryEventName.SLASH_COMMAND_USED, {
316+
commandType: "custom",
317+
commandName: value,
318+
})
319+
306320
// Handle command selection.
307321
setSelectedMenuIndex(-1)
308322
setInputValue("")

webview-ui/src/components/chat/SlashCommandsList.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
Button,
1818
} from "@/components/ui"
1919
import { vscode } from "@/utils/vscode"
20+
import { telemetryClient } from "@/utils/TelemetryClient"
21+
import { TelemetryEventName } from "@roo-code/types"
2022

2123
import { SlashCommandItem } from "./SlashCommandItem"
2224

@@ -82,6 +84,12 @@ export const SlashCommandsList: React.FC<SlashCommandsListProps> = ({ commands,
8284
}
8385

8486
const handleCommandClick = (command: Command) => {
87+
// Track telemetry for slash command usage
88+
telemetryClient.capture(TelemetryEventName.SLASH_COMMAND_USED, {
89+
commandType: "custom",
90+
commandName: command.name,
91+
})
92+
8593
// Insert the command into the textarea
8694
vscode.postMessage({
8795
type: "insertTextIntoTextarea",

0 commit comments

Comments
 (0)