mediawiki-extensions-Popups/resources/ext.popups.schemaPopups.js
Baha aba43fd560 Switch to Schema:Popups revid 15597282
Bug: T131315
Change-Id: I2ed18e00afb3e355327b417e68e5930b46d49086
2016-05-24 14:26:46 -07:00

31 lines
887 B
JavaScript

( function ( $, mw ) {
var previousLogData,
// Log the popup event as defined in the schema
// https://meta.wikimedia.org/wiki/Schema:Popups
schemaPopups = new mw.eventLog.Schema(
'Popups',
mw.popups.schemaPopups.getSamplingRate(),
mw.popups.schemaPopups.getDefaultValues()
);
mw.trackSubscribe( 'ext.popups.schemaPopups', function ( topic, data ) {
var shouldLog = true;
data = mw.popups.schemaPopups.getMassagedData( data );
// Only one action is recorded per link interaction token...
if ( data.linkInteractionToken &&
data.linkInteractionToken === previousLogData.linkInteractionToken ) {
// however, the 'disabled' action takes two clicks by nature, so allow it
if ( data.action !== 'disabled' ) {
shouldLog = false;
}
}
if ( shouldLog ) {
schemaPopups.log( data );
}
previousLogData = data;
} );
} )( jQuery, mediaWiki );