refs https://github.com/TryGhost/Toolbox/issues/164
- see referenced issue for more context but Ghost sometimes has issues
with the email analytics job getting stuck
- we don't provide a timeout to the Mailgun library, so we just
sit there idling for eternity if something between us and Mailgun is
causing issues
- this commit adds a 60s timeout so we can at least error out and try
again next time
- during a refactor, I moved the `BATCH_SIZE` variable around
- putting the variable export above a more general export means it get
overwritten and the value is `undefined` outside of the module
- when we chunk the emails, we were chunking in sized of `undefined`,
so I'm guessing it just defaulted to 1
- this means the email batches were of size 1 instead of 1000 - oops
refs https://github.com/TryGhost/Toolbox/issues/363
- this commit switches us to using the official and maintained
`mailgun.js` SDK, and updates the `mailgun-client` code to reflect the
changes between the two
- when I extracted `mailgun-client` to a separate package, I
accidentally removed the lazyloading for the `mailgun-js` library,
which takes a non-negligible amount of time to require on boot
- this fixes that by moving the require into the function where it's
used
- even though we don't do anything yet, the code was calling `.length`
on an object, which is `undefined`
- this fixes that by checking the length of the keys
- also moves the code block down so we can early-return if mailgun is
not configured
refs https://github.com/TryGhost/Toolbox/issues/363
- this commit pulls all code involving the Mailgun client SDK into one
new package called `mailgun-client`
- this means we should be able to replace `mailgun-js` (deprecated) with
`mailgun.js` (the new, official one) without editing code all over the
place
- this also lays some groundwork for better testing of smaller
components