Class: Sentiero::Analytics::FrustrationCollector
- Inherits:
-
Object
- Object
- Sentiero::Analytics::FrustrationCollector
- Defined in:
- lib/sentiero/analytics/collectors/frustration_collector.rb
Overview
Per-segment frustration attribution. Attributes incidents to segments by object identity (e.equal?(incident)) so a same-millisecond Meta boundary cannot mis-attribute one.
IMPORTANT: works on the RAW detector output (before refine_incidents de-noise), so dead_count may EXCEED /analytics/frustration for the same URL. Intentional: completeness over precision (no rages a de-noise rule might withdraw are missed).
Constant Summary collapse
- CLICK_TAG =
Recorder tag carrying the clicked element's CSS selector.
"__click"
Constants included from Events
Events::CUSTOM, Events::INCREMENTAL, Events::META, Events::SOURCE_INPUT, Events::SOURCE_MOUSE_INTERACTION, Events::SOURCE_SCROLL
Instance Attribute Summary collapse
-
#capped ⇒ Object
readonly
Returns the value of attribute capped.
-
#dead_count ⇒ Object
readonly
Returns the value of attribute dead_count.
-
#rage_count ⇒ Object
readonly
Returns the value of attribute rage_count.
-
#selectors ⇒ Object
readonly
Returns the value of attribute selectors.
Instance Method Summary collapse
-
#collect(incidents, segment) ⇒ Object
Returns the number attributed to this segment.
-
#initialize(max_selectors: nil) ⇒ FrustrationCollector
constructor
A new instance of FrustrationCollector.
Methods included from Bounded
#bounded_fetch, #bounded_increment
Constructor Details
#initialize(max_selectors: nil) ⇒ FrustrationCollector
Returns a new instance of FrustrationCollector.
25 26 27 28 29 30 31 |
# File 'lib/sentiero/analytics/collectors/frustration_collector.rb', line 25 def initialize(max_selectors: nil) @max_selectors = max_selectors @rage_count = 0 @dead_count = 0 @selectors = Hash.new(0) @capped = false end |
Instance Attribute Details
#capped ⇒ Object (readonly)
Returns the value of attribute capped.
23 24 25 |
# File 'lib/sentiero/analytics/collectors/frustration_collector.rb', line 23 def capped @capped end |
#dead_count ⇒ Object (readonly)
Returns the value of attribute dead_count.
23 24 25 |
# File 'lib/sentiero/analytics/collectors/frustration_collector.rb', line 23 def dead_count @dead_count end |
#rage_count ⇒ Object (readonly)
Returns the value of attribute rage_count.
23 24 25 |
# File 'lib/sentiero/analytics/collectors/frustration_collector.rb', line 23 def rage_count @rage_count end |
#selectors ⇒ Object (readonly)
Returns the value of attribute selectors.
23 24 25 |
# File 'lib/sentiero/analytics/collectors/frustration_collector.rb', line 23 def selectors @selectors end |
Instance Method Details
#collect(incidents, segment) ⇒ Object
Returns the number attributed to this segment.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sentiero/analytics/collectors/frustration_collector.rb', line 34 def collect(incidents, segment) return 0 if incidents.empty? attributed = 0 incidents.each do |incident| next unless segment.any? { |e| e.equal?(incident[:event]) } if incident[:subtype] == "rage_click" @rage_count += 1 selector = nearest_click_selector(segment, incident[:timestamp]) if selector @capped = true unless bounded_increment(@selectors, selector, @max_selectors) end else @dead_count += 1 end attributed += 1 end attributed end |