Bmansurov has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/178287

Change subject: EventLogging: break up MobileWebClickTracking
......................................................................

EventLogging: break up MobileWebClickTracking

The MobileWebClickTracking table is getting huge. Splitting it into
several schemas will make it easier to manage.

The new schemas are:
* MobileWebWatchlistClickTracking
* MobileWebDiffClickTracking
* MobileWebMainMenuClickTracking
* MobileWebUIClickTracking

Change-Id: I623fde482baaba753608160d486d79a313ee5825
---
M includes/MobileFrontend.hooks.php
M javascripts/loggingSchemas/MobileWebClickTracking.js
M javascripts/loggingSchemas/init.js
M javascripts/modules/categories/init.js
M javascripts/modules/languages/init.js
M javascripts/modules/notifications/notifications.js
M javascripts/modules/references/init.js
M javascripts/modules/search/init.js
M javascripts/modules/toc/TableOfContents.js
M javascripts/specials/mobilediff.js
M javascripts/specials/watchlist.js
11 files changed, 74 insertions(+), 51 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/87/178287/1

diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 3600ba0..928b9cc 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -871,7 +871,10 @@
                $mobileEventLoggingSchemas = array(
                        'MobileWebUploads'       => 8209043,
                        'MobileWebEditing'       => 8599025,
-                       'MobileWebClickTracking' => 5929948,
+                       'MobileWebWatchlistClickTracking' => 10703078,
+                       'MobileWebDiffClickTracking' => 10703099,
+                       'MobileWebMainMenuClickTracking' => 10703095,
+                       'MobileWebUIClickTracking' => 10703098,
                        'MobileWebWikiGrok'      => 10352247,
                        'MobileWebWikiGrokError' => 10353516,
                );
diff --git a/javascripts/loggingSchemas/MobileWebClickTracking.js 
b/javascripts/loggingSchemas/MobileWebClickTracking.js
index 6ebc3fb..9c611e9 100644
--- a/javascripts/loggingSchemas/MobileWebClickTracking.js
+++ b/javascripts/loggingSchemas/MobileWebClickTracking.js
@@ -9,11 +9,16 @@
         * Track an event and record it
         *
         * @method
+        * @param {string} [schema] name. Possible values are:
+        *   * Watchlist
+        *   * Diff
+        *   * MainMenu
+        *   * UI
         * @param {string} name of click tracking event to log
         * @param {string} [destination] of the link that has been clicked if 
applicable.
         */
