window.onerror = function(m, f, l){
var err = JSON.encode({ message:m, file:f, line:l })
(new Image).src = '/errors?e='+err
}
For Google Analytics users: window.onerror = function(m, f, l){
var err = [f, l, m].join(' : ')
_gaq.push(['_trackEvent', 'Errors', 'App', err, null, true])
}
Analytics will allow you to filter by OS, browser, and all the other environment data it already captures. And nice graphs as a bonus :)