From fbe3a4e6f1ac721f3f9b66e3f3dbfa74ae955f39 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 3 Nov 2022 11:20:29 +0200 Subject: [PATCH 01/13] add a test and fix rendering the dashboard link --- .../templates/email/spike_notification.html.eex | 2 +- lib/workers/spike_notifier.ex | 4 ++-- test/workers/spike_notifier_test.exs | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/plausible_web/templates/email/spike_notification.html.eex b/lib/plausible_web/templates/email/spike_notification.html.eex index 47a9f27a8..2243ca1bd 100644 --- a/lib/plausible_web/templates/email/spike_notification.html.eex +++ b/lib/plausible_web/templates/email/spike_notification.html.eex @@ -10,7 +10,7 @@ There are currently <%= @current_visitors %> visitors on <%= link(@site.domain, <%= if @link do %>

-View dashboard: @link +View dashboard: <%= link(@link, to: @link) %> <% end %>

-- diff --git a/lib/workers/spike_notifier.ex b/lib/workers/spike_notifier.ex index ddd0331b1..4e0b0c410 100644 --- a/lib/workers/spike_notifier.ex +++ b/lib/workers/spike_notifier.ex @@ -31,7 +31,7 @@ defmodule Plausible.Workers.SpikeNotifier do :ok end - def notify(notification, current_visitors, sources) do + defp notify(notification, current_visitors, sources) do for recipient <- notification.recipients do send_notification(recipient, notification.site, current_visitors, sources) end @@ -45,7 +45,7 @@ defmodule Plausible.Workers.SpikeNotifier do site = Repo.preload(site, :members) dashboard_link = - if Enum.member?(site.members, recipient) do + if Enum.any?(site.members, &(&1.email == recipient)) do PlausibleWeb.Endpoint.url() <> "/" <> URI.encode_www_form(site.domain) end diff --git a/test/workers/spike_notifier_test.exs b/test/workers/spike_notifier_test.exs index 5dbea18e0..dea8f6fc9 100644 --- a/test/workers/spike_notifier_test.exs +++ b/test/workers/spike_notifier_test.exs @@ -85,4 +85,18 @@ defmodule Plausible.Workers.SpikeNotifierTest do assert_no_emails_delivered() end + + test "adds a dashboard link if recipient has access to the site" do + user = insert(:user, email: "robert@example.com") + site = insert(:site, domain: "example.com", members: [user]) + insert(:spike_notification, site: site, threshold: 10, recipients: ["robert@example.com"]) + + clickhouse_stub = + stub(Plausible.Stats.Clickhouse, :current_visitors, fn _site, _query -> 10 end) + |> stub(:top_sources, fn _site, _query, _limit, _page, _show_noref -> [] end) + + SpikeNotifier.perform(nil, clickhouse_stub) + + assert_email_delivered_with(html_body: ~r/View dashboard: Date: Tue, 8 Nov 2022 19:17:47 +0200 Subject: [PATCH 02/13] add a default base_email layout to every email --- lib/plausible_web/email.ex | 12 +++++++++- .../templates/layout/base_email.html.eex | 24 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 lib/plausible_web/templates/layout/base_email.html.eex diff --git a/lib/plausible_web/email.ex b/lib/plausible_web/email.ex index 08568f929..70041a0a7 100644 --- a/lib/plausible_web/email.ex +++ b/lib/plausible_web/email.ex @@ -305,11 +305,21 @@ defmodule PlausibleWeb.Email do }) end - defp base_email() do + defp base_email(), do: base_email(%{layout: "base_email.html"}) + + defp base_email(%{layout: layout}) do mailer_from = Application.get_env(:plausible, :mailer_email) new_email() |> put_param("TrackOpens", false) |> from(mailer_from) + |> maybe_put_layout(layout) + end + + defp maybe_put_layout(email, nil), do: email + + defp maybe_put_layout(email, layout) do + email + |> put_html_layout({PlausibleWeb.LayoutView, layout}) end end diff --git a/lib/plausible_web/templates/layout/base_email.html.eex b/lib/plausible_web/templates/layout/base_email.html.eex new file mode 100644 index 000000000..c13e1a21b --- /dev/null +++ b/lib/plausible_web/templates/layout/base_email.html.eex @@ -0,0 +1,24 @@ +<%= case Map.get(assigns, :user) do + %{name: name} when is_binary(name) -> "Hey #{String.split(name) |> List.first()}," + _any -> "Hey," +end %> +

+ +<%= @inner_content %> +

+ +Thanks,
+<%= if Application.get_env(:plausible, :is_selfhost) do %> +Plausible +<% else %> +Uku and Marko +<% end %> +

+ +-- +

+<%= link(plausible_url(), to: plausible_url()) %>
+ +<%= if Map.get(assigns, :unsubscribe, false) do %> +{{{ pm:unsubscribe }}} +<% end %> From 1d2a15ea28c7525849f099e2299e451762de00ce Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 8 Nov 2022 19:46:01 +0200 Subject: [PATCH 03/13] remove user salutations by @user as done by the layout --- lib/plausible_web/templates/email/activation_email.html.eex | 2 -- lib/plausible_web/templates/email/check_stats_email.html.eex | 2 -- lib/plausible_web/templates/email/create_site_email.html.eex | 2 -- lib/plausible_web/templates/email/dashboard_locked.html.eex | 2 -- .../templates/email/existing_user_invitation.html.eex | 2 -- .../templates/email/google_analytics_import.html.eex | 2 -- lib/plausible_web/templates/email/new_user_invitation.html.eex | 2 -- lib/plausible_web/templates/email/over_limit.html.eex | 2 -- .../templates/email/ownership_transfer_request.html.eex | 2 -- .../templates/email/site_setup_help_email.html.eex | 2 -- .../templates/email/site_setup_success_email.html.eex | 2 -- .../templates/email/trial_one_week_reminder.html.eex | 2 -- lib/plausible_web/templates/email/trial_over_email.html.eex | 2 -- lib/plausible_web/templates/email/trial_upgrade_email.html.eex | 2 -- lib/plausible_web/templates/email/welcome_email.html.eex | 2 -- .../templates/email/yearly_expiration_notification.html.eex | 2 -- .../templates/email/yearly_renewal_notification.html.eex | 2 -- 17 files changed, 34 deletions(-) diff --git a/lib/plausible_web/templates/email/activation_email.html.eex b/lib/plausible_web/templates/email/activation_email.html.eex index 66367c2f9..6373e81b8 100644 --- a/lib/plausible_web/templates/email/activation_email.html.eex +++ b/lib/plausible_web/templates/email/activation_email.html.eex @@ -1,3 +1 @@ -Hey <%= user_salutation(@user) %>, -

