Adds centralized support to log slash commands + sub commands (#5128)

This commit is contained in:
Shreya Keshive
2025-07-29 16:20:37 -04:00
committed by GitHub
parent 80079cd2a5
commit 293bb82019
9 changed files with 187 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ import {
FlashFallbackEvent,
LoopDetectedEvent,
FlashDecidedToContinueEvent,
SlashCommandEvent,
} from '../types.js';
import { EventMetadataKey } from './event-metadata-key.js';
import { Config } from '../../config/config.js';
@@ -40,6 +41,7 @@ const end_session_event_name = 'end_session';
const flash_fallback_event_name = 'flash_fallback';
const loop_detected_event_name = 'loop_detected';
const flash_decided_to_continue_event_name = 'flash_decided_to_continue';
const slash_command_event_name = 'slash_command';
export interface LogResponse {
nextRequestWaitMs?: number;
@@ -528,6 +530,25 @@ export class ClearcutLogger {
this.flushIfNeeded();
}
logSlashCommandEvent(event: SlashCommandEvent): void {
const data = [
{
gemini_cli_key: EventMetadataKey.GEMINI_CLI_SLASH_COMMAND_NAME,
value: JSON.stringify(event.command),
},
];
if (event.subcommand) {
data.push({
gemini_cli_key: EventMetadataKey.GEMINI_CLI_SLASH_COMMAND_SUBCOMMAND,
value: JSON.stringify(event.subcommand),
});
}
this.enqueueLogEvent(this.createLogEvent(slash_command_event_name, data));
this.flushIfNeeded();
}
logEndSessionEvent(event: EndSessionEvent): void {
const data = [
{