Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixpanel.people.increment('something') fails on ServerSide #8

Open
tnj opened this issue Aug 6, 2015 · 2 comments
Open

mixpanel.people.increment('something') fails on ServerSide #8

tnj opened this issue Aug 6, 2015 · 2 comments

Comments

@tnj
Copy link

tnj commented Aug 6, 2015

When I try to use increment with Mengpaneel like:

mixpanel.people.increment 'something'

This works well with ClientSide strategy, but doesn't with ServerSide.

It looks like the arguments of people.increment are not compatible between Ruby and Javascript. Ruby version people.increment only accepts hash as it's arguments, whereas Javascript version accepts any of string, array or hash. There is a different method plus_one for that purpose.

NoMethodError: undefined method `inject' for "upload":String
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/mixpanel-ruby-2.2.0/lib/mixpanel-ruby/people.rb:245:in `fix_property_dates'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/mixpanel-ruby-2.2.0/lib/mixpanel-ruby/people.rb:96:in `increment'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/mengpaneel-0.0.2/lib/mengpaneel/tracker.rb:84:in `block (2 levels) in <class:People>'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/mengpaneel-0.0.2/lib/mengpaneel/strategy/server_side.rb:36:in `public_send'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/mengpaneel-0.0.2/lib/mengpaneel/strategy/server_side.rb:36:in `block in perform_calls'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/mengpaneel-0.0.2/lib/mengpaneel/strategy/server_side.rb:31:in `each'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/mengpaneel-0.0.2/lib/mengpaneel/strategy/server_side.rb:31:in `perform_calls'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/mengpaneel-0.0.2/lib/mengpaneel/strategy/server_side.rb:18:in `run'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/mengpaneel-0.0.2/lib/mengpaneel/strategy/async_server_side.rb:29:in `perform'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/processor.rb:75:in `execute_job'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/chain.rb:127:in `call'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/chain.rb:127:in `block in invoke'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-status-0.5.1/lib/sidekiq-status/server_middleware.rb:37:in `call'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/logging.rb:22:in `with_context'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/server/logging.rb:7:in `call'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/chain.rb:132:in `call'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/middleware/chain.rb:132:in `invoke'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/processor.rb:51:in `block in process'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/processor.rb:98:in `stats'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.0/lib/sidekiq/processor.rb:50:in `process'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `public_send'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `dispatch'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:122:in `dispatch'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60:in `block in invoke'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71:in `block in task'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357:in `block in task'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57:in `block in initialize'
        /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'

For the meantime, you can rewrite the statement as hash and it works.

mixpanel.people.increment 'something' => 1

I'm not sure mengpaneel should translate this for mixpanel-ruby though.

@DouweM
Copy link
Owner

DouweM commented Aug 6, 2015

We're already doing a lot of translating from mixpanel-js code to mixpanel-ruby here: https://github.com/DouweM/mengpaneel/blob/master/lib%2Fmengpaneel%2Ftracker.rb.

Right now, increment is just passed to mixpanel-ruby directly (https://github.com/DouweM/mengpaneel/blob/master/lib%2Fmengpaneel%2Ftracker.rb#L81), but I'm fine with implementing a smarter method.

Could you submit a pull request? :)

@tnj
Copy link
Author

tnj commented Aug 7, 2015

@DouweM Sure, I'll do that after finishing my work.

tnj added a commit to tnj/mengpaneel that referenced this issue Aug 7, 2015
mixpanel-ruby only handles hash, whereas Javascript handles string and
hash. This commit make these producing the same results:

```
mixpanel.people.increment 'something' => 1
mixpanel.people.increment 'something'
mixpanel.people.increment 'something', 1
```

This fixes DouweM#8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants