I am leveraging the mixpanel gem to fire off some events via Rack middleware as opposed the browser-based js constructed events. I know I can do all of this via their js API, but I have cases where it is much easier to fire the event from the controller.
BUT, for some reason none of these events include the user's browser and OS.
The gem documentation (https://github.com/zevarito/mixpanel#usage) seems to indicate that I would need to manually include these:
Additional information contained in your environment (e.g., http_referer) can simply be sent in as attributes where appropriate for your use case.
Is this really the case? If so, what's the best way to do this? Use something like the browser gem (https://github.com/fnando/browser) and then populate the browser and os properties in my events?
The reason the standard HTTP info was not being sent to Mixpanel was because I was not correctly using the Rack Middleware setup. To get it working, I had to
persist: true
option on both the Middleware config and when initializing the Mixpanel class. This allows messages to be be sent via js even if there is a redirect (pretty typical on a form submit)mixpanel.append_track
method instead of justmixpanel.track
All of this is present in the gem documentation, it's just not very clear.