Revert "Remove all main_menu tracking related code."

This reverts commit d11c84d08b.

We decided to track both old MobileWebMainMenuClickTracking and new MobileWebUIActionsTracking for some time. Then once everything goes stable and it's proven to work correctly we will merge d11c84d08b.

Bug: T220016
Change-Id: Ib4d52e8b8c870774041284e575564a9933af6136
This commit is contained in:
Pmiazga 2019-07-22 17:11:15 +00:00 committed by Jdlrobson
parent 8ae59453de
commit de353c06c9
7 changed files with 97 additions and 1 deletions

View File

@ -237,6 +237,13 @@ Group membership can be debugged from the console via:
And since session ID is an input in calculating the group, reassignment occurs
when clearing it: `mw.storage.session.remove('mwuser-sessionId')`.
#### $wgMinervaSchemaMainMenuClickTrackingSampleRate
Defines the sampling rate for the MobileWebMainMenuClickTracking schema.
* Type: `Number`
* Default: `0`
### Components
Components may be shared between server and client. Keeping all code for a single component only in

View File

@ -256,6 +256,8 @@ class MinervaHooks {
$config = MediaWikiServices::getInstance()->getConfigFactory()
->makeConfig( 'minerva' );
$vars += [
'wgMinervaSchemaMainMenuClickTrackingSampleRate' =>
$config->get( 'MinervaSchemaMainMenuClickTrackingSampleRate' ),
'wgMinervaABSamplingRate' => $config->get( 'MinervaABSamplingRate' ),
'wgMinervaCountErrors' => $config->get( 'MinervaCountErrors' ),
'wgMinervaErrorLogSamplingRate' => $config->get( 'MinervaErrorLogSamplingRate' ),

View File

@ -8,6 +8,7 @@
errorLogging = require( './errorLogging.js' ),
notifications = require( './notifications.js' ),
preInit = require( './preInit.js' ),
initLogging = require( './initLogging.js' ),
mobileRedirect = require( './mobileRedirect.js' ),
search = require( './search.js' ),
references = require( './references.js' ),
@ -345,6 +346,8 @@
// - main menu closes when you click outside of it
// - redirects show a toast.
preInit();
// - logging
initLogging();
// - references
references();
// - search

View File

@ -0,0 +1,8 @@
// This initialises EventLogging for main menu and some prominent links in the UI.
// This code should only be loaded on the Minerva skin, it does not apply to other skins.
// @deprecated and to be removed the moment that T220016 is live.
var mainMenu = require( './menu.js' );
module.exports = function () {
mainMenu.enableLogging();
};

View File

@ -33,6 +33,25 @@
activator: undefined
},
/**
* Turn on event logging on the existing main menu by reading `event-name` data
* attributes on elements.
* @memberof MainMenu
* @deprecated and to be removed the moment that T220016 is live.
* @instance
*/
enableLogging: function () {
this.$el.find( 'a' ).on( 'click', function () {
var $link = $( this ),
eventName = $link.data( 'event-name' );
if ( eventName ) {
mw.track( 'minerva.schemaMobileWebMainMenuClickTracking', {
name: eventName,
destination: $link.attr( 'href' )
} );
}
} );
},
/**
* Remove the nearby menu entry if the browser doesn't support geo location
* @memberof MainMenu

View File

@ -0,0 +1,53 @@
mw.loader.using( [
'ext.eventLogging'
] ).then( function () {
var M = mw.mobileFrontend,
user = mw.user,
editCount = mw.config.get( 'wgUserEditCount' ),
// Need to make amc default to false because it will not exist in mw.config
// if using desktop Minerva or if MobileFrontend extension is not installed.
amc = mw.config.get( 'wgMFAmc', false ),
// Schema class provided by ext.eventLogging module
Schema = mw.eventLog.Schema, // resource-modules-disable-line
context = M.require( 'mobile.startup' ).context,
DEFAULT_SAMPLING_RATE = mw.config.get( 'wgMinervaSchemaMainMenuClickTrackingSampleRate' ),
// T218627: Sampling rate should be 100% if user has amc enabled
AMC_SAMPLING_RATE = 1,
/**
* MobileWebMainMenuClickTracking schema
* https://meta.wikimedia.org/wiki/Schema:MobileWebMainMenuClickTracking
*
* @class MobileWebMainMenuClickTracking
* @deprecated and to be removed the moment that T220016 is live.
* @singleton
*/
schemaMobileWebMainMenuClickTracking = new Schema(
'MobileWebMainMenuClickTracking',
amc ? AMC_SAMPLING_RATE : DEFAULT_SAMPLING_RATE,
/**
* @property {Object} defaults Default options hash.
* @property {string} defaults.mode whether user is in stable, beta, or desktop
* @property {boolean} defaults.amc whether or not the user has advanced
* contributions mode enabled (true) or disabled (false)
* @property {string} [defaults.username] Username if the user is logged in,
* otherwise - undefined.
* Assigning undefined will make event logger omit this property when sending
* the data to a server. According to the schema username is optional.
* @property {number} [defaults.userEditCount] The number of edits the user has made
* if the user is logged in, otherwise - undefined. Assigning undefined will make event
* logger omit this property when sending the data to a server. According to the schema
* userEditCount is optional.
*/
{
mode: context.getMode() || 'desktop',
amc: amc,
username: user.getName() || undefined,
// FIXME: Use edit bucket here (T210106)
userEditCount: typeof editCount === 'number' ? editCount : undefined
}
);
mw.trackSubscribe( 'minerva.schemaMobileWebMainMenuClickTracking', function ( topic, data ) {
schemaMobileWebMainMenuClickTracking.log( data );
} );
} );

View File

@ -66,6 +66,7 @@
"base": false,
"beta": true
},
"MinervaSchemaMainMenuClickTrackingSampleRate": 0,
"MinervaABSamplingRate": 0
},
"ValidSkinNames": {
@ -186,7 +187,8 @@
},
"EventLoggingSchemas": {
"WebClientError": 18340282,
"MobileWebShareButton": 18923688
"MobileWebShareButton": 18923688,
"MobileWebMainMenuClickTracking": 18984528
},
"ResourceModules": {
"skins.minerva.base.styles": {
@ -481,6 +483,7 @@
"resources/skins.minerva.scripts/NotificationBadge.js",
"resources/skins.minerva.scripts/notifications.js",
"resources/skins.minerva.scripts/overlayManager.js",
"resources/skins.minerva.scripts/menu/schema.js",
"resources/skins.minerva.scripts/menu/MainMenu.js",
"resources/skins.minerva.scripts/menu.js",
"resources/skins.minerva.scripts/errorLogging.js",
@ -499,6 +502,7 @@
"resources/skins.minerva.scripts/TitleUtil.js",
"components/ToggleList/ToggleList.js",
"resources/skins.minerva.scripts/Toolbar.js",
"resources/skins.minerva.scripts/initLogging.js",
"resources/skins.minerva.scripts/mobileRedirect.js",
"resources/skins.minerva.scripts/search.js",
"resources/skins.minerva.scripts/references.js",