Skip to content

Commit 1886f48

Browse files
committed
Refactor timestamp default behavior
1 parent c9a3c96 commit 1886f48

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/outbound.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def Outbound.identify(user_id, info={})
4343
return @ob.identify(user_id, info)
4444
end
4545

46-
def Outbound.track(user_id, event, properties={}, timestamp=nil)
46+
def Outbound.track(user_id, event, properties={}, timestamp=Time.now.to_i)
4747
if @ob == nil
4848
res = Result.new Outbound::ERROR_INIT, false
4949
@logger.error res.error
@@ -136,7 +136,7 @@ def identify(user_id, info={})
136136
return post(@api_key, '/identify', user_data)
137137
end
138138

139-
def track(user_id, event, properties={}, user_info={}, timestamp)
139+
def track(user_id, event, properties={}, user_info={}, timestamp=Time.now.to_i)
140140
unless user_id.is_a? String or user_id.is_a? Numeric
141141
res = Result.new Outbound::ERROR_USER_ID, false
142142
@logger.error res.error
@@ -159,11 +159,8 @@ def track(user_id, event, properties={}, user_info={}, timestamp)
159159
@logger.error "Could not use event properties (#{properties}) given to track call."
160160
end
161161

162-
unless timestamp == nil
163-
data[:timestamp] = timestamp
164-
else
165-
data[:timestamp] = Time.now.to_i
166-
end
162+
data[:timestamp] = timestamp
163+
puts timestamp
167164

168165
return post(@api_key, '/track', data)
169166
end

0 commit comments

Comments
 (0)