Prtksxna has uploaded a new change for review.

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

Change subject: [WIP] Add EventLogging [WIP]
......................................................................

[WIP] Add EventLogging [WIP]

Schema: https://meta.wikimedia.org/wiki/Schema:Popups

Change-Id: Id17e81794561f022e004e18cf3595c3ffd6f3fd0
---
M Popups.hooks.php
M Popups.php
M resources/ext.popups.core.js
3 files changed, 25 insertions(+), 1 deletion(-)


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

diff --git a/Popups.hooks.php b/Popups.hooks.php
index 07e62cb..0bd8e8d 100644
--- a/Popups.hooks.php
+++ b/Popups.hooks.php
@@ -40,6 +40,7 @@
                        && class_exists( 'ApiQueryPageImages' )
                ) {
                        $out->addModules( array( 'ext.popups' ) );
+                       $out->addModules( array( 'schema.Popups' ) );
                }
        }
 }
diff --git a/Popups.php b/Popups.php
index 3faafaa..2ff3831 100644
--- a/Popups.php
+++ b/Popups.php
@@ -34,7 +34,7 @@
 $remoteExtPath = 'Popups';
 
 $wgResourceModules = array_merge( $wgResourceModules, array(
-       "ext.popups" => array(
+       'ext.popups' => array(
                'scripts' => 'resources/ext.popups.core.js',
                'styles' => array(
                        'resources/ext.popups.core.less',
@@ -46,8 +46,15 @@
                'remoteExtPath' => $remoteExtPath,
                'localBasePath' => $localBasePath,
        ),
+
+       'schema.Popups' => array(
+               'class'  => 'ResourceLoaderSchemaModule',
+               'schema' => 'Popups',
+               'revision' => 7446823,
+       ),
 ) );
 
+
 $wgAutoloadClasses['PopupsHooks'] = __DIR__ . '/Popups.hooks.php';
 $wgExtensionMessagesFiles['Popups'] = __DIR__ . '/Popups.i18n.php';
 
diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index 8b8c91a..e74d7c2 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -9,6 +9,8 @@
 
                var closeTimer, // The timer use to delay `closeBox`
                        openTimer, // The timer used to delay sending the API 
request/opening the popup form cache
+                       elTime, // EL: UNIX timestamp of when the popup was 
rendered
+                       elDuration, // EL: How long was the popup open in 
milliseconds
                        currentLink, // DOM element of the current anchor tag
                        cache = {},
                        curRequest, // Current API request
@@ -91,6 +93,7 @@
                        var bar = cache[ href ],
                                offsetTop = $el.offset().top + $el.height() + 5,
                                offsetLeft = $el.offset().left;
+                       elTime = +new Date();
                        $box
                                .children()
                                .detach()
@@ -141,6 +144,9 @@
                 * `currentLink` to undefined.
                 */
                function closeBox () {
+                       var now = +new Date();
+                       elDuration = now - elTime;
+
                        $( currentLink ).removeClass( 'mwe-popups-anchor-hover' 
).off( 'mouseleave', leaveActive );
 
                        $box
@@ -158,9 +164,19 @@
                        if ( closeTimer ){
                                clearTimeout( closeTimer );
                        }
+
+                       logEvent();
                        currentLink = closeTimer = undefined;
                }
 
+               function logEvent () {
+                       mw.eventLog.logEvent( 'Popups', {
+                               "page": mw.config.get( 'wgTitle' ),
+                               "duration": elDuration,
+                               "wasClicked": false
+                       } );
+               }
+
                // Remove title attribute to remove the default yellow tooltip
                // Put the title back after the hover
                $( '#mw-content-text a' )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id17e81794561f022e004e18cf3595c3ffd6f3fd0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to