Class: Hyrax::Analytics::Ga4::Events
- Defined in:
- app/services/hyrax/analytics/ga4/events.rb
Instance Attribute Summary
Attributes inherited from Base
#dimensions, #end_date, #metrics, #start_date
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(start_date:, end_date:, dimensions: [{ name: 'eventName' }, { name: 'contentType' }, { name: 'contentId' }], metrics: [{ name: 'eventCount' }]) ⇒ Events
constructor
A new instance of Events.
- #top_result_array ⇒ Object
Methods inherited from Base
#add_filter, #dimension_expressions, #dimension_filter, #filters, #filters=, #report, #results, #results_array
Constructor Details
#initialize(start_date:, end_date:, dimensions: [{ name: 'eventName' }, { name: 'contentType' }, { name: 'contentId' }], metrics: [{ name: 'eventCount' }]) ⇒ Events
Returns a new instance of Events.
6 7 8 9 10 11 |
# File 'app/services/hyrax/analytics/ga4/events.rb', line 6 def initialize(start_date:, end_date:, dimensions: [{ name: 'eventName' }, { name: 'contentType' }, { name: 'contentId' }], metrics: [{ name: 'eventCount' }]) super end |
Class Method Details
.list(start_date, end_date, action) ⇒ Object
13 14 15 16 17 |
# File 'app/services/hyrax/analytics/ga4/events.rb', line 13 def self.list(start_date, end_date, action) events = Events.new(start_date: start_date, end_date: end_date) events.add_filter(dimension: 'eventName', values: [action]) events.top_result_array end |
Instance Method Details
#top_result_array ⇒ Object
19 20 21 |
# File 'app/services/hyrax/analytics/ga4/events.rb', line 19 def top_result_array results.map { |r| [unwrap_dimension(metric: r, dimension: 2), unwrap_metric(r)] }.sort_by { |r| r[1] } end |