Added signup_events to the event timeline

refs https://github.com/TryGhost/Team/issues/469

Signup events are captured by status changes with no `from_status`, this
means that the member did not have a status (did not exist) before this
change.
This commit is contained in:
Fabien O'Carroll 2021-03-05 12:38:30 +00:00
parent c8eb50bf57
commit e003c10e8b

View File

@ -90,6 +90,24 @@ module.exports = class EventRepository {
};
}
async getSignupEvents(options = {}) {
options.withRelated = ['member'];
options.filter = 'from_status:null';
const {data: models, meta} = await this._MemberStatusEvent.findPage(options);
const data = models.map((data) => {
return {
type: 'signup_event',
data: data.toJSON(options)
};
});
return {
data,
meta
};
}
async getEventTimeline(options = {}) {
if (!options.limit) {
options.limit = 10;
@ -100,7 +118,8 @@ module.exports = class EventRepository {
const allEventPages = await Promise.all([
this.getNewsletterSubscriptionEvents(options),
this.getSubscriptionEvents(options),
this.getLoginEvents(options)
this.getLoginEvents(options),
this.getSignupEvents(options)
]);
const allEvents = allEventPages.reduce((allEvents, page) => allEvents.concat(page.data), []);