Class: Spree::Tracker
- Inherits:
-
Base
- Object
- ApplicationRecord
- Base
- Spree::Tracker
show all
- Defined in:
- app/models/spree/tracker.rb
Constant Summary
collapse
- TRACKING_ENGINES =
%i(google_analytics segment).freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
page, spree_base_scopes
#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.current(engine = TRACKING_ENGINES.first) ⇒ Object
12
13
14
15
16
17
|
# File 'app/models/spree/tracker.rb', line 12
def self.current(engine = TRACKING_ENGINES.first)
tracker = Rails.cache.fetch("current_tracker/#{engine}") do
send(engine).active.first
end
tracker.analytics_id.present? ? tracker : nil if tracker
end
|
Instance Method Details
#clear_cache ⇒ Object
19
20
21
22
23
|
# File 'app/models/spree/tracker.rb', line 19
def clear_cache
TRACKING_ENGINES.each do |engine|
Rails.cache.delete("current_tracker/#{engine}")
end
end
|