From e003c10e8bab280e855599903f61a8d886edaf51 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Fri, 5 Mar 2021 12:38:30 +0000 Subject: [PATCH] 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. --- .../lib/repositories/event/index.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ghost/members-api/lib/repositories/event/index.js b/ghost/members-api/lib/repositories/event/index.js index 1a6a7cb57a..ba6ab50e0e 100644 --- a/ghost/members-api/lib/repositories/event/index.js +++ b/ghost/members-api/lib/repositories/event/index.js @@ -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), []);