mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 22:27:22 +00:00
Use Sentry instead of console logs
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import handlebars from 'handlebars';
|
import handlebars from 'handlebars';
|
||||||
@@ -11,6 +10,7 @@ import {
|
|||||||
SMTP_PASSWORD
|
SMTP_PASSWORD
|
||||||
} from '../config';
|
} from '../config';
|
||||||
import SMTPConnection from 'nodemailer/lib/smtp-connection';
|
import SMTPConnection from 'nodemailer/lib/smtp-connection';
|
||||||
|
import * as Sentry from '@sentry/node';
|
||||||
|
|
||||||
const mailOpts: SMTPConnection.Options = {
|
const mailOpts: SMTPConnection.Options = {
|
||||||
host: SMTP_HOST,
|
host: SMTP_HOST,
|
||||||
@@ -26,12 +26,16 @@ if (SMTP_USERNAME && SMTP_PASSWORD) {
|
|||||||
const transporter = nodemailer.createTransport(mailOpts);
|
const transporter = nodemailer.createTransport(mailOpts);
|
||||||
transporter
|
transporter
|
||||||
.verify()
|
.verify()
|
||||||
.then(() => console.log('SMTP - Successfully connected'))
|
.then(() => {
|
||||||
.catch((err) =>
|
Sentry.setUser(null);
|
||||||
console.log(
|
Sentry.captureMessage('SMTP - Successfully connected');
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
Sentry.setUser(null);
|
||||||
|
Sentry.captureException(
|
||||||
`SMTP - Failed to connect to ${SMTP_HOST}:${SMTP_PORT} \n\t${err}`
|
`SMTP - Failed to connect to ${SMTP_HOST}:${SMTP_PORT} \n\t${err}`
|
||||||
)
|
);
|
||||||
);
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
@@ -66,7 +70,8 @@ const sendMail = async ({
|
|||||||
html: htmlToSend
|
html: htmlToSend
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
Sentry.setUser(null);
|
||||||
|
Sentry.captureException(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user