Gergő Tisza has uploaded a new change for review. https://gerrit.wikimedia.org/r/161363
Change subject: Log errors ...................................................................... Log errors Log the following error types: * filename errors * upload errors * API error for parsing custom license text (also fix a bug in the error handling code) * API errors when saving the final text Form validation errors are not logged. Uses schema https://meta.wikimedia.org/wiki/Schema:UploadWizardErrorFlowEvent Change-Id: I8bff7cc26210100ecf5930c4e9e063b441b14ed8 Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/903 --- M UploadWizard.php M UploadWizardHooks.php M resources/mw.UploadWizard.js M resources/mw.UploadWizardDeed.js M resources/mw.UploadWizardDetails.js M resources/mw.UploadWizardLicenseInput.js M resources/mw.UploadWizardUploadInterface.js M resources/uw.EventFlowLogger.js 8 files changed, 41 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard refs/changes/63/161363/1 diff --git a/UploadWizard.php b/UploadWizard.php index 1c4c254..881e9b3 100644 --- a/UploadWizard.php +++ b/UploadWizard.php @@ -138,6 +138,7 @@ $wgEventLoggingSchemas[ 'UploadWizardUploadActions' ] = 5811620; $wgEventLoggingSchemas[ 'UploadWizardStep' ] = 8851805; $wgEventLoggingSchemas[ 'UploadWizardFlowEvent' ] = 8851807; +$wgEventLoggingSchemas[ 'UploadWizardErrorFlowEvent' ] = 9924376; $wgEventLoggingSchemas[ 'UploadWizardUploadFlowEvent' ] = 9609883; // Campaign hook handlers diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php index 0546e14..cc5d004 100644 --- a/UploadWizardHooks.php +++ b/UploadWizardHooks.php @@ -647,15 +647,16 @@ if ( class_exists( 'ResourceLoaderSchemaModule' ) ) { self::$modules['ext.uploadWizard.events']['dependencies'] = array( 'ext.eventLogging', - 'schema.UploadWizardTutorialActions', - 'schema.UploadWizardUploadActions', + 'schema.UploadWizardTutorialActions', + 'schema.UploadWizardUploadActions', ); self::$modules['uw.EventFlowLogger']['dependencies'] += array( 'ext.eventLogging', - 'schema.UploadWizardStep', - 'schema.UploadWizardFlowEvent', - 'schema.UploadWizardUploadFlowEvent', + 'schema.UploadWizardStep', + 'schema.UploadWizardFlowEvent', + 'schema.UploadWizardErrorFlowEvent', + 'schema.UploadWizardUploadFlowEvent', ); } diff --git a/resources/mw.UploadWizard.js b/resources/mw.UploadWizard.js index 14fd00e..37f71ca 100644 --- a/resources/mw.UploadWizard.js +++ b/resources/mw.UploadWizard.js @@ -448,6 +448,10 @@ .on( 'filled', function () { wizard.setUploadFilled( upload ); + } ) + + .on( 'error', function ( code, message ) { + wizard.eventFlowLogger.logError( 'file', { code: code, message: message } ); } ); this.uploadToAdd = upload; diff --git a/resources/mw.UploadWizardDeed.js b/resources/mw.UploadWizardDeed.js index e74ccdc..0a2bec8 100644 --- a/resources/mw.UploadWizardDeed.js +++ b/resources/mw.UploadWizardDeed.js @@ -1,7 +1,7 @@ /** * Sort of an abstract class for deeds */ -( function ( mw, $ ) { +( function ( mw, uw, $ ) { // Runs through the third-party license groups and finds the // relevant ID for that license. Probably really hacky. @@ -518,7 +518,9 @@ return valid; }, + // FIXME does not seem to be used showError: function ( error ) { + uw.eventFlowLogger.logError( 'deeds', { message: error } ); this.$errorEl.html( error ); this.$errorEl.fadeIn(); }, @@ -596,4 +598,4 @@ }; // end UploadWizardDeed.prototype -} )( mediaWiki, jQuery ); +} )( mediaWiki, mediaWiki.uploadWizard, jQuery ); diff --git a/resources/mw.UploadWizardDetails.js b/resources/mw.UploadWizardDetails.js index e3b29c4..b0b1c78 100644 --- a/resources/mw.UploadWizardDetails.js +++ b/resources/mw.UploadWizardDetails.js @@ -11,7 +11,7 @@ * @param API * @param containerDiv The div to put the interface into */ -( function ( mw, $ ) { +( function ( mw, uw, $ ) { var fileNsId = mw.config.get( 'wgNamespaceIds' ).file; @@ -1571,6 +1571,7 @@ * @param {String} HTML error message to show. Make sure escaping text properly. */ recoverFromError: function ( fieldId, errorMessage ) { + uw.eventFlowLogger.logError( 'details', { code: fieldId, message: errorMessage } ); this.upload.state = 'error'; this.dataDiv.morphCrossfade( '.detailsForm' ); $( '#' + fieldId ).addClass( 'mwe-error' ); @@ -1586,6 +1587,7 @@ * @param {String} status line */ showError: function ( code, statusLine ) { + uw.eventFlowLogger.logError( 'details', { code: code, message: statusLine } ); this.showIndicator( 'error' ); this.setStatus( statusLine ); }, @@ -1712,4 +1714,4 @@ return this.optional( elem ) || mw.Title.newFromText( $.trim( s ) ); } ); -}) ( mediaWiki, jQuery ); +}) ( mediaWiki, mediaWiki.uploadWizard, jQuery ); diff --git a/resources/mw.UploadWizardLicenseInput.js b/resources/mw.UploadWizardLicenseInput.js index 785cf1f..4d82f9e 100644 --- a/resources/mw.UploadWizardLicenseInput.js +++ b/resources/mw.UploadWizardLicenseInput.js @@ -13,7 +13,7 @@ * @param {mw.Api} api object; useful for previews */ -( function ( mw, $ ) { +( function ( mw, uw, $ ) { mw.UploadWizardLicenseInput = function ( selector, values, config, count, api ) { this.count = count; @@ -486,10 +486,13 @@ input.$previewDialog.dialog( 'open' ); } - function error( e ) { + function error( code, result ) { + var message = result.textStatus || result.error && result.error.info || undefined; + + uw.eventFlowLogger.logError( 'license', { code: code, message: message } ); show( $( '<div></div>' ).append( - $( '<h3></h3>' ).append( e.code ), - $( '<p></p>' ).append( e.info ) + $( '<h3></h3>' ).append( code ), + $( '<p></p>' ).append( message ) ) ); } @@ -498,4 +501,4 @@ }; -} )( mediaWiki, jQuery ); +} )( mediaWiki, mediaWiki.uploadWizard, jQuery ); diff --git a/resources/mw.UploadWizardUploadInterface.js b/resources/mw.UploadWizardUploadInterface.js index 2867b7e..295640c 100644 --- a/resources/mw.UploadWizardUploadInterface.js +++ b/resources/mw.UploadWizardUploadInterface.js @@ -1,4 +1,4 @@ -( function ( mw, $, oo ) { +( function ( mw, uw, $, oo ) { var UIP; @@ -520,6 +520,7 @@ }; UIP.showFilenameError = function ( $text ) { + uw.eventFlowLogger.logError( 'file', { code: 'filename', message: $text.text() } ); $( '<div>' ) .html( $text ) .dialog({ @@ -682,4 +683,4 @@ mw.UploadWizardUploadInterface = UploadWizardUploadInterface; -}( mediaWiki, jQuery, OO ) ); +}( mediaWiki, mediaWiki.uploadWizard, jQuery, OO ) ); diff --git a/resources/uw.EventFlowLogger.js b/resources/uw.EventFlowLogger.js index d793e78..c979775 100644 --- a/resources/uw.EventFlowLogger.js +++ b/resources/uw.EventFlowLogger.js @@ -100,6 +100,14 @@ this.log( 'UploadWizardFlowEvent', { event: name } ); }; + EFLP.logError = function ( step, data ) { + this.log( 'UploadWizardErrorFlowEvent', { + step: step, + code: data.code, + message: data.message + } ); + }; + /** * Logs an upload event. * @param {string} name Event name. Recognized names: @@ -125,4 +133,7 @@ }; uw.EventFlowLogger = EventFlowLogger; + + // FIXME + uw.eventFlowLogger = new EventFlowLogger( mw.eventLog ); }( mediaWiki, mediaWiki.uploadWizard ) ); -- To view, visit https://gerrit.wikimedia.org/r/161363 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8bff7cc26210100ecf5930c4e9e063b441b14ed8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/UploadWizard Gerrit-Branch: master Gerrit-Owner: Gergő Tisza <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
