diff --git a/README.md b/README.md index 2d45be51b..461e54d42 100644 --- a/README.md +++ b/README.md @@ -42,16 +42,6 @@ See . 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` diff --git a/includes/MinervaHooks.php b/includes/MinervaHooks.php index 30ffc5735..aa2093c79 100644 --- a/includes/MinervaHooks.php +++ b/includes/MinervaHooks.php @@ -278,7 +278,6 @@ class MinervaHooks { $vars += [ 'wgMinervaABSamplingRate' => $config->get( 'MinervaABSamplingRate' ), 'wgMinervaCountErrors' => $config->get( 'MinervaCountErrors' ), - 'wgMinervaErrorLogSamplingRate' => $config->get( 'MinervaErrorLogSamplingRate' ), 'wgMinervaReadOnly' => $roConf->isReadOnly(), ]; } diff --git a/resources/skins.minerva.scripts/errorLogging.js b/resources/skins.minerva.scripts/errorLogging.js index a483d2e51..48c588f57 100644 --- a/resources/skins.minerva.scripts/errorLogging.js +++ b/resources/skins.minerva.scripts/errorLogging.js @@ -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 ) ); diff --git a/skin.json b/skin.json index 70d95cc27..05f89950a 100644 --- a/skin.json +++ b/skin.json @@ -23,7 +23,6 @@ }, "config": { "MinervaCountErrors": false, - "MinervaErrorLogSamplingRate": 0, "MinervaDownloadNamespaces": [ 0 ], "MinervaEnableSiteNotice": false, "MinervaCustomLogos": [],