Last active
December 21, 2015 22:29
-
-
Save Darep/6375128 to your computer and use it in GitHub Desktop.
Use Rollbar (https://rollbar.com/) with Browserify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Download rollbar.js and rollbar.min.js from: | |
// http://d37gvrvc0wt4s1.cloudfront.net/js/1/rollbar.js | |
// http://d37gvrvc0wt4s1.cloudfront.net/js/1/rollbar.min.js | |
// | |
// Place them into vendor/ and this code into lib/rollbar.js, or something | |
(function(w, d) { | |
w._rollbarParams = { | |
"server.environment": "production", | |
"notifier.snippet_version": "2" | |
}; | |
w._rollbar = ["PASTE_CLIENT_ACCESS_TOKEN_HERE_PLEASE", w._rollbarParams]; | |
w._ratchet = _rollbar; | |
// Catch all exceptions and errors | |
w.onerror = function(e, u, l) { | |
_rollbar.push({ | |
_t: 'uncaught', | |
e: e, | |
u: u, | |
l: l | |
}); | |
}; | |
})(window, document); | |
require('../vendor/rollbar'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This little "hack" gets Rollbar working with Browserify, and with no extra requests! :) The client-side Rollbar script is bundled in with your own code. You just have to periodically check for new Rollbar version and update it in your Browserify project.