Module: Spotlight::ExhibitAnalytics
- Included in:
- Exhibit
- Defined in:
- app/models/concerns/spotlight/exhibit_analytics.rb
Overview
Exhibit mixin to provide analytics data
Instance Method Summary collapse
- #analytics(start_date = 1.month, path = nil) ⇒ Object
- #analytics_provider ⇒ Object
- #page_analytics(start_date = 1.month, path = nil) ⇒ Object
Instance Method Details
#analytics(start_date = 1.month, path = nil) ⇒ Object
7 8 9 10 11 12 |
# File 'app/models/concerns/spotlight/exhibit_analytics.rb', line 7 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 |
#analytics_provider ⇒ Object
21 22 23 |
# File 'app/models/concerns/spotlight/exhibit_analytics.rb', line 21 def analytics_provider @analytics_provider ||= Spotlight::Engine.config.analytics_provider.new end |
#page_analytics(start_date = 1.month, path = nil) ⇒ Object
14 15 16 17 18 19 |
# File 'app/models/concerns/spotlight/exhibit_analytics.rb', line 14 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 |