mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 09:40:41 +00:00
Merge "Log cross-wiki & bundle items impressions and add their source wiki"
This commit is contained in:
commit
db9b8fe037
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Log the expand action
|
||||
|
|
|
@ -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() : ''
|
||||
);
|
||||
} )
|
||||
);
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 ) );
|
||||
|
|
|
@ -449,6 +449,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' ) || []
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue