When using Mixpanel it’s best not to send events while in development, staging, demo, or QA environments. I created a class to load a mock that will simply log to the console for tracking events.
class MixpanelMock track: () -> console.log("mixpanel.track", arguments) window.mixpanel = new MixpanelMock()
You can get the updated source of MixpanelMock on GitHub.
Using in Rails
Then I place MixpanelMock in
I use the code below to conditionally load the real or fake Mixpanel library.
This way, when not in production, all of your Mixpanel tracking events will simply be printed to the console. This also makes it super simple, as a developer, to know when certain events are being sent to Mixpanel.