diff --git a/extensions/cli/src/slashCommands.ts b/extensions/cli/src/slashCommands.ts index 509ce8f61..7ff2612e3 100644 --- a/extensions/cli/src/slashCommands.ts +++ b/extensions/cli/src/slashCommands.ts @@ -10,6 +10,7 @@ import { getAllSlashCommands } from "./commands/commands.js"; import { reloadService, SERVICE_NAMES, services } from "./services/index.js"; import { getCurrentSession, getSessionFilePath } from "./session.js"; import { posthogService } from "./telemetry/posthogService.js"; +import { telemetryService } from "./telemetry/telemetryService.js"; import { SlashCommandResult } from "./ui/hooks/useChat.types.js"; import { getVersion } from "./version.js"; @@ -285,6 +286,9 @@ export async function handleSlashCommands( const [command, ...args] = input.slice(1).split(" "); + telemetryService.recordSlashCommand(command); + posthogService.capture("useSlashCommand", { name: command }); + const handler = commandHandlers[command]; if (handler) { return await handler(args, assistant); diff --git a/extensions/cli/src/telemetry/telemetryService.ts b/extensions/cli/src/telemetry/telemetryService.ts index 42d31ba91..2684c267e 100644 --- a/extensions/cli/src/telemetry/telemetryService.ts +++ b/extensions/cli/src/telemetry/telemetryService.ts @@ -54,6 +54,7 @@ class TelemetryService { private mcpConnectionsGauge: any = null; private startupTimeHistogram: any = null; private responseTimeHistogram: any = null; + private slashCommandCounter: any = null; constructor() { this.config = this.loadConfig(); @@ -285,6 +286,14 @@ class TelemetryService { unit: "ms", }, ); + + this.slashCommandCounter = this.meter.createCounter( + "continue_cli_slash_command_usage", + { + description: "Count of slash commands used", + unit: "count", + }, + ); } // Check if telemetry is enabled - this is the single point of checking @@ -571,6 +580,16 @@ class TelemetryService { return this.config.sessionId; } + public recordSlashCommand(commandName: string) { + if (!this.isEnabled()) return; + + console.log("ADD: ", commandName); + this.slashCommandCounter.add( + 1, + this.getStandardAttributes({ command: commandName }), + ); + } + /** * Shutdown telemetry service and ensure all metrics are flushed */