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
This commit is contained in:
Michael Barrett 2024-06-05 17:48:43 +01:00 committed by GitHub
parent 0f283da8eb
commit 7f92777f89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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') {