Remove wgMinervaErrorLogSamplingRate

We are counting errors rather than sending them via EventLogging.
This code is thus being shipped unnecessarily to our users and is
not ever enabled in production

Given our work to use Sentry (T106915) let's remove this code.

Bug: T233663
Change-Id: I71ef7377e91e38f9ccc13493d52ab629d433f8f4
This commit is contained in:
jdlrobson 2019-09-19 09:35:31 -07:00 committed by Pmiazga
parent 783e391bb9
commit 8ee17cf2b0
4 changed files with 16 additions and 76 deletions

View file

@ -42,16 +42,6 @@ See <https://www.mediawiki.org/wiki/Manual:$wgSiteNotice>.
Whether to count client side errors in statsv.
#### $wgMinervaErrorLogSamplingRate
* Type: `Integer`
* Default: `0`
Whether to log client side errors to EventLogging. If 0, error logging is disabled.
If 0.5, 50% of all client side errors will be logged to the EventLogging client.
If 1, all errors will be logged to the EventLogging client, thus when enabling this
care should be taken that your setup is bug free in order to not overwhelm the EventLogging
server.
#### $wgMinervaShowCategoriesButton
* Type: `Array`

View file

@ -278,7 +278,6 @@ class MinervaHooks {
$vars += [
'wgMinervaABSamplingRate' => $config->get( 'MinervaABSamplingRate' ),
'wgMinervaCountErrors' => $config->get( 'MinervaCountErrors' ),
'wgMinervaErrorLogSamplingRate' => $config->get( 'MinervaErrorLogSamplingRate' ),
'wgMinervaReadOnly' => $roConf->isReadOnly(),
];
}

View file

@ -1,73 +1,25 @@
( function ( M, track, config, trackSubscribe, user, experiments ) {
( function ( track, config, trackSubscribe, user ) {
module.exports = function () {
/**
* Handle an error and log it if necessary
* @param {string} errorMessage to be logged
* @param {number} [lineNumber] of error
* @param {number} [columnNumber] of error
* @param {string} [errorUrl] to be logged
*/
function handleError( errorMessage, lineNumber, columnNumber, errorUrl ) {
var suffix,
errorSamplingRate = config.get( 'wgMinervaErrorLogSamplingRate', 0 ),
sessionToken = user.sessionId(),
EVENT_CLIENT_ERROR_LOG = 'wikimedia.event.WebClientError',
mobile = M.require( 'mobile.startup' ),
currentPage = mobile.currentPage(),
util = mobile.util,
errorExperiment = {
name: 'WebClientError',
enabled: errorSamplingRate > 0,
buckets: {
on: errorSamplingRate,
off: 1 - errorSamplingRate
}
},
isErrorLoggingEnabled = experiments.getBucket( errorExperiment, sessionToken ) === 'on',
DEFAULT_ERROR_DATA = {
sessionToken: sessionToken,
skin: config.get( 'skin' ),
wgVersion: config.get( 'wgVersion' ),
mobileMode: config.get( 'wgMFMode', 'desktop' ),
isAnon: user.isAnon(),
revision: currentPage.getRevisionId()
};
var suffix = user.isAnon() ? '.anon' : '.loggedin',
COUNTER_NAME = 'counter.MediaWiki.minerva.WebClientError' + suffix;
if ( isErrorLoggingEnabled ) {
track( EVENT_CLIENT_ERROR_LOG,
util.extend( {
userUrl: window.location.href,
errorUrl: errorUrl,
errorMessage: errorMessage,
// Due to concerns for the length of the stack trace and going over the
// limit for URI length this is currently set to empty string.
errorStackTrace: '',
errorLineNumber: lineNumber || 0,
errorColumnNumber: columnNumber || 0
}, DEFAULT_ERROR_DATA )
);
}
if ( config.get( 'wgMinervaCountErrors' ) ) {
suffix = user.isAnon() ? '.anon' : '.loggedin';
mw.track( 'counter.MediaWiki.minerva.WebClientError' + suffix, 1 );
}
/**
* Count javascript error
*/
function countError() {
track( COUNTER_NAME, 1 );
}
if ( config.get( 'wgMinervaCountErrors' ) ) {
// track RL exceptions
trackSubscribe( 'resourceloader.exception', countError );
// setup the global error handler
trackSubscribe( 'global.error', countError );
}
// track RL exceptions
trackSubscribe( 'resourceloader.exception', function ( topic, data ) {
var error = data.exception;
handleError( error.message, error.lineNumber, error.columnNumber );
} );
// setup the global error handler
trackSubscribe( 'global.error', function ( topic, error ) {
handleError( error.errorMessage, error.lineNumber, error.columnNumber, error.url );
} );
};
}(
// eslint-disable-next-line no-restricted-properties
mw.mobileFrontend,
mw.track,
mw.config,
mw.trackSubscribe,
mw.user,
mw.experiments
mw.user
) );

View file

@ -23,7 +23,6 @@
},
"config": {
"MinervaCountErrors": false,
"MinervaErrorLogSamplingRate": 0,
"MinervaDownloadNamespaces": [ 0 ],
"MinervaEnableSiteNotice": false,
"MinervaCustomLogos": [],