-       function log( name, destination ) {
-               var
+       function log( schema, name, destination ) {
+               var schemas = ['Watchlist', 'Diff', 'MainMenu', 'UI'],
                        user = M.require( 'user' ),
                        username = user.getName(),
                        data = {
@@ -22,11 +27,13 @@
                                mobileMode: M.getMode()
                        };
 
-               if ( username ) {
-                       data.username = username;
-                       data.userEditCount = mw.config.get( 'wgUserEditCount' );
+               if ( $.inArray( schema, schemas ) !== -1 ) {
+                       if ( username ) {
+                               data.username = username;
+                               data.userEditCount = mw.config.get( 
'wgUserEditCount' );
+                       }
+                       return M.log( 'MobileWeb' + schema + 'ClickTracking', 
data );
                }
-               return M.log( 'MobileWebClickTracking', data );
        }
 
        /*
@@ -34,10 +41,16 @@
         * server until the next page load
         *
         * @method
+        * @param {string} [schema] name. Possible values are:
+        *   * Watchlist
+        *   * Diff
+        *   * MainMenu
+        *   * UI
         * @param {string} name of click tracking event to log
         * @param {string} href the link that has been clicked.
         */
-       function futureLog( name, href ) {
+       function futureLog( schema, name, href ) {
+               s.save( 'MobileWebClickTracking-schema', schema );
                s.save( 'MobileWebClickTracking-name', name );
                s.save( 'MobileWebClickTracking-href', href );
        }
@@ -46,13 +59,18 @@
         * Record a click to a link in the schema
         *
         * @method
+        * @param {string} [schema] name. Possible values are:
+        *   * Watchlist
+        *   * Diff
+        *   * MainMenu
+        *   * UI
         * @param {string} selector of element
         * @param {string} name unique to this click tracking event that will 
allow you to distinguish
         *  it from others.
         */
-       function hijackLink( selector, name ) {
+       function hijackLink( schema, selector, name ) {
                $( selector ).on( 'click', function () {
-                       futureLog( name, $( this ).attr( 'href' ) );
+                       futureLog( schema, name, $( this ).attr( 'href' ) );
                } );
        }
 
@@ -62,16 +80,18 @@
         * @method
         */
        function logPastEvent() {
-               var name = s.get( 'MobileWebClickTracking-name' ),
+               var schema = s.get( 'MobileWebClickTracking-schema' ),
+                       name = s.get( 'MobileWebClickTracking-name' ),
                        href = s.get( 'MobileWebClickTracking-href' );
 
                // Make sure they do not log a second time...
-               if ( name && href ) {
+               if ( schema && name && href ) {
+                       s.remove( 'MobileWebClickTracking-schema' );
                        s.remove( 'MobileWebClickTracking-name' );
                        s.remove( 'MobileWebClickTracking-href' );
                        // Since MobileWebEditing schema declares the 
dependencies to
                        // EventLogging and the schema we can be confident this 
will always log.
-                       log( name, href );
+                       log( schema, name, href );
                }
        }
 
diff --git a/javascripts/loggingSchemas/init.js 
b/javascripts/loggingSchemas/init.js
index 05d1baa..ee64763 100644
--- a/javascripts/loggingSchemas/init.js
+++ b/javascripts/loggingSchemas/init.js
@@ -24,31 +24,31 @@
                        } );
 
                $( '#mw-mf-main-menu-button' ).on( 'click', function () {
-                       MobileWebClickTracking.log( 'hamburger' );
+                       MobileWebClickTracking.log( 'UI', 'hamburger' );
                } );
 
-               MobileWebClickTracking.hijackLink( '.icon-home',
-                       'hamburger-home' );
-               MobileWebClickTracking.hijackLink( mainMenuIconSelector( 
'random' ),
-                       'hamburger-random' );
-               MobileWebClickTracking.hijackLink( mainMenuIconSelector( 
'nearby' ),
-                       'hamburger-nearby' );
-               MobileWebClickTracking.hijackLink( mainMenuIconSelector( 
'watchlist' ),
-                       'hamburger-watchlist' );
-               MobileWebClickTracking.hijackLink( mainMenuIconSelector( 
'settings' ),
-                       'hamburger-settings' );
-               MobileWebClickTracking.hijackLink( mainMenuIconSelector( 
'uploads' ),
-                       'hamburger-uploads' );
-               MobileWebClickTracking.hijackLink( mainMenuIconSelector( 
'profile' ),
-                       'hamburger-profile' );
-               MobileWebClickTracking.hijackLink( mainMenuIconSelector( 'anon' 
),
-                       'hamburger-login' );
-               MobileWebClickTracking.hijackLink( mainMenuIconSelector( 
'secondary-logout' ),
-                       'hamburger-logout' );
-               MobileWebClickTracking.hijackLink( $( '#mw-mf-last-modified a 
span' ).parent(),
+               MobileWebClickTracking.hijackLink( 'MainMenu', '.icon-home',
+                       'home' );
+               MobileWebClickTracking.hijackLink( 'MainMenu', 
mainMenuIconSelector( 'random' ),
+                       'random' );
+               MobileWebClickTracking.hijackLink( 'MainMenu', 
mainMenuIconSelector( 'nearby' ),
+                       'nearby' );
+               MobileWebClickTracking.hijackLink( 'MainMenu', 
mainMenuIconSelector( 'watchlist' ),
+                       'watchlist' );
+               MobileWebClickTracking.hijackLink( 'MainMenu', 
mainMenuIconSelector( 'settings' ),
+                       'settings' );
+               MobileWebClickTracking.hijackLink( 'MainMenu', 
mainMenuIconSelector( 'uploads' ),
+                       'uploads' );
+               MobileWebClickTracking.hijackLink( 'MainMenu', 
mainMenuIconSelector( 'profile' ),
+                       'profile' );
+               MobileWebClickTracking.hijackLink( 'MainMenu', 
mainMenuIconSelector( 'anon' ),
+                       'login' );
+               MobileWebClickTracking.hijackLink( 'MainMenu', 
mainMenuIconSelector( 'secondary-logout' ),
+                       'logout' );
+               MobileWebClickTracking.hijackLink( 'UI', $( 
'#mw-mf-last-modified a span' ).parent(),
                        'lastmodified-history' );
-               MobileWebClickTracking.hijackLink( $profileLink, 
'lastmodified-profile' );
-               MobileWebClickTracking.hijackLink( '.nearby-button', 
'nearby-button' );
+               MobileWebClickTracking.hijackLink( 'UI', $profileLink, 
'lastmodified-profile' );
+               MobileWebClickTracking.hijackLink( 'UI', '.nearby-button', 
'nearby-button' );
        } );
 
        MobileWebClickTracking.logPastEvent();
diff --git a/javascripts/modules/categories/init.js 
b/javascripts/modules/categories/init.js
index a659de9..93272db 100644
--- a/javascripts/modules/categories/init.js
+++ b/javascripts/modules/categories/init.js
@@ -21,7 +21,7 @@
         */
        function initButton() {
                $( '.category-button' ).removeClass( 'hidden' );
-               MobileWebClickTracking.hijackLink( '.category-button', 
'category-button' );
+               MobileWebClickTracking.hijackLink( 'UI', '.category-button', 
'category-button' );
        }
 
        $( initButton );
diff --git a/javascripts/modules/languages/init.js 
b/javascripts/modules/languages/init.js
index 493dcce..03a9cdb 100644
--- a/javascripts/modules/languages/init.js
+++ b/javascripts/modules/languages/init.js
@@ -27,7 +27,7 @@
                $( '#page-secondary-actions .languageSelector' ).on( 'click', 
function ( ev ) {
                        ev.preventDefault();
                        M.router.navigate( '/languages' );
-                       MobileWebClickTracking.log( 'languages' );
+                       MobileWebClickTracking.log( 'UI', 'languages' );
                } );
        }
 
diff --git a/javascripts/modules/notifications/notifications.js 
b/javascripts/modules/notifications/notifications.js
index 06d6bc3..2ee9910 100644
--- a/javascripts/modules/notifications/notifications.js
+++ b/javascripts/modules/notifications/notifications.js
@@ -34,7 +34,7 @@
        // than linking to Special:Notifications.
        $( function () {
                $btn.on( 'click', function () {
-                       schema.log( 'notifications' );
+                       schema.log( 'UI', 'notifications' );
                        M.router.navigate( '#/notifications' );
                        // Important that we also prevent propagation to avoid 
interference with events that may be
                        // binded on #mw-mf-page-center that close overlay
diff --git a/javascripts/modules/references/init.js 
b/javascripts/modules/references/init.js
index 5efda4e..e0e83bb 100644
--- a/javascripts/modules/references/init.js
+++ b/javascripts/modules/references/init.js
@@ -15,7 +15,7 @@
                var $dest = $( this ),
                        href = $dest.attr( 'href' );
 
-               MobileWebClickTracking.log( 'reference', href );
+               MobileWebClickTracking.log( 'UI', 'reference', href );
                drawer.render( {
                        title: $dest.text(),
                        text: getReference( href ).html()
diff --git a/javascripts/modules/search/init.js 
b/javascripts/modules/search/init.js
index 9b7065e..8ebd9a4 100644
--- a/javascripts/modules/search/init.js
+++ b/javascripts/modules/search/init.js
@@ -10,7 +10,7 @@
        // from user context event, so using it in route callback won't work
        // 
http://stackoverflow.com/questions/6837543/show-virtual-keyboard-on-mobile-phones-in-javascript
        $( '#searchInput' ).on( 'click', function () {
-               schema.log( 'search' );
+               schema.log( 'UI', 'search' );
                new SearchOverlay( {
                        searchTerm: $( this ).val()
                } ).show();
diff --git a/javascripts/modules/toc/TableOfContents.js 
b/javascripts/modules/toc/TableOfContents.js
index 9b692e1..41107b7 100644
--- a/javascripts/modules/toc/TableOfContents.js
+++ b/javascripts/modules/toc/TableOfContents.js
@@ -33,10 +33,10 @@
                        View.prototype.postRender.apply( this, arguments );
                        // Click tracking for table of contents so we can see 
if people interact with it
                        this.$( 'h2' ).on( 'click', function () {
-                               log( 'page-toc-toggle' );
+                               log( 'UI', 'page-toc-toggle' );
                        } );
                        this.$( 'a' ).on( 'click', function () {
-                               log( 'page-toc-link' );
+                               log( 'UI', 'page-toc-link' );
                        } );
                }
        } );
diff --git a/javascripts/specials/mobilediff.js 
b/javascripts/specials/mobilediff.js
index 1c175f2..58b0f96 100644
--- a/javascripts/specials/mobilediff.js
+++ b/javascripts/specials/mobilediff.js
@@ -3,12 +3,12 @@
 
        // EventLogging events
        // Clicking through to article
-       schema.hijackLink( 'h2 a', 'diff-view' );
+       schema.hijackLink( 'Diff', 'h2 a', 'view' );
 
        // Clicking previous or next diff links
-       schema.hijackLink( '.revision-history-links a', 'diff-prev-or-next' );
+       schema.hijackLink( 'Diff', '.revision-history-links a', 
'diff-prev-or-next' );
 
        // user link
-       schema.hijackLink( '.mw-mf-user a', 'diff-user' );
+       schema.hijackLink( 'Diff', '.mw-mf-user a', 'user' );
 
 } )( jQuery, mw.mobileFrontend );
diff --git a/javascripts/specials/watchlist.js 
b/javascripts/specials/watchlist.js
index 6b09fee..fa55a15 100644
--- a/javascripts/specials/watchlist.js
+++ b/javascripts/specials/watchlist.js
@@ -22,18 +22,18 @@
                                enhance: true
                        } );
                        watchlist.on( 'unwatch', function () {
-                               schema.log( actionNamePrefix + 'unwatch' );
+                               schema.log( 'Watchlist', actionNamePrefix + 
'unwatch' );
                        } );
                        watchlist.on( 'watch', function () {
-                               schema.log( actionNamePrefix + 'watch' );
+                               schema.log( 'Watchlist', actionNamePrefix + 
'watch' );
                        } );
                }
 
                // Register EventLogging events
-               schema.hijackLink( '.button-bar a', actionNamePrefix + 'switch' 
);
-               schema.hijackLink( '.mw-mf-watchlist-selector a', 
actionNamePrefix + 'filter' );
-               schema.hijackLink( '.page-list .title', actionNamePrefix + 
'view' );
-               schema.hijackLink( '.more', actionNamePrefix + 'more' );
+               schema.hijackLink( 'Watchlist', '.button-bar a', 
actionNamePrefix + 'switch' );
+               schema.hijackLink( 'Watchlist', '.mw-mf-watchlist-selector a', 
actionNamePrefix + 'filter' );
+               schema.hijackLink( 'Watchlist', '.page-list .title', 
actionNamePrefix + 'view' );
+               schema.hijackLink( 'Watchlist', '.more', actionNamePrefix + 
'more' );
        }
 
        $( function () {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I623fde482baaba753608160d486d79a313ee5825
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>

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

Reply via email to