From c5e4fb50d586967773c66ff1b75c514246486123 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 25 Jun 2020 12:31:54 +0300 Subject: [PATCH] Include new plans in trial upgrade email --- .../email/trial_upgrade_email.html.eex | 11 ++-- .../templates/layout/_tracking.html.eex | 2 +- lib/plausible_web/views/email_view.ex | 44 ++++++++++---- .../workers/send_trial_notifications_test.exs | 58 +++++++++++++++++++ 4 files changed, 100 insertions(+), 15 deletions(-) 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 aa6e79395..1a8f64c7b 100644 --- a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex +++ b/lib/plausible_web/templates/email/trial_upgrade_email.html.eex @@ -3,14 +3,17 @@ 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(@pageviews) %> pageviews. -<%= if @pageviews < 900_000 do %> - Based on that we recommend you select the <%= suggested_plan_name(@pageviews) %> plan which runs at <%= suggested_plan_cost(@pageviews) %>. - You can also go with yearly billing to get 33% off on your plan. -<% end %> +<%= if @pageviews <= 4_500_000 do %> +Based on that we recommend you select the <%= suggested_plan_name(@pageviews) %> plan which runs at <%= suggested_plan_cost(@pageviews) %>. + +You can also go with yearly billing to get 33% off on your plan.

<%= link("Upgrade now", to: "#{plausible_url()}/billing/upgrade") %>

Have a question, feedback or need some guidance? Just reply to this email to get in touch! +<% else %> +This is more than our standard plans, so please reply back to this email to get a quote for your volume. +<% end %>



Thanks,
diff --git a/lib/plausible_web/templates/layout/_tracking.html.eex b/lib/plausible_web/templates/layout/_tracking.html.eex index ddd286600..9b068c724 100644 --- a/lib/plausible_web/templates/layout/_tracking.html.eex +++ b/lib/plausible_web/templates/layout/_tracking.html.eex @@ -1,4 +1,4 @@ <%= if !@conn.assigns[:skip_plausible_tracking] do %> -<% end %> \ No newline at end of file +<% end %> diff --git a/lib/plausible_web/views/email_view.ex b/lib/plausible_web/views/email_view.ex index 5548506b7..6e4342140 100644 --- a/lib/plausible_web/views/email_view.ex +++ b/lib/plausible_web/views/email_view.ex @@ -23,14 +23,26 @@ defmodule PlausibleWeb.EmailView do def suggested_plan_name(usage) do cond do - usage < 9_000 -> - "Personal" + usage <= 9_000 -> + "10k/mo" - usage < 90_000 -> - "Startup" + usage <= 90_000 -> + "100k/mo" - usage < 900_000 -> - "Business" + usage <= 180_000 -> + "200k/mo" + + usage <= 450_000 -> + "500k/mo" + + usage <= 900_000 -> + "1m/mo" + + usage <= 1_800_000 -> + "2m/mo" + + usage <= 4_500_000 -> + "5m/mo" true -> throw("Huge account") @@ -39,14 +51,26 @@ defmodule PlausibleWeb.EmailView do def suggested_plan_cost(usage) do cond do - usage < 9_000 -> + usage <= 9_000 -> "$6/mo" - usage < 90_000 -> + usage <= 90_000 -> "$12/mo" - usage < 900_000 -> - "$36/mo" + usage <= 180_000 -> + "$18/mo" + + usage <= 450_000 -> + "$27/mo" + + usage <= 900_000 -> + "$48/mo" + + usage <= 1_800_000 -> + "$69/mo" + + usage <= 4_500_000 -> + "$99/mo" true -> throw("Huge account") diff --git a/test/workers/send_trial_notifications_test.exs b/test/workers/send_trial_notifications_test.exs index 619bd27b9..3612d7795 100644 --- a/test/workers/send_trial_notifications_test.exs +++ b/test/workers/send_trial_notifications_test.exs @@ -65,4 +65,62 @@ defmodule Plausible.Workers.SendTrialNotificationsTest do assert_no_emails_delivered() end end + + describe "Suggested plans" do + test "suggests 10k/mo plan" do + user = insert(:user) + + email = PlausibleWeb.Email.trial_upgrade_email(user, "today", 9_000) + assert email.html_body =~ "we recommend you select the 10k/mo plan which runs at $6/mo." + end + + test "suggests 100k/mo plan" do + user = insert(:user) + + email = PlausibleWeb.Email.trial_upgrade_email(user, "today", 90_000) + assert email.html_body =~ "we recommend you select the 100k/mo plan which runs at $12/mo." + end + + test "suggests 200k/mo plan" do + user = insert(:user) + + email = PlausibleWeb.Email.trial_upgrade_email(user, "today", 180_000) + assert email.html_body =~ "we recommend you select the 200k/mo plan which runs at $18/mo." + end + + test "suggests 500k/mo plan" do + user = insert(:user) + + email = PlausibleWeb.Email.trial_upgrade_email(user, "today", 450_000) + assert email.html_body =~ "we recommend you select the 500k/mo plan which runs at $27/mo." + end + + test "suggests 1m/mo plan" do + user = insert(:user) + + email = PlausibleWeb.Email.trial_upgrade_email(user, "today", 900_000) + assert email.html_body =~ "we recommend you select the 1m/mo plan which runs at $48/mo." + end + + test "suggests 2m/mo plan" do + user = insert(:user) + + email = PlausibleWeb.Email.trial_upgrade_email(user, "today", 1_800_000) + assert email.html_body =~ "we recommend you select the 2m/mo plan which runs at $69/mo." + end + + test "suggests 5m/mo plan" do + user = insert(:user) + + email = PlausibleWeb.Email.trial_upgrade_email(user, "today", 4_500_000) + assert email.html_body =~ "we recommend you select the 5m/mo plan which runs at $99/mo." + end + + test "does not suggest a plan above that" do + user = insert(:user) + + email = PlausibleWeb.Email.trial_upgrade_email(user, "today", 10_000_000) + assert email.html_body =~ "please reply back to this email to get a quote for your volume" + end + end end