jenkins-bot has submitted this change and it was merged.
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, 106 insertions(+), 58 deletions(-)
Approvals:
Jdlrobson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/MobileFrontend.hooks.php
b/includes/MobileFrontend.hooks.php
index 3600ba0..8cdcd3b 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -871,7 +871,10 @@
$mobileEventLoggingSchemas = array(
'MobileWebUploads' => 8209043,
'MobileWebEditing' => 8599025,
- 'MobileWebClickTracking' => 5929948,
+ 'MobileWebWatchlistClickTracking' => 10720361,
+ 'MobileWebDiffClickTracking' => 10720373,
+ 'MobileWebMainMenuClickTracking' => 10703095,
+ 'MobileWebUIClickTracking' => 10733934,
'MobileWebWikiGrok' => 10352247,
'MobileWebWikiGrokError' => 10353516,
);
diff --git a/javascripts/loggingSchemas/MobileWebClickTracking.js
b/javascripts/loggingSchemas/MobileWebClickTracking.js
index 6ebc3fb..849d365 100644
--- a/javascripts/loggingSchemas/MobileWebClickTracking.js
+++ b/javascripts/loggingSchemas/MobileWebClickTracking.js
@@ -6,15 +6,40 @@
var s = M.require( 'settings' );
/**
- * Track an event and record it
+ * Check whether 'schema' is one of the predefined schemas.
+ * @param {string} [schema] name. Possible values are:
+ * * Watchlist
+ * * Diff
+ * * MainMenu
+ * * UI
+ */
+ function assertSchema( schema ) {
+ var schemas = [ 'Watchlist', 'Diff', 'MainMenu', 'UI' ];
+
+ if ( $.inArray( schema, schemas ) === -1 ) {
+ throw new Error(
+ 'Invalid schema "' + schema + '". ' +
+ 'Possible values are: "' + schemas.join( '", "'
) + '".'
+ );
+ }
+ }
+
+ /**
+ * Track an event and record it. Throw an error if schema is not
+ * one of the predefined values.
*
* @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
- user = M.require( 'user' ),
+ function log( schema, name, destination ) {
+ assertSchema( schema );
+ var user = M.require( 'user' ),
username = user.getName(),
data = {
name: name,
@@ -26,33 +51,48 @@
data.username = username;
data.userEditCount = mw.config.get( 'wgUserEditCount' );
}
- return M.log( 'MobileWebClickTracking', data );
+ return M.log( 'MobileWeb' + schema + 'ClickTracking', data );
}
/*
* Using localStorage track an event but delay recording it on the
- * server until the next page load
+ * server until the next page load. Throw an error if schema is not
+ * one of the predefined values.
*
* @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 ) {
+ assertSchema( schema );
+ s.save( 'MobileWebClickTracking-schema', schema );
s.save( 'MobileWebClickTracking-name', name );
s.save( 'MobileWebClickTracking-href', href );
}
/**
- * Record a click to a link in the schema
+ * Record a click to a link in the schema. Throw an error if schema is
not
+ * one of the predefined values.
*
* @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.
+ * @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 ) {
+ assertSchema( schema );
$( selector ).on( 'click', function () {
- futureLog( name, $( this ).attr( 'href' ) );
+ futureLog( schema, name, $( this ).attr( 'href' ) );
} );
}
@@ -62,16 +102,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 0131bc1..8aef7af 100644
--- a/javascripts/loggingSchemas/init.js
+++ b/javascripts/loggingSchemas/init.js
@@ -24,35 +24,35 @@
} );
$( '#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( '.fontchanger.link',
'fontchaner-menu' );
- MobileWebClickTracking.hijackLink( '.fontchanger-size1',
'fontchanger-size1' );
- MobileWebClickTracking.hijackLink( '.fontchanger-size2',
'fontchanger-size2' );
- MobileWebClickTracking.hijackLink( '.fontchanger-size3',
'fontchanger-size3' );
+ MobileWebClickTracking.hijackLink( 'UI', $profileLink,
'lastmodified-profile' );
+ MobileWebClickTracking.hijackLink( 'UI', '.nearby-button',
'nearby-button' );
+ MobileWebClickTracking.hijackLink( 'UI', '.fontchanger.link',
'fontchanger-menu' );
+ MobileWebClickTracking.hijackLink( 'UI', '.fontchanger-size1',
'fontchanger-size1' );
+ MobileWebClickTracking.hijackLink( 'UI', '.fontchanger-size2',
'fontchanger-size2' );
+ MobileWebClickTracking.hijackLink( 'UI', '.fontchanger-size3',
'fontchanger-size3' );
} );
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..6d9e206 100644
--- a/javascripts/specials/mobilediff.js
+++ b/javascripts/specials/mobilediff.js
@@ -3,12 +3,15 @@
// 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' );
+
+ // thank button
+ schema.hijackLink( 'Diff', '#mw-mf-userinfo > button', 'thank' );
} )( 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: merged
Gerrit-Change-Id: I623fde482baaba753608160d486d79a313ee5825
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits