feat: slash command counter
This commit is contained in:
parent
6e786f130a
commit
a215f357bb
2 changed files with 23 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue