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
Bring back premium feature notices in tiles (#4742)
hq18bd32b68c9e4
diff --git a/lib/plausible/billing/enterprise_plan.ex b/lib/plausible/billing/enterprise_plan.exindex 2a224cce2d..9589c1e0d8 100644--- a/lib/plausible/billing/enterprise_plan.ex+++ b/lib/plausible/billing/enterprise_plan.ex@@ -2,6 +2,8 @@ defmodule Plausible.Billing.EnterprisePlan douse Ecto.Schemaimport Ecto.Changeset+ @type t() :: %__MODULE__{}+@required_fields [:user_id,:paddle_plan_id,diff --git a/lib/plausible/billing/plan.ex b/lib/plausible/billing/plan.exindex 78a6b8551c..132a7c585d 100644--- a/lib/plausible/billing/plan.ex+++ b/lib/plausible/billing/plan.ex@@ -4,7 +4,7 @@ defmodule Plausible.Billing.Plan douse Ecto.Schemaimport Ecto.Changeset- @type t() :: %__MODULE__{} | :enterprise+ @type t() :: %__MODULE__{}embedded_schema do# Due to grandfathering, we sometimes need to check the "generation" (e.g.diff --git a/lib/plausible/billing/plans.ex b/lib/plausible/billing/plans.exindex 901ed2d968..15f56e4964 100644--- a/lib/plausible/billing/plans.ex+++ b/lib/plausible/billing/plans.ex@@ -105,6 +105,8 @@ defmodule Plausible.Billing.Plans doend)end+ @spec get_subscription_plan(nil | Subscription.t()) ::+ nil | :free_10k | Plan.t() | EnterprisePlan.t()def get_subscription_plan(nil), do: nildef get_subscription_plan(subscription) dodiff --git a/lib/plausible_web/components/billing/notice.ex b/lib/plausible_web/components/billing/notice.exindex 409d4b4bcf..eafd5b28e4 100644--- a/lib/plausible_web/components/billing/notice.ex+++ b/lib/plausible_web/components/billing/notice.ex@@ -302,17 +302,24 @@ defmodule PlausibleWeb.Components.Billing.Notice dodefp upgrade_call_to_action(assigns) dobillable_user = Plausible.Users.with_subscription(assigns.billable_user)- plan =- Plans.get_regular_plan(billable_user.subscription, only_non_expired: true)-- trial? = Plausible.Users.on_trial?(assigns.billable_user)- growth? = plan && plan.kind == :growth+ upgrade_assistance_required? =+ case Plans.get_subscription_plan(billable_user.subscription) do+ %Plausible.Billing.Plan{kind: :business} -> true+ %Plausible.Billing.EnterprisePlan{} -> true+ _ -> false+ endcond doassigns.billable_user.id !== assigns.current_user.id ->~H"please reach out to the site owner to upgrade their subscription"- growth? || trial? ->+ upgrade_assistance_required? ->+ ~H"""+ please contact <a href="mailto:[email protected]" class="underline">[email protected]</a>+ to upgrade your subscription+ """++ true ->~H"""please<.link@@ -322,12 +329,6 @@ defmodule PlausibleWeb.Components.Billing.Notice doupgrade your subscription</.link>"""-- true ->- ~H"""- please contact <a href="mailto:[email protected]" class="underline">[email protected]</a>- to upgrade your subscription- """endenddiff --git a/lib/plausible_web/templates/site/settings_funnels.html.heex b/lib/plausible_web/templates/site/settings_funnels.html.heexindex d583c341a4..e668b3e21c 100644--- a/lib/plausible_web/templates/site/settings_funnels.html.heex+++ b/lib/plausible_web/templates/site/settings_funnels.html.heex@@ -12,12 +12,13 @@Compose Goals into Funnels</:subtitle>+ <PlausibleWeb.Components.Billing.Notice.premium_feature+ billable_user={@site.owner}+ current_user={@current_user}+ feature_mod={Plausible.Billing.Feature.Funnels}+ />+<div :if={Plausible.Billing.Feature.Funnels.enabled?(@site)}>- <PlausibleWeb.Components.Billing.Notice.premium_feature- billable_user={@site.owner}- current_user={@current_user}- feature_mod={Plausible.Billing.Feature.Funnels}- /><%= live_render(@conn, PlausibleWeb.Live.FunnelSettings,session: %{"site_id" => @site.id, "domain" => @site.domain}) %>diff --git a/lib/plausible_web/templates/site/settings_props.html.heex b/lib/plausible_web/templates/site/settings_props.html.heexindex 35ffc1a211..fe39e4cc62 100644--- a/lib/plausible_web/templates/site/settings_props.html.heex+++ b/lib/plausible_web/templates/site/settings_props.html.heex@@ -13,13 +13,14 @@create custom metrics.</:subtitle>+ <PlausibleWeb.Components.Billing.Notice.premium_feature+ billable_user={@site.owner}+ current_user={@current_user}+ feature_mod={Plausible.Billing.Feature.Props}+ grandfathered?+ />+<div :if={Plausible.Billing.Feature.Props.enabled?(@site)}>- <PlausibleWeb.Components.Billing.Notice.premium_feature- billable_user={@site.owner}- current_user={@current_user}- feature_mod={Plausible.Billing.Feature.Props}- grandfathered?- /><%= live_render(@conn, PlausibleWeb.Live.PropsSettings,id: "props-form",session: %{"site_id" => @site.id, "domain" => @site.domain}diff --git a/test/plausible_web/live/funnel_settings_test.exs b/test/plausible_web/live/funnel_settings_test.exsindex f46c714de9..245cae4752 100644--- a/test/plausible_web/live/funnel_settings_test.exs+++ b/test/plausible_web/live/funnel_settings_test.exs@@ -10,6 +10,18 @@ defmodule PlausibleWeb.Live.FunnelSettingsTest dodescribe "GET /:domain/settings/funnels" dosetup [:create_user, :log_in, :create_site]+ @tag :ee_only+ test "premium feature notice renders", %{conn: conn, site: site, user: user} do+ user+ |> Plausible.Auth.User.end_trial()+ |> Plausible.Repo.update!()++ conn = get(conn, "/#{site.domain}/settings/funnels")+ resp = conn |> html_response(200) |> text()++ assert resp =~ "please upgrade your subscription"+ end+test "lists funnels for the site and renders help link", %{conn: conn, site: site} do{:ok, _} = setup_funnels(site)conn = get(conn, "/#{site.domain}/settings/funnels")@@ -18,6 +30,8 @@ defmodule PlausibleWeb.Live.FunnelSettingsTest doassert resp =~ "Compose Goals into Funnels"assert resp =~ "From blog to signup"assert resp =~ "From signup to blog"+ refute resp =~ "Your account does not have access"+ refute resp =~ "please upgrade your subscription"assert element_exists?(resp, "a[href=\"https://plausible.io/docs/funnel-analysis\"]")enddiff --git a/test/plausible_web/live/props_settings_test.exs b/test/plausible_web/live/props_settings_test.exsindex 79b578d875..8154e38a7b 100644--- a/test/plausible_web/live/props_settings_test.exs+++ b/test/plausible_web/live/props_settings_test.exs@@ -6,6 +6,18 @@ defmodule PlausibleWeb.Live.PropsSettingsTest dodescribe "GET /:domain/settings/properties" dosetup [:create_user, :log_in, :create_site]+ @tag :ee_only+ test "premium feature notice renders", %{conn: conn, site: site, user: user} do+ user+ |> Plausible.Auth.User.end_trial()+ |> Plausible.Repo.update!()++ conn = get(conn, "/#{site.domain}/settings/properties")+ resp = conn |> html_response(200) |> text()++ assert resp =~ "please upgrade your subscription"+ end+test "lists props for the site and renders links", %{conn: conn, site: site} do{:ok, site} = Plausible.Props.allow(site, ["amount", "logged_in", "is_customer"])conn = get(conn, "/#{site.domain}/settings/properties")@@ -21,6 +33,7 @@ defmodule PlausibleWeb.Live.PropsSettingsTest doassert resp =~ "amount"assert resp =~ "logged_in"assert resp =~ "is_customer"+ refute resp =~ "please upgrade your subscription"endtest "lists props with disallow actions", %{conn: conn, site: site} do