MinervaNeue/resources/skins.minerva.scripts/menu/schema.js
jdlrobson b356c7f134 Merge skins.minerva.scripts.top and skins.minerva.mainMenu into scripts
These modules can safely be merged.

Since skins.minerva.scripts.top is added via addModules to the HTML it must
be marked as deprecated and remain temporarily as a redirection to skins.minerva.scripts

All modules have been renamed to be in there new home - no deprecation notices are needed
as they are not used outside Minerva.

I leave skins.minerva.mainMenu.styles as it is used by Special:MobileMenu
and needs to continue to do so.

Change-Id: Ie919151630f4389f8e84e808bec003a6d3d07bd9
2019-02-07 18:10:15 -08:00

49 lines
1.9 KiB
JavaScript

/**
* This module is loaded by resources/skins.minerva.scripts/menu/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 = mw.user,
editCount = mw.config.get( 'wgUserEditCount' ),
// 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',
mw.config.get( 'wgMinervaSchemaMainMenuClickTrackingSampleRate' ),
/**
* @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.
*/
{
mode: context.getMode() || 'desktop',
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 );
} );
} );