mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-01 09:16:34 +00:00
33a7484676
Additional changes: * Rename hook prefix from 'mf.' to 'minerva.' * Remove now unnecessary RL call Bug: T204584 Change-Id: I50619e71c5a98e95c8aed3c3f346d4cb8a70abbe
48 lines
2 KiB
JavaScript
48 lines
2 KiB
JavaScript
/**
|
|
* This module is loaded by resources/skins.minerva.mainMenu/MainMenu.js
|
|
* inside the Minerva skin. It should be moved to Minerva at our earliest possible
|
|
* convenience.
|
|
*/
|
|
mw.loader.using( [
|
|
'ext.eventLogging.subscriber'
|
|
] ).then( function () {
|
|
var M = mw.mobileFrontend,
|
|
user = M.require( 'mobile.startup/user' ),
|
|
// Schema provided by ext.eventLogging.subscriber class
|
|
Schema = mw.eventLog.Schema, // resource-modules-disable-line
|
|
context = M.require( 'mobile.startup/context' ),
|
|
/**
|
|
* MobileWebMainMenuClickTracking schema
|
|
* https://meta.wikimedia.org/wiki/Schema:MobileWebMainMenuClickTracking
|
|
*
|
|
* @class MobileWebMainMenuClickTracking
|
|
* @singleton
|
|
*/
|
|
schemaMobileWebMainMenuClickTracking = new Schema(
|
|
'MobileWebMainMenuClickTracking',
|
|
// todo: use a default value of 0 once config lands in production (T205008).
|
|
mw.config.get( 'wgMinervaSchemaMainMenuClickTrackingSampleRate', 0.5 ),
|
|
/**
|
|
* @property {Object} defaults Default options hash.
|
|
* @property {string} defaults.mobileMode whether user is in stable or beta
|
|
* @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.
|
|
*/
|
|
{
|
|
mobileMode: context.getMode(),
|
|
username: user.getName() || undefined,
|
|
userEditCount: typeof user.getEditCount() === 'number' ? user.getEditCount() : undefined
|
|
}
|
|
);
|
|
|
|
mw.trackSubscribe( 'minerva.schemaMobileWebMainMenuClickTracking', function ( topic, data ) {
|
|
schemaMobileWebMainMenuClickTracking.log( data );
|
|
} );
|
|
} );
|