1290477d71
fixes https://github.com/TryGhost/Team/issues/1952 Adds a new MemberLinkClickEvent event that is fired when a member clicks a link. This code has been added to the `linkClickRepository` because that is the only place that has access to the member model (and the event requires the id and current last seen at value). The LastSeenAtUpdater listens for this event and updates the timestamp if required.
29 lines
668 B
JavaScript
29 lines
668 B
JavaScript
/**
|
|
* @typedef {object} MemberLinkClickEventData
|
|
* @prop {string} memberId
|
|
* @prop {string} memberLastSeenAt
|
|
* @prop {string} linkId
|
|
*/
|
|
|
|
/**
|
|
* Server-side event firing on page views (page, post, tags...)
|
|
*/
|
|
module.exports = class MemberLinkClickEvent {
|
|
/**
|
|
* @param {MemberLinkClickEventData} data
|
|
* @param {Date} timestamp
|
|
*/
|
|
constructor(data, timestamp) {
|
|
this.data = data;
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
/**
|
|
* @param {MemberLinkClickEventData} data
|
|
* @param {Date} [timestamp]
|
|
*/
|
|
static create(data, timestamp) {
|
|
return new MemberLinkClickEvent(data, timestamp || new Date);
|
|
}
|
|
};
|