mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-15 03:34:03 +00:00
Merge "Send dwelledButAbandoned
action for links when popups are not enabled"
This commit is contained in:
commit
0071ea9fc6
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
|
|
Loading…
Reference in a new issue