Skip to content

Instantly share code, notes, and snippets.

@Coridyn
Forked from alexgb/Segment Debugger.js
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Coridyn/10618907 to your computer and use it in GitHub Desktop.
Save Coridyn/10618907 to your computer and use it in GitHub Desktop.
var methodColors = {
identify: "#c66",
track: "#66c",
pageview: "#c6c",
_default: "#888"
};
function log(method, objects) {
var color = methodColors[method] || methodColors._default;
var args = ['%c Segment.io %c '+method+' ','background: #6c6; color: white;', 'background: '+color+'; color: white;'];
objects = objects || [];
console.log.apply(console, args.concat(objects));
}
Object.keys(analytics).forEach(function(method) {
if (typeof analytics[method] != 'function'){
return;
}
var originalFn = analytics[method];
analytics[method] = function() {
var args = Array.prototype.slice.call(arguments, 0);
log(method, args);
originalFn.apply(this, arguments);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment