typescript-sdk
24
总安装量
24
周安装量
#15646
全站排名
安装命令
npx skills add https://github.com/comet-ml/opik --skill typescript-sdk
Agent 安装分布
github-copilot
24
codex
24
kimi-cli
24
gemini-cli
24
opencode
24
amp
24
Skill 文档
TypeScript SDK
Architecture
- Layered, non-blocking by default
- Data buffered and flushed async to backend
- Node >= 18, ESM + CJS builds
Layer Flow
Public API â OpikClient â Domain (Trace/Span) â BatchQueues â REST Client â Backend
Critical Gotchas
- When changing dependencies or minimum versions, update and verify version references in
README.mdand integration README files in the same PR.
Flush Before Exit
// â
REQUIRED - especially in CLI/tests
await client.flush();
// or globally:
await flushAll();
Domain Objects Don’t Do HTTP
// â
GOOD - domain objects enqueue, not HTTP
trace.update({ metadata: { key: 'value' } }); // Enqueues update
trace.end(); // Enqueues update
// â BAD - don't call REST directly from domain
Never Leak rest_api
// â
GOOD - export from public API
export { Opik, track, flushAll } from 'opik';
// â BAD - don't expose generated clients
import { TracesApi } from 'opik/rest_api'; // Internal!
Batching Semantics
- Updates wait for pending creates
- Deletes wait for creates and updates
flush()flushes all queues in order- Debounce window configurable via
OpikConfig
Error Handling
- HTTP failures:
OpikApiError,OpikApiTimeoutError - 404s translate to domain errors:
DatasetNotFoundError,ExperimentNotFoundError - Never swallow errors, include context in logs
Integration Guidelines
- Integrations wrap public API only
- Keep adapters thin, non-blocking
- Provide
flush()escape hatch if needed
Reference Files
- testing.md – Vitest patterns, mocking, flush timing