Mock Mixpanel.js in development and staging
If you're using Mixpanel for tracking users and analyzing their behaviors (and you should be!), here is how I setup my site to mock the mixpanel tracking service so that I'm not posting events while in my development or staging environments.
index.html.haml
- if Rails.env.production?
= javascript_include_tag "mixpanel"
- else
:javascript
function MixPanelMock() {
this.track = track;
function track(eventString) {
console.log(eventString);
}
}
window.mixpanel = new MixPanelMock();
Now, anytime you call mixpanel.track("Some event");
it just prints to the console.
Written by Matthew Boston
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#