zevarito / mixpanel

Simple lib to track events in Mixpanel service. It can be used in any rack based framework.
MIT License
274 stars 84 forks source link

Updated README #109

Closed prouty closed 11 years ago

prouty commented 11 years ago

...ected to be in epoch time (e.g., 5.weeks.ago should be 5.weeks.ago.to_i)

reconbot commented 11 years ago

This actually isn't needed, it will do the right thing with a Time object

prouty commented 11 years ago

Are you sure about that? I can specifically see this not working correctly without calling to_i.

I'm doing an import of Member login activity. This first example does not work—it puts all of the events at the current date/time. The second example does work, putting the time of the events where I specify (by the login create time). The only difference is that to_i appended to login.created_at. It's very possible there's something else that's causing the problem, but from what I can see the to_i is necessary.

@logins.each do |login|
  @mixpanel.import 'Member logged in', super_properties.merge({ :distinct_id => user.mixpanel_identifier, :time => login.created_at }), import_options
end

@logins.each do |login|
  @mixpanel.import 'Member logged in', super_properties.merge({ :distinct_id => user.mixpanel_identifier, :time => login.created_at.to_i }), import_options
end
reconbot commented 11 years ago

@prouty you were right, we've got #120 out there that should fix the issue.