Enter <%= @code %> to verify your email address. This code will expire in 4 hours. diff --git a/lib/plausible_web/templates/email/check_stats_email.html.eex b/lib/plausible_web/templates/email/check_stats_email.html.eex index 5c746e628..8668825a6 100644 --- a/lib/plausible_web/templates/email/check_stats_email.html.eex +++ b/lib/plausible_web/templates/email/check_stats_email.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

Plausible is tracking your website stats without compromising the user experience and the privacy of your visitors.

<%= link("View your Plausible dashboard now", to: "#{plausible_url()}") %> for the most valuable traffic insights at a glance. diff --git a/lib/plausible_web/templates/email/create_site_email.html.eex b/lib/plausible_web/templates/email/create_site_email.html.eex index e34eafb26..ce1700407 100644 --- a/lib/plausible_web/templates/email/create_site_email.html.eex +++ b/lib/plausible_web/templates/email/create_site_email.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

You've activated your free 30-day trial of Plausible, a simple and privacy-friendly website analytics tool.

<%= link("Click here", to: "#{plausible_url()}/sites/new") %> to add your website URL, your timezone and install our one-line JavaScript snippet to start collecting visitor statistics. diff --git a/lib/plausible_web/templates/email/dashboard_locked.html.eex b/lib/plausible_web/templates/email/dashboard_locked.html.eex index 67b9d867a..b82c0afa0 100644 --- a/lib/plausible_web/templates/email/dashboard_locked.html.eex +++ b/lib/plausible_web/templates/email/dashboard_locked.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

Last week we sent a reminder that your traffic has exceeded your Plausible Analytics subscription tier two months in a row.

Your dashboard is now locked. We're still counting your stats, but you no longer have access to the stats. As you have outgrown your subscription tier, we kindly ask you to upgrade your subscription to accommodate your new traffic levels. diff --git a/lib/plausible_web/templates/email/existing_user_invitation.html.eex b/lib/plausible_web/templates/email/existing_user_invitation.html.eex index c1bc0354b..3d2335d11 100644 --- a/lib/plausible_web/templates/email/existing_user_invitation.html.eex +++ b/lib/plausible_web/templates/email/existing_user_invitation.html.eex @@ -1,5 +1,3 @@ -Hey, -

<%= @invitation.inviter.email %> has invited you to the <%= @invitation.site.domain %> site on Plausible Analytics. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :index)) %> to view and respond to the invitation. The invitation will expire 48 hours after this email is sent. diff --git a/lib/plausible_web/templates/email/google_analytics_import.html.eex b/lib/plausible_web/templates/email/google_analytics_import.html.eex index 388db86e5..9a78d8b96 100644 --- a/lib/plausible_web/templates/email/google_analytics_import.html.eex +++ b/lib/plausible_web/templates/email/google_analytics_import.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

<%= if @success do %> Your Google Analytics import has completed successfully. The Plausible dashboard for <%= @site.domain %> now contains historical imported data from <%= date_format(@site.imported_data.start_date) %> to <%= date_format(@site.imported_data.end_date) %>

diff --git a/lib/plausible_web/templates/email/new_user_invitation.html.eex b/lib/plausible_web/templates/email/new_user_invitation.html.eex index d21a004ab..67476dacb 100644 --- a/lib/plausible_web/templates/email/new_user_invitation.html.eex +++ b/lib/plausible_web/templates/email/new_user_invitation.html.eex @@ -1,5 +1,3 @@ -Hey, -

<%= @invitation.inviter.email %> has invited you to join the <%= @invitation.site.domain %> site on Plausible Analytics. <%= link("Click here", to: Routes.auth_url(PlausibleWeb.Endpoint, :register_from_invitation_form, @invitation.invitation_id)) %> to create your account. The link is valid for 48 hours after this email is sent.

diff --git a/lib/plausible_web/templates/email/over_limit.html.eex b/lib/plausible_web/templates/email/over_limit.html.eex index f0ebea30d..248ad13ef 100644 --- a/lib/plausible_web/templates/email/over_limit.html.eex +++ b/lib/plausible_web/templates/email/over_limit.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

Thanks for being a Plausible Analytics subscriber!

This is a notice that your traffic has exceeded your subscription tier two months in a row. Congrats on all that traffic! diff --git a/lib/plausible_web/templates/email/ownership_transfer_request.html.eex b/lib/plausible_web/templates/email/ownership_transfer_request.html.eex index 1ba11000a..dad5fb8d8 100644 --- a/lib/plausible_web/templates/email/ownership_transfer_request.html.eex +++ b/lib/plausible_web/templates/email/ownership_transfer_request.html.eex @@ -1,5 +1,3 @@ -Hey, -

<%= @invitation.inviter.email %> has requested to transfer the ownership of <%= @invitation.site.domain %> site on Plausible Analytics to you. <%= if @new_owner_account do %> <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :index)) %> to view and respond to the invitation. diff --git a/lib/plausible_web/templates/email/site_setup_help_email.html.eex b/lib/plausible_web/templates/email/site_setup_help_email.html.eex index 0f4b2b0a3..a6311ac32 100644 --- a/lib/plausible_web/templates/email/site_setup_help_email.html.eex +++ b/lib/plausible_web/templates/email/site_setup_help_email.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

<%= if Plausible.Billing.on_trial?(@user) do %> You signed up for a free 30-day trial of Plausible, a simple and privacy-friendly website analytics tool.

diff --git a/lib/plausible_web/templates/email/site_setup_success_email.html.eex b/lib/plausible_web/templates/email/site_setup_success_email.html.eex index 0bf6b8654..7ed6e9322 100644 --- a/lib/plausible_web/templates/email/site_setup_success_email.html.eex +++ b/lib/plausible_web/templates/email/site_setup_success_email.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

Congrats! The Plausible script has been installed correctly on <%= link(@site.domain, to: "https://#{@site.domain}") %>. Your website traffic is now being tracked without compromising the user experience and the privacy of your visitors.

<%= link("Check your stats", to: "#{plausible_url()}/#{URI.encode_www_form(@site.domain)}") %> diff --git a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex index b28a4015a..20f8beb6b 100644 --- a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex +++ b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

Time flies! Your 30-day free trial of Plausible will end next week.

Over the last three weeks, I hope you got to experience the potential benefits of having website stats in a simple dashboard while respecting the privacy of your visitors, not annoying them with the cookie and privacy notices and still having a fast loading site. diff --git a/lib/plausible_web/templates/email/trial_over_email.html.eex b/lib/plausible_web/templates/email/trial_over_email.html.eex index 03148de0b..7e03c66d3 100644 --- a/lib/plausible_web/templates/email/trial_over_email.html.eex +++ b/lib/plausible_web/templates/email/trial_over_email.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

Your free Plausible trial has now expired. Upgrade your account to continue receiving valuable website traffic insights at a glance while respecting the privacy of your visitors and still having a fast loading site.

