From 7f92777f890c195ce5292bc412f78f9dbc1dbd32 Mon Sep 17 00:00:00 2001 From: Michael Barrett Date: Wed, 5 Jun 2024 17:48:43 +0100 Subject: [PATCH] Added logging to track offer redemption (#20329) refs [ONC-56](https://linear.app/tryghost/issue/ONC-56/support-escalation-re-offers-not-tracking) Added logging to track offer redemption logic to debug issue with offer redemptions tracking incorrectly --- .../members-api/lib/repositories/MemberRepository.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ghost/members-api/lib/repositories/MemberRepository.js b/ghost/members-api/lib/repositories/MemberRepository.js index f3660cebc5..5dbe014994 100644 --- a/ghost/members-api/lib/repositories/MemberRepository.js +++ b/ghost/members-api/lib/repositories/MemberRepository.js @@ -104,8 +104,12 @@ module.exports = class MemberRepository { // Only dispatch the event after the transaction has finished options.transacting.executionPromise.then(async () => { DomainEvents.dispatch(event); - }).catch(() => { + }).catch((err) => { // catches transaction errors/rollback to not dispatch event + logging.error({ + err, + message: `Error dispatching event ${event.constructor.name} for member ${event.data.memberId} after transaction finished` + }); }); } else { DomainEvents.dispatch(event); @@ -1134,6 +1138,11 @@ module.exports = class MemberRepository { attribution: data.attribution, batchId: options.batch_id }); + + if (offerId) { + logging.info(`Dispatching ${event.constructor.name} for member ${member.id} with offer ${offerId}`); + } + this.dispatchEvent(event, options); if (getStatus(subscriptionModel) === 'active') {