From 0e8f1879485ac9afab545a8d6fe9c07850d24ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Wed, 14 May 2025 15:55:38 +0100 Subject: [PATCH] chore: new getting started email template (#9980) https://linear.app/unleash/issue/2-3567/improve-the-look-of-the-unleash-instance-getting-started-email Adds a new getting started email template, hidden behind a `newGettingStartedEmail` flag. If it works nicely, we may follow up with PRs to update and align the remaining email templates. ### Old ![image](https://github.com/user-attachments/assets/a1bf1ccd-7adb-4a41-b101-653c648c24f3) ### New ![image](https://github.com/user-attachments/assets/ebe600df-254f-4ebb-8976-69aa6b200d8a) --- src/lib/services/email-service.test.ts | 3 + src/lib/services/email-service.ts | 15 +- src/lib/types/experimental.ts | 7 +- .../getting-started-new.html.mustache | 165 ++++++++++++++++++ .../getting-started-new.plain.mustache | 27 +++ 5 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 src/mailtemplates/getting-started-new/getting-started-new.html.mustache create mode 100644 src/mailtemplates/getting-started-new/getting-started-new.plain.mustache diff --git a/src/lib/services/email-service.test.ts b/src/lib/services/email-service.test.ts index f6fbd2212a..67ba9132aa 100644 --- a/src/lib/services/email-service.test.ts +++ b/src/lib/services/email-service.test.ts @@ -40,6 +40,9 @@ test('Can send welcome mail', async () => { sender: 'noreply@getunleash.ai', }, getLogger: noLoggerProvider, + flagResolver: { + isEnabled: () => true, + }, } as unknown as IUnleashConfig); const content = await emailService.sendGettingStartedMail( 'Some username', diff --git a/src/lib/services/email-service.ts b/src/lib/services/email-service.ts index 8520cf7f74..bdf2396843 100644 --- a/src/lib/services/email-service.ts +++ b/src/lib/services/email-service.ts @@ -10,6 +10,7 @@ import { productivityReportViewModel, } from '../features/productivity-report/productivity-report-view-model.js'; import { fileURLToPath } from 'node:url'; +import type { IFlagResolver } from '../types/index.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -85,9 +86,12 @@ export class EmailService { private readonly sender: string; + private flagResolver: IFlagResolver; + constructor(config: IUnleashConfig, transportProvider?: TransportProvider) { this.config = config; this.logger = config.getLogger('services/email-service.ts'); + this.flagResolver = config.flagResolver; const { email } = config; if (email?.host) { this.sender = email.sender; @@ -420,14 +424,21 @@ export class EmailService { name: this.stripSpecialCharacters(name), year, unleashUrl, + recipient, }; + + let gettingStartedTemplate = 'getting-started'; + if (this.flagResolver.isEnabled('newGettingStartedEmail')) { + gettingStartedTemplate = 'getting-started-new'; + } + const bodyHtml = await this.compileTemplate( - 'getting-started', + gettingStartedTemplate, TemplateFormat.HTML, context, ); const bodyText = await this.compileTemplate( - 'getting-started', + gettingStartedTemplate, TemplateFormat.PLAIN, context, ); diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index 185749ac2d..c0a92fc085 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -66,7 +66,8 @@ export type IFlagKey = | 'registerFrontendClient' | 'featureLinks' | 'projectLinkTemplates' - | 'reportUnknownFlags'; + | 'reportUnknownFlags' + | 'newGettingStartedEmail'; export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>; @@ -315,6 +316,10 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_REPORT_UNKNOWN_FLAGS, false, ), + newGettingStartedEmail: parseEnvVarBoolean( + process.env.UNLEASH_EXPERIMENTAL_NEW_GETTING_STARTED_EMAIL, + false, + ), }; export const defaultExperimentalOptions: IExperimentalOptions = { diff --git a/src/mailtemplates/getting-started-new/getting-started-new.html.mustache b/src/mailtemplates/getting-started-new/getting-started-new.html.mustache new file mode 100644 index 0000000000..bde36dfcd5 --- /dev/null +++ b/src/mailtemplates/getting-started-new/getting-started-new.html.mustache @@ -0,0 +1,165 @@ + + + + + + + Welcome to Unleash + + + + + Welcome to Unleash! You’ve been invited to your organization’s Unleash account – start experimenting with features today. + +
+ Unleash logo +
+
+
+ Welcome to Unleash +
+
+

Welcome to Unleash {{ name }}!

+

+ You have been invited to your organization’s Unleash account. +

+ {{# passwordLink }} +

+ Start using Unleash by clicking the sign-up link below. Follow the + steps provided to set your password and get started. +

+

+ Set up account +

+ {{/ passwordLink }} + {{^ passwordLink }} +

+ Start using Unleash by clicking the log in link below. +

+

+ Log in +

+ {{/ passwordLink }} +
+
+

Useful resources

+

Once you are up and running, you might want to take a look at the following resources:

+ +
+
+

Best,
Your Unleash team

+
+ +
+ + diff --git a/src/mailtemplates/getting-started-new/getting-started-new.plain.mustache b/src/mailtemplates/getting-started-new/getting-started-new.plain.mustache new file mode 100644 index 0000000000..e9386d25f5 --- /dev/null +++ b/src/mailtemplates/getting-started-new/getting-started-new.plain.mustache @@ -0,0 +1,27 @@ +Welcome to Unleash {{ name }}! + +You have been invited to your organization's Unleash account. + +{{# passwordLink }} +Start using Unleash by clicking the sign-up link below. Follow the steps provided to set your password and get started. + +{{{ passwordLink }}} +{{/ passwordLink }} + +{{^ passwordLink }} +Start using Unleash by clicking the log in link below. + +{{{ unleashUrl }}} +{{/ passwordLink }} + +Once you're up and running, you might want to take a look at the following resources: + +- Documentation: https://docs.getunleash.io +- Code examples: https://github.com/unleash +- SDKs: https://docs.getunleash.io/reference/sdks + +Best, +Your Unleash team + +By starting to use Unleash, you are agreeing to our Terms of Service: https://www.getunleash.io/terms-of-service +This email was sent to {{ recipient }}