<%= link("Upgrade now", to: "#{plausible_url()}/billing/upgrade") %> diff --git a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex b/lib/plausible_web/templates/email/trial_upgrade_email.html.eex index 1c1dd960f..e150e251f 100644 --- a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex +++ b/lib/plausible_web/templates/email/trial_upgrade_email.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

Thanks for exploring Plausible, a simple and privacy-friendly alternative to Google Analytics. Your free 30-day trial is ending <%= @day %>, but you can keep using Plausible by upgrading to a paid plan.

In the last month, your account has used <%= PlausibleWeb.AuthView.delimit_integer(@usage) %> billable pageviews<%= if @custom_events > 0, do: " and custom events in total", else: "" %>. diff --git a/lib/plausible_web/templates/email/welcome_email.html.eex b/lib/plausible_web/templates/email/welcome_email.html.eex index 044290e2d..11c1f4e96 100644 --- a/lib/plausible_web/templates/email/welcome_email.html.eex +++ b/lib/plausible_web/templates/email/welcome_email.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

We are building Plausible to provide a simple and ethical approach to tracking website visitors. We're super excited to have you on board!

diff --git a/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex b/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex index d3103dc35..de60070d7 100644 --- a/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex +++ b/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

Time flies! This is a reminder that your annual subscription for Plausible Analytics will expire on <%= @date %>.

You need to renew your subscription on <%= link("account settings page", to: "#{plausible_url()}/billing/upgrade") %> if you want to continue using Plausible to count your website stats in a privacy-friendly way. diff --git a/lib/plausible_web/templates/email/yearly_renewal_notification.html.eex b/lib/plausible_web/templates/email/yearly_renewal_notification.html.eex index b08c45efd..f1d695a18 100644 --- a/lib/plausible_web/templates/email/yearly_renewal_notification.html.eex +++ b/lib/plausible_web/templates/email/yearly_renewal_notification.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@user) %>, -

Time flies! This is a reminder that your annual subscription for Plausible Analytics is due to renew on <%= @date %>. We will automatically charge <%= PlausibleWeb.BillingView.present_currency(@currency) %><%= @next_bill_amount %> from your preferred billing method.

There's no action required if you're happy to continue using Plausible to count your website stats in a privacy-friendly way. From a45580099dc14e169286196c5fd8569aefaf8ba0 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 8 Nov 2022 19:58:53 +0200 Subject: [PATCH 04/13] replace other salutation cases and make sure @user available in assigns --- lib/plausible_web/email.ex | 7 ++++++- .../templates/email/cancellation_email.html.eex | 2 -- .../templates/email/invitation_accepted.html.eex | 2 -- .../templates/email/invitation_rejected.html.eex | 2 -- .../templates/email/ownership_transfer_accepted.html.eex | 2 -- .../templates/email/ownership_transfer_rejected.html.eex | 2 -- .../templates/email/site_member_removed.html.eex | 2 -- 7 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/plausible_web/email.ex b/lib/plausible_web/email.ex index 70041a0a7..6e84653ec 100644 --- a/lib/plausible_web/email.ex +++ b/lib/plausible_web/email.ex @@ -188,7 +188,7 @@ defmodule PlausibleWeb.Email do |> to(user.email) |> tag("cancelled-email") |> subject("Your Plausible Analytics subscription has been canceled") - |> render("cancellation_email.html", name: user.name) + |> render("cancellation_email.html", user: user) end def new_user_invitation(invitation) do @@ -230,6 +230,7 @@ defmodule PlausibleWeb.Email do "[Plausible Analytics] #{invitation.email} accepted your invitation to #{invitation.site.domain}" ) |> render("invitation_accepted.html", + user: invitation.inviter, invitation: invitation ) end @@ -242,6 +243,7 @@ defmodule PlausibleWeb.Email do "[Plausible Analytics] #{invitation.email} rejected your invitation to #{invitation.site.domain}" ) |> render("invitation_rejected.html", + user: invitation.inviter, invitation: invitation ) end @@ -254,6 +256,7 @@ defmodule PlausibleWeb.Email do "[Plausible Analytics] #{invitation.email} accepted the ownership transfer of #{invitation.site.domain}" ) |> render("ownership_transfer_accepted.html", + user: invitation.inviter, invitation: invitation ) end @@ -266,6 +269,7 @@ defmodule PlausibleWeb.Email do "[Plausible Analytics] #{invitation.email} rejected the ownership transfer of #{invitation.site.domain}" ) |> render("ownership_transfer_rejected.html", + user: invitation.inviter, invitation: invitation ) end @@ -276,6 +280,7 @@ defmodule PlausibleWeb.Email do |> tag("site-member-removed") |> subject("[Plausible Analytics] Your access to #{membership.site.domain} has been revoked") |> render("site_member_removed.html", + user: membership.user, membership: membership ) end diff --git a/lib/plausible_web/templates/email/cancellation_email.html.eex b/lib/plausible_web/templates/email/cancellation_email.html.eex index 119e46001..4575ed608 100644 --- a/lib/plausible_web/templates/email/cancellation_email.html.eex +++ b/lib/plausible_web/templates/email/cancellation_email.html.eex @@ -1,5 +1,3 @@ -Hi <%= @name %>, -

Thanks for being a Plausible Analytics subscriber and I'm sorry to see you go.

I'd love to hear about your experience and how you think we can improve Plausible Analytics for our other subscribers (and for you if you decide to come back). Please reply back to this email with your feedback.

diff --git a/lib/plausible_web/templates/email/invitation_accepted.html.eex b/lib/plausible_web/templates/email/invitation_accepted.html.eex index f437183d2..121afa379 100644 --- a/lib/plausible_web/templates/email/invitation_accepted.html.eex +++ b/lib/plausible_web/templates/email/invitation_accepted.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@invitation.inviter) %>, -

<%= @invitation.email %> has accepted your invitation to <%= @invitation.site.domain %>. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings.

diff --git a/lib/plausible_web/templates/email/invitation_rejected.html.eex b/lib/plausible_web/templates/email/invitation_rejected.html.eex index ef40174ba..09e9641c4 100644 --- a/lib/plausible_web/templates/email/invitation_rejected.html.eex +++ b/lib/plausible_web/templates/email/invitation_rejected.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@invitation.inviter) %>, -

<%= @invitation.email %> has rejected your invitation to <%= @invitation.site.domain %>. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings.

diff --git a/lib/plausible_web/templates/email/ownership_transfer_accepted.html.eex b/lib/plausible_web/templates/email/ownership_transfer_accepted.html.eex index 1d8dcf53c..36f0596fe 100644 --- a/lib/plausible_web/templates/email/ownership_transfer_accepted.html.eex +++ b/lib/plausible_web/templates/email/ownership_transfer_accepted.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@invitation.inviter) %>, -

