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
Fixing Business Tier related bugs (#3504)
RobertJoonas26d9e16d7dbc
diff --git a/lib/plausible_web/components/billing.ex b/lib/plausible_web/components/billing.exindex 33823e4942..d4abc1276f 100644--- a/lib/plausible_web/components/billing.ex+++ b/lib/plausible_web/components/billing.ex@@ -50,7 +50,7 @@ defmodule PlausibleWeb.Components.Billing donot has_access? ->~H"""<.notice class="rounded-t-md rounded-b-none" size={@size} {@rest}>- This account does not have access to <%= assigns.feature_mod.display_name() %>. To get access to this feature,+ <%= account_label(@current_user, @billable_user) %> does not have access to <%= assigns.feature_mod.display_name() %>. To get access to this feature,<.upgrade_call_to_action current_user={@current_user} billable_user={@billable_user} />.</.notice>"""@@ -80,6 +80,18 @@ defmodule PlausibleWeb.Components.Billing do# credo:disable-for-next-line Credo.Check.Refactor.CyclomaticComplexitydef limit_exceeded_notice(assigns) do+ ~H"""+ <.notice {@rest}>+ <%= account_label(@current_user, @billable_user) %> is limited to <%= @limit %> <%= @resource %>. To increase this limit,+ <.upgrade_call_to_action current_user={@current_user} billable_user={@billable_user} />.+ </.notice>+ """+ end++ attr(:current_user, :map)+ attr(:billable_user, :map)++ defp upgrade_call_to_action(assigns) dobillable_user = Plausible.Users.with_subscription(assigns.billable_user)plan =@@ -88,37 +100,28 @@ defmodule PlausibleWeb.Components.Billing dotrial? = Plausible.Billing.on_trial?(assigns.billable_user)growth? = plan && plan.kind == :growth- if growth? || trial? do- ~H"""- <.notice {@rest}>- This account is limited to <%= @limit %> <%= @resource %>. To increase this limit,- <.upgrade_call_to_action current_user={@current_user} billable_user={@billable_user} />.- </.notice>- """- else- ~H"""- <.notice {@rest}>- Your account is limited to <%= @limit %> <%= @resource %>. To increase this limit, please contact [email protected] about the Enterprise plan- </.notice>- """+ cond do+ assigns.billable_user.id !== assigns.current_user.id ->+ ~H"please reach out to the site owner to upgrade their subscription"++ growth? || trial? ->+ ~H"""+ please+ <.link class="underline inline-block" href={Plausible.Billing.upgrade_route_for(@current_user)}>+ upgrade your subscription+ </.link>+ """++ true ->+ ~H"please contact [email protected] about the Enterprise plan"endend- attr(:current_user, :map)- attr(:billable_user, :map)-- defp upgrade_call_to_action(assigns) do- if assigns.current_user.id == assigns.billable_user.id do- ~H"""- please- <.link class="underline" href={Plausible.Billing.upgrade_route_for(@current_user)}>- upgrade your subscription- </.link>- """+ defp account_label(current_user, billable_user) do+ if current_user.id == billable_user.id do+ "Your account"else- ~H"""- please reach out to the site owner to upgrade their subscription- """+ "The owner of this site"endenddiff --git a/lib/plausible_web/templates/site/new.html.heex b/lib/plausible_web/templates/site/new.html.heexindex a24059ff0a..9ca83c02e7 100644--- a/lib/plausible_web/templates/site/new.html.heex+++ b/lib/plausible_web/templates/site/new.html.heex@@ -3,6 +3,7 @@<h2 class="text-xl font-black dark:text-gray-100 mb-4">Your website details</h2><PlausibleWeb.Components.Billing.limit_exceeded_notice+ :if={Map.get(assigns, :is_at_limit, false)}current_user={@current_user}billable_user={@current_user}limit={Map.get(assigns, :site_limit, 0)}diff --git a/test/plausible_web/components/billing_test.exs b/test/plausible_web/components/billing_test.exsindex 9880c64cc0..befcf44e4e 100644--- a/test/plausible_web/components/billing_test.exs+++ b/test/plausible_web/components/billing_test.exs@@ -24,7 +24,7 @@ defmodule PlausibleWeb.Components.BillingTest dofeature_mod: Plausible.Billing.Feature.Props)- assert rendered =~ "This account does not have access to Custom Properties"+ assert rendered =~ "Your account does not have access to Custom Properties"assert rendered =~ "upgrade your subscription"assert rendered =~ "/billing/choose-plan"end@@ -40,7 +40,7 @@ defmodule PlausibleWeb.Components.BillingTest dofeature_mod: Plausible.Billing.Feature.Funnels)- assert rendered =~ "This account does not have access to Funnels"+ assert rendered =~ "The owner of this site does not have access to Funnels"assert rendered =~ "please reach out to the site owner to upgrade their subscription"end@@ -68,7 +68,7 @@ defmodule PlausibleWeb.Components.BillingTest doresource: "users")- assert rendered =~ "This account is limited to 10 users. To increase this limit"+ assert rendered =~ "Your account is limited to 10 users. To increase this limit"assert rendered =~ "upgrade your subscription"assert rendered =~ "/billing/choose-plan"end@@ -84,7 +84,7 @@ defmodule PlausibleWeb.Components.BillingTest doresource: "users")- assert rendered =~ "This account is limited to 10 users"+ assert rendered =~ "The owner of this site is limited to 10 users"assert rendered =~ "please reach out to the site owner to upgrade their subscription"end@@ -99,7 +99,7 @@ defmodule PlausibleWeb.Components.BillingTest doresource: "users")- assert rendered =~ "This account is limited to 10 users"+ assert rendered =~ "Your account is limited to 10 users"assert rendered =~ "upgrade your subscription"assert rendered =~ "/billing/choose-plan"end@@ -119,8 +119,8 @@ defmodule PlausibleWeb.Components.BillingTest doresource: "users")- assert rendered =~- "Your account is limited to 10 users. To increase this limit, please contact [email protected] about the Enterprise plan"+ assert rendered =~ "Your account is limited to 10 users."+ assert rendered =~ "please contact [email protected] about the Enterprise plan"endtest "limit_exceeded_notice/1 when billable user is on a business plan displays support email" do@@ -134,7 +134,7 @@ defmodule PlausibleWeb.Components.BillingTest doresource: "users")- assert rendered =~- "Your account is limited to 10 users. To increase this limit, please contact [email protected] about the Enterprise plan"+ assert rendered =~ "Your account is limited to 10 users."+ assert rendered =~ "please contact [email protected] about the Enterprise plan"endenddiff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exsindex 02bb233874..e7d4319824 100644--- a/test/plausible_web/controllers/site_controller_test.exs+++ b/test/plausible_web/controllers/site_controller_test.exs@@ -32,6 +32,21 @@ defmodule PlausibleWeb.SiteControllerTest dorefute html_response(conn, 200) =~ "Add site info"end++ test "does not display limit notice when user is on an enterprise plan", %{+ conn: conn,+ user: user+ } do+ ep = insert(:enterprise_plan, user: user)+ insert(:subscription, user: user, paddle_plan_id: ep.paddle_plan_id)++ insert(:site, members: [user])+ insert(:site, members: [user])+ insert(:site, members: [user])++ conn = get(conn, "/sites/new")+ refute html_response(conn, 200) =~ "is limited to"+ endenddescribe "GET /sites" do@@ -271,7 +286,7 @@ defmodule PlausibleWeb.SiteControllerTest do})assert html = html_response(conn, 200)- assert html =~ "This account is limited to 10 sites"+ assert html =~ "Your account is limited to 10 sites"refute Repo.get_by(Plausible.Site, domain: "over-limit.example.com")end