Files
stack/apps/backend/scripts
mantrakp04 8d124a4517 feat(analytics): spans telemetry surface + event parent_span_ids
Add a generic Spans telemetry surface alongside events, written directly to
ClickHouse (spans are siblings of events, not routed through ext-db-sync).

- analytics_internal.spans table (ReplacingMergeTree, versioned) + default.spans
  view, isolated by a row policy and granted to limited_user exactly like
  default.events.
- Span types: $session-replay and $session-replay-segment (per browser tab),
  written directly from the session-replays batch route and re-written per batch
  so their end advances; $refresh-token, derived in the view from the synced
  refresh_tokens dimension.
- events.parent_span_ids: additive column holding the root-first ancestor span-id
  list ([rti, sri, srsi]), stamped on each event insert. Typed-id prefixes live
  only on span ids / parent_span_ids; scalar id columns stay raw so existing
  customer SQL keeps working (additive, backwards compatible).
- SDK: EventTracker and SessionRecorder now share one per-tab
  session_replay_segment_id (each previously minted its own, so events could not
  be correlated to a replay recording).
- Dashboard: Spans tab on the analytics tables page.
- Tests: spans unit tests + e2e for session replays, analytics events batch, and
  the analytics query surface.
2026-07-01 17:27:54 -07:00
..
2025-12-12 17:29:57 -08:00