Page MenuHomePhabricator

Create error logging JS module
Closed, DuplicatePublic

Description

Migrated from: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/927

Create an mw.errorLog ResourceLoader module in core. The module should have two entry points:

  • logException takes an exception (and optionally additional data) and reports it to the server.
  • logError takes the same arguments as window.onerror and reports them to the server.

Reporting to the server means composing an error object, and sending it via one of these methods:

  • AJAX request to a configurable endpoint
  • GET parameters of a HTTP request to a configurable endpoint (with a fake image, the same way EventLogging does it)
  • configurable callback function
  • log to console

The method and endpoint/callback should be configurable in LocalSettings. There should also be a configuration variable to automatically call the logger from window.onerror.

At this point, it is OK to assume exceptions and onerror events behave the way they do in modern browsers. Unexpected input should not cause a new error, though.

The entry points should return an error id that can help the user to find or report the error. At this point it is fine to just return a random token (eventually this will be something like the hash of the error location). The error id should be reported home along with all other error data.

Document the concept, functionality and configuration settings on mw.org.

(Also tracked athttps://phabricator.wikimedia.org/T499 )