When raven.js is installed, it automatically catches and reports uncaught exceptions via window.onerror. We need a way to catch errors which happen before raven.js is loaded, though - in part because some modules might be loaded before Sentry is, and in debug mode window.onerror is the only way to catch module initialization errors; and in part because we might want to lazy-load raven.js.
We can use the same mw.track mechanism that is used to catch async callback errors; the difficulty is that there is no way to make raven.js not handle window.onerror, so we must be careful not to report errors twice.