update security + chart events è anomaly service

This commit is contained in:
Emily
2024-09-24 16:48:23 +02:00
parent 5b7e93bcbb
commit f5edf187fd
18 changed files with 1417 additions and 75 deletions

View File

@@ -92,7 +92,7 @@ class EmailService {
sendSmtpEmail.to = [{ "email": target }];
sendSmtpEmail.htmlContent = PURCHASE_EMAIL
.replace(/\[Project Name\]/, projectName)
.toString();;
.toString();
await this.apiInstance.sendTransacEmail(sendSmtpEmail);
return true;
} catch (ex) {
@@ -101,7 +101,11 @@ class EmailService {
}
}
async sendAnomalyVisitsEventsEmail(target: string, projectName: string) {
async sendAnomalyVisitsEventsEmail(target: string, projectName: string,
data: {
visits: { _id: string, count: number }[],
events: { _id: string, count: number }[]
}) {
try {
const sendSmtpEmail = new SendSmtpEmail();
sendSmtpEmail.subject = "🚨 Unexpected Activity Detected by our AI";
@@ -109,7 +113,14 @@ class EmailService {
sendSmtpEmail.to = [{ "email": target }];
sendSmtpEmail.htmlContent = ANOMALY_VISITS_EVENTS_EMAIL
.replace(/\[Project Name\]/, projectName)
.toString();;
.replace(/\[ENTRIES\]/,
[
...data.visits.map(e => (`<li> Visits in date ${e._id} [ ${e.count} ] </li>`)),
...data.events.map(e => (`<li> Events in date ${e._id} [ ${e.count} ] </li>`))
]
.join('<br>')
)
.toString();
await this.apiInstance.sendTransacEmail(sendSmtpEmail);
return true;
} catch (ex) {
@@ -118,7 +129,7 @@ class EmailService {
}
}
async sendAnomalyDomainEmail(target: string, projectName: string) {
async sendAnomalyDomainEmail(target: string, projectName: string, domains: string[]) {
try {
const sendSmtpEmail = new SendSmtpEmail();
sendSmtpEmail.subject = "🚨 Anomaly detected by our AI";
@@ -126,7 +137,11 @@ class EmailService {
sendSmtpEmail.to = [{ "email": target }];
sendSmtpEmail.htmlContent = ANOMALY_DOMAIN_EMAIL
.replace(/\[Project Name\]/, projectName)
.toString();;
.replace(/\[CURRENT_DATE\]/, new Date().toLocaleDateString('en-EN'))
.replace(/\[DNS_ENTRIES\]/,
domains.map(e => (`<li> ${e} </li>`)).join('<br>')
)
.toString();
await this.apiInstance.sendTransacEmail(sendSmtpEmail);
return true;
} catch (ex) {

View File

@@ -14,7 +14,19 @@ export const ANOMALY_DOMAIN_EMAIL = `<!DOCTYPE html>
<p>We wanted to let you know that <strong>[Project Name]</strong> on <strong>Litlyx</strong> has an anomaly that our AI agent detected.</p>
<p>You can analyze a suspicious DNS on your Litlyx dashboard. We put a symbol next to each suspicious DNS to let users know something might be wrong!</p>
<p> <strong>Anomaly</strong>: Suspicious DNS </p>
<p> Message: </p>
<ul>
[DNS_ENTRIES]
</ul>
<p> Date: [CURRENT_DATE] </p>
<p> Are logging data in your project. Is that you? </p>
<p>You can analyze a suspicious DNS on your Litlyx dashboard. Visit the Security tab to find out more.</p>
<h3>What can I do?</h3>

View File

@@ -14,6 +14,14 @@ export const ANOMALY_VISITS_EVENTS_EMAIL = `<!DOCTYPE html>
<p>We wanted to let you know that <strong>[Project Name]</strong> on <strong>Litlyx</strong> is receiving an unexpected amount of visits or events. This could indicate unusual activity that might require your attention.</p>
<p> <strong>Anomaly</strong>: Unexpected usage </p>
<p> Message: </p>
<ul>
[ENTRIES]
</ul>
<p>If this spike in activity is expected, theres no need to worry. However, if you believe this could be unexpected or suspicious, we recommend taking a closer look at your data on the <strong>Litlyx Dashboard</strong>. You can analyze your recent traffic and event logs to identify any irregularities or potential issues.</p>
<h3>What can I do?</h3>

View File

@@ -18,7 +18,7 @@ export const WELCOME_EMAIL = `
<ol>
<li><strong><a href="https://dashboard.litlyx.com" style="color: #007BFF; text-decoration: none;">Create a new project</a></strong> by just naming it</li>
<li><strong><a style="color: #0a0a0a; text-decoration: none;">Copy the universal Script</a></strong> we provide you the snippets to copy in your index.html file and start instantly to track metrics on your website or web app.</li>
<li><strong><a style="color: #0a0a0a; text-decoration: none;">Third Step</a></strong> Encourage engagement or interaction.</li>
<li><strong><a style="color: #0a0a0a; text-decoration: none;">Deploy</a></strong> Litlyx is production ready.</li>
</ol>
<p>If you have any questions or need support, visit <a href="http://docs.litlyx.com" style="color: #007BFF;">docs.litlyx.com</a>.</p>