Sha256: ad5b500c616f1237eca134cc030738512771c1f0dec6b95822ae7473a0bba80f

Contents?: true

Size: 760 Bytes

Versions: 35

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true

module Spotlight
  ##
  # Exhibit mixin to provide analytics data
  module ExhibitAnalytics
    def analytics(start_date = 1.month, path = nil)
      return OpenStruct.new unless analytics_provider&.enabled?

      @analytics ||= {}
      @analytics[start_date] ||= analytics_provider.exhibit_data(path || self, start_date: start_date.ago)
    end

    def page_analytics(start_date = 1.month, path = nil)
      return [] unless analytics_provider&.enabled?

      @page_analytics ||= {}
      @page_analytics[start_date] ||= analytics_provider.page_data(path || self, start_date: start_date.ago)
    end

    def analytics_provider
      @analytics_provider ||= Spotlight::Engine.config.analytics_provider.new
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
blacklight-spotlight-4.0.3 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-4.0.2 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-4.0.1 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-4.0.0 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.6.0.beta10 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.6.0.beta9 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.6.0.beta8 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.5.0.4 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.6.0.beta7 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.5.0.3 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.6.0.beta6 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.6.0.beta5 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.6.0.beta4 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.6.0.beta3 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.6.0.beta1 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.5.0.2 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.5.0.1 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.5.0 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.4.4.1 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-3.4.4 app/models/concerns/spotlight/exhibit_analytics.rb