I have implemented client side exception logging using window.onerror
, where I retrieve the current error and stack trace and send it to the server using AJAX
window.onerror = function(message, url, line) {
var stackTrace = printStackTrace(); //get stack trace
//send message, url, line and stackTrace to the server using an ajax call
}
where printStackTrace
is a function provided by this library: http://stacktracejs.com/
The problem is that in production all JavaScript files are minified so the stack trace and the line number are not really helpful as all errors are being reported on Line 1 in the file which is normal as the minified version contains a single line of code. For example:
Message: Object doesn't support property or method 'indexOf'
URL: http://[server]/[site]/content/combined/combined.635EE367354E6DF721593CAC56FECF95.min.js
Line: 1
Can this be improved using source maps or does that work only when Developer Tools is active ?
What I would like is to get the full stack trace using the source maps (or at least the real line number) when an error occurs for a user who doesn't have the developer tools activated/source maps enabled. Is this possible at all ?