<%= @invitation.email %> has accepted the ownership transfer of <%= @invitation.site.domain %>. They will be responsible for billing of it going forward and your role has been changed to admin. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings. diff --git a/lib/plausible_web/templates/email/ownership_transfer_rejected.html.eex b/lib/plausible_web/templates/email/ownership_transfer_rejected.html.eex index b67ca63e0..497e3f1eb 100644 --- a/lib/plausible_web/templates/email/ownership_transfer_rejected.html.eex +++ b/lib/plausible_web/templates/email/ownership_transfer_rejected.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@invitation.inviter) %>, -

<%= @invitation.email %> has rejected the ownership transfer of <%= @invitation.site.domain %>. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings.

diff --git a/lib/plausible_web/templates/email/site_member_removed.html.eex b/lib/plausible_web/templates/email/site_member_removed.html.eex index 1634b7dcf..35bffc2c0 100644 --- a/lib/plausible_web/templates/email/site_member_removed.html.eex +++ b/lib/plausible_web/templates/email/site_member_removed.html.eex @@ -1,5 +1,3 @@ -Hey <%= user_salutation(@membership.user) %>, -

An administrator of <%= @membership.site.domain %> has removed you as a member. You won't be able to see the stats anymore.

<%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :index)) %> to view your sites. From eaf61ff1702a474120761311cdb1098e333ad92f Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 9 Nov 2022 09:50:38 +0200 Subject: [PATCH 05/13] set unsubscribe flags for unsubscribable emails --- lib/plausible_web/email.ex | 28 +++++++++++++------ .../email/check_stats_email.html.eex | 1 - .../email/create_site_email.html.eex | 1 - .../templates/email/over_limit.html.eex | 1 - .../email/site_setup_help_email.html.eex | 1 - .../email/site_setup_success_email.html.eex | 1 - .../email/trial_one_week_reminder.html.eex | 1 - .../templates/email/trial_over_email.html.eex | 1 - .../email/trial_upgrade_email.html.eex | 1 - .../templates/email/welcome_email.html.eex | 1 - 10 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/plausible_web/email.ex b/lib/plausible_web/email.ex index 6e84653ec..0c9ac82fb 100644 --- a/lib/plausible_web/email.ex +++ b/lib/plausible_web/email.ex @@ -19,7 +19,7 @@ defmodule PlausibleWeb.Email do |> to(user) |> tag("welcome-email") |> subject("Welcome to Plausible") - |> render("welcome_email.html", user: user) + |> render("welcome_email.html", user: user, unsubscribe: true) end def create_site_email(user) do @@ -27,7 +27,7 @@ defmodule PlausibleWeb.Email do |> to(user) |> tag("create-site-email") |> subject("Your Plausible setup: Add your website details") - |> render("create_site_email.html", user: user) + |> render("create_site_email.html", user: user, unsubscribe: true) end def site_setup_help(user, site) do @@ -35,7 +35,11 @@ defmodule PlausibleWeb.Email do |> to(user) |> tag("help-email") |> subject("Your Plausible setup: Waiting for the first page views") - |> render("site_setup_help_email.html", user: user, site: site) + |> render("site_setup_help_email.html", + user: user, + site: site, + unsubscribe: true + ) end def site_setup_success(user, site) do @@ -43,7 +47,11 @@ defmodule PlausibleWeb.Email do |> to(user) |> tag("setup-success-email") |> subject("Plausible is now tracking your website stats") - |> render("site_setup_success_email.html", user: user, site: site) + |> render("site_setup_success_email.html", + user: user, + site: site, + unsubscribe: true + ) end def check_stats_email(user) do @@ -51,7 +59,7 @@ defmodule PlausibleWeb.Email do |> to(user) |> tag("check-stats-email") |> subject("Check your Plausible website stats") - |> render("check_stats_email.html", user: user) + |> render("check_stats_email.html", user: user, unsubscribe: true) end def password_reset_email(email, reset_link) do @@ -67,7 +75,7 @@ defmodule PlausibleWeb.Email do |> to(user) |> tag("trial-one-week-reminder") |> subject("Your Plausible trial expires next week") - |> render("trial_one_week_reminder.html", user: user) + |> render("trial_one_week_reminder.html", user: user, unsubscribe: true) end def trial_upgrade_email(user, day, {pageviews, custom_events}) do @@ -82,7 +90,8 @@ defmodule PlausibleWeb.Email do day: day, custom_events: custom_events, usage: pageviews + custom_events, - suggested_plan: suggested_plan + suggested_plan: suggested_plan, + unsubscribe: true ) end @@ -91,7 +100,7 @@ defmodule PlausibleWeb.Email do |> to(user) |> tag("trial-over-email") |> subject("Your Plausible trial has ended") - |> render("trial_over_email.html", user: user) + |> render("trial_over_email.html", user: user, unsubscribe: true) end def weekly_report(email, site, assigns) do @@ -124,7 +133,8 @@ defmodule PlausibleWeb.Email do user: user, usage: usage, last_cycle: last_cycle, - suggested_plan: suggested_plan + suggested_plan: suggested_plan, + unsubscribe: true }) end diff --git a/lib/plausible_web/templates/email/check_stats_email.html.eex b/lib/plausible_web/templates/email/check_stats_email.html.eex index 8668825a6..f97107c8e 100644 --- a/lib/plausible_web/templates/email/check_stats_email.html.eex +++ b/lib/plausible_web/templates/email/check_stats_email.html.eex @@ -10,4 +10,3 @@ Uku Taht --

