2018-10-02 21:54:11 +00:00
|
|
|
mw.loader.using( [
|
|
|
|
'ext.eventLogging.subscriber'
|
|
|
|
] ).then( function () {
|
|
|
|
var M = mw.mobileFrontend,
|
2018-11-21 19:12:41 +00:00
|
|
|
user = mw.user,
|
|
|
|
editCount = mw.config.get( 'wgUserEditCount' ),
|
2019-04-01 15:58:09 +00:00
|
|
|
// 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 ),
|
2018-10-02 21:54:11 +00:00
|
|
|
// Schema provided by ext.eventLogging.subscriber class
|
|
|
|
Schema = mw.eventLog.Schema, // resource-modules-disable-line
|
2019-02-07 16:34:18 +00:00
|
|
|
context = M.require( 'mobile.startup' ).context,
|
2019-04-26 16:07:22 +00:00
|
|
|
DEFAULT_SAMPLING_RATE = mw.config.get( 'wgMinervaSchemaMainMenuClickTrackingSampleRate' ),
|
|
|
|
// T218627: Sampling rate should be 100% if user has amc enabled
|
|
|
|
AMC_SAMPLING_RATE = 1,
|
2018-10-02 21:54:11 +00:00
|
|
|
/**
|
|
|
|
* MobileWebMainMenuClickTracking schema
|
|
|
|
* https://meta.wikimedia.org/wiki/Schema:MobileWebMainMenuClickTracking
|
|
|
|
*
|
|
|
|
* @class MobileWebMainMenuClickTracking
|
|
|
|
* @singleton
|
|
|
|
*/
|
|
|
|
schemaMobileWebMainMenuClickTracking = new Schema(
|
|
|
|
'MobileWebMainMenuClickTracking',
|
2019-04-26 16:07:22 +00:00
|
|
|
amc ? AMC_SAMPLING_RATE : DEFAULT_SAMPLING_RATE,
|
2018-10-02 21:54:11 +00:00
|
|
|
/**
|
|
|
|
* @property {Object} defaults Default options hash.
|
2019-04-01 15:58:09 +00:00
|
|
|
* @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)
|
2018-10-02 21:54:11 +00:00
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
{
|
2018-11-26 23:42:33 +00:00
|
|
|
mode: context.getMode() || 'desktop',
|
2019-04-01 15:58:09 +00:00
|
|
|
amc: amc,
|
2018-10-02 21:54:11 +00:00
|
|
|
username: user.getName() || undefined,
|
2018-11-21 19:12:41 +00:00
|
|
|
// FIXME: Use edit bucket here (T210106)
|
|
|
|
userEditCount: typeof editCount === 'number' ? editCount : undefined
|
2018-10-02 21:54:11 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
mw.trackSubscribe( 'minerva.schemaMobileWebMainMenuClickTracking', function ( topic, data ) {
|
|
|
|
schemaMobileWebMainMenuClickTracking.log( data );
|
|
|
|
} );
|
|
|
|
} );
|