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 / wire / rows-of.ts
27 lines · 962 BRaw
1import type { SentSession } from '../sent-session.js'
2import { base64Decoded } from './base64-decoded.js'
3import { batchOf } from './batch-of.js'
4
5/**
6 * Every row the session's posts carried, in order, held steady for a test:
7 * a row's random id and timestamp told as present, its metadata decoded.
8 *
9 * @param session what the plugin did
10 * @returns each row's type and fields, with `metadata` decoded
11 */
12export const rowsOf = (session: SentSession): unknown[] =>
13 session.posts.flatMap(post =>
14 batchOf(post).events.map(event => {
15 const { event_id, client_timestamp, additional_metadata, ...rest } =
16 event.event_data
17
18 return {
19 event_type: event.event_type,
20 hasEventId:
21 typeof event_id === 'string' && /^[0-9a-f-]{36}$/.test(event_id),
22 hasTimestamp: typeof client_timestamp === 'string',
23 ...rest,
24 metadata: JSON.parse(base64Decoded(String(additional_metadata))),
25 }
26 }),
27 )