jenkins-bot has submitted this change and it was merged.

Change subject: Story 986: Log watchlist interactions
......................................................................


Story 986: Log watchlist interactions

Log various things around watchlist and diff view
activity

See: https://gerrit.wikimedia.org/r/76026

Change-Id: Ifd8b173c1851a01d61464547ffa382dfd15555b9
---
M includes/Resources.php
M javascripts/common/application.js
A javascripts/loggingSchemas/watchlist.js
M javascripts/modules/mf-watchstar.js
A javascripts/specials/mobilediff.js
M javascripts/specials/watchlist.js
6 files changed, 76 insertions(+), 3 deletions(-)

Approvals:
  JGonera: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Resources.php b/includes/Resources.php
index 0f404a2..6fd95d3 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -654,6 +654,7 @@
        ),
        'mobile.watchlist.scripts' => 
$wgMFMobileSpecialPageResourceScriptBoilerplate + array(
                'scripts' => array(
+                       'javascripts/loggingSchemas/watchlist.js',
                        'javascripts/specials/watchlist.js',
                ),
        ),
@@ -716,6 +717,16 @@
                ),
        ),
 
+       'mobile.mobilediff.scripts' => $wgMFMobileResourceBoilerplate + array(
+               'dependencies' => array(
+                       'mobile.startup',
+               ),
+               'scripts' => array(
+                       'javascripts/loggingSchemas/watchlist.js',
+                       'javascripts/specials/mobilediff.js',
+               ),
+       ),
+
        'mobile.mobilediff.scripts.beta' => $wgMFMobileResourceBoilerplate + 
array(
                // should be no dependencies except mobile.head and position to 
top to avoid flash of unstyled content
                'dependencies' => array(
diff --git a/javascripts/common/application.js 
b/javascripts/common/application.js
index dc5c9fc..1a427b2 100644
--- a/javascripts/common/application.js
+++ b/javascripts/common/application.js
@@ -230,7 +230,9 @@
        // FIXME: sandbox from mf-application.js
        function log( schemaName, data ) {
                if ( mw.eventLog ) {
-                       mw.eventLog.logEvent( schemaName, data );
+                       return mw.eventLog.logEvent( schemaName, data );
+               } else {
+                       return $.Deferred().reject( 'EventLogging not 
installed.' );
                }
        }
 
diff --git a/javascripts/loggingSchemas/watchlist.js 
b/javascripts/loggingSchemas/watchlist.js
new file mode 100644
index 0000000..1930c84
--- /dev/null
+++ b/javascripts/loggingSchemas/watchlist.js
@@ -0,0 +1,33 @@
+( function( M, $ ) {
+       var qs = window.location.search.substr( 1 ),
+               params = mw.mobileFrontend.deParam( qs );
+
+       M.define( 'loggingSchemas/watchlist', {
+               log: function( action, destination ) {
+                       return M.log( 'MobileWatchlistInteraction', {
+                               action: action,
+                               userEditCount: parseInt( mw.config.get( 
'wgUserEditCount' ), 10 ),
+                               watchlistview: params.watchlistview,
+                               filter: params.filters,
+                               destination: destination,
+                               page: mw.config.get( 'wgTitle' ),
+                               username: mw.config.get( 'wgUserName' ),
+                               mobileMode: mw.config.get( 'wgMFMode' )
+                       } );
+               },
+               hijackLink: function( selector, action ) {
+                       var schema = this;
+                       function linkHandler( ev ) {
+                               var action = $( this ).data( 'action' ),
+                                       href = $( this ).attr( 'href' );
+                               ev.preventDefault();
+                               schema.log( action, href ).always( function() {
+                                       window.location.href = href;
+                               } );
+                       }
+                       $( selector ).data( 'action', action ).
+                               on( 'click', linkHandler );
+               }
+       } );
+
+} )( mw.mobileFrontend, jQuery );
diff --git a/javascripts/modules/mf-watchstar.js 
b/javascripts/modules/mf-watchstar.js
index 7229a35..fbabb6d 100644
--- a/javascripts/modules/mf-watchstar.js
+++ b/javascripts/modules/mf-watchstar.js
@@ -107,12 +107,14 @@
 
                // FIXME change when micro.tap.js in stable
                $( watchBtn ).on( mw.config.get( 'wgMFMode' ) === 'alpha' ? 
'tap' : 'click', function( ev ) {
+                       var isWatched = $( watchBtn ).hasClass( 'watched' );
                        if( prevent ) {
                                ev.preventDefault();
                        }
                        prevent = true;
                        $( watchBtn ).addClass( 'disabled loading' );
-                       toggleWatchStatus( $( watchBtn ).hasClass( 'watched' ) 
);
+                       M.emit( 'watch', isWatched );
+                       toggleWatchStatus( isWatched );
                } );
 
        }
diff --git a/javascripts/specials/mobilediff.js 
b/javascripts/specials/mobilediff.js
new file mode 100644
index 0000000..9b6d092
--- /dev/null
+++ b/javascripts/specials/mobilediff.js
@@ -0,0 +1,14 @@
+( function( $, M ) {
+       var schema = M.require( 'loggingSchemas/watchlist' );
+
+       // EventLogging events
+       // Clicking through to article
+       schema.hijackLink( 'h2 a', 'view' );
+
+       // Clicking previous or next diff links
+       schema.hijackLink( '.revision-history-links a', 'diff-prev-or-next' );
+
+       // user link
+       schema.hijackLink( '.mw-mf-user a', 'user' );
+
+} )( jQuery, mw.mobileFrontend );
diff --git a/javascripts/specials/watchlist.js 
b/javascripts/specials/watchlist.js
index 93a610d..5a19ca8 100644
--- a/javascripts/specials/watchlist.js
+++ b/javascripts/specials/watchlist.js
@@ -1,5 +1,6 @@
 ( function( M, $ ) {
-       var star = M.require( 'watchstar' );
+       var star = M.require( 'watchstar' ),
+               schema = M.require( 'loggingSchemas/watchlist' );
 
        function init() {
                var $watchlist = $( 'ul.page-list' );
@@ -11,6 +12,16 @@
                                $.cookie( 'mwUploadsFunnel', 'watchlist', { 
expires: new Date( new Date().getTime() + 60000 ) } );
                        } );
                }
+
+               // Register EventLogging events
+               schema.hijackLink( '.header .button-bar a', 'switch' );
+               schema.hijackLink( '.mw-mf-watchlist-selector a', 'filter' );
+               schema.hijackLink( '.page-list .title', 'view' );
+               schema.hijackLink( '.more', 'more' );
+
+               M.on( 'watch', function( isWatched ) {
+                       schema.log( isWatched ? 'unwatch' : 'watch' );
+               } );
        }
 
        $( function() {

-- 
To view, visit https://gerrit.wikimedia.org/r/76025
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifd8b173c1851a01d61464547ffa382dfd15555b9
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to