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
List only premium features on the CRM (#3530)
Vinicius Brasil0175158e8101
diff --git a/lib/plausible/billing/ecto/feature.ex b/lib/plausible/billing/ecto/feature.exindex 98ac24e8c5..a1356f2e7c 100644--- a/lib/plausible/billing/ecto/feature.ex+++ b/lib/plausible/billing/ecto/feature.ex@@ -49,7 +49,7 @@ defmodule Plausible.Billing.Ecto.FeatureList dofeatures = Ecto.Changeset.get_field(changeset, field)checkboxes =- for mod <- Plausible.Billing.Feature.list() do+ for mod <- Plausible.Billing.Feature.list(), not mod.free?() do[{:safe, ~s(<label style="padding-right: 15px;">)},Phoenix.HTML.Tag.tag(diff --git a/lib/plausible/billing/feature.ex b/lib/plausible/billing/feature.exindex 3c5ed0b47c..16008950bc 100644--- a/lib/plausible/billing/feature.ex+++ b/lib/plausible/billing/feature.ex@@ -38,6 +38,11 @@ defmodule Plausible.Billing.Feature do"""@callback toggle_field() :: atom()+ @doc """+ Returns whether the feature is free to use or not.+ """+ @callback free?() :: boolean()+@doc """Toggles the feature on and off for a site. Returns`{:error, :upgrade_required}` when toggling a feature the site owner does not@@ -87,6 +92,9 @@ defmodule Plausible.Billing.Feature do@impl truedef toggle_field, do: Keyword.get(unquote(opts), :toggle_field)+ @impl true+ def free?, do: Keyword.get(unquote(opts), :free, false)+@impl truedef enabled?(%Plausible.Site{} = site) dosite = Plausible.Repo.preload(site, :owner)@@ -101,7 +109,7 @@ defmodule Plausible.Billing.Feature do@impl truedef check_availability(%Plausible.Auth.User{} = user) docond do- Keyword.get(unquote(opts), :free) -> :ok+ free?() -> :ok__MODULE__ in Quota.allowed_features_for(user) -> :oktrue -> {:error, :upgrade_required}end