Skip to content

Commit

Permalink
Add config options for enable/disable storage methods
Browse files Browse the repository at this point in the history
  • Loading branch information
g3ortega committed Apr 25, 2024
1 parent f1100de commit 660644a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/utm_conversion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module UTMConversion
class Error < StandardError; end

class << self
attr_accessor :storage_adapter
attr_accessor :storage_adapter, :store_utm_data_in_session, :store_utm_date_in_storage_adapter

def configure
yield self
Expand All @@ -33,4 +33,6 @@ def record_conversion(session, event_data)
end

self.storage_adapter ||= UTMConversion::Storage::InMemory.new
self.store_utm_data_in_session = true
self.store_utm_date_in_storage_adapter = true
end
4 changes: 2 additions & 2 deletions lib/utm_conversion/capture/utm_params_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def extract_utm_params(request)
def store_utm_data(session, utm_params)
return if utm_params.nil? || utm_params == {}

UTMConversion::Session::UTMData.store(session, utm_params)
UTMConversion.storage_adapter.store(session.id, utm_params)
UTMConversion::Session::UTMData.store(session, utm_params) if UTMConversion.store_utm_data_in_session
UTMConversion.storage_adapter.store(session.id, utm_params) if UTMConversion.store_utm_date_in_storage_adapter
end
end
end
Expand Down

0 comments on commit 660644a

Please sign in to comment.