surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
| 1 | import type { Fields } from './fields' |
| 2 | import type { RowSession } from './row-session' |
| 3 | |
| 4 | /** |
| 5 | * The first-party event batch for one entry, shaped as the CLI's own |
| 6 | * event exporter shapes its batches. |
| 7 | * |
| 8 | * The ClaudeCodeInternalEvent JSON, one event per batch; the properties ride |
| 9 | * as base64 JSON in `additional_metadata`, the field the exporter uses; |
| 10 | * `user_type` is what the environment's USER_TYPE says of the build. |
| 11 | * |
| 12 | * @param fields the entry as checked |
| 13 | * @param session the session's id and model, and the build's user type |
| 14 | * @returns the batch's JSON text, ready to send to the exporter |
| 15 | */ |
| 16 | export function batchOf(fields: Fields, session: RowSession) { |
| 17 | const metadata = JSON.stringify(fields.props) |
| 18 | |
| 19 | return JSON.stringify({ |
| 20 | events: [ |
| 21 | { |
| 22 | event_type: 'ClaudeCodeInternalEvent', |
| 23 | event_data: { |
| 24 | event_name: fields.name, |
| 25 | client_timestamp: new Date().toISOString(), |
| 26 | session_id: session.sessionId, |
| 27 | model: session.model, |
| 28 | user_type: session.userType, |
| 29 | additional_metadata: btoa(metadata), |
| 30 | }, |
| 31 | }, |
| 32 | ], |
| 33 | }) |
| 34 | } |