I have setup a Sentry application to collect HTTP / JS errors that can occur on the client side. However, it seems that when I try to make some 400 HTTP requests, Sentry failed to capture the request accordingly.
Is it the default behavior of Sentry, or if something missing in my code (below)?
<!DOCTYPE html>
<html>
<head>
<title>Hi there</title>
<script src="//code.jquery/jquery-1.12.0.min.js"></script>
<script src=".1.1/raven.min.js"></script>
<script>Raven.config('http://[email protected]/4').install();</script>
</head>
<body>
Hello the world :-)
<script type="text/javascript">
$.get("/");
</script>
</body>
</html>
Thanks for your feedback
I have setup a Sentry application to collect HTTP / JS errors that can occur on the client side. However, it seems that when I try to make some 400 HTTP requests, Sentry failed to capture the request accordingly.
Is it the default behavior of Sentry, or if something missing in my code (below)?
<!DOCTYPE html>
<html>
<head>
<title>Hi there</title>
<script src="//code.jquery./jquery-1.12.0.min.js"></script>
<script src="https://cdn.ravenjs./2.1.1/raven.min.js"></script>
<script>Raven.config('http://[email protected]/4').install();</script>
</head>
<body>
Hello the world :-)
<script type="text/javascript">
$.get("http://somehttp400url./");
</script>
</body>
</html>
Thanks for your feedback
Share Improve this question asked Mar 1, 2016 at 12:18 Hoang HUAHoang HUA 3354 silver badges7 bronze badges 1- please check this link: stackoverflow./questions/49462553/… – Rajashekhar Commented Apr 1, 2018 at 9:17
3 Answers
Reset to default 3You can use ajaxError
handler ( https://api.jquery./ajaxError/ ):
$( document ).ajaxError(function( event, request, settings ) {
Raven.captureException(new Error(JSON.stringify(request)));
});
Sentry docs on function wrapping will be the most canonical source on this, but effectively tell you to do what Bob says. :)
I found this to work best bining all available information into additional data field:
$(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
var new_obj= Object.assign({},jqXHR, ajaxSettings);
Raven.captureMessage(thrownError || jqXHR.statusText, {
extra: new_obj
});
});