* Detects if a file path is a session-related file for analytics logging. * Only matches files within the Claude config directory (e.g., ~/.claude). * Returns the type of session file or null if not a session file.
( filePath: string, )
| 193 | * Returns the type of session file or null if not a session file. |
| 194 | */ |
| 195 | function detectSessionFileType( |
| 196 | filePath: string, |
| 197 | ): 'session_memory' | 'session_transcript' | null { |
| 198 | const configDir = getClaudeConfigHomeDir() |
| 199 | |
| 200 | // Only match files within the Claude config directory |
| 201 | if (!filePath.startsWith(configDir)) { |
| 202 | return null |
| 203 | } |
| 204 | |
| 205 | // Normalize path to use forward slashes for consistent matching across platforms |
| 206 | const normalizedPath = filePath.split(win32.sep).join(posix.sep) |
| 207 | |
| 208 | // Session memory files: ~/.claude/session-memory/*.md (including summary.md) |
| 209 | if ( |
| 210 | normalizedPath.includes('/session-memory/') && |
| 211 | normalizedPath.endsWith('.md') |
| 212 | ) { |
| 213 | return 'session_memory' |
| 214 | } |
| 215 | |
| 216 | // Session JSONL transcript files: ~/.claude/projects/*/*.jsonl |
| 217 | if ( |
| 218 | normalizedPath.includes('/projects/') && |
| 219 | normalizedPath.endsWith('.jsonl') |
| 220 | ) { |
| 221 | return 'session_transcript' |
| 222 | } |
| 223 | |
| 224 | return null |
| 225 | } |
| 226 | |
| 227 | const inputSchema = lazySchema(() => |
| 228 | z.strictObject({ |