Display and hover events are logged but not recorded

This adds two new events "display" and "hover" which are not
recorded back to the server. The benefits of having these events
is that they are important events in the lifecycle of a hovercard.

This allows us to debug trackSubscribe and ensure we see the behaviour
we expect to see and in a future patchset will allow us to use these
events to drive the calculation of interaction time in one single location
(Sneak preview:
 https://gerrit.wikimedia.org/r/316481 to get a feel for the why.)

Change-Id: I58eefc29444179fd245cfd722093dedea19455e8
This commit is contained in:
jdlrobson 2016-10-17 13:52:08 -07:00 committed by Bmansurov
parent c4460ba2ea
commit 47c2df09d4
4 changed files with 30 additions and 2 deletions

View file

@ -222,6 +222,10 @@
namespaceIdHover: cache.settings.namespace, namespaceIdHover: cache.settings.namespace,
perceivedWait: Math.round( mw.now() - logData.dwellStartTime ) perceivedWait: Math.round( mw.now() - logData.dwellStartTime )
} ); } );
mw.track( 'ext.popups.schemaPopups', $.extend( {}, logData, {
action: 'display'
} )
);
cache.process( link, $.extend( {}, logData ) ); cache.process( link, $.extend( {}, logData ) );

View file

@ -94,12 +94,17 @@
* @return {Object|boolean} * @return {Object|boolean}
*/ */
function getMassagedData( data, previousLogData ) { function getMassagedData( data, previousLogData ) {
// We don't log hover and display events as they are not compatible with the schema
// but they are useful for debugging
var action = data.action;
if ( action && [ 'hover', 'display' ].indexOf( action ) > -1 ) {
return false;
// Only one action is recorded per link interaction token... // Only one action is recorded per link interaction token...
if ( data.linkInteractionToken && } else if ( data.linkInteractionToken &&
data.linkInteractionToken === previousLogData.linkInteractionToken ) { data.linkInteractionToken === previousLogData.linkInteractionToken ) {
// however, the 'disabled' action takes two clicks by nature, so allow it // however, the 'disabled' action takes two clicks by nature, so allow it
if ( data.action !== 'disabled' ) { if ( action !== 'disabled' ) {
return false; return false;
} }
} }

View file

@ -46,6 +46,10 @@
hovercardsSuppressedByGadget: isNavigationPopupsGadgetEnabled() hovercardsSuppressedByGadget: isNavigationPopupsGadgetEnabled()
}; };
mw.track( 'ext.popups.schemaPopups', $.extend( {}, eventData, {
action: 'hover'
} )
);
// Only enable Popups when the Navigation popups gadget is not enabled // Only enable Popups when the Navigation popups gadget is not enabled
if ( !eventData.hovercardsSuppressedByGadget && mw.popups.enabled ) { if ( !eventData.hovercardsSuppressedByGadget && mw.popups.enabled ) {
if ( mw.popups.scrolled ) { if ( mw.popups.scrolled ) {

View file

@ -147,4 +147,19 @@
assert.ok( schemaPopups.getMassagedData( settingsEvent, thisEvent ) !== false, '... unless disabled event' ); assert.ok( schemaPopups.getMassagedData( settingsEvent, thisEvent ) !== false, '... unless disabled event' );
assert.ok( thisEvent.dwellStartTime === 1, 'and no side effects' ); assert.ok( thisEvent.dwellStartTime === 1, 'and no side effects' );
} ); } );
QUnit.test( 'getMassagedData - returns false for hover and display events', 2, function ( assert ) {
var
hoverEvent = {
action: 'hover'
},
displayEvent = {
action: 'display',
linkInteractionToken: 't'
};
assert.ok( schemaPopups.getMassagedData( hoverEvent ) === false );
assert.ok( schemaPopups.getMassagedData( displayEvent ) === false );
} );
} )( jQuery, mediaWiki ); } )( jQuery, mediaWiki );