2019-09-19 16:35:31 +00:00
|
|
|
( function ( track, config, trackSubscribe, user ) {
|
2019-07-16 21:41:37 +00:00
|
|
|
module.exports = function () {
|
2019-09-19 16:35:31 +00:00
|
|
|
var suffix = user.isAnon() ? '.anon' : '.loggedin',
|
|
|
|
COUNTER_NAME = 'counter.MediaWiki.minerva.WebClientError' + suffix;
|
|
|
|
|
2018-08-24 00:34:37 +00:00
|
|
|
/**
|
2020-05-26 11:08:48 +00:00
|
|
|
* 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
|
2018-08-24 00:34:37 +00:00
|
|
|
*/
|
2020-05-26 11:08:48 +00:00
|
|
|
function countError( topic, data ) {
|
|
|
|
var isLocalStorage = data && data.source === 'store-localstorage-update';
|
|
|
|
if ( !isLocalStorage ) {
|
|
|
|
track( COUNTER_NAME, 1 );
|
|
|
|
}
|
2019-09-19 16:35:31 +00:00
|
|
|
}
|
2019-02-11 18:11:16 +00:00
|
|
|
|
2019-09-19 16:35:31 +00:00
|
|
|
if ( config.get( 'wgMinervaCountErrors' ) ) {
|
|
|
|
// track RL exceptions
|
|
|
|
trackSubscribe( 'resourceloader.exception', countError );
|
|
|
|
// setup the global error handler
|
|
|
|
trackSubscribe( 'global.error', countError );
|
2018-08-24 00:34:37 +00:00
|
|
|
}
|
2019-07-16 21:41:37 +00:00
|
|
|
};
|
2018-09-13 15:33:20 +00:00
|
|
|
}(
|
|
|
|
mw.track,
|
|
|
|
mw.config,
|
|
|
|
mw.trackSubscribe,
|
2019-09-19 16:35:31 +00:00
|
|
|
mw.user
|
2018-09-13 15:33:20 +00:00
|
|
|
) );
|