Created
November 6, 2014 23:52
-
-
Save feifanzhou/a83153e806b9bbd216ec to your computer and use it in GitHub Desktop.
Post JS errors to server
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
window.onerror = function(msg, url, line) { | |
message = 'Javascript error: *' + msg + '* (' + url + ':' + line + ') for session: *' + getCookie('session_code') + '*' | |
$.post('/alerts', { | |
message: message | |
}, | |
function() { console.log('Successfully reported error') } | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
session_code
is a cookie that refers to the token for tracking logged in users. Useful to determine who hit the error