Log notification impressions and clicks

This logging was taken out by accident during the split notifications
rewrite.

Bug: T114833
Change-Id: I7672c20bb12e06f3efc63763aacbe81fd0f34ece
This commit is contained in:
Moriel Schottlender 2015-10-06 14:34:51 -07:00 committed by Catrope
parent f8c68648f8
commit f9e8c5057c
2 changed files with 23 additions and 0 deletions

View file

@ -321,6 +321,9 @@
// the case where the promise is already underway.
this.populateNotifications()
.then( function () {
var i,
items = widget.notificationsWidget.getItems();
if ( widget.popup.isVisible() ) {
// Update seen time
widget.notificationsModel.updateSeenTime();
@ -328,6 +331,16 @@
if ( widget.markReadWhenSeen ) {
widget.notificationsModel.markAllRead();
}
// Log impressions
for ( i = 0; i < items.length; i++ ) {
mw.echo.logger.logInteraction(
mw.echo.Logger.static.actions.notificationImpression,
'flyout',
widget.getModel().getId(),
items[ i ].getModel().getCategory()
);
}
}
} );
this.hasRunFirstTime = true;

View file

@ -10,6 +10,7 @@
* @cfg {boolean} [markReadWhenSeen=false] This option is marked as read when it is viewed
*/
mw.echo.ui.NotificationOptionWidget = function MwEchoUiNotificationOptionWidget( model, config ) {
var widget = this;
config = config || {};
this.model = model;
@ -53,6 +54,15 @@
this.markAsReadButton.$element,
this.$label
)
.on( 'click', function () {
// Log notification click
mw.echo.logger.logInteraction(
mw.echo.Logger.static.actions.notificationClick,
'flyout',
widget.getModel().getId(),
widget.getModel().getCategory()
);
} )
);
this.$element.toggleClass( 'mw-echo-ui-notificationOptionWidget-initiallyUnseen', !this.model.isSeen() );