0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Used the higher of click count and open count for email open count (#15508)

fixes https://github.com/TryGhost/Team/issues/2017

We process clicks much faster than we process Mailgun events which can result in a higher click rater than open rate shown on the dashboard. This ensures that the open rate will never be lower than the click rate. This is a stopgap solution until we can get click events updating the opened_at time for email_recipients
This commit is contained in:
Fabien 'egg' O'Carroll 2022-10-03 09:29:58 +01:00 committed by GitHub
parent b80c2cd81b
commit 1613470a8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,6 +110,18 @@ module.exports = async (model, frame, options = {}) => {
});
}
if (labs.isSet('emailClicks')) {
if (jsonModel.email && jsonModel.count) {
jsonModel.email.opened_count = Math.min(
Math.max(
jsonModel.email.opened_count || 0,
jsonModel.count.clicks || 0
),
jsonModel.email.email_count
);
}
}
if (!labs.isSet('memberAttribution') && !labs.isSet('emailClicks')) {
delete jsonModel.count;
}