Merge pull request #16833 from overleaf/bg-google-spam-add-email-metrics

Include email type and rate-limit status in metrics

GitOrigin-RevId: eb5645e68d9ee3571d04b87b2c0fc09f9caa126a
This commit is contained in:
Brian Gough 2024-01-31 10:10:06 +00:00 committed by Copybot
parent f6a693c1f5
commit 9702b36c64
2 changed files with 6 additions and 2 deletions

View file

@ -22,7 +22,7 @@ async function sendEmail(emailType, opts) {
opts.html = email.html
opts.text = email.text
opts.subject = email.subject
await EmailSender.promises.sendEmail(opts)
await EmailSender.promises.sendEmail(opts, emailType)
}
function sendDeferredEmail(emailType, opts, delay) {

View file

@ -66,9 +66,13 @@ function getClient() {
return client
}
async function sendEmail(options) {
async function sendEmail(options, emailType) {
try {
const canContinue = await checkCanSendEmail(options)
metrics.inc('email_status', {
status: canContinue ? 'sent' : 'rate_limited',
path: emailType,
})
if (!canContinue) {
logger.debug(
{