<%= plausible_url() %>
-{{{ pm:unsubscribe }}} diff --git a/lib/plausible_web/templates/email/create_site_email.html.eex b/lib/plausible_web/templates/email/create_site_email.html.eex index ce1700407..04f5c1861 100644 --- a/lib/plausible_web/templates/email/create_site_email.html.eex +++ b/lib/plausible_web/templates/email/create_site_email.html.eex @@ -8,4 +8,3 @@ Thanks,
Uku and Marko
--
<%= plausible_url() %>
-{{{ pm:unsubscribe }}} diff --git a/lib/plausible_web/templates/email/over_limit.html.eex b/lib/plausible_web/templates/email/over_limit.html.eex index 248ad13ef..d521e228b 100644 --- a/lib/plausible_web/templates/email/over_limit.html.eex +++ b/lib/plausible_web/templates/email/over_limit.html.eex @@ -23,4 +23,3 @@ Thanks,
Uku and Marko
--
<%= plausible_url() %>
-{{{ pm:unsubscribe }}} diff --git a/lib/plausible_web/templates/email/site_setup_help_email.html.eex b/lib/plausible_web/templates/email/site_setup_help_email.html.eex index a6311ac32..d830c8128 100644 --- a/lib/plausible_web/templates/email/site_setup_help_email.html.eex +++ b/lib/plausible_web/templates/email/site_setup_help_email.html.eex @@ -12,4 +12,3 @@ Thanks,
Uku and Marko
--
<%= plausible_url() %>
-{{{ pm:unsubscribe }}} diff --git a/lib/plausible_web/templates/email/site_setup_success_email.html.eex b/lib/plausible_web/templates/email/site_setup_success_email.html.eex index 7ed6e9322..afe22adad 100644 --- a/lib/plausible_web/templates/email/site_setup_success_email.html.eex +++ b/lib/plausible_web/templates/email/site_setup_success_email.html.eex @@ -14,4 +14,3 @@ Thanks,
Uku and Marko
--
<%= plausible_url() %>
-{{{ pm:unsubscribe }}} diff --git a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex index 20f8beb6b..3564a41ff 100644 --- a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex +++ b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex @@ -10,4 +10,3 @@ Thanks,
Uku and Marko
--
<%= plausible_url() %>
-{{{ pm:unsubscribe }}} diff --git a/lib/plausible_web/templates/email/trial_over_email.html.eex b/lib/plausible_web/templates/email/trial_over_email.html.eex index 7e03c66d3..43502281b 100644 --- a/lib/plausible_web/templates/email/trial_over_email.html.eex +++ b/lib/plausible_web/templates/email/trial_over_email.html.eex @@ -10,4 +10,3 @@ Thanks,
Uku and Marko
--
<%= plausible_url() %>
-{{{ pm:unsubscribe }}} diff --git a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex b/lib/plausible_web/templates/email/trial_upgrade_email.html.eex index e150e251f..81f1b69fc 100644 --- a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex +++ b/lib/plausible_web/templates/email/trial_upgrade_email.html.eex @@ -15,4 +15,3 @@ Thanks,
Uku and Marko
--
<%= plausible_url() %>
-{{{ pm:unsubscribe }}} diff --git a/lib/plausible_web/templates/email/welcome_email.html.eex b/lib/plausible_web/templates/email/welcome_email.html.eex index 11c1f4e96..c9b86ff0e 100644 --- a/lib/plausible_web/templates/email/welcome_email.html.eex +++ b/lib/plausible_web/templates/email/welcome_email.html.eex @@ -20,4 +20,3 @@ Uku and Marko --
<%= plausible_url() %>
-{{{ pm:unsubscribe }}} From ff16aa9df8f7017cef12c39aa7595ae87d821de2 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 9 Nov 2022 10:20:12 +0200 Subject: [PATCH 06/13] remove all repeated email footers --- .../templates/email/cancellation_email.html.eex | 3 +-- .../templates/email/check_stats_email.html.eex | 7 ------- .../templates/email/create_site_email.html.eex | 5 ----- .../templates/email/dashboard_locked.html.eex | 5 ----- .../email/enterprise_over_limit_internal.html.eex | 3 --- .../templates/email/existing_user_invitation.html.eex | 5 ----- .../templates/email/google_analytics_import.html.eex | 10 +--------- .../templates/email/invitation_accepted.html.eex | 5 ----- .../templates/email/invitation_rejected.html.eex | 5 ----- .../templates/email/new_user_invitation.html.eex | 5 ----- lib/plausible_web/templates/email/over_limit.html.eex | 5 ----- .../email/ownership_transfer_accepted.html.eex | 5 ----- .../email/ownership_transfer_rejected.html.eex | 5 ----- .../email/ownership_transfer_request.html.eex | 5 ----- .../templates/email/site_member_removed.html.eex | 5 ----- .../templates/email/site_setup_help_email.html.eex | 5 ----- .../templates/email/site_setup_success_email.html.eex | 5 ----- .../templates/email/spike_notification.html.eex | 4 ---- .../templates/email/trial_one_week_reminder.html.eex | 5 ----- .../templates/email/trial_over_email.html.eex | 6 ------ .../templates/email/trial_upgrade_email.html.eex | 5 ----- .../templates/email/welcome_email.html.eex | 7 ------- .../email/yearly_expiration_notification.html.eex | 5 ----- .../email/yearly_renewal_notification.html.eex | 5 ----- 24 files changed, 2 insertions(+), 123 deletions(-) diff --git a/lib/plausible_web/templates/email/cancellation_email.html.eex b/lib/plausible_web/templates/email/cancellation_email.html.eex index 4575ed608..7e82602be 100644 --- a/lib/plausible_web/templates/email/cancellation_email.html.eex +++ b/lib/plausible_web/templates/email/cancellation_email.html.eex @@ -4,5 +4,4 @@ I'd love to hear about your experience and how you think we can improve Plausibl If you decide you'd like to continue keeping track of your site traffic while respecting the privacy of your visitors, obviously we'd love to have you back. You can restart your subscription from your
account settings.

-Hope to see you around!
-Uku Taht +Hope to see you around! diff --git a/lib/plausible_web/templates/email/check_stats_email.html.eex b/lib/plausible_web/templates/email/check_stats_email.html.eex index f97107c8e..a6432e656 100644 --- a/lib/plausible_web/templates/email/check_stats_email.html.eex +++ b/lib/plausible_web/templates/email/check_stats_email.html.eex @@ -3,10 +3,3 @@ Plausible is tracking your website stats without compromising the user experienc <%= link("View your Plausible dashboard now", to: "#{plausible_url()}") %> for the most valuable traffic insights at a glance.

Do reply back to this email if you have any questions or need some guidance. -

-Thanks,
-Uku Taht -

--- -

-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/create_site_email.html.eex b/lib/plausible_web/templates/email/create_site_email.html.eex index 04f5c1861..d6c2ca196 100644 --- a/lib/plausible_web/templates/email/create_site_email.html.eex +++ b/lib/plausible_web/templates/email/create_site_email.html.eex @@ -3,8 +3,3 @@ You've activated your free 30-day trial of Plausible, a simple and privacy-frien <%= link("Click here", to: "#{plausible_url()}/sites/new") %> 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. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/dashboard_locked.html.eex b/lib/plausible_web/templates/email/dashboard_locked.html.eex index b82c0afa0..b3c870c9f 100644 --- a/lib/plausible_web/templates/email/dashboard_locked.html.eex +++ b/lib/plausible_web/templates/email/dashboard_locked.html.eex @@ -14,8 +14,3 @@ Based on that we recommend you select the <%= @suggested_plan[:volume] %>/mo pla The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire. We will unlock your dashboard immediately after your account has been upgraded to the appropriate tier.

