Sha256: c27062087c881fcc8e52813455f5b8d3e256221fa592c4e35516c1230cff03d4

Contents?: true

Size: 1.5 KB

Versions: 17

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true
module Hyrax
  module Analytics
    module Google
      module Events
        extend Legato::Model

        metrics :total_events
        dimensions :event_category, :event_action, :event_label

        # Filter by event id
        filter :for_id, &->(id) { matches(:eventLabel, id) }

        # Filter by event action
        filter(:work_view) { |_event_action| matches(:eventAction, 'work-view') }
        filter(:work_in_collection_view) { |_event_action| matches(:eventAction, 'work-in-collection-view') }
        filter(:collection_page_view) { |_event_action| matches(:eventAction, 'collection-page-view') }
        filter(:file_set_download) { |_event_action| matches(:eventAction, 'file-set-download') }
        filter(:work_in_collection_download) { |_event_action| matches(:eventAction, 'work-in-collection-download') }
        filter(:file_set_in_work_download) { |_event_action| matches(:eventAction, 'file-set-in-work-download') }
        filter(:collection_file_download) { |_event_action| matches(:eventAction, 'file-set-in-collection-download') }

        def self.list(profile, start_date, end_date, action)
          action = action.underscore
          results = []
          Events.results(profile,
            start_date: start_date,
            end_date: end_date,
            sort: ['-totalEvents']).send(action).each do |result|
              results.push([result.eventLabel, result.totalEvents.to_i])
            end
          results
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/services/hyrax/analytics/google/events.rb
hyrax-5.0.0 app/services/hyrax/analytics/google/events.rb
hyrax-5.0.0.rc3 app/services/hyrax/analytics/google/events.rb
hyrax-5.0.0.rc2 app/services/hyrax/analytics/google/events.rb
hyrax-5.0.0.rc1 app/services/hyrax/analytics/google/events.rb
hyrax-3.6.0 app/services/hyrax/analytics/google/events.rb
hyrax-4.0.0 app/services/hyrax/analytics/google/events.rb
hyrax-4.0.0.rc3 app/services/hyrax/analytics/google/events.rb
hyrax-4.0.0.rc2 app/services/hyrax/analytics/google/events.rb
hyrax-4.0.0.rc1 app/services/hyrax/analytics/google/events.rb
hyrax-3.5.0 app/services/hyrax/analytics/google/events.rb
hyrax-4.0.0.beta2 app/services/hyrax/analytics/google/events.rb
hyrax-3.4.2 app/services/hyrax/analytics/google/events.rb
hyrax-4.0.0.beta1 app/services/hyrax/analytics/google/events.rb
hyrax-3.4.1 app/services/hyrax/analytics/google/events.rb
hyrax-3.4.0 app/services/hyrax/analytics/google/events.rb
hyrax-3.3.0 app/services/hyrax/analytics/google/events.rb