Class: Sentiero::Analytics::BrowserEventDiscovery
- Defined in:
- lib/sentiero/analytics/browser_event_discovery.rb
Overview
Cross-session newest-first listing of browser custom events (rrweb type==5) excluding the "error" tag (errors have ErrorDiscovery). Each row carries session/window + offset(ms) from window start for replay deep-links (?t=).
Constant Summary collapse
- ERROR_TAG =
"error"- MAX_ROWS =
500- ACCUMULATION_LIMIT =
Trim cap during the scan so a busy store can't balloon memory. Mid-scan trimming is safe: it keeps the globally-newest seen, and newer events from later sessions still get added and survive the next trim.
MAX_ROWS * 4
Constants included from Events
Events::CUSTOM, Events::INCREMENTAL, Events::META, Events::SOURCE_INPUT, Events::SOURCE_MOUSE_INTERACTION, Events::SOURCE_SCROLL
Instance Attribute Summary
Attributes inherited from Analyzer
Instance Method Summary collapse
Methods inherited from Analyzer
Methods included from EntryAttribution
#earlier?, #first_meta_href, #same_origin?, #update_entry_candidate
Methods included from Bounded
#bounded_fetch, #bounded_increment
Methods included from Stats
#mean, #offset_ms, #percentile, #top_counts
Constructor Details
This class inherits a constructor from Sentiero::Analytics::Analyzer
Instance Method Details
#recent_events(since: nil, until_time: nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sentiero/analytics/browser_event_discovery.rb', line 20 def recent_events(since: nil, until_time: nil) rows = [] truncated = false _scanned, hit_cap = scan_sessions(since: since, until_time: until_time) do |summary, window_id, events| anchor = events.first&.fetch("timestamp", nil) events.each do |event| next unless browser_event?(event) rows << build_row(summary, window_id, anchor, event) end next unless rows.size > ACCUMULATION_LIMIT rows.sort_by! { |r| -(r[:timestamp] || 0) } rows = rows.first(MAX_ROWS) truncated = true end rows.sort_by! { |r| -(r[:timestamp] || 0) } { rows: rows.first(MAX_ROWS), was_truncated: truncated || hit_cap || rows.size > MAX_ROWS } end |