spacehub

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

claude-code / mods / telemetry / tests / fixtures / row-of.ts
29 lines · 831 BRaw
1import type { Args } from 'claude-code'
2
3import { base64Decoded } from './base64-decoded.js'
4import { batchOf } from './batch-of.js'
5
6/**
7 * The one row a post to the ingest carries, held steady for a test: its
8 * random id and timestamp dropped, `hasTimestamp` and `metadata` decoded.
9 *
10 * @param post the `http.fetch` the plugin made
11 * @returns the row's type, whether it was stamped, its fields and metadata
12 */
13export function rowOf(post: Args<'http.fetch'>): unknown {
14 const [event] = batchOf(post).events
15
16 const {
17 event_id: _eventId,
18 client_timestamp,
19 additional_metadata,
20 ...rest
21 } = event?.event_data ?? {}
22
23 return {
24 event_type: event?.event_type,
25 hasTimestamp: typeof client_timestamp === 'string',
26 ...rest,
27 metadata: JSON.parse(base64Decoded(String(additional_metadata))),
28 }
29}