Mooeypoo has uploaded a new change for review.

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

Change subject: Log cross-wiki & bundle items impressions and add their source 
wiki
......................................................................

Log cross-wiki & bundle items impressions and add their source wiki

Bug: T120158
Change-Id: Ibcd1923aaff4e1fd6fb1f54eefbc010122caa398
---
M modules/ooui/mw.echo.ui.NotificationGroupItemWidget.js
M modules/ooui/mw.echo.ui.NotificationItemWidget.js
M modules/viewmodel/mw.echo.dm.NotificationGroupItem.js
M modules/viewmodel/mw.echo.dm.NotificationItem.js
M modules/viewmodel/mw.echo.dm.NotificationsModel.js
5 files changed, 54 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/76/260776/1

diff --git a/modules/ooui/mw.echo.ui.NotificationGroupItemWidget.js 
b/modules/ooui/mw.echo.ui.NotificationGroupItemWidget.js
index 63ace57..716841d 100644
--- a/modules/ooui/mw.echo.ui.NotificationGroupItemWidget.js
+++ b/modules/ooui/mw.echo.ui.NotificationGroupItemWidget.js
@@ -126,7 +126,27 @@
                        // Query all sources
                        this.model.fetchAllNotificationsInGroups()
                                .then( function ( /* Groups */ ) {
+                                       var source, items, i,
+                                               models = 
widget.model.getSubModels();
+
                                        widget.popPending();
+
+                                       // Log impressions of all items from 
each group
+                                       for ( source in models ) {
+                                               items = 
models[source].getItems();
+                                               for ( i = 0; i < items.length; 
i++ ) {
+                                                       if ( items[ i 
].getModel ) {
+                                                               
mw.echo.logger.logInteraction(
+                                                                       
mw.echo.Logger.static.actions.notificationImpression,
+                                                                       
mw.echo.Logger.static.context.popup,
+                                                                       items[ 
i ].getModel().getId(),
+                                                                       items[ 
i ].getModel().getCategory(),
+                                                                       false,
+                                                                       source
+                                                               );
+                                                       }
+                                               }
+                                       }
                                } );
                }
        };
diff --git a/modules/ooui/mw.echo.ui.NotificationItemWidget.js 
b/modules/ooui/mw.echo.ui.NotificationItemWidget.js
index 7ec907e..25caba0 100644
--- a/modules/ooui/mw.echo.ui.NotificationItemWidget.js
+++ b/modules/ooui/mw.echo.ui.NotificationItemWidget.js
@@ -166,7 +166,10 @@
                                                                
mw.echo.Logger.static.actions.notificationClick,
                                                                
mw.echo.Logger.static.context.popup,
                                                                
widget.getModel().getId(),
-                                                               
widget.getModel().getCategory()
+                                                               
widget.getModel().getCategory(),
+                                                               false,
+                                                               // Source of 
this notification if it is cross-wiki
+                                                               widget.bundle ? 
widget.getModel().getSource() : ''
                                                        );
                                                } )
                                );
diff --git a/modules/viewmodel/mw.echo.dm.NotificationGroupItem.js 
b/modules/viewmodel/mw.echo.dm.NotificationGroupItem.js
index a4c30f0..f774c80 100644
--- a/modules/viewmodel/mw.echo.dm.NotificationGroupItem.js
+++ b/modules/viewmodel/mw.echo.dm.NotificationGroupItem.js
@@ -180,4 +180,23 @@
                return this.count;
        };
 
+       /**
+        * Get the array of sources for this group
+        *
+        * @return {string[]} Sources
+        */
+       mw.echo.dm.NotificationGroupItem.prototype.getSources = function () {
+               return this.sources;
+       };
+
+       /**
+        * Get all the sub-notification models for this group
+        *
+        * @return {Object} A keyed object containing 
mw.echo.dm.NotificationModel
+        *  objects keyed by their source name.
+        */
+       mw.echo.dm.NotificationGroupItem.prototype.getSubModels = function () {
+               return this.notifModels;
+       };
+
 } )( mediaWiki );
diff --git a/modules/viewmodel/mw.echo.dm.NotificationItem.js 
b/modules/viewmodel/mw.echo.dm.NotificationItem.js
index 60ea573..7a63cf4 100644
--- a/modules/viewmodel/mw.echo.dm.NotificationItem.js
+++ b/modules/viewmodel/mw.echo.dm.NotificationItem.js
@@ -55,6 +55,7 @@
                this.category = config.category || '';
                this.type = config.type || 'alert';
                this.external = !!config.external;
+               this.source = config.source || '';
                this.iconType = config.iconType;
                this.iconURL = config.iconURL;
 
@@ -253,4 +254,13 @@
        mw.echo.dm.NotificationItem.prototype.getSecondaryUrls = function () {
                return this.secondaryUrls;
        };
+
+       /**
+        * Get the notification's source
+        *
+        * @return {string} Notification source
+        */
+       mw.echo.dm.NotificationItem.prototype.getSource = function () {
+               return this.source;
+       };
 }( mediaWiki, jQuery ) );
diff --git a/modules/viewmodel/mw.echo.dm.NotificationsModel.js 
b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
index 870c522..c241a4d 100644
--- a/modules/viewmodel/mw.echo.dm.NotificationsModel.js
+++ b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
@@ -442,6 +442,7 @@
                                                                iconType: 
content.icon,
                                                                type: 
model.getType(),
                                                                external: 
model.isExternal(),
+                                                               source: 
model.getSource(),
                                                                primaryUrl: 
OO.getProp( content.links, 'primary', 'url' ),
                                                                secondaryUrls: 
OO.getProp( content.links, 'secondary' ) || []
                                                        };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibcd1923aaff4e1fd6fb1f54eefbc010122caa398
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>

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

Reply via email to