stack/apps
mantrakp04 b8215a8595 feat(analytics): public trackEvent/startSpan SDK + custom events/spans ingestion
Client SDK (browser):
- app.trackEvent(type, data?, {parentIds?}) and app.startSpan(type, {data?, parentIds?, startedAtMs?}) on StackClientApp
- Span handles: setData (merge + re-write), end (idempotent), trackEvent/startSpan (inherit full chain), ref() for cross-tier parenting
- setGlobalSpan/unsetGlobalSpan (ambient parents for spans AND events, auto-unset on end), app.flush()
- Per-item promises settle on batch ack; pre-caught (no unhandled rejections); nothing throws synchronously
- Spans are versioned upserts: written open on start, re-written on setData/end with per-handle monotonic updated_at_ms
- Batch-poisoning protection: full item validation at enqueue (name regex, 16KB data cap, uuid parents, depth<=10)
- clearBuffer rejects pending + inert-ifies live spans (sign-out privacy, pairs with segment-id rotation)

Server SDK:
- serverApp.trackEvent/startSpan with explicit {userId}; same-tick coalescing per userId (one POST per sync burst)
- sendAnalyticsEventBatchAsServer on HexclaveServerInterface (secret server key -> analytics base URL)

Backend:
- events batch route accepts custom event types, events[*].parent_span_ids, spans[], and server/admin auth with body user_id (verified in tenancy)
- buildCustomSpanRows: cs- prefixed ids, system ancestry (rti-/sri-/srsi-, same gating as events) prepended to client chain, version clamped to now+5min
- custom spans insert off the response path (waitUntil), quota debits events+spans
- stripLoneSurrogates moved to lib/clickhouse for reuse

Tests: 8 new spans.test.ts cases, 9 new event-tracker.test.ts cases, 17 new e2e cases (e2e not executed: dev stack down; 2 pre-existing snapshots updated for intentional schema-message changes)
2026-07-02 11:34:34 -07:00
..
backend feat(analytics): public trackEvent/startSpan SDK + custom events/spans ingestion 2026-07-02 11:34:34 -07:00
dashboard feat(analytics): spans telemetry surface + event parent_span_ids 2026-07-01 17:27:54 -07:00
dev-launchpad chore: update package versions 2026-06-30 23:15:23 +00:00
e2e feat(analytics): public trackEvent/startSpan SDK + custom events/spans ingestion 2026-07-02 11:34:34 -07:00
hosted-components More consistent dashboard (#1613) 2026-07-01 09:24:08 -07:00
internal-tool chore: update package versions 2026-06-30 23:15:23 +00:00
mcp chore: update package versions 2026-06-30 23:15:23 +00:00
mock-oauth-server chore: update package versions 2026-06-30 23:15:23 +00:00
oauth-mock-server In-source unit tests (#429) 2025-02-14 11:47:52 -08:00
skills chore: update package versions 2026-06-30 23:15:23 +00:00