@@ -48,6 +48,7 @@ export function runBashCommand(command: string) {
4848 const ghost = streamingAgents . size > 0 || isChainInProgress
4949 const id = crypto . randomUUID ( )
5050 const commandCwd = process . cwd ( )
51+ const startTime = Date . now ( )
5152
5253 if ( ghost ) {
5354 // Ghost mode: add to pending messages
@@ -85,11 +86,17 @@ export function runBashCommand(command: string) {
8586 const exitCode = 'exitCode' in value ? value . exitCode ?? 0 : 0
8687
8788 // Track terminal command completion
89+ const durationMs = Date . now ( ) - startTime
8890 trackEvent ( AnalyticsEvent . TERMINAL_COMMAND_COMPLETED , {
8991 command : command . split ( ' ' ) [ 0 ] , // Just the command name, not args
9092 exitCode,
9193 success : exitCode === 0 ,
9294 ghost,
95+ durationMs,
96+ hasStdout : stdout . length > 0 ,
97+ hasStderr : stderr . length > 0 ,
98+ stdoutLength : stdout . length ,
99+ stderrLength : stderr . length ,
93100 } )
94101
95102 if ( ghost ) {
@@ -143,12 +150,18 @@ export function runBashCommand(command: string) {
143150 error instanceof Error ? error . message : String ( error )
144151
145152 // Track terminal command completion with error
153+ const durationMs = Date . now ( ) - startTime
146154 trackEvent ( AnalyticsEvent . TERMINAL_COMMAND_COMPLETED , {
147155 command : command . split ( ' ' ) [ 0 ] , // Just the command name, not args
148156 exitCode : 1 ,
149157 success : false ,
150158 ghost,
151- error : true ,
159+ durationMs,
160+ hasStdout : false ,
161+ hasStderr : true ,
162+ stdoutLength : 0 ,
163+ stderrLength : errorMessage . length ,
164+ isException : true ,
152165 } )
153166
154167 if ( ghost ) {
@@ -261,13 +274,18 @@ export async function routeUserPrompt(
261274 if ( ! trimmed && pendingImages . length === 0 ) return
262275
263276 // Track user input complete
277+ // Count @ mentions (simple pattern match - more accurate than nothing)
278+ const mentionMatches = trimmed . match ( / @ \S + / g) || [ ]
264279 trackEvent ( AnalyticsEvent . USER_INPUT_COMPLETE , {
265280 inputLength : trimmed . length ,
266281 mode : agentMode ,
267282 inputMode,
268283 hasImages : pendingImages . length > 0 ,
269284 imageCount : pendingImages . length ,
270285 isSlashCommand : isSlashCommand ( trimmed ) ,
286+ isBashCommand : trimmed . startsWith ( '!' ) ,
287+ hasMentions : mentionMatches . length > 0 ,
288+ mentionCount : mentionMatches . length ,
271289 } )
272290
273291 // Handle bash mode commands
@@ -407,6 +425,8 @@ export async function routeUserPrompt(
407425 trackEvent ( AnalyticsEvent . SLASH_COMMAND_USED , {
408426 command : commandDef . name ,
409427 hasArgs : args . trim ( ) . length > 0 ,
428+ argsLength : args . trim ( ) . length ,
429+ agentMode,
410430 } )
411431
412432 // The command handler (via defineCommand/defineCommandWithArgs factories)
@@ -444,9 +464,12 @@ export async function routeUserPrompt(
444464
445465 // Unknown slash command - show error
446466 if ( isSlashCommand ( trimmed ) ) {
447- // Track invalid/unknown command
467+ // Track invalid/unknown command (only log command name, not full input for privacy)
468+ const attemptedCmd = parseCommand ( trimmed )
448469 trackEvent ( AnalyticsEvent . INVALID_COMMAND , {
449- command : trimmed ,
470+ attemptedCommand : attemptedCmd ,
471+ inputLength : trimmed . length ,
472+ agentMode,
450473 } )
451474
452475 setMessages ( ( prev ) => [
0 commit comments