Bsitu has uploaded a new change for review.
https://gerrit.wikimedia.org/r/67147
Change subject: Add clickthrough eventlogging to Echo
......................................................................
Add clickthrough eventlogging to Echo
Change-Id: I3d05d1aeca92f9a0265a522cc5027ae18394c5b4
---
M Echo.php
M Hooks.php
M modules/base/ext.echo.base.js
M modules/overlay/ext.echo.overlay.js
M modules/special/ext.echo.special.js
M special/SpecialNotifications.php
6 files changed, 125 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/47/67147/1
diff --git a/Echo.php b/Echo.php
index 7679b16..50c5aaf 100644
--- a/Echo.php
+++ b/Echo.php
@@ -515,7 +515,7 @@
// Echo Configuration for EventLogging
$wgEchoConfig = array(
- 'version' => '1.3',
+ 'version' => '1.4',
// default all eventlogging off, overwrite them in site configuration
'eventlogging' => array (
'Echo' => array (
@@ -530,5 +530,9 @@
'enabled' => false,
'revision' => 5488876
),
+ 'EchoInteraction' => array (
+ 'enabled' => false,
+ 'revision' => 5539940
+ ),
)
);
diff --git a/Hooks.php b/Hooks.php
index 2c3b76d..1aa1fa0 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -670,7 +670,7 @@
* @return bool true in all cases
*/
public static function makeGlobalVariablesScript( &$vars, OutputPage
$outputPage ) {
- global $wgEchoHelpPage, $wgEchoMaxNotificationCount;
+ global $wgEchoHelpPage, $wgEchoMaxNotificationCount,
$wgEchoConfig;
$user = $outputPage->getUser();
// Provide info for the Overlay
@@ -682,6 +682,7 @@
'max-notification-count' =>
$wgEchoMaxNotificationCount,
);
$vars['wgEchoHelpPage'] = $wgEchoHelpPage;
+ $vars['wgEchoConfig'] = $wgEchoConfig;
}
return true;
diff --git a/modules/base/ext.echo.base.js b/modules/base/ext.echo.base.js
index bda5b40..d8f4d61 100644
--- a/modules/base/ext.echo.base.js
+++ b/modules/base/ext.echo.base.js
@@ -8,6 +8,74 @@
'dismissOutputFormats': ['web', 'email'],
+ 'version': mw.config.get( 'wgEchoConfig' ).version,
+
+ 'eventlogging': mw.config.get( 'wgEchoConfig' ).eventlogging,
+
+ /**
+ * Set up event logging for individual notification
+ * @param {JQuery} notification JQuery representing a single
notification
+ * @param {string} context 'flyout'/'archive'
+ */
+ 'setupNotificationLogging': function ( notification, context ) {
+ var _this = this;
+
+ // Check if Schema:EchoInteraction is enabled
+ if ( !this.eventlogging.EchoInteraction.enabled ) {
+ return;
+ }
+ // Log the impression
+ this.logEchoInteraction(
+ 'notification-impression',
+ context,
+ notification.attr( 'data-notification-event' ),
+ notification.attr( 'data-notification-type' )
+ );
+ // Set up logging for clickthrough
+ notification.find( 'a' ).click( function() {
+ _this.logEchoInteraction(
+ 'notification-link-click',
+ context,
+ notification.attr(
'data-notification-event' ),
+ notification.attr(
'data-notification-type' )
+ );
+ } );
+ },
+
+ /**
+ * Log all Echo interaction related events
+ * @param {string} action The interaction
+ * @param {string} context 'flyout'/'archive' or undefined for
the badge
+ * @param {int} eventId Notification event id
+ * @param {string} type notification type
+ */
+ 'logEchoInteraction': function( action, context, eventId, type
) {
+ // Check if Schema:EchoInteraction is enabled
+ if ( !this.eventlogging.EchoInteraction.enabled ) {
+ return;
+ }
+
+ var data = {
+ version: this.version,
+ action: action,
+ userId: parseInt( mw.config.get( 'wgUserId' ) ),
+ editCount: parseInt( mw.config.get(
'wgUserEditCount' ) )
+ };
+
+ // All the three fields below are optional
+ if ( context ) {
+ data.context = context;
+ }
+ if ( eventId ) {
+ data.eventId = parseInt( eventId );
+ }
+ if ( type ) {
+ data.notificationType = type;
+ }
+
+ mw.eventLog.logEvent( 'EchoInteraction', data );
+ },
+
/**
* Change the user's preferences related to this notification
type and
* reload the page.
diff --git a/modules/overlay/ext.echo.overlay.js
b/modules/overlay/ext.echo.overlay.js
index f823d3b..19d1050 100644
--- a/modules/overlay/ext.echo.overlay.js
+++ b/modules/overlay/ext.echo.overlay.js
@@ -62,9 +62,13 @@
.data(
'details', data )
.data( 'id', id
)
.attr(
'data-notification-category', data.category )
+ .attr(
'data-notification-event', data.id )
+ .attr(
'data-notification-type', data.type )
.addClass(
'mw-echo-notification' )
.append(
data['*'] )
.appendTo( $ul
);
+
+
mw.echo.setupNotificationLogging( $li, 'flyout' );
if ( !data.read ) {
$li.addClass(
'mw-echo-unread' );
@@ -145,6 +149,11 @@
.attr( 'title', mw.msg(
'echo-more-info' ) )
.attr( 'id',
'mw-echo-overlay-moreinfo-link' )
.attr( 'target', '_blank' )
+ .click(
+ function() {
+
mw.echo.logEchoInteraction( 'ui-help-click', 'flyout' );
+ }
+ )
.appendTo( $title );
// Insert the title area into the
overlay
@@ -163,6 +172,11 @@
.attr( 'id',
'mw-echo-overlay-link' )
.attr( 'href',
mw.util.wikiGetlink( 'Special:Notifications' ) )
.text( mw.msg(
'echo-overlay-link' ) )
+ .click(
+ function() {
+
mw.echo.logEchoInteraction( 'ui-archive-link-click', 'flyout' );
+ }
+ )
);
// add link to notification preferences
@@ -171,6 +185,11 @@
.clone()
.attr( 'id',
'mw-echo-overlay-pref-link' )
.attr( 'href',
$prefLink.attr( 'href' ) + '#mw-prefsection-echo' )
+ .click(
+ function() {
+
mw.echo.logEchoInteraction( 'ui-prefs-click', 'flyout' );
+ }
+ )
);
$overlay.append( $overlayFooter );
@@ -211,6 +230,10 @@
var $target, $overlay;
e.preventDefault();
+
+ // log the badge click
+ mw.echo.logEchoInteraction( 'ui-badge-link-click' );
+
$target = $( e.target );
// If the user clicked on the overlay or any child,
// ignore the click
diff --git a/modules/special/ext.echo.special.js
b/modules/special/ext.echo.special.js
index 7388aa7..cba1d34 100644
--- a/modules/special/ext.echo.special.js
+++ b/modules/special/ext.echo.special.js
@@ -29,9 +29,10 @@
_this.notcontinue = mw.config.get( 'wgEchoNextContinue'
);
_this.header = mw.config.get( 'wgEchoDateHeader' );
- // Set up each individual notification with a close box
and dismiss
- // interface if it is dismissable.
+ // Set up each individual notification with
eventlogging, a close
+ // box and dismiss interface if it is dismissable.
$( '.mw-echo-notification' ).each( function() {
+ mw.echo.setupNotificationLogging( $( this ),
'archive' );
if ( $( this ).find( '.mw-echo-dismiss'
).length ) {
mw.echo.setUpDismissability( this );
}
@@ -42,9 +43,19 @@
.attr( 'title', mw.msg( 'echo-more-info' ) )
.attr( 'id', 'mw-echo-moreinfo-link' )
.attr( 'target', '_blank' )
+ .click(
+ function() {
+ mw.echo.logEchoInteraction(
'ui-help-click', 'archive' );
+ }
+ )
.appendTo( $( '#firstHeading' ) );
$( '#mw-echo-pref-link' )
+ .click(
+ function() {
+ mw.echo.logEchoInteraction(
'ui-prefs-click', 'archive' );
+ }
+ )
.appendTo( $( '#firstHeading' ) );
$( '<span/>' )
@@ -97,6 +108,8 @@
.data( 'id', id
)
.addClass(
'mw-echo-notification' )
.attr(
'data-notification-category', data.category )
+ .attr(
'data-notification-event', data.id )
+ .attr(
'data-notification-type', data.type )
.append(
data['*'] )
.appendTo(
container );
@@ -105,6 +118,8 @@
unread.push( id
);
}
+
mw.echo.setupNotificationLogging( $li, 'archive' );
+
if ( $li.find(
'.mw-echo-dismiss' ).length ) {
mw.echo.setUpDismissability( $li );
}
diff --git a/special/SpecialNotifications.php b/special/SpecialNotifications.php
index e74c448..f9f664f 100644
--- a/special/SpecialNotifications.php
+++ b/special/SpecialNotifications.php
@@ -71,7 +71,16 @@
$class .= ' mw-echo-unread';
$unread[] = $row['id'];
}
- $notices .= Html::rawElement( 'li', array( 'class' =>
$class, 'data-notification-category' => $row['category'] ), $row['*'] );
+ $notices .= Html::rawElement(
+ 'li',
+ array(
+ 'class' => $class,
+ 'data-notification-category' =>
$row['category'],
+ 'data-notification-event' => $row['id'],
+ 'data-notification-type' => $row['type']
+ ),
+ $row['*']
+ );
}
$html .= Html::rawElement( 'ul', array( 'id' =>
'mw-echo-special-container' ), $notices );
--
To view, visit https://gerrit.wikimedia.org/r/67147
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d05d1aeca92f9a0265a522cc5027ae18394c5b4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits