zevarito / mixpanel

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

People sets ip from env and allows setting of request properties, fixes issue 59 #62

Closed jochu closed 11 years ago

jochu commented 11 years ago

Sets the geolocation ip automatically based on the provided env.

For those who won't necessarily have a sane env around, I've also updated it so you can set the geolocation ip by doing:

mixpanel.set {:distinct_id => "...", :ip => "127.0.0.1"}, {:status => "spiffy"}

This change is backward compatible - simply providing a distinctid as the first argument will still work. This change does not apply to append series of methods because those will automatically use the javascript behavior.

zevarito commented 11 years ago

Hello @jochu!

Please look at my comment in here: https://github.com/zevarito/mixpanel/issues/59#issuecomment-11640333

A few things...

Thanks!

jochu commented 11 years ago

I'm out right now but I'll take a look when I get back.

jochu commented 11 years ago

@zevarito Updated to include ignore_time, documentation, and test.

jeremybdk commented 11 years ago

I am sorry but cannot get your code working that is not working : mixpanel.set {:distinct_id => ''....', :ip => "127.0.0.1"}, {:status => "spiffy"}

Or @env is not defined where do you define it ? wouldn't it be simplier to replace @env with request.env ? so that you don't have to define it ?

Even with testing with that : mixpanel.delay.set { :distinct_id => 'john-doe', :ignore_time => true }, { :age => 31, :email => 'john@doe.com' } I have an error /Users/jeremy/Sites/pockiz/app/controllers/registrations_controller.rb:58: syntax error, unexpected tASSOC, expecting '}' ...nel.delay.set { :distinct_id => 'john-doe', :ignore_time => ... ... ^ /Users/jeremy/Sites/pockiz/app/controllers/registrations_controller.rb:58: syntax error, unexpected ',', expecting '}' ...t { :distinct_id => 'john-doe', :ignore_time => true }, { :a... ... ^

Thanks

jochu commented 11 years ago

@jaybbb

... syntax error ...

Oops, sorry - the documentation is a bit off. It should be

mixpanel.set({:distinct_id => 'john-doe', :ignore_time => true}, {:age => 31, :email => 'john@doe.com'})

The surrounding parens are important.

@zevarito It's just adding parens to the documentaiton. I can make a pull request if you want. Just let me know.

zevarito commented 11 years ago

Yes pelease do.

Sent from a placea where internet isn't a sure thing. On Dec 26, 2012 3:50 PM, "Jeffrey Chu" notifications@github.com wrote:

@jaybbb https://github.com/jaybbb

... syntax error ...

Oops, sorry - the documentation is a bit off. It should be

mixpanel.set({:distinct_id => 'john-doe', :ignore_time => true}, {:age => 31, :email => 'john@doe.com'})

The surrounding parens are important.

@zevarito https://github.com/zevarito It's just adding parens to the documentaiton. I can make a pull request if you want. Just let me know.

— Reply to this email directly or view it on GitHubhttps://github.com/zevarito/mixpanel/pull/62#issuecomment-11690698.