Skip to content

Commit

Permalink
Minor adjustment: use session_id instead of session
Browse files Browse the repository at this point in the history
  • Loading branch information
g3ortega committed Apr 25, 2024
1 parent 0b42d8a commit 4e48ff9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/utm_conversion/storage/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ module UTMConversion
module Storage
# Base class for storage adapters
class Base
def store(session, utm_params = nil)
def store(session_id, utm_params = nil)
raise NotImplementedError
end

def retrieve(session_id)
raise NotImplementedError
end

def record_conversion(session, event_data)
def record_conversion(session_id, event_data)
raise NotImplementedError
end
end
Expand Down
20 changes: 6 additions & 14 deletions lib/utm_conversion/storage/in_memory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def initialize
@data = {}
end

def store(session, utm_params = nil)
def store(session_id, utm_params = nil)
utm_data = utm_params || utm_data(session)
return if utm_data.blank?
return if utm_data.nil? || utm_data == {}

@data[session.id] = {
utm_data: utm_params || utm_data(session),
@data[session_id] = {
utm_data: utm_data,
conversions: []
}
end
Expand All @@ -25,16 +25,8 @@ def retrieve(session_id)
@data[session_id]&.fetch(:utm_data, nil)
end

def record_conversion(session, event_data)
return if utm_data(session).blank?

@data[session.id][:conversions] << event_data if @data[session_id]
end

private

def utm_data(session)
@utm_data ||= UTMConversion::Session::UTMData.load(session)
def record_conversion(session_id, event_data)
@data[session_id][:conversions] << event_data if @data[session_id]
end
end
end
Expand Down

0 comments on commit 4e48ff9

Please sign in to comment.