mediawiki-extensions-Popups/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
jdlrobson 1f010664ef Hygiene: Rename track topic to be more consistent with new plans
I plan to track events that will not be logged by the schema so
am dropping the 'schema' from the topic name.

This will allow us to track events that we do not log via the schema

Change-Id: I0c2762f7ed6e54fff765513b2c2d32f73fe8902f
2016-10-25 20:00:18 +01:00

31 lines
880 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.event', 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 );