Log uncaught JavaScript errors to the server

Addresses #623