📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
sending emails
Blue Mouseff95f0396ecb
diff --git a/src/common/templates/en/trial-ends-tomorrow.html b/src/common/templates/en/trial-ends-tomorrow.htmlnew file mode 100644index 000000000..60d9f34ae--- /dev/null+++ b/src/common/templates/en/trial-ends-tomorrow.html@@ -0,0 +1,231 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<html>+ <head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <title>+ Your free Swetrix trial ends tomorrow+ </title>+ <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet" />+ </head>+ <body style="margin: 0; padding: 0; background-color: #f0f4f7;">+ <table cellpadding="0" cellspacing="0" border="0" width="100%" style="background: #f0f4f7; min-width: 340px; font-size: 1px; line-height: normal;">+ <tr>+ <td align="center" valign="top" bgcolor="#f0f4f7">+ <!--[if (gte mso 9)|(IE)]>+ <table border="0" cellspacing="0" cellpadding="0">+ <tr><td align="center" valign="top" width="750"><![endif]-->+ <table cellpadding="0" cellspacing="0" border="0" width="750" style="width: 100%; max-width: 750px; min-width: 340px; background: #f0f4f7;">+ <tr>+ <td width="25" style="width: 25px; max-width: 25px; min-width: 25px;"> </td>+ <td align="center" valign="top" style="background: #ffffff;">+ <table cellpadding="0" cellspacing="0" border="0" width="100%" style="width: 100% !important; min-width: 100%; max-width: 100%; background: #f0f4f7;">+ <tr>+ <td align="right" valign="top">+ <div style="height: 25px; line-height: 25px; font-size: 23px;"> </div>+ </td>+ </tr>+ </table>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="center" valign="top">+ <div style="height: 40px; line-height: 40px; font-size: 38px;"> </div>+ <a href="https://swetrix.com" target="_blank" style="display: block; max-width: 173px;text-decoration: none;">+ <img src="https://swetrix.com/assets/logo_blue.png" alt="Swetrix" width="175" border="0" style="display: block; width: 175px; font-size: 32px;" />+ </a>+ <div style="height: 40px; line-height: 40px; font-size: 40px;"> </div>+ </td>+ </tr>+ </table>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="center" valign="top">+ <font align="center" style="font-size: 52px; line-height: 55px; font-weight: 300; letter-spacing: -1.5px;">+ <span+ align="center"+ style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; font-size: 44px; color: #1a1a1a;"+ >+ Your free Swetrix trial ends tomorrow+ </span>+ </font>+ <div style="height: 38px; line-height: 38px; font-size: 36px;"> </div>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="left" valign="top">+ <font face="'Source Sans Pro', sans-serif" color="#6d6d6d" style="font-size: 17px; line-height: 23px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #6d6d6d;+ font-size: 17px;+ line-height: 23px;+ "+ >+ Time goes by so fast! Your free Swetrix trial ends tomorrow.+ <br /><br />+ We hope that you enjoyed using Swetrix and liked the experience of using a service that respects user privacy, does not annoy your users with cookie banners and keeps your website as fast as possible :)+ <br /><br />+ If you wish to continue using Swetrix and receiving all the needed analytics data easily, you'll need to upgrade your account.+ <br /><br />+ You can do it by clicking the button below or going to the Billing page.+ </span>+ </font>+ <div style="height: 30px; line-height: 30px; font-size: 28px;"> </div>+ </td>+ </tr>+ </table>+ </td>+ </tr>+ </table>++ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="center" valign="top">+ <table cellpadding="0" cellspacing="0" border="0" style="background: #4f46e5; border-radius: 4px;">+ <tr>+ <td align="center" valign="top">+ <a+ href="{{url}}"+ target="_blank"+ style="+ display: block;+ border: 1px solid #4f46e5;+ border-radius: 4px;+ padding: 19px 26px;+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #ffffff;+ font-size: 20px;+ line-height: 30px;+ text-decoration: none;+ white-space: nowrap;+ font-weight: 600;+ "+ >+ <font face="'Source Sans Pro', sans-serif" color="#ffffff" style="font-size: 26px; line-height: 30px; text-decoration: none; white-space: nowrap; font-weight: 600;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #ffffff;+ font-size: 26px;+ line-height: 30px;+ text-decoration: none;+ white-space: nowrap;+ font-weight: 600;+ "+ >+ Upgrade tier+ </span>+ </font>+ </a>+ </td>+ </tr>+ </table>+ <div style="height: 30px; line-height: 30px; font-size: 28px;"> </div>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="left" valign="top">+ <font face="'Source Sans Pro', sans-serif" color="#6d6d6d" style="font-size: 17px; line-height: 23px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #6d6d6d;+ font-size: 17px;+ line-height: 23px;+ "+ >+ You can reply back to this email in case you have any questions!+ </span>+ </font>+ </td>+ </tr>+ </table>+ <div style="height: 40px; line-height: 40px; font-size: 38px;"> </div>+ </td>+ </tr>+ </table>++ <table cellpadding="0" cellspacing="0" border="0" width="100%" style="width: 100% !important; min-width: 100%; max-width: 100%; background: #f0f4f7;">+ <tr>+ <td align="center" valign="top">+ <div style="height: 25px; line-height: 25px; font-size: 32px;"> </div>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="center" valign="top">+ <font style="font-size: 17px; line-height: 20px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #3c4858;+ font-size: 17px;+ line-height: 20px;+ "+ >+ <a+ href="https://swetrix.com/terms"+ target="_blank"+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #3c4858;+ font-size: 17px;+ line-height: 20px;+ text-decoration: none;+ "+ >+ Terms of Service+ </a>+ </span>+ </font>+ <font face="'Source Sans Pro', sans-serif" color="#3c4858" style="font-size: 17px; line-height: 20px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #1a1a1a;+ font-size: 17px;+ line-height: 20px;+ "+ >+ | + </span>+ </font>+ <font style="font-size: 17px; line-height: 20px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #1a1a1a;+ font-size: 17px;+ line-height: 20px;+ "+ >+ <a+ href="https://swetrix.com/privacy"+ target="_blank"+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #3c4858;+ font-size: 17px;+ line-height: 20px;+ text-decoration: none;+ "+ >+ Privacy Policy+ </a>+ </span>+ </font>+ </td>+ </tr>+ </table>+ <div style="height: 25px; line-height: 25px; font-size: 28px;"> </div>+ </td>+ </tr>+ </table>+ </td>+ <td width="25" style="width: 25px; max-width: 25px; min-width: 25px;"> </td>+ </tr>+ </table>+ <!--[if (gte mso 9)|(IE)]>+ </td></tr>+ </table><![endif]-->+ </td>+ </tr>+ </table>+ </body>+</html>diff --git a/src/common/templates/en/trial-expired.html b/src/common/templates/en/trial-expired.htmlnew file mode 100644index 000000000..0ef152ed0--- /dev/null+++ b/src/common/templates/en/trial-expired.html@@ -0,0 +1,229 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">+<html>+ <head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <title>+ Your free Swetrix trial has ended+ </title>+ <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet" />+ </head>+ <body style="margin: 0; padding: 0; background-color: #f0f4f7;">+ <table cellpadding="0" cellspacing="0" border="0" width="100%" style="background: #f0f4f7; min-width: 340px; font-size: 1px; line-height: normal;">+ <tr>+ <td align="center" valign="top" bgcolor="#f0f4f7">+ <!--[if (gte mso 9)|(IE)]>+ <table border="0" cellspacing="0" cellpadding="0">+ <tr><td align="center" valign="top" width="750"><![endif]-->+ <table cellpadding="0" cellspacing="0" border="0" width="750" style="width: 100%; max-width: 750px; min-width: 340px; background: #f0f4f7;">+ <tr>+ <td width="25" style="width: 25px; max-width: 25px; min-width: 25px;"> </td>+ <td align="center" valign="top" style="background: #ffffff;">+ <table cellpadding="0" cellspacing="0" border="0" width="100%" style="width: 100% !important; min-width: 100%; max-width: 100%; background: #f0f4f7;">+ <tr>+ <td align="right" valign="top">+ <div style="height: 25px; line-height: 25px; font-size: 23px;"> </div>+ </td>+ </tr>+ </table>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="center" valign="top">+ <div style="height: 40px; line-height: 40px; font-size: 38px;"> </div>+ <a href="https://swetrix.com" target="_blank" style="display: block; max-width: 173px;text-decoration: none;">+ <img src="https://swetrix.com/assets/logo_blue.png" alt="Swetrix" width="175" border="0" style="display: block; width: 175px; font-size: 32px;" />+ </a>+ <div style="height: 40px; line-height: 40px; font-size: 40px;"> </div>+ </td>+ </tr>+ </table>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="center" valign="top">+ <font align="center" style="font-size: 52px; line-height: 55px; font-weight: 300; letter-spacing: -1.5px;">+ <span+ align="center"+ style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; font-size: 44px; color: #1a1a1a;"+ >+ Your free Swetrix trial has ended+ </span>+ </font>+ <div style="height: 38px; line-height: 38px; font-size: 36px;"> </div>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="left" valign="top">+ <font face="'Source Sans Pro', sans-serif" color="#6d6d6d" style="font-size: 17px; line-height: 23px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #6d6d6d;+ font-size: 17px;+ line-height: 23px;+ "+ >+ We hope that you enjoyed using Swetrix so far!+ <br /><br />+ If you wish to continue using Swetrix and receiving all the needed analytics data easily, you'll need to upgrade your account.+ <br /><br />+ You can do it by clicking the button below or going to the Billing page.+ </span>+ </font>+ <div style="height: 30px; line-height: 30px; font-size: 28px;"> </div>+ </td>+ </tr>+ </table>+ </td>+ </tr>+ </table>++ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="center" valign="top">+ <table cellpadding="0" cellspacing="0" border="0" style="background: #4f46e5; border-radius: 4px;">+ <tr>+ <td align="center" valign="top">+ <a+ href="{{url}}"+ target="_blank"+ style="+ display: block;+ border: 1px solid #4f46e5;+ border-radius: 4px;+ padding: 19px 26px;+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #ffffff;+ font-size: 20px;+ line-height: 30px;+ text-decoration: none;+ white-space: nowrap;+ font-weight: 600;+ "+ >+ <font face="'Source Sans Pro', sans-serif" color="#ffffff" style="font-size: 26px; line-height: 30px; text-decoration: none; white-space: nowrap; font-weight: 600;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #ffffff;+ font-size: 26px;+ line-height: 30px;+ text-decoration: none;+ white-space: nowrap;+ font-weight: 600;+ "+ >+ Upgrade tier+ </span>+ </font>+ </a>+ </td>+ </tr>+ </table>+ <div style="height: 30px; line-height: 30px; font-size: 28px;"> </div>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="left" valign="top">+ <font face="'Source Sans Pro', sans-serif" color="#6d6d6d" style="font-size: 17px; line-height: 23px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #6d6d6d;+ font-size: 17px;+ line-height: 23px;+ "+ >+ You can reply back to this email in case you have any questions!+ </span>+ </font>+ </td>+ </tr>+ </table>+ <div style="height: 40px; line-height: 40px; font-size: 38px;"> </div>+ </td>+ </tr>+ </table>++ <table cellpadding="0" cellspacing="0" border="0" width="100%" style="width: 100% !important; min-width: 100%; max-width: 100%; background: #f0f4f7;">+ <tr>+ <td align="center" valign="top">+ <div style="height: 25px; line-height: 25px; font-size: 32px;"> </div>+ <table cellpadding="0" cellspacing="0" border="0" width="88%" style="width: 88% !important; min-width: 88%; max-width: 88%;">+ <tr>+ <td align="center" valign="top">+ <font style="font-size: 17px; line-height: 20px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #3c4858;+ font-size: 17px;+ line-height: 20px;+ "+ >+ <a+ href="https://swetrix.com/terms"+ target="_blank"+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #3c4858;+ font-size: 17px;+ line-height: 20px;+ text-decoration: none;+ "+ >+ Terms of Service+ </a>+ </span>+ </font>+ <font face="'Source Sans Pro', sans-serif" color="#3c4858" style="font-size: 17px; line-height: 20px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #1a1a1a;+ font-size: 17px;+ line-height: 20px;+ "+ >+ | + </span>+ </font>+ <font style="font-size: 17px; line-height: 20px;">+ <span+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #1a1a1a;+ font-size: 17px;+ line-height: 20px;+ "+ >+ <a+ href="https://swetrix.com/privacy"+ target="_blank"+ style="+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;+ color: #3c4858;+ font-size: 17px;+ line-height: 20px;+ text-decoration: none;+ "+ >+ Privacy Policy+ </a>+ </span>+ </font>+ </td>+ </tr>+ </table>+ <div style="height: 25px; line-height: 25px; font-size: 28px;"> </div>+ </td>+ </tr>+ </table>+ </td>+ <td width="25" style="width: 25px; max-width: 25px; min-width: 25px;"> </td>+ </tr>+ </table>+ <!--[if (gte mso 9)|(IE)]>+ </td></tr>+ </table><![endif]-->+ </td>+ </tr>+ </table>+ </body>+</html>diff --git a/src/mailer/letter.ts b/src/mailer/letter.tsindex 69fae193a..b88105109 100644--- a/src/mailer/letter.ts+++ b/src/mailer/letter.ts@@ -11,4 +11,6 @@ export enum LetterTemplate {ProjectInvitation = 'customer_project-invitation',TwoFAOn = '2fa-turned-on',TwoFAOff = '2fa-turned-off',+ TrialExpired = 'trial-expired',+ TrialEndsTomorrow = 'trial-ends-tomorrow',}diff --git a/src/mailer/mailer.service.ts b/src/mailer/mailer.service.tsindex 2e30621b0..f71e3dc02 100644--- a/src/mailer/mailer.service.ts+++ b/src/mailer/mailer.service.ts@@ -71,6 +71,16 @@ const metaInfoJson = {en: () => '2FA has been disabled on your Swetrix account',},},+ [LetterTemplate.TrialExpired]: {+ subject: {+ en: () => 'Your free Swetrix trial has ended',+ },+ },+ [LetterTemplate.TrialEndsTomorrow]: {+ subject: {+ en: () => 'Your free Swetrix trial ends tomorrow',+ },+ },}interface Params {diff --git a/src/task-manager/task-manager.service.ts b/src/task-manager/task-manager.service.tsindex 237ed104d..16d8e694f 100644--- a/src/task-manager/task-manager.service.ts+++ b/src/task-manager/task-manager.service.ts@@ -420,9 +420,15 @@ export class TaskManagerService {}})- // TODO:- // send email reminding user that trial period will end tomorrow- // set trialReminderSent to true+ for (let i = 0; i < _size(users); ++i) {+ await this.userService.update(users[i].id, {+ trialReminderSent: true,+ })+ await this.mailerService.sendEmail(+ users[i].email,+ LetterTemplate.TrialEndsTomorrow,+ )+ }}@Cron(CronExpression.EVERY_2_HOURS)@@ -439,8 +445,10 @@ export class TaskManagerService {planCode: PlanCode.none,trialEndDate: null,})-- // TODO: send email notifying user that trial period has ended+ await this.mailerService.sendEmail(+ users[i].email,+ LetterTemplate.TrialExpired,+ )}}