Thanks for understanding and for being a Plausible subscriber! -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/enterprise_over_limit_internal.html.eex b/lib/plausible_web/templates/email/enterprise_over_limit_internal.html.eex index af82475e0..2ee4f37e4 100644 --- a/lib/plausible_web/templates/email/enterprise_over_limit_internal.html.eex +++ b/lib/plausible_web/templates/email/enterprise_over_limit_internal.html.eex @@ -4,6 +4,3 @@ Customer email: <%= @user.email %>
Last billing cycle: <%= date_format(@last_cycle.first) %> to <%= date_format(@last_cycle.last) %>
Pageview Usage: <%= PlausibleWeb.StatsView.large_number_format(@usage) %> billable pageviews
Site usage: <%= @site_usage %> / <%= @site_allowance %> allowed sites
- ---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/existing_user_invitation.html.eex b/lib/plausible_web/templates/email/existing_user_invitation.html.eex index 3d2335d11..3bdd91a18 100644 --- a/lib/plausible_web/templates/email/existing_user_invitation.html.eex +++ b/lib/plausible_web/templates/email/existing_user_invitation.html.eex @@ -1,8 +1,3 @@ <%= @invitation.inviter.email %> has invited you to the <%= @invitation.site.domain %> site on Plausible Analytics. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :index)) %> to view and respond to the invitation. The invitation will expire 48 hours after this email is sent. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/google_analytics_import.html.eex b/lib/plausible_web/templates/email/google_analytics_import.html.eex index 9a78d8b96..a99c2f91a 100644 --- a/lib/plausible_web/templates/email/google_analytics_import.html.eex +++ b/lib/plausible_web/templates/email/google_analytics_import.html.eex @@ -29,14 +29,6 @@ <%= if !Application.get_env(:plausible, :is_selfhost) do %>

- - Please reply to this email to let us know if you're still experiencing issues with the import. Thanks! -

- - The Plausible Team 💌 + Please reply to this email to let us know if you're still experiencing issues with the import. <% end %> <% end %> -

--- -

-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/invitation_accepted.html.eex b/lib/plausible_web/templates/email/invitation_accepted.html.eex index 121afa379..5717ce262 100644 --- a/lib/plausible_web/templates/email/invitation_accepted.html.eex +++ b/lib/plausible_web/templates/email/invitation_accepted.html.eex @@ -1,7 +1,2 @@ <%= @invitation.email %> has accepted your invitation to <%= @invitation.site.domain %>. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/invitation_rejected.html.eex b/lib/plausible_web/templates/email/invitation_rejected.html.eex index 09e9641c4..b6c520690 100644 --- a/lib/plausible_web/templates/email/invitation_rejected.html.eex +++ b/lib/plausible_web/templates/email/invitation_rejected.html.eex @@ -1,7 +1,2 @@ <%= @invitation.email %> has rejected your invitation to <%= @invitation.site.domain %>. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/new_user_invitation.html.eex b/lib/plausible_web/templates/email/new_user_invitation.html.eex index 67476dacb..ffef74616 100644 --- a/lib/plausible_web/templates/email/new_user_invitation.html.eex +++ b/lib/plausible_web/templates/email/new_user_invitation.html.eex @@ -2,8 +2,3 @@ <%= link("Click here", to: Routes.auth_url(PlausibleWeb.Endpoint, :register_from_invitation_form, @invitation.invitation_id)) %> to create your account. The link is valid for 48 hours after this email is sent.

Plausible is a lightweight and open-source website analytics tool. We hope you like our simple and ethical approach to tracking website visitors. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/over_limit.html.eex b/lib/plausible_web/templates/email/over_limit.html.eex index d521e228b..01fbb54bb 100644 --- a/lib/plausible_web/templates/email/over_limit.html.eex +++ b/lib/plausible_web/templates/email/over_limit.html.eex @@ -18,8 +18,3 @@ You can upgrade your subscription using our self-serve platform. The new charge Have questions or need help with anything? Just reply to this email and we'll gladly help.

Thanks again for using our product and for your support! -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/ownership_transfer_accepted.html.eex b/lib/plausible_web/templates/email/ownership_transfer_accepted.html.eex index 36f0596fe..c8c274007 100644 --- a/lib/plausible_web/templates/email/ownership_transfer_accepted.html.eex +++ b/lib/plausible_web/templates/email/ownership_transfer_accepted.html.eex @@ -1,8 +1,3 @@ <%= @invitation.email %> has accepted the ownership transfer of <%= @invitation.site.domain %>. They will be responsible for billing of it going forward and your role has been changed to admin. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/ownership_transfer_rejected.html.eex b/lib/plausible_web/templates/email/ownership_transfer_rejected.html.eex index 497e3f1eb..14deeacb3 100644 --- a/lib/plausible_web/templates/email/ownership_transfer_rejected.html.eex +++ b/lib/plausible_web/templates/email/ownership_transfer_rejected.html.eex @@ -1,7 +1,2 @@ <%= @invitation.email %> has rejected the ownership transfer of <%= @invitation.site.domain %>. <%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/ownership_transfer_request.html.eex b/lib/plausible_web/templates/email/ownership_transfer_request.html.eex index dad5fb8d8..13ce240f5 100644 --- a/lib/plausible_web/templates/email/ownership_transfer_request.html.eex +++ b/lib/plausible_web/templates/email/ownership_transfer_request.html.eex @@ -6,8 +6,3 @@

Plausible is a lightweight and open-source website analytics tool. We hope you like our simple and ethical approach to tracking website visitors. <% end %> -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/site_member_removed.html.eex b/lib/plausible_web/templates/email/site_member_removed.html.eex index 35bffc2c0..eacdb5dff 100644 --- a/lib/plausible_web/templates/email/site_member_removed.html.eex +++ b/lib/plausible_web/templates/email/site_member_removed.html.eex @@ -1,8 +1,3 @@ An administrator of <%= @membership.site.domain %> has removed you as a member. You won't be able to see the stats anymore.

<%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :index)) %> to view your sites. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/site_setup_help_email.html.eex b/lib/plausible_web/templates/email/site_setup_help_email.html.eex index d830c8128..a49b55912 100644 --- a/lib/plausible_web/templates/email/site_setup_help_email.html.eex +++ b/lib/plausible_web/templates/email/site_setup_help_email.html.eex @@ -7,8 +7,3 @@ To finish your setup for <%= @site.domain %>, you need to install <%= link("this This Plausible script is 45 times smaller than Google Analytics script so you’ll have a fast loading site while getting all the important traffic insights on one single page.

Do reply back to this email if you have any questions or need some guidance. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/site_setup_success_email.html.eex b/lib/plausible_web/templates/email/site_setup_success_email.html.eex index afe22adad..fed91eabc 100644 --- a/lib/plausible_web/templates/email/site_setup_success_email.html.eex +++ b/lib/plausible_web/templates/email/site_setup_success_email.html.eex @@ -9,8 +9,3 @@ Congrats! The Plausible script has been installed correctly on <%= link(@site.do PS: You can import your historical Google Analytics (Universal Analytics) stats into your Plausible dashboard. <%= link("Learn how our GA importer works", to: "https://plausible.io/docs/google-analytics-import") %>.

Do reply back to this email if you have any questions. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/spike_notification.html.eex b/lib/plausible_web/templates/email/spike_notification.html.eex index 2243ca1bd..f1fc4871b 100644 --- a/lib/plausible_web/templates/email/spike_notification.html.eex +++ b/lib/plausible_web/templates/email/spike_notification.html.eex @@ -12,7 +12,3 @@ There are currently <%= @current_visitors %> visitors on <%= link(@site.domain,

View dashboard: <%= link(@link, to: @link) %> <% end %> -

--- -

-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex index 3564a41ff..2a6b17b2b 100644 --- a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex +++ b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex @@ -5,8 +5,3 @@ Over the last three weeks, I hope you got to experience the potential benefits o In order to continue receiving valuable website traffic insights at a glance, you’ll need to <%= link("Upgrade your account", to: "#{plausible_url()}/billing/upgrade") %>.

If you have any questions or feedback for me, feel free to reply to this email. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/trial_over_email.html.eex b/lib/plausible_web/templates/email/trial_over_email.html.eex index 43502281b..7c8981b8f 100644 --- a/lib/plausible_web/templates/email/trial_over_email.html.eex +++ b/lib/plausible_web/templates/email/trial_over_email.html.eex @@ -4,9 +4,3 @@ Your free Plausible trial has now expired. Upgrade your account to continue rece

We will keep recording stats for another month to give you time to upgrade. - -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex b/lib/plausible_web/templates/email/trial_upgrade_email.html.eex index 81f1b69fc..5f6ce642b 100644 --- a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex +++ b/lib/plausible_web/templates/email/trial_upgrade_email.html.eex @@ -10,8 +10,3 @@ Have a question, feedback or need some guidance? Just reply to this email to get <% else %> This is more than our standard plans, so please reply back to this email to get a quote for your volume. <% end %> -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/welcome_email.html.eex b/lib/plausible_web/templates/email/welcome_email.html.eex index c9b86ff0e..785d7c71d 100644 --- a/lib/plausible_web/templates/email/welcome_email.html.eex +++ b/lib/plausible_web/templates/email/welcome_email.html.eex @@ -13,10 +13,3 @@ Here's how to get the most out of your Plausible experience: Then you're ready to start exploring your fast loading, ethical and actionable <%= link("Plausible dashboard", to: "https://plausible.io/sites") %>.

Have a question, feedback or need some guidance? Do reply back to this email. -

-Thanks,
-Uku and Marko -
--- -
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex b/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex index de60070d7..6a4009c10 100644 --- a/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex +++ b/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex @@ -5,8 +5,3 @@ You need to renew your subscription on <%= link("account settings page", to: "#{ If you don't want to continue your subscription, there's no action required. You will lose access to the stats on <%= @date %>.

Have a question, feedback or need some guidance? Just reply to this email to get in touch! -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
diff --git a/lib/plausible_web/templates/email/yearly_renewal_notification.html.eex b/lib/plausible_web/templates/email/yearly_renewal_notification.html.eex index f1d695a18..879e52491 100644 --- a/lib/plausible_web/templates/email/yearly_renewal_notification.html.eex +++ b/lib/plausible_web/templates/email/yearly_renewal_notification.html.eex @@ -5,8 +5,3 @@ There's no action required if you're happy to continue using Plausible to count If you don't want to continue your subscription, you can cancel it on your <%= link("account settings page", to: "#{plausible_url()}/settings") %>.

Have a question, feedback or need some guidance? Do reply back to this email. -

-Thanks,
-Uku and Marko
---
-<%= plausible_url() %>
From 69f846fb075593f0d2e726790e334aa458d1e0f6 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 9 Nov 2022 11:12:53 +0200 Subject: [PATCH 07/13] do not use default layout in some emails --- lib/plausible_web/email.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plausible_web/email.ex b/lib/plausible_web/email.ex index 0c9ac82fb..22fdc6695 100644 --- a/lib/plausible_web/email.ex +++ b/lib/plausible_web/email.ex @@ -63,7 +63,7 @@ defmodule PlausibleWeb.Email do end def password_reset_email(email, reset_link) do - base_email() + base_email(%{layout: nil}) |> to(email) |> tag("password-reset-email") |> subject("Plausible password reset") @@ -104,7 +104,7 @@ defmodule PlausibleWeb.Email do end def weekly_report(email, site, assigns) do - base_email() + base_email(%{layout: nil}) |> to(email) |> tag("weekly-report") |> subject("#{assigns[:name]} report for #{site.domain}") From d6125ffeb1d09f58e7fbef195d874de59f37fcf9 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 9 Nov 2022 16:05:42 +0200 Subject: [PATCH 08/13] add tests for base_email template --- lib/plausible_web/email.ex | 4 +- test/plausible_web/email_test.exs | 68 +++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 test/plausible_web/email_test.exs diff --git a/lib/plausible_web/email.ex b/lib/plausible_web/email.ex index 22fdc6695..382eb47bc 100644 --- a/lib/plausible_web/email.ex +++ b/lib/plausible_web/email.ex @@ -320,9 +320,9 @@ defmodule PlausibleWeb.Email do }) end - defp base_email(), do: base_email(%{layout: "base_email.html"}) + def base_email(), do: base_email(%{layout: "base_email.html"}) - defp base_email(%{layout: layout}) do + def base_email(%{layout: layout}) do mailer_from = Application.get_env(:plausible, :mailer_email) new_email() diff --git a/test/plausible_web/email_test.exs b/test/plausible_web/email_test.exs new file mode 100644 index 000000000..578d8c386 --- /dev/null +++ b/test/plausible_web/email_test.exs @@ -0,0 +1,68 @@ +defmodule PlausibleWeb.EmailTest do + alias PlausibleWeb.Email + use ExUnit.Case, async: true + import Plausible.Factory + + describe "base_email layout" do + test "greets user by first name if user in template assigns" do + email = + Email.base_email() + |> Email.render("activation_email.html", %{ + user: build(:user, name: "John Doe"), + code: "123" + }) + + assert email.html_body =~ "Hey John," + end + + test "greets impersonally when user not in template assigns" do + email = + Email.base_email() + |> Email.render("password_reset_email.html", %{ + reset_link: "imaginary" + }) + + assert email.html_body =~ "Hey," + end + + test "renders plausible link" do + email = + Email.base_email() + |> Email.render("cancellation_email.html") + + assert email.html_body =~ plausible_link() + end + + test "does not render unsubscribe placeholder by default" do + email = + Email.base_email() + |> Email.render("welcome_email.html") + + refute email.html_body =~ "{{{ pm:unsubscribe }}}" + end + + test "renders unsubscribe placeholder if told" do + email = + Email.base_email() + |> Email.render("welcome_email.html", %{unsubscribe: true}) + + assert email.html_body =~ "{{{ pm:unsubscribe }}}" + end + + test "can be disabled with a nil layout" do + email = + Email.base_email(%{layout: nil}) + |> Email.render("welcome_email.html", %{ + user: build(:user, name: "John Doe") + }) + + refute email.html_body =~ "Hey John," + refute email.html_body =~ plausible_link() + end + end + + def plausible_link() do + plausible_url = PlausibleWeb.EmailView.plausible_url() + "#{plausible_url}" + end +end From 37c927287e844cb57725297299bd995403eb06ca Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 10 Nov 2022 10:31:32 +0200 Subject: [PATCH 09/13] speak on behalf of 'we' not 'I' --- lib/plausible_web/templates/email/cancellation_email.html.eex | 4 ++-- .../templates/email/trial_one_week_reminder.html.eex | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/plausible_web/templates/email/cancellation_email.html.eex b/lib/plausible_web/templates/email/cancellation_email.html.eex index 7e82602be..746e314f7 100644 --- a/lib/plausible_web/templates/email/cancellation_email.html.eex +++ b/lib/plausible_web/templates/email/cancellation_email.html.eex @@ -1,6 +1,6 @@ -Thanks for being a Plausible Analytics subscriber and I'm sorry to see you go.

+Thanks for being a Plausible Analytics subscriber and we're sorry to see you go.

-I'd love to hear about your experience and how you think we can improve Plausible Analytics for our other subscribers (and for you if you decide to come back). Please reply back to this email with your feedback.

+We'd love to hear about your experience and how you think we can improve Plausible Analytics for our other subscribers (and for you if you decide to come back). Please reply back to this email with your feedback.

If you decide you'd like to continue keeping track of your site traffic while respecting the privacy of your visitors, obviously we'd love to have you back. You can restart your subscription from your account settings.

diff --git a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex index 2a6b17b2b..740880955 100644 --- a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex +++ b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex @@ -1,7 +1,7 @@ Time flies! Your 30-day free trial of Plausible will end next week.

-Over the last three weeks, I hope you got to experience the potential benefits of having website stats in a simple dashboard while respecting the privacy of your visitors, not annoying them with the cookie and privacy notices and still having a fast loading site. +Over the last three weeks, We hope you got to experience the potential benefits of having website stats in a simple dashboard while respecting the privacy of your visitors, not annoying them with the cookie and privacy notices and still having a fast loading site.

In order to continue receiving valuable website traffic insights at a glance, you’ll need to <%= link("Upgrade your account", to: "#{plausible_url()}/billing/upgrade") %>.

-If you have any questions or feedback for me, feel free to reply to this email. +If you have any questions or feedback for us, feel free to reply to this email. From 92df3b257748962d436e7b98438eb5aa6203a186 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 10 Nov 2022 10:32:33 +0200 Subject: [PATCH 10/13] do not use default layout in internal email --- lib/plausible_web/email.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plausible_web/email.ex b/lib/plausible_web/email.ex index 382eb47bc..5387f8408 100644 --- a/lib/plausible_web/email.ex +++ b/lib/plausible_web/email.ex @@ -139,7 +139,7 @@ defmodule PlausibleWeb.Email do end def enterprise_over_limit_internal_email(user, usage, last_cycle, site_usage, site_allowance) do - base_email() + base_email(%{layout: nil}) |> to("enterprise@plausible.io") |> tag("enterprise-over-limit") |> subject("#{user.email} has outgrown their enterprise plan") From f9fc0a741e38beeefc90ae9dae7a4fdeedf729ce Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 10 Nov 2022 15:52:55 +0200 Subject: [PATCH 11/13] use EmailView function for greeting user and change layout email signature --- .../templates/layout/base_email.html.eex | 13 +++---------- lib/plausible_web/views/email_view.ex | 10 ++++------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/lib/plausible_web/templates/layout/base_email.html.eex b/lib/plausible_web/templates/layout/base_email.html.eex index c13e1a21b..5fd940ad9 100644 --- a/lib/plausible_web/templates/layout/base_email.html.eex +++ b/lib/plausible_web/templates/layout/base_email.html.eex @@ -1,18 +1,11 @@ -<%= case Map.get(assigns, :user) do - %{name: name} when is_binary(name) -> "Hey #{String.split(name) |> List.first()}," - _any -> "Hey," -end %> +<%= PlausibleWeb.EmailView.greet_recipient(assigns) %>

<%= @inner_content %>

-Thanks,
-<%= if Application.get_env(:plausible, :is_selfhost) do %> -Plausible -<% else %> -Uku and Marko -<% end %> +Regards,
+The Plausible Team 💌

-- diff --git a/lib/plausible_web/views/email_view.ex b/lib/plausible_web/views/email_view.ex index 5d43bd667..dddf17005 100644 --- a/lib/plausible_web/views/email_view.ex +++ b/lib/plausible_web/views/email_view.ex @@ -13,14 +13,12 @@ defmodule PlausibleWeb.EmailView do PlausibleWeb.Endpoint.host() end - def user_salutation(user) do - if user.name do - String.split(user.name) |> List.first() - else - "" - end + def greet_recipient(%{user: %{name: name}}) when is_binary(name) do + "Hey #{String.split(name) |> List.first()}," end + def greet_recipient(_), do: "Hey," + def date_format(date) do Timex.format!(date, "{D} {Mshort} {YYYY}") end From 27e8d8db3c2dedb947ba81596bd4cc51f7742884 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 10 Nov 2022 15:55:33 +0200 Subject: [PATCH 12/13] remove redundant test --- test/plausible_web/views/email_view_test.exs | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 test/plausible_web/views/email_view_test.exs diff --git a/test/plausible_web/views/email_view_test.exs b/test/plausible_web/views/email_view_test.exs deleted file mode 100644 index 37521055d..000000000 --- a/test/plausible_web/views/email_view_test.exs +++ /dev/null @@ -1,16 +0,0 @@ -defmodule PlausibleWeb.EmailViewTest do - use PlausibleWeb.ConnCase, async: true - alias PlausibleWeb.EmailView - - describe "user salutation" do - test "picks first name if full name has two parts" do - user1 = %Plausible.Auth.User{name: "Jane"} - user2 = %Plausible.Auth.User{name: "Jane Doe"} - user3 = %Plausible.Auth.User{name: "Jane Alice Doe"} - - assert EmailView.user_salutation(user1) == "Jane" - assert EmailView.user_salutation(user2) == "Jane" - assert EmailView.user_salutation(user3) == "Jane" - end - end -end From 061d0412135e2e60a9dbd3bcceb235118e10e168 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 10 Nov 2022 16:08:16 +0200 Subject: [PATCH 13/13] small addition to spike_notification email --- lib/plausible_web/templates/email/spike_notification.html.eex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/plausible_web/templates/email/spike_notification.html.eex b/lib/plausible_web/templates/email/spike_notification.html.eex index f1fc4871b..1b7b031d8 100644 --- a/lib/plausible_web/templates/email/spike_notification.html.eex +++ b/lib/plausible_web/templates/email/spike_notification.html.eex @@ -12,3 +12,6 @@ There are currently <%= @current_visitors %> visitors on <%= link(@site.domain,

View dashboard: <%= link(@link, to: @link) %> <% end %> +

+ +Congrats on the spike in traffic!