Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Clarify subscription (#289)

Uku Taht43b56d6e6133
diff --git a/lib/plausible_web/templates/auth/user_settings.html.eex b/lib/plausible_web/templates/auth/user_settings.html.eex
index b6b4ab7bfa..80d35476f0 100644
--- a/lib/plausible_web/templates/auth/user_settings.html.eex
+++ b/lib/plausible_web/templates/auth/user_settings.html.eex
@@ -32,9 +32,9 @@
<div class="flex flex-col items-center sm:flex-row sm:items-start justify-between mt-8">
<div class="text-center bg-gray-100 py-4 px-2 rounded h-32 my-4" style="width: 11.75rem;">
- <h4 class="font-black">Current plan</h4>
+ <h4 class="font-black">Monthly quota</h4>
<%= if @subscription do %>
- <div class="text-xl py-2 font-medium"><%= subscription_name(@subscription) %></div>
+ <div class="text-xl py-2 font-medium"><%= subscription_quota(@subscription) %> pageviews</div>
<%= case @subscription.status do %>
<% "active" -> %>
<%= link("Change plan", to: "/billing/change-plan", class: "text-sm text-indigo-500 font-medium") %>
@@ -63,6 +63,7 @@
<%= if @subscription && @subscription.next_bill_date && @subscription.status in ["active", "past_due"] do %>
<div class="text-xl py-2 font-medium"><%= Timex.format!(@subscription.next_bill_date, "{Mshort} {D}, {YYYY}") %></div>
+ <div class="text-sm text-gray-600 font-medium">(<%= subscription_interval(@subscription) %> billing)</div>
<% else %>
<div class="text-xl py-2 font-medium">---</div>
<% end %>
diff --git a/lib/plausible_web/views/auth_view.ex b/lib/plausible_web/views/auth_view.ex
index f009fa4626..ee8190be1d 100644
--- a/lib/plausible_web/views/auth_view.ex
+++ b/lib/plausible_web/views/auth_view.ex
@@ -1,24 +1,27 @@
defmodule PlausibleWeb.AuthView do
use PlausibleWeb, :view
- @subscription_names %{
- "558018" => "10k / monthly",
- "558745" => "100k / monthly",
- "597485" => "200k / monthly",
- "597487" => "500k / monthly",
- "597642" => "1m / monthly",
- "558746" => "1m / monthly / grandfathered",
- "597309" => "2m / monthly",
- "597311" => "5m / monthly",
- "572810" => "10k / yearly",
- "590752" => "100k / yearly",
- "597486" => "200k / yearly",
- "597488" => "500k / yearly",
- "597643" => "1m / yearly",
- "590753" => "1m / yearly / grandfathered",
- "597310" => "2m / yearly",
- "597312" => "5m / yearly",
- "free_10k" => "10k / free"
+ @monthly_plans ["558018", "558745", "597485", "597487", "597642", "558746", "597309", "597311"]
+ @yearly_plans ["572810", "590752", "597486", "597488", "597643", "590753", "597310", "597312"]
+
+ @subscription_quotas %{
+ "558018" => "10k",
+ "558745" => "100k",
+ "597485" => "200k",
+ "597487" => "500k",
+ "597642" => "1m",
+ "558746" => "1m",
+ "597309" => "2m",
+ "597311" => "5m",
+ "572810" => "10k",
+ "590752" => "100k",
+ "597486" => "200k",
+ "597488" => "500k",
+ "597643" => "1m",
+ "590753" => "1m",
+ "597310" => "2m",
+ "597312" => "5m",
+ "free_10k" => "10k"
}
def admin_email do
@@ -33,8 +36,16 @@ defmodule PlausibleWeb.AuthView do
PlausibleWeb.Endpoint.clean_url()
end
- def subscription_name(subscription) do
- @subscription_names[subscription.paddle_plan_id]
+ def subscription_quota(subscription) do
+ @subscription_quotas[subscription.paddle_plan_id]
+ end
+
+ def subscription_interval(subscription) do
+ cond do
+ subscription.paddle_plan_id in @monthly_plans -> "monthly"
+ subscription.paddle_plan_id in @yearly_plans -> "yeary"
+ true -> raise "Unknown interval for subscription #{subscription.paddle_plan_id}"
+ end
end
def delimit_integer(number) do
diff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exs
index de2d3f0fe3..f7de934359 100644
--- a/test/plausible_web/controllers/auth_controller_test.exs
+++ b/test/plausible_web/controllers/auth_controller_test.exs
@@ -157,6 +157,13 @@ defmodule PlausibleWeb.AuthControllerTest do
conn = get(conn, "/settings")
assert html_response(conn, 200) =~ "Account settings"
end
+
+ test "shows subscription", %{conn: conn, user: user} do
+ insert(:subscription, paddle_plan_id: "558018", user: user)
+ conn = get(conn, "/settings")
+ assert html_response(conn, 200) =~ "10k pageviews"
+ assert html_response(conn, 200) =~ "monthly billing"
+ end
end
describe "PUT /settings" do