Skip to content

Instantly share code, notes, and snippets.

@karolisdzeja
Last active March 13, 2019 13:41
Show Gist options
  • Save karolisdzeja/8010574 to your computer and use it in GitHub Desktop.
Save karolisdzeja/8010574 to your computer and use it in GitHub Desktop.
Load Raven async
(function(w){
if (typeof Raven == 'undefined') {
w._r = w._r || [];
w.onerror = function e(msg, url, ln) {
w._r.push([msg, url, ln]);
}
}
})(window)
function loadJS(src, callback) {
var script = document.createElement('script'),
loaded;
script.setAttribute('src', src);
if (callback) {
script.onreadystatechange = script.onload = function() {
if (!loaded) {
callback();
}
loaded = true;
};
}
document.getElementsByTagName('head')[0].appendChild(script);
}
loadJS("//d3nslu0hdya83q.cloudfront.net/dist/1.0/raven.min.js", function() {
Raven.config('//url').install();
_r = _r || [];
for (var i = 0; i < _r.length; i++) {
Raven.captureMessage('Message: ' + _r[i][0] + ' - URL: ' + _r[i][1] + ' - Line: ' + _r[i][2])
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment