[MediaWiki-commits] [Gerrit] mediawiki...Popups[master]: Event and hover events are logged but not recorded

2016-10-24 Thread Jdlrobson (Code Review)
Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/317713

Change subject: Event and hover events are logged but not recorded
..

Event 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 debut trackSubscribe and ensure we see the behaviour
we expect to see.

Change-Id: I58eefc29444179fd245cfd722093dedea19455e8
---
M resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js
M resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js
M resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
M resources/ext.popups.targets.desktopTarget/desktopTarget.js
M tests/qunit/ext.popups.schemaPopups.utils.test.js
5 files changed, 28 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/13/317713/1

diff --git a/resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js 
b/resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js
index 06604cd..ef1c280 100644
--- a/resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js
+++ b/resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js
@@ -222,6 +222,10 @@
namespaceIdHover: cache.settings.namespace,
perceivedWait: Math.round( mw.now() - 
logData.dwellStartTime )
} );
+   mw.track( 'ext.popups.schemaPopups', $.extend( {}, logData, {
+   action: 'displayed'
+   } )
+   );
 
cache.process( link, $.extend( {}, logData ) );
 
diff --git 
a/resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js 
b/resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js
index 7c9c9da..7487365 100644
--- a/resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js
+++ b/resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js
@@ -93,14 +93,19 @@
 * @return {Object}
 */
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;
 
// 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' ) {
+   if ( action !== 'disabled' ) {
return false;
}
+   } else if ( action && [ 'hover', 'display' ].indexOf( action ) 
> -1 ) {
+   return false;
}
data.previewCountBucket = mw.popups.getPreviewCountBucket();
delete data.dwellStartTime;
diff --git a/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js 
b/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
index c419660..a78db75 100644
--- a/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
+++ b/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
@@ -9,8 +9,6 @@
);
 
mw.trackSubscribe( 'ext.popups.event', function ( topic, data ) {
-   var shouldLog = true;
-
data = mw.popups.schemaPopups.getMassagedData( data, 
previousLogData );
 
if ( data ) {
diff --git a/resources/ext.popups.targets.desktopTarget/desktopTarget.js 
b/resources/ext.popups.targets.desktopTarget/desktopTarget.js
index 4b47d46..b7a6386 100644
--- a/resources/ext.popups.targets.desktopTarget/desktopTarget.js
+++ b/resources/ext.popups.targets.desktopTarget/desktopTarget.js
@@ -46,6 +46,10 @@
hovercardsSuppressedByGadget: 
isNavigationPopupsGadgetEnabled()
};
 
+   mw.track( 'ext.popups.schemaPopups', $.extend( {}, eventData, {
+   action: 'hover'
+   } )
+   );
// Only enable Popups when the Navigation popups gadget is not 
enabled
if ( !eventData.hovercardsSuppressedByGadget && 
mw.popups.enabled ) {
if ( mw.popups.scrolled ) {
diff --git a/tests/qunit/ext.popups.schemaPopups.utils.test.js 
b/tests/qunit/ext.popups.schemaPopups.utils.test.js
index 9a6b7d7..1ec7549 100644
--- a/tests/qunit/ext.popups.schemaPopups.utils.test.js
+++ b/tests/qunit/ext.popups.schemaPopups.utils.test.js
@@ -145,4 +145,17 @@

[MediaWiki-commits] [Gerrit] mediawiki...Popups[master]: Event and hover events are logged but not recorded

2016-10-17 Thread Jdlrobson (Code Review)
Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316479

Change subject: Event and hover events are logged but not recorded
..

Event 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 debut trackSubscribe and ensure we see the behaviour
we expect to see.

Change-Id: I1a025d0ba56ed2b017e25a29b232810fd884d927
---
M resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js
M resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
M resources/ext.popups.targets.desktopTarget/desktopTarget.js
3 files changed, 17 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/79/316479/1

diff --git a/resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js 
b/resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js
index 54aa0d2..e6bf16e 100644
--- a/resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js
+++ b/resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js
@@ -230,6 +230,10 @@
namespaceIdHover: cache.settings.namespace,
perceivedWait: Math.round( mw.now() - 
logData.dwellStartTime )
} );
+   mw.track( 'ext.popups.schemaPopups', $.extend( {}, logData, {
+   action: 'displayed'
+   } )
+   );
 
cache.process( link, $.extend( {}, logData ) );
 
diff --git a/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js 
b/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
index afe31b3..4e2215b 100644
--- a/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
+++ b/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
@@ -9,15 +9,21 @@
);
 
mw.trackSubscribe( 'ext.popups.schemaPopups', function ( topic, data ) {
-   var shouldLog = true;
+   // 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,
+   shouldLog = action && [ 'hover', 'display' ].indexOf( 
action ) === -1;
 
-   data = mw.popups.schemaPopups.getMassagedData( data );
+   // since this method has side effects only restrict to it to 
the things we actually want
+   if ( shouldLog ) {
+   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' ) {
+   if ( action !== 'disabled' ) {
shouldLog = false;
}
}
diff --git a/resources/ext.popups.targets.desktopTarget/desktopTarget.js 
b/resources/ext.popups.targets.desktopTarget/desktopTarget.js
index f8cb7cd..6ab7258 100644
--- a/resources/ext.popups.targets.desktopTarget/desktopTarget.js
+++ b/resources/ext.popups.targets.desktopTarget/desktopTarget.js
@@ -48,6 +48,10 @@
hovercardsSuppressedByGadget: 
isNavigationPopupsGadgetEnabled()
};
 
+   mw.track( 'ext.popups.schemaPopups', $.extend( {}, eventData, {
+   action: 'hover'
+   } )
+   );
// Only enable Popups when the Navigation popups gadget is not 
enabled
if ( !eventData.hovercardsSuppressedByGadget && 
mw.popups.enabled ) {
if ( mw.popups.scrolled ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/316479
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a025d0ba56ed2b017e25a29b232810fd884d927
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits