From 8a9bdf85fba067750874b75abc1b4615092618af Mon Sep 17 00:00:00 2001 From: ruslandoga Date: Thu, 19 Dec 2024 01:38:10 +0700 Subject: [PATCH] Remove trial mentions from site emails in CE (#4668) * remove trial mentions from site emails in ce * your * fix test? --- .../email/create_site_email.html.heex | 10 ++++- .../email/site_setup_help_email.html.heex | 6 ++- test/plausible_web/email_test.exs | 43 ++++++++++++------- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/lib/plausible_web/templates/email/create_site_email.html.heex b/lib/plausible_web/templates/email/create_site_email.html.heex index 92f5c9646694..b17746e23f10 100644 --- a/lib/plausible_web/templates/email/create_site_email.html.heex +++ b/lib/plausible_web/templates/email/create_site_email.html.heex @@ -1,5 +1,11 @@ -You've activated your free 30-day trial of Plausible, a simple and privacy-friendly website analytics tool. +You've activated +<%= if Plausible.ee?() do %> + your free 30-day trial of +<% end %> +<%= Plausible.product_name() %>, a simple and privacy-friendly website analytics tool.

Click here to add your website URL, your timezone and install our one-line JavaScript snippet to start collecting visitor statistics. -

Do reply back to this email if you have any questions or need some guidance. +<%= if Plausible.ee?() do %> +

Do reply back to this email if you have any questions or need some guidance. +<% end %> diff --git a/lib/plausible_web/templates/email/site_setup_help_email.html.heex b/lib/plausible_web/templates/email/site_setup_help_email.html.heex index 8b4ad4e5d9f8..04b4d5d18599 100644 --- a/lib/plausible_web/templates/email/site_setup_help_email.html.heex +++ b/lib/plausible_web/templates/email/site_setup_help_email.html.heex @@ -1,4 +1,4 @@ -<%= if Plausible.Teams.on_trial?(@site.team) do %> +<%= if Plausible.ee?() and Plausible.Teams.on_trial?(@site.team) do %> You signed up for a free 30-day trial of Plausible, a simple and privacy-friendly website analytics tool.

<% end %> @@ -9,4 +9,6 @@ This Plausible script is 45 times smaller than Google Analytics script so you’

On WordPress? We have a WordPress plugin that makes the process simpler. We also have integration guides for different site builders to help you start counting stats in no time. -

Do reply back to this email if you have any questions or need some guidance. +<%= if Plausible.ee?() do %> +

Do reply back to this email if you have any questions or need some guidance. +<% end %> diff --git a/test/plausible_web/email_test.exs b/test/plausible_web/email_test.exs index 280664c06bdb..eabbb25a93b0 100644 --- a/test/plausible_web/email_test.exs +++ b/test/plausible_web/email_test.exs @@ -283,30 +283,43 @@ defmodule PlausibleWeb.EmailTest do end end - describe "site_setup_success" do + describe "site setup emails" do setup do trial_user = new_user(trial_expiry_date: Date.add(Date.utc_today(), 100)) site = new_site(owner: trial_user) - email = PlausibleWeb.Email.site_setup_success(trial_user, team_of(trial_user), site) - {:ok, email: email} + + emails = [ + PlausibleWeb.Email.create_site_email(trial_user), + PlausibleWeb.Email.site_setup_help(trial_user, site), + PlausibleWeb.Email.site_setup_success(trial_user, site.team, site) + ] + + {:ok, emails: emails} end - @tag :ee_only - test "renders 'trial' and 'reply' blocks", %{email: email} do - assert email.html_body =~ - "You're on a 30-day free trial with no obligations so do take your time to explore Plausible." + @trial_message "trial" + @reply_message "reply back" - assert email.html_body =~ - "Do reply back to this email if you have any questions. We're here to help." + @tag :ee_only + test "has 'trial' and 'reply' blocks, correct product name", %{emails: emails} do + for email <- emails do + assert email.html_body =~ @trial_message + assert email.html_body =~ @reply_message + refute email.html_body =~ "Plausible CE" + end + + assert Enum.any?(emails, fn email -> email.html_body =~ "Plausible Analytics" end) end @tag :ce_build_only - test "does not render 'trial' and 'reply' blocks", %{email: email} do - refute email.html_body =~ - "You're on a 30-day free trial with no obligations so do take your time to explore Plausible." - - refute email.html_body =~ - "Do reply back to this email if you have any questions. We're here to help." + test "no 'trial' or 'reply' blocks, correct product name", %{emails: emails} do + for email <- emails do + refute email.html_body =~ @trial_message + refute email.html_body =~ @reply_message + refute email.html_body =~ "Plausible Analytics" + end + + assert Enum.any?(emails, fn email -> email.html_body =~ "Plausible CE" end) end end