trackError = (err = {}, fieldsObj = {}) => {
  ga('send', 'event', Object.assign({
    eventCategory: 'Error',
    eventAction: err.name || '(no error name)',
    eventLabel: `${err.message}\n${err.stack || '(no stack trace)'}`,
    nonInteraction: true,
  }, fieldsObj));
}
Tracks a JavaScript error with optional fields object overrides.
This function is exported so it can be used in other parts of the codebase.
E.g.:

   `fetch('/api.json').catch(trackError);`

@param {(Error|Object)=} err
@param {Object=} fieldsObj