Files
telemetry-client-js/CLAUDE.md
Jason Woltje 177720e523 feat: TypeScript telemetry client SDK v0.1.0
Standalone npm package (@mosaicstack/telemetry-client) for reporting
task-completion telemetry and querying predictions from the Mosaic
Stack Telemetry server.

- TelemetryClient with setInterval-based background flush
- EventQueue (bounded FIFO array)
- BatchSubmitter with native fetch, exponential backoff, Retry-After
- PredictionCache (Map + TTL)
- EventBuilder with auto-generated event_id/timestamp
- Zero runtime dependencies (Node 18+ native APIs)
- 43 tests, 86% branch coverage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 23:25:31 -06:00

31 lines
1.1 KiB
Markdown

# @mosaicstack/telemetry-client
TypeScript/JavaScript client SDK for Mosaic Stack Telemetry. Zero runtime dependencies.
## Commands
```bash
npm install # Install dependencies
npm run typecheck # Type check
npm run lint # Lint
npm run format:check # Format check
npm test # Run tests
npm run test:coverage # Tests with coverage (85% threshold)
npm run build # Build to dist/
```
## Architecture
- `client.ts` — TelemetryClient (main public API, setInterval-based background flush)
- `queue.ts` — EventQueue (bounded FIFO array)
- `submitter.ts` — BatchSubmitter (native fetch, exponential backoff, Retry-After)
- `prediction-cache.ts` — PredictionCache (Map + TTL)
- `event-builder.ts` — EventBuilder (auto-generates event_id, timestamp)
- `types/` — Standalone type definitions matching server API schema v1.0
## Key Patterns
- `track()` never throws — catches everything, routes to `onError` callback
- Zero runtime deps: uses native `fetch` (Node 18+), `crypto.randomUUID()`, `setInterval`
- All types are standalone — no dependency on the telemetry server package