Merge "Send dwelledButAbandoned action for links when popups are not enabled"

This commit is contained in:
jenkins-bot 2016-05-26 12:31:02 +00:00 committed by Gerrit Code Review
commit 0071ea9fc6
2 changed files with 36 additions and 26 deletions

View file

@ -13,8 +13,9 @@
popupEnabled: mw.popups.getEnabledState(),
popupDelay: mw.popups.render.POPUP_DELAY,
pageToken: mw.user.generateRandomSessionId() +
Math.floor( mw.now() ).toString() +
mw.user.generateRandomSessionId(),
Math.floor( mw.now() ).toString() +
mw.user.generateRandomSessionId(),
sessionToken: mw.user.sessionId(),
// arbitrary name that represents the current UI of the popups
version: 'legacy',
// current API version
@ -26,8 +27,6 @@
defaults.editCountBucket = mw.popups.schemaPopups.getEditCountBucket(
mw.config.get( 'wgUserEditCount' ) );
}
// Also add the session token
defaults.sessionToken = mw.user.sessionId();
return defaults;
}

View file

@ -101,32 +101,43 @@
mw.popups.removeTooltips( $elements );
mw.popups.setupTriggers( $elements );
} else {
$elements.on( mw.popups.triggers, function () {
// cache the hover start time and link interaction token for a later use
dwellStartTime = mw.now();
linkInteractionToken = mw.popups.getRandomToken();
} );
// Events are logged even when Hovercards are disabled
// See T88166 for details
$elements.on( 'click', function ( event ) {
var $this = $( this ),
action = mw.popups.getAction( event ),
href = $this.attr( 'href' );
$elements
.on( mw.popups.triggers, function () {
// cache the hover start time and link interaction token for a later use
dwellStartTime = mw.now();
linkInteractionToken = mw.popups.getRandomToken();
} )
.on( 'mouseleave blur', function () {
var $this = $( this );
mw.track( 'ext.popups.schemaPopups', {
pageTitleHover: $this.attr( 'title' ),
action: action,
totalInteractionTime: Math.round( mw.now() - dwellStartTime ),
linkInteractionToken: linkInteractionToken
if ( dwellStartTime && linkInteractionToken && mw.now() - dwellStartTime >= 250 ) {
mw.track( 'ext.popups.schemaPopups', {
pageTitleHover: $this.attr( 'title' ),
action: 'dwelledButAbandoned',
totalInteractionTime: Math.round( mw.now() - dwellStartTime ),
linkInteractionToken: linkInteractionToken
} );
}
} )
.on( 'click', function ( event ) {
var $this = $( this ),
action = mw.popups.getAction( event ),
href = $this.attr( 'href' );
mw.track( 'ext.popups.schemaPopups', {
pageTitleHover: $this.attr( 'title' ),
action: action,
totalInteractionTime: Math.round( mw.now() - dwellStartTime ),
linkInteractionToken: linkInteractionToken
} );
if ( action === 'opened in same tab' ) {
event.preventDefault();
window.location.href = href;
}
} );
if ( action === 'opened in same tab' ) {
event.preventDefault();
window.location.href = href;
}
} );
}
} );