Robmoen has uploaded a new change for review. https://gerrit.wikimedia.org/r/150965
Change subject: Instrument task recommendation schemas ...................................................................... Instrument task recommendation schemas Change-Id: Idf2ec7f3c53e795b04c295bea33b8e3f908f05ff See: https://meta.wikimedia.org/wiki/Research:Task_recommendations#Schemas Schema:TaskRecommendationImpression blocked on flyout pagination. --- M GettingStarted.php M resources/lightbulb/lightbulb.flyout.js M resources/lightbulb/lightbulb.parser.js M resources/lightbulb/lightbulb.postEdit.js M resources/lightbulb/lightbulb.suggestionView.js 5 files changed, 74 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GettingStarted refs/changes/65/150965/1 diff --git a/GettingStarted.php b/GettingStarted.php index fbbe670..9ee56f9 100644 --- a/GettingStarted.php +++ b/GettingStarted.php @@ -189,6 +189,7 @@ // should be extracted from the GuidedTour library, but, for // now, it's enough to emulate it. 'ext.guidedTour.styles', + 'schema.TaskRecommendationLightbulbClick', ), 'messages' => array( 'gettingstarted-lightbulb-recommendations-personal-tool', @@ -207,6 +208,9 @@ 'ext.gettingstarted.api', 'mediawiki.util', 'moment', + 'schema.TaskRecommendationImpression', + 'schema.TaskRecommendation', + 'schema.TaskRecommendationClick', ), ) + $gettingStartedModuleInfo; @@ -375,6 +379,32 @@ 'revision' => 8965028 ); +/* Events for Task Suggestions */ + +$wgResourceModules[ 'schema.TaskRecommendationLightbulbClick' ] = array( + 'class' => 'ResourceLoaderSchemaModule', + 'schema' => 'TaskRecommendationLightbulbClick', + 'revision' => 9266338 +); + +$wgResourceModules[ 'schema.TaskRecommendationImpression' ] = array( + 'class' => 'ResourceLoaderSchemaModule', + 'schema' => 'TaskRecommendationImpression', + 'revision' => 9266226 +); + +$wgResourceModules[ 'schema.TaskRecommendation' ] = array( + 'class' => 'ResourceLoaderSchemaModule', + 'schema' => 'TaskRecommendation', + 'revision' => 9266319 +); + +$wgResourceModules[ 'schema.TaskRecommendationClick' ] = array( + 'class' => 'ResourceLoaderSchemaModule', + 'schema' => 'TaskRecommendationClick', + 'revision' => 9266317 +); + $wgResourceModules[ 'ext.gettingstarted.assignToken' ] = array( 'scripts' => 'ext.gettingstarted.assignToken.js', 'dependencies' => array( diff --git a/resources/lightbulb/lightbulb.flyout.js b/resources/lightbulb/lightbulb.flyout.js index 07dbf90..6428e5f 100644 --- a/resources/lightbulb/lightbulb.flyout.js +++ b/resources/lightbulb/lightbulb.flyout.js @@ -18,7 +18,8 @@ </li>', POKEY_HEIGHT = 42, // (px) (See mediawiki.libs.guiders.js, L183) FLYOUT_WIDTH = 390, // (px) - parser = new mw.gettingStarted.lightbulb.Parser(); + parser = new mw.gettingStarted.lightbulb.Parser(), + cfg = mw.config.get( [ 'wgArticleId', 'wgUserId' ] ); function renderFlyout( suggestions ) { @@ -45,10 +46,15 @@ $lightbulb.find( 'a' ).text( mw.msg( 'gettingstarted-lightbulb-recommendations-personal-tool' ) ); - $lightbulb.on( 'click', 'a', function ( event ) { + $lightbulb.on( 'click', 'a', function ( event ) { event.preventDefault(); $flyout.toggle(); + + mw.eventLog.logEvent( 'TaskRecommendationLightbulbClick', { + userId: cfg.wgUserId, + pageId: cfg.wgArticleId + } ); } ); return $lightbulb; diff --git a/resources/lightbulb/lightbulb.parser.js b/resources/lightbulb/lightbulb.parser.js index 912f55e..76a44af 100644 --- a/resources/lightbulb/lightbulb.parser.js +++ b/resources/lightbulb/lightbulb.parser.js @@ -17,15 +17,28 @@ * @return {Object[]} Zero or more suggestions */ Parser.prototype.parse = function ( response ) { + var setId = mw.user.generateRandomSessionId(), + offset = 0; return $.map( response.pageids, function( pageID ) { var page = response.pages[pageID]; + + // Log Task Recommendation + mw.eventLog.logEvent( 'TaskRecommendation', { + setId: setId, + pageId: pageID, + offset: offset + } ); + + offset++; // NOTE (phuedx, 2014/07/30): Should title be an instance of // mw.Title? Should lastEdited be an instance of Date? return { title: page.title, thumbnail: page.thumbnail ? page.thumbnail.source : null, - lastEdited: page.revisions[0].timestamp + lastEdited: page.revisions[0].timestamp, + pageId: pageID, + setId: setId }; } ); }; diff --git a/resources/lightbulb/lightbulb.postEdit.js b/resources/lightbulb/lightbulb.postEdit.js index 02482c5..df3da0c 100644 --- a/resources/lightbulb/lightbulb.postEdit.js +++ b/resources/lightbulb/lightbulb.postEdit.js @@ -9,7 +9,8 @@ </div>\ </div>', notificationBodyMsg = mw.msg( 'gettingstarted-lightbulb-notification-body' ), - parser = new mw.gettingStarted.lightbulb.Parser(); + parser = new mw.gettingStarted.lightbulb.Parser(), + mwConfig = mw.config.get( [ 'wgArticleId', 'wgUserId' ] ); function createNotification( suggestions, headerMsg ) { var $notification = $( notificationTemplate ), @@ -50,6 +51,15 @@ // Show the notification. $( document.body ).append( $notification ); + + // Log Impression + mw.eventLog.logEvent( 'TaskRecommendationImpression', { + setId: suggestions[0].setId, + userId: mwConfig.wgUserId, + pageId: mwConfig.wgArticleId, + 'interface': 'post-edit', + offset: 0 + } ); } ); } ); diff --git a/resources/lightbulb/lightbulb.suggestionView.js b/resources/lightbulb/lightbulb.suggestionView.js index 5582657..f64f3bb 100644 --- a/resources/lightbulb/lightbulb.suggestionView.js +++ b/resources/lightbulb/lightbulb.suggestionView.js @@ -19,7 +19,17 @@ // Set href attribute of the overlay and info links. $result.find( 'a' ) - .attr( 'href', mw.util.getUrl( suggestion.title ) ); + .attr( 'href', mw.util.getUrl( suggestion.title ) ) + .on( 'click', function ( event ) { + event.preventDefault(); + // Log Task click and then go to the article + mw.eventLog.logEvent( 'TaskRecommendationClick', { + setId: suggestion.setId, + pageId: suggestion.pageId + } ).always( function () { + window.location.href = suggestion.title; + } ); + } ); $result.find( '.lightbulb-suggestion-overlay' ) .attr( 'title', suggestion.title ); -- To view, visit https://gerrit.wikimedia.org/r/150965 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idf2ec7f3c53e795b04c295bea33b8e3f908f05ff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GettingStarted Gerrit-Branch: master Gerrit-Owner: Robmoen <rm...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits