Skip to content

Instantly share code, notes, and snippets.

@Darep
Last active December 21, 2015 22:29
Show Gist options
  • Save Darep/6375128 to your computer and use it in GitHub Desktop.
Save Darep/6375128 to your computer and use it in GitHub Desktop.
Use Rollbar (https://rollbar.com/) with Browserify
// 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');
@Darep
Copy link
Author

Darep commented Aug 29, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment