[MediaWiki-commits] [Gerrit] Track image unviews - change (mediawiki...MultimediaViewer)
jenkins-bot has submitted this change and it was merged. Change subject: Track image unviews .. Track image unviews Change-Id: I4441b6df511f99b73bfafea0d804171435e129d2 Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/998 --- M MultimediaViewer.php M resources/mmv/logging/mmv.logging.ActionLogger.js M resources/mmv/mmv.js M tests/qunit/mmv/logging/mmv.logging.ActionLogger.test.js 4 files changed, 49 insertions(+), 24 deletions(-) Approvals: Gergő Tisza: Looks good to me, approved jenkins-bot: Verified diff --git a/MultimediaViewer.php b/MultimediaViewer.php index 5751aba..fbb4492 100644 --- a/MultimediaViewer.php +++ b/MultimediaViewer.php @@ -1031,7 +1031,7 @@ $wgHooks['EventLoggingRegisterSchemas'][] = function( array $schemas ) { $schemas += array( - 'MediaViewer' = 10308479, + 'MediaViewer' = 10536413, 'MultimediaViewerNetworkPerformance' = 7917896, 'MultimediaViewerDuration' = 10427980, 'MultimediaViewerAttribution' = 9758179, diff --git a/resources/mmv/logging/mmv.logging.ActionLogger.js b/resources/mmv/logging/mmv.logging.ActionLogger.js index c394570..1a7d937 100644 --- a/resources/mmv/logging/mmv.logging.ActionLogger.js +++ b/resources/mmv/logging/mmv.logging.ActionLogger.js @@ -113,37 +113,33 @@ 'options-open': 'User opened the enable/disable dialog.', 'options-close': 'User either canceled an enable/disable action or closed a confirmation window.', 'disable-about-link': 'User clicked on the Learn more link in the disable window.', - 'enable-about-link': 'User clicked on the Learn more link in the enable window.' + 'enable-about-link': 'User clicked on the Learn more link in the enable window.', + 'image-unview': 'User stopped looking at the current image.' }; /** * Logs an action * @param {string} action The key representing the action -* @param {boolean} skipEventLog True if we don't want the action to be recorded in the event log -* @param {Object} substitutions A list of variable subtitutions for parametrized action texts +* @param {boolean} forceEventLog True if we want the action to be logged regardless of the sampling factor * @returns {jQuery.Promise} */ - L.log = function ( action, skipEventLog, substitutions ) { - var translatedAction = this.logActions[action] || action, + L.log = function ( action, forceEventLog ) { + var actionText = this.logActions[action] || action, self = this; - if ( $.isPlainObject( substitutions ) ) { - $.each( substitutions, function( key, value ) { - translatedAction = translatedAction.replace( key, value ); - } ); - } + mw.log( actionText ); - mw.log( translatedAction ); - - if ( !skipEventLog self.isInSample( action ) ) { + if ( forceEventLog || self.isInSample( action ) ) { return this.loadDependencies().then( function () { self.eventLog.logEvent( self.schema, { action : action, samplingFactor : self.getActionFactor( action ) } ); + + return true; } ); } else { - return $.Deferred().resolve(); + return $.Deferred().resolve( false ); } }; diff --git a/resources/mmv/mmv.js b/resources/mmv/mmv.js index af4d381..11392a3 100644 --- a/resources/mmv/mmv.js +++ b/resources/mmv/mmv.js @@ -104,6 +104,12 @@ /** @property {string} documentTitle base document title, MediaViewer will expand this */ this.documentTitle = document.title; + + /** +* Was the last image view logged or was logging skipped? +* @property {boolean} +*/ + this.wasLastViewLogged = false; } MMVP = MultimediaViewer.prototype; @@ -404,6 +410,8 @@ * @param {number} loadTime Time it took to load the thumbnail */ MMVP.displayRealThumbnail = function ( thumbnail, imageElement, imageWidths, loadTime ) { + var viewer = this; + this.realThumbnailShown = true; this.setImage( this.ui, thumbnail, imageElement, imageWidths ); @@ -416,7 +424,15 @@ this.ui.canvas.unblur(); } - mw.mmv.actionLogger.log( 'image-view' ); + mw.mmv.actionLogger.log( 'image-view'
[MediaWiki-commits] [Gerrit] Track image unviews - change (mediawiki...MultimediaViewer)
Gilles has uploaded a new change for review. https://gerrit.wikimedia.org/r/173515 Change subject: Track image unviews .. Track image unviews Change-Id: I4441b6df511f99b73bfafea0d804171435e129d2 Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/998 --- M MultimediaViewer.php M resources/mmv/logging/mmv.logging.ActionLogger.js M resources/mmv/mmv.js M tests/qunit/mmv/logging/mmv.logging.ActionLogger.test.js 4 files changed, 48 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer refs/changes/15/173515/1 diff --git a/MultimediaViewer.php b/MultimediaViewer.php index ef9724e..a9abc28 100644 --- a/MultimediaViewer.php +++ b/MultimediaViewer.php @@ -1022,7 +1022,7 @@ $wgHooks['EventLoggingRegisterSchemas'][] = function( array $schemas ) { $schemas += array( - 'MediaViewer' = 10308479, + 'MediaViewer' = 10536413, 'MultimediaViewerNetworkPerformance' = 7917896, 'MultimediaViewerDuration' = 8572641, 'MultimediaViewerAttribution' = 9758179, diff --git a/resources/mmv/logging/mmv.logging.ActionLogger.js b/resources/mmv/logging/mmv.logging.ActionLogger.js index c394570..1a7d937 100644 --- a/resources/mmv/logging/mmv.logging.ActionLogger.js +++ b/resources/mmv/logging/mmv.logging.ActionLogger.js @@ -113,37 +113,33 @@ 'options-open': 'User opened the enable/disable dialog.', 'options-close': 'User either canceled an enable/disable action or closed a confirmation window.', 'disable-about-link': 'User clicked on the Learn more link in the disable window.', - 'enable-about-link': 'User clicked on the Learn more link in the enable window.' + 'enable-about-link': 'User clicked on the Learn more link in the enable window.', + 'image-unview': 'User stopped looking at the current image.' }; /** * Logs an action * @param {string} action The key representing the action -* @param {boolean} skipEventLog True if we don't want the action to be recorded in the event log -* @param {Object} substitutions A list of variable subtitutions for parametrized action texts +* @param {boolean} forceEventLog True if we want the action to be logged regardless of the sampling factor * @returns {jQuery.Promise} */ - L.log = function ( action, skipEventLog, substitutions ) { - var translatedAction = this.logActions[action] || action, + L.log = function ( action, forceEventLog ) { + var actionText = this.logActions[action] || action, self = this; - if ( $.isPlainObject( substitutions ) ) { - $.each( substitutions, function( key, value ) { - translatedAction = translatedAction.replace( key, value ); - } ); - } + mw.log( actionText ); - mw.log( translatedAction ); - - if ( !skipEventLog self.isInSample( action ) ) { + if ( forceEventLog || self.isInSample( action ) ) { return this.loadDependencies().then( function () { self.eventLog.logEvent( self.schema, { action : action, samplingFactor : self.getActionFactor( action ) } ); + + return true; } ); } else { - return $.Deferred().resolve(); + return $.Deferred().resolve( false ); } }; diff --git a/resources/mmv/mmv.js b/resources/mmv/mmv.js index 46d440c..6e7aba8 100644 --- a/resources/mmv/mmv.js +++ b/resources/mmv/mmv.js @@ -104,6 +104,12 @@ /** @property {string} documentTitle base document title, MediaViewer will expand this */ this.documentTitle = document.title; + + /** +* Was the last image view logged or was logging skipped? +* @property {boolean} +*/ + this.wasLastViewLogged = false; } MMVP = MultimediaViewer.prototype; @@ -385,6 +391,8 @@ * @param {number} loadTime Time it took to load the thumbnail */ MMVP.displayRealThumbnail = function ( thumbnail, imageElement, imageWidths, loadTime ) { + var viewer = this; + this.realThumbnailShown = true; this.setImage( this.ui, thumbnail, imageElement, imageWidths ); @@ -397,7 +405,16 @@ this.ui.canvas.unblur(); } - mw.mmv.actionLogger.log(