Support Center

Catching errors in client-side Javascript

Last Updated: Apr 06, 2012 10:53AM EDT
In some cases it is helpful to automatically trap errors and have events posted to Loggr. Javascript has a global event (window.onerror) that gets fired when a runtime error occurs. Use the code below to handle that event and post an error to Loggr.

window.onerror = function (msg, url, line) {
    var data = "Message: " + msg + "<br>";
    data += "URL: " + url + "<br>";
    data += "Line: " + line + "<br>";
    data += "Platform: " + navigator.platform + "<br>";
    data += "User Agent: " + navigator.userAgent + "<br>";
    log.events.createEvent()
        .text("Runtime error: " + msg)
        .tags("error")
        .user(appUserName)
        .dataType(Loggr.dataType.html)
        .data(data)
        .post();
}

See Documentation
support@loggr.net
http://assets2.desk.com/
false
assistly
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete