mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Enabled Mailgun open tracking when dev experiments is enabled
no issue - set `emails.track_opens` to `true` when the `enableDeveloperExperiments` flag is set - update mailgun bulk-email provider to pass the open-tracking header to Mailgun when the email's `track_opens` flag is set
This commit is contained in:
parent
6795797179
commit
aface9ed4c
2 changed files with 11 additions and 1 deletions
|
@ -92,6 +92,11 @@ function send(message, recipientData, replacements) {
|
|||
messageData['o:testmode'] = true;
|
||||
}
|
||||
|
||||
// enable tracking if turned on for this email
|
||||
if (message.track_opens) {
|
||||
messageData['o:tracking-opens'] = true;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
mailgunInstance.messages().send(messageData, (error, body) => {
|
||||
if (error) {
|
||||
|
|
|
@ -6,6 +6,7 @@ const ObjectID = require('bson-objectid');
|
|||
const errors = require('@tryghost/errors');
|
||||
const {events, i18n} = require('../../lib/common');
|
||||
const logging = require('../../../shared/logging');
|
||||
const config = require('../../../shared/config');
|
||||
const settingsCache = require('../settings/cache');
|
||||
const membersService = require('../members');
|
||||
const bulkEmailService = require('../bulk-email');
|
||||
|
@ -68,6 +69,9 @@ const sendTestEmail = async (postModel, toEmails) => {
|
|||
};
|
||||
}));
|
||||
|
||||
// enable tracking for previews to match real-world behaviour
|
||||
emailData.track_opens = config.get('enableDeveloperExperiments');
|
||||
|
||||
const response = await bulkEmailService.send(emailData, recipients);
|
||||
|
||||
if (response instanceof bulkEmailService.FailedBatch) {
|
||||
|
@ -121,7 +125,8 @@ const addEmail = async (postModel, options) => {
|
|||
reply_to: emailData.replyTo,
|
||||
html: emailData.html,
|
||||
plaintext: emailData.plaintext,
|
||||
submitted_at: moment().toDate()
|
||||
submitted_at: moment().toDate(),
|
||||
track_opens: config.get('enableDeveloperExperiments')
|
||||
}, knexOptions);
|
||||
} else {
|
||||
return existing;
|
||||
|
|
Loading…
Add table
Reference in a new issue