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

Mixpanel and Sidekiq #91

Closed jeremybdk closed 11 years ago

jeremybdk commented 11 years ago

Hello, I am trying to setup Mixpanel and Sidekiq but I am having a hard time getting sidekiq work with mixpanel.

By anychange does anyone had success with Sidekiq as a delay/queue manager ?

Thanks in advance,

zevarito commented 11 years ago

Hi @jaybbb,

I am using Sikediq and it works fine, do not remember any issues while integrating it.

What are the errors you are getting?

jeremybdk commented 11 years ago

I am really new to sidekiq, so not sure how to configure it... Did you just create a worker like you would do for resque but adapted to sidekiq ? or is there another way to do it ?

zevarito commented 11 years ago

Yes, it is basically the same.

On Mon, Apr 22, 2013 at 10:16 AM, Jeremy Bod notifications@github.comwrote:

I am really new to sidekiq, so not sure how to configure it... Did you just create a worker like you would do for resque but adapted to sidekiq ? or is there another way to do it ?

— Reply to this email directly or view it on GitHubhttps://github.com/zevarito/mixpanel/issues/91#issuecomment-16785011 .

Alvaro

jeremybdk commented 11 years ago

class MixpanelWorker include Sidekiq::Worker

def mixpanel(env) Mixpanel::Tracker.new ENV['MIX_PANEL'], { :env => env } end

def perform(name, properties, env) mixpanel(env).track name, properties end end

That's what I did but I am having an issue with the env parameters I think, when I try to do : MixpanelWorker.perform_async('Sign up', { :invited => 123 },Rails.env) Here is the error I have :

2013-04-22T13:40:45Z 43008 TID-oxbbn0jo0 WARN: {"retry"=>true, "queue"=>"default", "class"=>"MixpanelWorker", "args"=>["Sign up", {"invited"=>123}, "development"], "jid"=>"20810bf5f2a698bf3c07e15b", "error_message"=>"string not matched", "error_class"=>"IndexError", "failed_at"=>"2013-04-22T13:40:18Z", "retry_count"=>1, "retried_at"=>2013-04-22 13:40:45 UTC}

2013-04-22T13:40:45Z 43008 TID-oxbbn0jo0 WARN: string not matched

If I remove the env parameters and do that :

def perform(name, properties) mixpanel.track name, properties end

It works, but how can I pass the env parameter ?

Thanks a lot for you help and support

zevarito commented 11 years ago

You can't pass the whole env to a worker, it will not be serialized properly, please take a look at Readme examples about how to do it: https://github.com/zevarito/mixpanel#how-to-track-events-using-resque-and-rails

jeremybdk commented 11 years ago

Ok thanks so I ended up doing that : two worker one for tracking one for set, and creating the env variable in my controller. Thanks for your help

zevarito commented 11 years ago

You welcome.