PR Summary

What problems was I solving

User interaction sequences (scroll depth, video watching, conversations, etc.) were not materialized. The prospect timeline UI had to reconstruct raw events for every view, incurring read latency and limiting the ability to compute summary-level aggregates beyond click counters.

What user-facing changes did I ship

The prospect timeline now displays deeper user behavior signals: scroll depth direction and percentage, video watch time windows and completion status. Timeline tooltips include component snapshot attribution for richer debugging without additional volatile lookups.

How I implemented it

Implemented a sequence materialization pipeline in page-analytics-service that: (1) ingests analytics events and component snapshots, (2) reduces raw events into semantic sequences (conversations, scroll runs, video runs, general actions), (3) persists sequences to a new analytic_session_sequences table, (4) derives interaction aggregate fields (thread count, FAQ hits, keyword clicks, meaningful-interaction flag) for analytics_session_summaries, and (5) switches the timeline read path to use materialized sequences when available. The service recomputes summaries plus sequences after form conversions and batch event processing. UI components were extended to render new scroll_depth and video_watched timeline item types.

Description for the changelog

Add analytic_session_sequences table with unique constraints on tenant_id + sequence_id/projection_idempotency_key; add componentDepth, video time, interaction aggregates fields to analytics_session_summaries; implement sequence materialization; update timeline API and UI with scroll/interaction semantics; upgrade CURRENT_SUMMARY_VERSION to 5.

Implement analytic session sequence projection and materialization

high5 files
Materialize user interaction sequences from raw events; derive interaction aggregates for session summaries; materialize timeline from sequence-backed read path

Integrate sequence materialization into main workflow pipeline

high15 files
Invoke recomputeSessionSequences after summary recomputation; integrate sequence materialization preprocessing into event queue processing; update cache test expectations; extend timeline tests for sequence-backed items and aggregates

Add analytic session sequences table and summary interaction fields

medium2 files
Create analytic_session_sequences table with unique constraints and indexes, add interaction aggregate fields to analytics_session_summaries table

Add analytic session sequence repository

medium4 files
Create AnalyticSessionSequenceRepository with upsert/replace/list operations; add AnalyticSessionSequenceWrite/SequenceEventMetadata types; update repositories export index

Update page session timeline API with sequence-backed events

medium3 files
Extend PageSessionTimelineItem to include scroll_depth and video_watched event types; add componentSnapshotKey and descriptorHead to TimelineComponent schema

Update repository contracts and query logic for sequence support

medium11 files
Add AnalyticsEventSequenceComponent type; update interaction feed queries; add interaction aggregate fields to summary records/write; bump CURRENT_SUMMARY_VERSION to 5

Add repository-level tests for sequences, interaction queries, and summary aggregates

medium3 files
Add analyticSessionSequenceRepository integration tests; update analyticsRepository tests for listSequenceComponentsForAnalyticsEvents; add session summary aggregate coverage; verify CURRENT_SUMMARY_VERSION

Display scroll_depth and video_watched timeline items

low4 files
Add getScrollDepthPresentation and getVideoWatchedPresentation helpers; extend SessionTimelineItem type with scroll_depth and video_watched metadata; add beforePageStateId/afterPageStateId fields to timeline component type

Regenerate Sapatos TypeScript types and update migration test snapshot

low2 files
Add AnalyticSessionSequence types to Sapatos ORM schema; update migration snapshot hash to reflect 055.do file changes