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

@@ -17,6 +17,7 @@ import {
EVENT_FLASH_FALLBACK,
EVENT_FLASH_DECIDED_TO_CONTINUE,
SERVICE_NAME,
EVENT_SLASH_COMMAND,
} from './constants.js';
import {
ApiErrorEvent,
@@ -28,6 +29,7 @@ import {
FlashFallbackEvent,
FlashDecidedToContinueEvent,
LoopDetectedEvent,
SlashCommandEvent,
} from './types.js';
import {
recordApiErrorMetrics,
@@ -332,3 +334,24 @@ export function logFlashDecidedToContinue(
};
logger.emit(logRecord);
}
export function logSlashCommand(
config: Config,
event: SlashCommandEvent,
): void {
ClearcutLogger.getInstance(config)?.logSlashCommandEvent(event);
if (!isTelemetrySdkInitialized()) return;
const attributes: LogAttributes = {
...getCommonAttributes(config),
...event,
'event.name': EVENT_SLASH_COMMAND,
};
const logger = logs.getLogger(SERVICE_NAME);
const logRecord: LogRecord = {
body: `Slash command: ${event.command}.`,
attributes,
};
logger.emit(logRecord);
}