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
Legacy plans (#3455)
RobertJoonasa226773da163
diff --git a/lib/plausible/billing/plans.ex b/lib/plausible/billing/plans.exindex 93d2c84725..dd397db9ca 100644--- a/lib/plausible/billing/plans.ex+++ b/lib/plausible/billing/plans.ex@@ -5,12 +5,11 @@ defmodule Plausible.Billing.Plans doalias Plausible.Auth.Userfor f <- [+ :legacy_plans,:plans_v1,:plans_v2,:plans_v3,:plans_v4,- :unlisted_plans_v1,- :unlisted_plans_v2,:sandbox_plans] dopath = Application.app_dir(:plausible, ["priv", "#{f}.json"])@@ -41,7 +40,7 @@ defmodule Plausible.Billing.Plans doowned_plan = get_regular_plan(user.subscription)cond do- Application.get_env(:plausible, :environment) == "dev" -> plans_sandbox()+ Application.get_env(:plausible, :environment) == "dev" -> @sandbox_plans!owned_plan -> if v4_available, do: @plans_v4, else: @plans_v3owned_plan.kind == :business -> @plans_v4owned_plan.generation == 1 -> @plans_v1@@ -57,7 +56,7 @@ defmodule Plausible.Billing.Plans doowned_plan = get_regular_plan(user.subscription)cond do- Application.get_env(:plausible, :environment) == "dev" -> plans_sandbox()+ Application.get_env(:plausible, :environment) == "dev" -> @sandbox_plansowned_plan && owned_plan.generation < 4 -> @plans_v3true -> @plans_v4end@@ -80,12 +79,10 @@ defmodule Plausible.Billing.Plans dodo: yearly_product_idend- defp find(product_id, scope \\ all())+ defp find(nil), do: nil- defp find(nil, _scope), do: nil-- defp find(product_id, scope) do- Enum.find(scope, fn plan ->+ defp find(product_id) do+ Enum.find(all(), fn plan ->product_id in [plan.monthly_product_id, plan.yearly_product_id]end)end@@ -220,15 +217,6 @@ defmodule Plausible.Billing.Plans doenddefp all() do- @plans_v1 ++- @unlisted_plans_v1 ++- @plans_v2 ++ @unlisted_plans_v2 ++ @plans_v3 ++ @plans_v4 ++ plans_sandbox()- end-- defp plans_sandbox() do- case Application.get_env(:plausible, :environment) do- "dev" -> @sandbox_plans- _ -> []- end+ @legacy_plans ++ @plans_v1 ++ @plans_v2 ++ @plans_v3 ++ @plans_v4endenddiff --git a/priv/legacy_plans.json b/priv/legacy_plans.jsonnew file mode 100644index 0000000000..024807a6fd--- /dev/null+++ b/priv/legacy_plans.json@@ -0,0 +1,22 @@+[+ {+ "kind":"growth",+ "generation": 1,+ "monthly_pageview_limit":1000000,+ "yearly_product_id":"590753",+ "monthly_product_id":"558746",+ "site_limit":50,+ "team_member_limit":"unlimited",+ "features":["goals","props","stats_api"]+ },+ {+ "kind":"growth",+ "generation": 1,+ "monthly_pageview_limit":150000000,+ "yearly_product_id":"648089",+ "monthly_product_id":null,+ "site_limit":50,+ "team_member_limit":"unlimited",+ "features":["goals","props","stats_api"]+ }+]diff --git a/priv/unlisted_plans_v1.json b/priv/unlisted_plans_v1.jsondeleted file mode 100644index b7fd14b27a..0000000000--- a/priv/unlisted_plans_v1.json+++ /dev/null@@ -1,12 +0,0 @@-[- {- "kind":"growth",- "generation":1,- "monthly_pageview_limit":150000000,- "yearly_product_id":"648089",- "monthly_product_id":null,- "site_limit":50,- "team_member_limit":"unlimited",- "features":["goals","props"]- }-]diff --git a/priv/unlisted_plans_v2.json b/priv/unlisted_plans_v2.jsondeleted file mode 100644index ff635879b7..0000000000--- a/priv/unlisted_plans_v2.json+++ /dev/null@@ -1,12 +0,0 @@-[- {- "kind":"growth",- "generation":2,- "monthly_pageview_limit":10000000,- "monthly_product_id":"655350",- "yearly_product_id":null,- "site_limit":50,- "team_member_limit":"unlimited",- "features":["goals","props"]- }-]diff --git a/test/plausible/billing/plans_test.exs b/test/plausible/billing/plans_test.exsindex d0f18e32ad..f98dfdbf59 100644--- a/test/plausible/billing/plans_test.exs+++ b/test/plausible/billing/plans_test.exs@@ -2,6 +2,7 @@ defmodule Plausible.Billing.PlansTest douse Plausible.DataCase, async: truealias Plausible.Billing.Plans+ @legacy_plan_id "558746"@v1_plan_id "558018"@v2_plan_id "654177"@v4_plan_id "857097"@@ -9,6 +10,11 @@ defmodule Plausible.Billing.PlansTest do@v4_business_plan_id "857105"describe "getting subscription plans for user" do+ test "growth_plans_for/1 returns v1 plans for a user on a legacy plan" do+ user = insert(:user, subscription: build(:subscription, paddle_plan_id: @legacy_plan_id))+ assert List.first(Plans.growth_plans_for(user)).monthly_product_id == @v1_plan_id+ end+test "growth_plans_for/1 returns v1 plans for users who are already on v1 pricing" douser = insert(:user, subscription: build(:subscription, paddle_plan_id: @v1_plan_id))assert List.first(Plans.growth_plans_for(user)).monthly_product_id == @v1_plan_id@@ -40,7 +46,12 @@ defmodule Plausible.Billing.PlansTest doassert List.first(Plans.growth_plans_for(user)).monthly_product_id == @v4_plan_idend- test "business_plans_for/1 returns v3 business plans for a legacy subscriber" do+ test "business_plans_for/1 returns v3 business plans for a user on a legacy plan" do+ user = insert(:user, subscription: build(:subscription, paddle_plan_id: @legacy_plan_id))+ assert List.first(Plans.business_plans_for(user)).monthly_product_id == @v3_business_plan_id+ end++ test "business_plans_for/1 returns v3 business plans for a v2 subscriber" douser = insert(:user, subscription: build(:subscription, paddle_plan_id: @v2_plan_id))business_plans = Plans.business_plans_for(user)@@ -157,6 +168,8 @@ defmodule Plausible.Billing.PlansTest dodescribe "yearly_product_ids/0" dotest "lists yearly plan ids" doassert [+ "590753",+ "648089","572810","590752","597486",@@ -167,7 +180,6 @@ defmodule Plausible.Billing.PlansTest do"642354","642356","650653",- "648089","653232","653234","653236",diff --git a/test/plausible/billing/quota_test.exs b/test/plausible/billing/quota_test.exsindex 36542ba4cf..908d889048 100644--- a/test/plausible/billing/quota_test.exs+++ b/test/plausible/billing/quota_test.exs@@ -3,6 +3,7 @@ defmodule Plausible.Billing.QuotaTest doalias Plausible.Billing.Quotaalias Plausible.Billing.Feature.{Goals, RevenueGoals, Funnels, Props, StatsAPI}+ @legacy_plan_id "558746"@v1_plan_id "558018"@v2_plan_id "654177"@v3_plan_id "749342"@@ -115,6 +116,12 @@ defmodule Plausible.Billing.QuotaTest doenddescribe "monthly_pageview_limit/1" do+ test "is based on the plan if user is on a legacy plan" do+ user = insert(:user, subscription: build(:subscription, paddle_plan_id: @legacy_plan_id))++ assert Quota.monthly_pageview_limit(user.subscription) == 1_000_000+ end+test "is based on the plan if user is on a standard plan" douser = insert(:user, subscription: build(:subscription, paddle_plan_id: @v1_plan_id))