jenkins-bot has submitted this change and it was merged.
Change subject: Send `dwelledButAbandoned` action for links when popups are not
enabled
......................................................................
Send `dwelledButAbandoned` action for links when popups are not enabled
This action was sent correctly when popups are enabled, but not when
disabled. This commit sends this event also when popups are disabled
so that we are able to compare the metric with popups enabled vs disabled.
Additional changes:
* Chain events in resources/ext.popups.targets/desktopTarget.js
* Add a separate property to the list of defaults and fix formatting.
Bug: T131315
Change-Id: I426f0a1a735b8fe6b16f3d2695d9099dd0d0469b
---
M resources/ext.popups.schemaPopups.utils.js
M resources/ext.popups.targets/desktopTarget.js
2 files changed, 36 insertions(+), 26 deletions(-)
Approvals:
Jhernandez: Looks good to me, approved
Jdlrobson: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/resources/ext.popups.schemaPopups.utils.js
b/resources/ext.popups.schemaPopups.utils.js
index 11a7796..faf10ed 100644
--- a/resources/ext.popups.schemaPopups.utils.js
+++ b/resources/ext.popups.schemaPopups.utils.js
@@ -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;
}
diff --git a/resources/ext.popups.targets/desktopTarget.js
b/resources/ext.popups.targets/desktopTarget.js
index a34e151..f68b17d 100644
--- a/resources/ext.popups.targets/desktopTarget.js
+++ b/resources/ext.popups.targets/desktopTarget.js
@@ -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;
- }
- } );
}
} );
--
To view, visit https://gerrit.wikimedia.org/r/290749
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I426f0a1a735b8fe6b16f3d2695d9099dd0d0469b
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits