Class: Hyrax::Analytics::Ga4::EventsDaily

Inherits:
Base
  • Object
show all
Defined in:
app/services/hyrax/analytics/ga4/events_daily.rb

Instance Attribute Summary

Attributes inherited from Base

#dimensions, #end_date, #metrics, #start_date

Class Method Summary collapse

Instance Method Summary collapse

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: 'date' }, { name: 'eventName' }, { name: 'contentType' }, { name: 'contentId' }], metrics: [{ name: 'eventCount' }]) ⇒ EventsDaily

Returns a new instance of EventsDaily.



6
7
8
9
10
11
# File 'app/services/hyrax/analytics/ga4/events_daily.rb', line 6

def initialize(start_date:,
               end_date:,
               dimensions: [{ name: 'date' }, { name: 'eventName' }, { name: 'contentType' }, { name: 'contentId' }],
               metrics: [{ name: 'eventCount' }])
  super
end

Class Method Details

.by_id(start_date, end_date, id, action) ⇒ Object

returns a daily number of events for a specific action



24
25
26
27
28
29
30
31
32
# File 'app/services/hyrax/analytics/ga4/events_daily.rb', line 24

def self.by_id(start_date, end_date, id, action)
  events_daily = EventsDaily.new(
    start_date: start_date,
    end_date: end_date
  )
  events_daily.add_filter(dimension: 'contentId', values: [id])
  events_daily.add_filter(dimension: 'eventName', values: [action])
  events_daily.results_array
end

.summary(start_date, end_date, action) ⇒ Object

returns a daily number of events for a specific action



14
15
16
17
18
19
20
21
# File 'app/services/hyrax/analytics/ga4/events_daily.rb', line 14

def self.summary(start_date, end_date, action)
  events_daily = EventsDaily.new(
    start_date: start_date,
    end_date: end_date
  )
  events_daily.add_filter(dimension: 'eventName', values: [action])
  events_daily.results_array
end