mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-12 00:48:46 +00:00
Hygiene: Track minerva errors count only once
To minimize the traffic sent to the stats endpoint we should track errors only once after request is done, not on every error occurence. Bug: T212970 Change-Id: I64f101159aa1f2179e612effa850851fffcf39c6
This commit is contained in:
parent
e1c3fb68e4
commit
a486bde329
|
@ -1,5 +1,10 @@
|
|||
( function ( M, requestIdleCallback, track, config, trackSubscribe, user, experiments ) {
|
||||
requestIdleCallback( function () {
|
||||
/**
|
||||
* Errors count in the current pageview
|
||||
* @type {number}
|
||||
*/
|
||||
var errorsCount = 0;
|
||||
/**
|
||||
* Handle an error and log it if necessary
|
||||
* @param {string} errorMessage to be logged
|
||||
|
@ -30,7 +35,7 @@
|
|||
isAnon: user.isAnon(),
|
||||
revision: page.getRevisionId()
|
||||
};
|
||||
|
||||
errorsCount++;
|
||||
if ( isErrorLoggingEnabled ) {
|
||||
track( EVENT_CLIENT_ERROR_LOG,
|
||||
util.extend( {
|
||||
|
@ -45,8 +50,10 @@
|
|||
}, DEFAULT_ERROR_DATA )
|
||||
);
|
||||
}
|
||||
if ( config.get( 'wgMinervaCountErrors' ) ) {
|
||||
mw.track( 'counter.MediaWiki.minerva.WebClientError', 1 );
|
||||
}
|
||||
function logErrorsCount() {
|
||||
if ( errorsCount > 0 ) {
|
||||
mw.track( 'counter.MediaWiki.minerva.WebClientError', errorsCount );
|
||||
}
|
||||
}
|
||||
// track RL exceptions
|
||||
|
@ -58,6 +65,9 @@
|
|||
trackSubscribe( 'global.error', function ( topic, error ) {
|
||||
handleError( error.errorMessage, error.lineNumber, error.columnNumber, error.url );
|
||||
} );
|
||||
if ( config.get( 'wgMinervaCountErrors' ) ) {
|
||||
$( window ).on( 'beforeunload', logErrorsCount );
|
||||
}
|
||||
} );
|
||||
}(
|
||||
mw.mobileFrontend,
|
||||
|
|
Loading…
Reference in a new issue