Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Include new plans in trial upgrade email
Uku Tahtc5e4fb50d586
diff --git a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex b/lib/plausible_web/templates/email/trial_upgrade_email.html.eexindex aa6e79395e..1a8f64c7ba 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.<br /><br />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.<br /><br /><%= link("Upgrade now", to: "#{plausible_url()}/billing/upgrade") %><br /><br />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 %><br /><br /><br /><br />Thanks,<br />diff --git a/lib/plausible_web/templates/layout/_tracking.html.eex b/lib/plausible_web/templates/layout/_tracking.html.eexindex ddd2866004..9b068c7247 100644--- a/lib/plausible_web/templates/layout/_tracking.html.eex+++ b/lib/plausible_web/templates/layout/_tracking.html.eex@@ -1,4 +1,4 @@<%= if [email protected][:skip_plausible_tracking] do %><script async defer src="<%="#{plausible_url()}/js/plausible.js"%>"></script><script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>-<% 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.exindex 5548506b73..6e4342140a 100644--- a/lib/plausible_web/views/email_view.ex+++ b/lib/plausible_web/views/email_view.ex@@ -23,14 +23,26 @@ defmodule PlausibleWeb.EmailView dodef suggested_plan_name(usage) docond 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 dodef suggested_plan_cost(usage) docond 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.exsindex 619bd27b9a..3612d7795e 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 doassert_no_emails_delivered()endend++ 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+ endend