mediawiki-skins-MinervaNeue/resources/skins.minerva.scripts/errorLogging.js
Ed Sanders a32999e641 build: Update eslint-config-wikimedia to 0.16.0
Change-Id: Icabf6e065ed5685207731262db72faf848a0a04d
2020-06-04 08:39:32 -07:00

33 lines
908 B
JavaScript

( function ( track, config, trackSubscribe, user ) {
module.exports = function () {
var suffix = user.isAnon() ? '.anon' : '.loggedin',
COUNTER_NAME = 'counter.MediaWiki.minerva.WebClientError' + suffix;
/**
* Count javascript errors, except for those associated with localStorage
* being full or unavailable.
*
* @param {string} topic name of the event being tracked
* @param {Object} data event payload
*/
function countError( topic, data ) {
var isLocalStorage = data && data.source === 'store-localstorage-update';
if ( !isLocalStorage ) {
track( COUNTER_NAME, 1 );
}
}
if ( config.get( 'wgMinervaCountErrors' ) ) {
// track RL exceptions
trackSubscribe( 'resourceloader.exception', countError );
// setup the global error handler
trackSubscribe( 'global.error', countError );
}
};
}(
mw.track,
mw.config,
mw.trackSubscribe,
mw.user
) );