jenkins-bot has submitted this change and it was merged.
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, 57 insertions(+), 3 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ooui/mw.echo.ui.NotificationGroupItemWidget.js
b/modules/ooui/mw.echo.ui.NotificationGroupItemWidget.js
index 63ace57..12d120b 100644
--- a/modules/ooui/mw.echo.ui.NotificationGroupItemWidget.js
+++ b/modules/ooui/mw.echo.ui.NotificationGroupItemWidget.js
@@ -126,7 +126,25 @@
// 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++ ) {
+
mw.echo.logger.logInteraction(
+
mw.echo.Logger.static.actions.notificationImpression,
+
mw.echo.Logger.static.context.popup,
+ items[ i
].getId(),
+ items[ i
].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..d6f7373 100644
--- a/modules/viewmodel/mw.echo.dm.NotificationGroupItem.js
+++ b/modules/viewmodel/mw.echo.dm.NotificationGroupItem.js
@@ -114,6 +114,7 @@
mw.echo.dm.NotificationGroupItem.prototype.fetchAllNotificationsInGroups =
function () {
var notifModel,
model = this,
+ fetchPromises = [],
sourceKeys = Object.keys( this.sources );
return this.networkHandler.fetchNotificationGroups( sourceKeys )
@@ -123,11 +124,12 @@
for ( i = 0; i < sourceKeys.length; i++ ) {
notifModel = model.getItemById(
sourceKeys[ i ] );
if ( notifModel ) {
- notifModel.fetchNotifications(
promises[ i ] );
+ fetchPromises.push(
notifModel.fetchNotifications( promises[ i ] ) );
}
}
- return promises;
+ // Wait for all fetch processes to finish
before we resolve this promise
+ return
mw.echo.dm.NetworkHandler.static.waitForAllPromises( fetchPromises );
} );
};
@@ -180,4 +182,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..2ea4a64 100644
--- a/modules/viewmodel/mw.echo.dm.NotificationItem.js
+++ b/modules/viewmodel/mw.echo.dm.NotificationItem.js
@@ -22,6 +22,7 @@
* @cfg {string} [timestamp] Notification timestamp in Mediawiki
timestamp format
* @cfg {string} [primaryUrl] Notification primary link in raw url
format
* @cfg {boolean} [external=false] This notification is from an
external source
+ * @cfg {string} [source] The source this notification is coming from,
if it is external
* @cfg {Object[]} [secondaryUrls] An array of objects defining the
secondary URLs
* for this notification. The secondary URLs are expected to have this
structure:
* {
@@ -55,6 +56,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 +255,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: merged
Gerrit-Change-Id: Ibcd1923aaff4e1fd6fb1f54eefbc010122caa398
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits