Remove business tier feature flag (#3632)

* Remove business tier feature flag

This commit removes all code branches related to the business tier
feature flag, as we're not flipping this flag off anymore. It also
removes unused routes, e.g. /billing/change-plan and /billing/upgrade

* remove unused billing templates

* refactor with clause to case instead

* assert on the url in email tests

---------

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
pull/3635/head
Vinicius Brasil 3 years ago committed by GitHub
parent 6639d6af63
commit 7f51928338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,11 +4,6 @@ defmodule Plausible.Billing do
require Plausible.Billing.Subscription.Status
alias Plausible.Billing.{Subscription, Plans, Quota}
def upgrade_route_for(user) do
action = if FunWithFlags.enabled?(:business_tier, for: user), do: :choose_plan, else: :upgrade
PlausibleWeb.Router.Helpers.billing_path(PlausibleWeb.Endpoint, action)
end
@spec active_subscription_for(integer()) :: Subscription.t() | nil
def active_subscription_for(user_id) do
user_id |> active_subscription_query() |> Repo.one()

@ -38,13 +38,11 @@ defmodule Plausible.Billing.Plans do
"""
def growth_plans_for(%User{} = user) do
user = Plausible.Users.with_subscription(user)
v4_available = FunWithFlags.enabled?(:business_tier, for: user)
owned_plan = get_regular_plan(user.subscription)
cond do
Application.get_env(:plausible, :environment) == "dev" -> @sandbox_plans
is_nil(owned_plan) && v4_available -> @plans_v4
is_nil(owned_plan) -> @plans_v3
is_nil(owned_plan) -> @plans_v4
user.subscription && Subscriptions.expired?(user.subscription) -> @plans_v4
owned_plan.kind == :business -> @plans_v4
owned_plan.generation == 1 -> @plans_v1

@ -64,7 +64,10 @@ defmodule PlausibleWeb.Components.Billing do
growth? || trial? ->
~H"""
please
<.link class="underline inline-block" href={Plausible.Billing.upgrade_route_for(@current_user)}>
<.link
class="underline inline-block"
href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}
>
upgrade your subscription
</.link>
"""
@ -256,7 +259,7 @@ defmodule PlausibleWeb.Components.Billing do
"""
end
def monthly_quota_box(%{business_tier: true} = assigns) do
def monthly_quota_box(assigns) do
~H"""
<div
id="monthly-quota-box"
@ -280,42 +283,6 @@ defmodule PlausibleWeb.Components.Billing do
"""
end
def monthly_quota_box(%{business_tier: false} = assigns) do
~H"""
<div
class="h-32 px-2 py-4 my-4 text-center bg-gray-100 rounded dark:bg-gray-900"
style="width: 11.75rem;"
>
<h4 class="font-black dark:text-gray-100">Monthly quota</h4>
<%= if @subscription do %>
<div class="py-2 text-xl font-medium dark:text-gray-100">
<%= PlausibleWeb.AuthView.subscription_quota(@subscription) %> pageviews
</div>
<.styled_link
:if={Subscription.Status.active?(@subscription)}
href={Routes.billing_path(PlausibleWeb.Endpoint, :change_plan_form)}
>
Change plan
</.styled_link>
<span
:if={Subscription.Status.past_due?(@subscription)}
class="text-sm text-gray-600 dark:text-gray-400 font-medium"
tooltip="Please update your billing details before changing plans"
>
Change plan
</span>
<% else %>
<div class="py-2 text-xl font-medium dark:text-gray-100">Free trial</div>
<.styled_link href={Routes.billing_path(PlausibleWeb.Endpoint, :upgrade)}>
Upgrade
</.styled_link>
<% end %>
</div>
"""
end
attr(:user, :map, required: true)
attr(:dismissable, :boolean, default: true)
@ -520,7 +487,7 @@ defmodule PlausibleWeb.Components.Billing do
"""
end
def upgrade_link(%{business_tier: true} = assigns) do
def upgrade_link(assigns) do
~H"""
<PlausibleWeb.Components.Generic.button_link
id="upgrade-link-2"
@ -531,20 +498,13 @@ defmodule PlausibleWeb.Components.Billing do
"""
end
def upgrade_link(assigns) do
~H"""
<PlausibleWeb.Components.Generic.button_link href={
Routes.billing_path(PlausibleWeb.Endpoint, :upgrade)
}>
Upgrade
</PlausibleWeb.Components.Generic.button_link>
"""
end
defp subscription_cancelled_notice_body(assigns) do
if Plausible.Billing.Subscriptions.expired?(assigns.user.subscription) do
~H"""
<.link class="underline inline-block" href={Plausible.Billing.upgrade_route_for(@user)}>
<.link
class="underline inline-block"
href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}
>
Upgrade your subscription
</.link>
to get access to your stats again.
@ -553,7 +513,10 @@ defmodule PlausibleWeb.Components.Billing do
~H"""
<p>
You have access to your stats until <span class="font-semibold inline"><%= Timex.format!(@user.subscription.next_bill_date, "{Mshort} {D}, {YYYY}") %></span>.
<.link class="underline inline-block" href={Plausible.Billing.upgrade_route_for(@user)}>
<.link
class="underline inline-block"
href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}
>
Upgrade your subscription
</.link>
to make sure you don't lose access.
@ -563,10 +526,9 @@ defmodule PlausibleWeb.Components.Billing do
end
end
defp lose_grandfathering_warning(%{user: %{subscription: subscription} = user} = assigns) do
business_tiers_available? = FunWithFlags.enabled?(:business_tier, for: user)
defp lose_grandfathering_warning(%{user: %{subscription: subscription}} = assigns) do
plan = Plans.get_regular_plan(subscription, only_non_expired: true)
loses_grandfathering = business_tiers_available? && plan && plan.generation < 4
loses_grandfathering = plan && plan.generation < 4
assigns = assign(assigns, :loses_grandfathering, loses_grandfathering)

@ -13,48 +13,18 @@ defmodule PlausibleWeb.BillingController do
json(conn, %{is_subscribed: subscribed?})
end
def upgrade(conn, _params) do
user = conn.assigns[:current_user]
cond do
Plausible.Auth.enterprise_configured?(user) ->
redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
FunWithFlags.enabled?(:business_tier, for: user) ->
redirect(conn, to: Routes.billing_path(conn, :choose_plan))
Subscription.Status.active?(user.subscription) ->
redirect(conn, to: Routes.billing_path(conn, :change_plan_form))
true ->
render(conn, "upgrade.html",
skip_plausible_tracking: true,
usage: Plausible.Billing.Quota.usage_cycle(user, :last_30_days).total,
user: user,
layout: {PlausibleWeb.LayoutView, "focus.html"}
)
end
end
def choose_plan(conn, _params) do
user = conn.assigns.current_user
if FunWithFlags.enabled?(:business_tier, for: user) do
if Plausible.Auth.enterprise_configured?(user) do
redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
else
render(conn, "choose_plan.html",
skip_plausible_tracking: true,
user: user,
layout: {PlausibleWeb.LayoutView, "focus.html"},
connect_live_socket: true
)
end
if Plausible.Auth.enterprise_configured?(user) do
redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
else
# This will be needed in case we need to flip back the flag.
# With the :business_tier flag enabled we'll have sent emails
# linking to `/billing/choose-plan`.
redirect(conn, to: Routes.billing_path(conn, :upgrade))
render(conn, "choose_plan.html",
skip_plausible_tracking: true,
user: user,
layout: {PlausibleWeb.LayoutView, "focus.html"},
connect_live_socket: true
)
end
end
@ -95,61 +65,23 @@ defmodule PlausibleWeb.BillingController do
end
end
def upgrade_enterprise_plan(conn, _params) do
# DEPRECATED - For some time we need to ensure that the existing
# links sent out to customers will lead the user to the right place
redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
end
def upgrade_success(conn, _params) do
render(conn, "upgrade_success.html", layout: {PlausibleWeb.LayoutView, "focus.html"})
end
def change_plan_form(conn, _params) do
user = conn.assigns[:current_user]
subscription = Billing.active_subscription_for(user.id)
cond do
FunWithFlags.enabled?(:business_tier, for: user) ->
render_error(conn, 404)
Plausible.Auth.enterprise_configured?(user) ->
redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
def change_plan_preview(conn, %{"plan_id" => new_plan_id}) do
user = conn.assigns.current_user
subscription ->
render(conn, "change_plan.html",
case preview_subscription(user, new_plan_id) do
{:ok, {subscription, preview_info}} ->
render(conn, "change_plan_preview.html",
back_link: Routes.billing_path(conn, :choose_plan),
skip_plausible_tracking: true,
subscription: subscription,
preview_info: preview_info,
layout: {PlausibleWeb.LayoutView, "focus.html"}
)
true ->
redirect(conn, to: Routes.billing_path(conn, :upgrade))
end
end
def change_enterprise_plan(conn, _params) do
# DEPRECATED - For some time we need to ensure that the existing
# links sent out to customers will lead the user to the right place
redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
end
def change_plan_preview(conn, %{"plan_id" => new_plan_id}) do
user = conn.assigns.current_user
business_tier_enabled? = FunWithFlags.enabled?(:business_tier, for: user)
with {:ok, {subscription, preview_info}} <- preview_subscription(user, new_plan_id) do
back_action = if business_tier_enabled?, do: :choose_plan, else: :change_plan_form
render(conn, "change_plan_preview.html",
back_link: Routes.billing_path(conn, back_action),
skip_plausible_tracking: true,
subscription: subscription,
preview_info: preview_info,
layout: {PlausibleWeb.LayoutView, "focus.html"}
)
else
_ ->
msg =
"Something went wrong with loading your plan change information. Please try again, or contact us at support@plausible.io if the issue persists."
@ -164,7 +96,7 @@ defmodule PlausibleWeb.BillingController do
conn
|> put_flash(:error, msg)
|> redirect(to: Plausible.Billing.upgrade_route_for(user))
|> redirect(to: Routes.billing_path(conn, :choose_plan))
end
end

@ -233,14 +233,10 @@ defmodule PlausibleWeb.Router do
get "/", PageController, :index
get "/billing/change-plan", BillingController, :change_plan_form
get "/billing/change-plan/preview/:plan_id", BillingController, :change_plan_preview
post "/billing/change-plan/:new_plan_id", BillingController, :change_plan
get "/billing/upgrade", BillingController, :upgrade
get "/billing/choose-plan", BillingController, :choose_plan
get "/billing/upgrade-to-enterprise-plan", BillingController, :upgrade_to_enterprise_plan
get "/billing/upgrade/enterprise/:plan_id", BillingController, :upgrade_enterprise_plan
get "/billing/change-plan/enterprise/:plan_id", BillingController, :change_enterprise_plan
get "/billing/upgrade-success", BillingController, :upgrade_success
get "/billing/subscription/ping", BillingController, :ping_subscription

@ -35,7 +35,6 @@
<PlausibleWeb.Components.Billing.monthly_quota_box
user={@user}
subscription={@subscription}
business_tier={FunWithFlags.enabled?(:business_tier, for: @user)}
/>
<div
class="h-32 px-2 py-4 my-4 text-center bg-gray-100 rounded dark:bg-gray-900"
@ -106,10 +105,7 @@
</div>
<% true -> %>
<div class="mt-8">
<PlausibleWeb.Components.Billing.upgrade_link
user={@user}
business_tier={FunWithFlags.enabled?(:business_tier, for: @user)}
/>
<PlausibleWeb.Components.Billing.upgrade_link user={@user} />
</div>
<% end %>
</div>

@ -1,7 +0,0 @@
<script type="text/javascript" src="https://cdn.paddle.com/paddle/paddle.js"></script>
<script>
<%= if Application.get_env(:plausible, :environment) == "dev" do %>
Paddle.Environment.set('sandbox');
<% end %>
Paddle.Setup({vendor: <%= Application.get_env(:plausible, :paddle) |> Keyword.fetch!(:vendor_id) %> });
</script>

@ -1,7 +0,0 @@
<tr @click="volume = '<%= @plan.volume %>'" :class="{'border-2 border-green-300 bg-opacity-20 bg-green-300': volume === '<%= @plan.volume %>', 'border-b border-gray-200 cursor-pointer': volume !== '<%= @plan.volume %>'}">
<td class="px-6 py-4 text-sm leading-5 dark:text-gray-100" :class="{'font-bold': volume === '<%= @plan.volume %>'}"><%= @plan.volume %></td>
<td class="px-6 py-4 text-sm leading-5 dark:text-gray-100" :class="{'font-bold': volume === '<%= @plan.volume %>'}">
<span x-show="billingCycle === 'monthly'"><span x-text="priceFor(<%= @plan.monthly_product_id %>)"></span> / mo</span>
<span x-cloak x-show="billingCycle === 'yearly'"><span x-text="priceFor(<%= @plan.yearly_product_id %>)"></span> / yr</span>
</td>
</tr>

@ -1,122 +0,0 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fetch-jsonp/1.1.3/fetch-jsonp.min.js"></script>
<script>
plans = function() {
return {
rawPlans: <%= raw Jason.encode!(Plausible.Billing.Plans.growth_plans_for(@conn.assigns[:current_user])) %>,
localizedPlans: null,
volume: '10k',
billingCycle: 'monthly',
selectedPlanPrice() {
return this.priceFor(this.selectedPlanProductId())
},
selectedPlanProductId() {
var selectedPlan = this.rawPlans.find((plan) => plan.volume === this.volume)
if (this.billingCycle === 'monthly'){
return selectedPlan.monthly_product_id
} else {
return selectedPlan.yearly_product_id
}
},
priceFor(productId) {
var plan = this.localizedPlans.find(plan => plan.product_id === Number(productId))
var currency = {
'USD': '$',
'EUR': '€',
'GBP': '£'
}[plan.currency]
return currency + plan.price.net
},
fetchPlans() {
var productIds = []
this.rawPlans.forEach((plan) => {
productIds.push(plan.monthly_product_id)
productIds.push(plan.yearly_product_id)
})
fetchJsonp('https://checkout.paddle.com/api/2.0/prices?product_ids=' + productIds.join(','))
.then((res) => res.json())
.then((data) => {
this.localizedPlans = data.response.products
})
}
}
}
</script>
<div class="mx-auto mt-6 text-center">
<h1 class="text-3xl font-black dark:text-gray-100">Change subscription plan</h1>
</div>
<div class="w-full max-w-lg px-4 mx-auto mt-4">
<div x-init="fetchPlans" x-data="plans()" class="flex-1 px-8 py-4 mt-8 mb-4 bg-white rounded shadow-md dark:bg-gray-800">
<div class="w-full pt-2 text-xl font-bold dark:text-gray-100">
Select your new plan
</div>
<div class="w-full text-sm text-gray-500 dark:text-gray-200">
Depending on which plan you choose, your card might be charged immediately and your
next payment date could change. You can preview these changes before committing.
</div>
<div class="pt-8"></div>
<span class="relative z-0 inline-flex w-full shadow-sm">
<button type="button" @click="billingCycle = 'monthly'" :class="{'bg-indigo-600 text-white border-indigo-600': billingCycle === 'monthly', 'bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:text-gray-500 dark:hover:text-gray-200 border-gray-300 dark:border-gray-500': billingCycle === 'yearly'}" class="relative w-full px-4 py-2 text-sm font-medium text-center border rounded-l-md leading-5 focus:outline-none focus:border-blue-300 focus:ring transition ease-in-out duration-150">
Monthly billing
</button>
<button type="button" @click="billingCycle = 'yearly'" :class="{'bg-indigo-600 text-white border-indigo-600': billingCycle === 'yearly', 'bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:text-gray-500 dark:hover:text-gray-200 border-gray-300 dark:border-gray-500': billingCycle === 'monthly'}" class="relative w-full px-4 py-2 -ml-px text-sm font-medium text-center border rounded-r-md leading-5 focus:outline-none focus:border-blue-300 focus:ring transition ease-in-out duration-150">
Yearly billing
</button>
</span>
<div class="pt-6"></div>
<template x-if="localizedPlans" class="flex flex-col">
<div class="py-2 -my-2 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8">
<div class="inline-block min-w-full overflow-hidden align-middle border-b border-gray-200 shadow sm:rounded-lg dark:border-t dark:border-l dark:border-r dark:shadow-none">
<table class="min-w-full">
<thead>
<tr>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase bg-gray-100 border-b border-gray-200 dark:bg-gray-900 leading-4 dark:text-gray-200">
Monthly pageviews
</th>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase bg-gray-100 border-b border-gray-200 dark:bg-gray-900 leading-4 dark:text-gray-200">
Price
</th>
</tr>
</thead>
<tbody class="bg-white dark:bg-gray-800">
<%= for plan <- Plausible.Billing.Plans.growth_plans_for(@conn.assigns[:current_user]) do %>
<%= render("_plan_option.html", plan: plan) %>
<% end %>
</tbody>
</table>
</div>
</div>
</template>
<div x-show="!localizedPlans" class="mx-auto my-56 loading sm"><div></div></div>
<div class="mt-6 text-right">
<span class="inline-flex rounded-md shadow-sm">
<a x-show="selectedPlanProductId() !== '<%= @subscription.paddle_plan_id %>'" style="display: none;" :href="'/billing/change-plan/preview/' + selectedPlanProductId()" class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-indigo-600 border border-transparent leading-5 rounded-md hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:ring active:bg-indigo-700 transition ease-in-out duration-150">
<svg fill="currentColor" viewBox="0 0 20 20" class="inline w-4 h-4 mr-2"><path d="M10 12a2 2 0 100-4 2 2 0 000 4z"></path><path fill-rule="evenodd" d="M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z" clip-rule="evenodd"></path></svg>
Preview changes
</a>
<a x-show="selectedPlanProductId() === '<%= @subscription.paddle_plan_id %>'" style="display: none;" tooltip="Select a different plan to continue" class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-gray-400 border border-transparent leading-5 rounded-md">
<svg fill="currentColor" viewBox="0 0 20 20" class="inline w-4 h-4 mr-2"><path d="M10 12a2 2 0 100-4 2 2 0 000 4z"></path><path fill-rule="evenodd" d="M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z" clip-rule="evenodd"></path></svg>
Preview changes
</a>
</span>
</div>
</div>
</div>
<div class="mt-8 text-center dark:text-gray-100">
Questions? <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-500") %>
</div>
<%= render("_paddle_script.html") %>

@ -80,5 +80,3 @@
<div class="text-center mt-8 dark:text-gray-100">
Questions? <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-500") %>
</div>
<%= render("_paddle_script.html") %>

@ -1,128 +0,0 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fetch-jsonp/1.1.3/fetch-jsonp.min.js"></script>
<script>
plans = function() {
return {
rawPlans: <%= raw Jason.encode!(Plausible.Billing.Plans.growth_plans_for(@user)) %>,
localizedPlans: null,
volume: '10k',
billingCycle: 'monthly',
selectedPlanPrice() {
return this.priceFor(this.selectedPlanProductId())
},
selectedPlanProductId() {
var selectedPlan = this.rawPlans.find((plan) => plan.volume === this.volume)
if (this.billingCycle === 'monthly'){
return selectedPlan.monthly_product_id
} else {
return selectedPlan.yearly_product_id
}
},
priceFor(productId) {
var plan = this.localizedPlans.find(plan => plan.product_id === Number(productId))
var currency = {
'USD': '$',
'EUR': '€',
'GBP': '£'
}[plan.currency]
return currency + plan.price.net
},
fetchPlans() {
var productIds = []
this.rawPlans.forEach((plan) => {
productIds.push(plan.monthly_product_id)
productIds.push(plan.yearly_product_id)
})
var checkoutDomain = '<%= Plausible.Billing.PaddleApi.checkout_domain() %>'
fetchJsonp(checkoutDomain + '/api/2.0/prices?product_ids=' + productIds.join(','))
.then((res) => res.json())
.then((data) => {
this.localizedPlans = data.response.products
})
}
}
}
</script>
<div class="mx-auto mt-6 text-center">
<h1 class="text-3xl font-black dark:text-gray-100">Upgrade your free trial</h1>
</div>
<div>
<div class="flex flex-col w-full max-w-4xl px-4 mx-auto mt-4 md:flex-row">
<div x-init="fetchPlans()" x-data="window.plans()" class="flex-1 px-8 py-4 mt-8 mb-4 bg-white rounded shadow-md dark:bg-gray-800">
<div class="w-full py-4 dark:text-gray-100">
<span>You've used <b><%= PlausibleWeb.AuthView.delimit_integer(@usage) %></b> billable pageviews in the last 30 days</span>
</div>
<div class="pt-2"></div>
<span class="relative z-0 inline-flex w-full shadow-sm">
<button type="button" @click="billingCycle = 'monthly'" :class="{'bg-indigo-600 text-white border-indigo-600': billingCycle === 'monthly', 'bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:text-gray-500 dark:hover:text-gray-200 border-gray-300 dark:border-gray-500': billingCycle === 'yearly'}" class="relative w-full px-4 py-2 text-sm font-medium text-center border rounded-l-md leading-5 focus:outline-none focus:border-blue-300 focus:ring transition ease-in-out duration-150">
Monthly billing
</button>
<button type="button" @click="billingCycle = 'yearly'" :class="{'bg-indigo-600 text-white border-indigo-600': billingCycle === 'yearly', 'bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:text-gray-500 dark:hover:text-gray-200 border-gray-300 dark:border-gray-500': billingCycle === 'monthly'}" class="relative w-full px-4 py-2 -ml-px text-sm font-medium text-center border rounded-r-md leading-5 focus:outline-none focus:border-blue-300 focus:ring transition ease-in-out duration-150">
Yearly billing
</button>
</span>
<div class="pt-6"></div>
<template x-if="localizedPlans" class="flex flex-col">
<div class="py-2 -my-2 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8">
<div class="inline-block min-w-full overflow-hidden align-middle border-b border-gray-200 shadow sm:rounded-lg dark:border-t dark:border-l dark:border-r dark:shadow-none">
<table class="min-w-full">
<thead>
<tr>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase bg-gray-100 border-b border-gray-200 dark:bg-gray-900 leading-4 dark:text-gray-200">
Monthly pageviews
</th>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase bg-gray-100 border-b border-gray-200 dark:bg-gray-900 leading-4 dark:text-gray-200">
Price
</th>
</tr>
</thead>
<tbody class="bg-white dark:bg-gray-800">
<%= for plan <- Plausible.Billing.Plans.growth_plans_for(@user) do %>
<%= render("_plan_option.html", plan: plan) %>
<% end %>
</tbody>
</table>
</div>
</div>
</template>
<div x-show="!localizedPlans" class="mx-auto my-56 loading sm"><div></div></div>
<div class="mt-6 text-right">
<div class="text-sm font-medium dark:text-gray-100">Due today: <template x-if="localizedPlans"><b x-text="selectedPlanPrice()"></b></template></div>
<div class="mb-4 text-xs font-medium dark:text-gray-100">+ VAT if applicable</div>
<span class="inline-flex rounded-md shadow-sm">
<button type="button" data-theme="none" :data-product="selectedPlanProductId()" data-email="<%= @conn.assigns[:current_user].email %>" data-disable-logout="true" data-passthrough="<%= @conn.assigns[:current_user].id %>" data-success="<%= Routes.billing_path(@conn, :upgrade_success) %>" class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-indigo-600 border border-transparent paddle_button leading-5 rounded-md hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:ring active:bg-indigo-700 transition ease-in-out duration-150">
<svg fill="currentColor" viewBox="0 0 20 20" class="inline w-4 h-4 mr-2"><path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd"></path></svg>
Pay securely via Paddle
</button>
</span>
</div>
</div>
<div class="flex-1 pl-8 pt-14">
<h3 class="text-lg font-medium text-gray-900 leading-6 dark:text-gray-100">
What happens if I go over my page views limit?
</h3>
<div class="mt-2 text-base text-gray-500 leading-6 dark:text-gray-200">
You will never be charged extra for an occasional traffic spike. There are no surprise fees and your card will never be charged unexpectedly.<br /><br />
If your page views exceed your plan for two consecutive months, we will contact you to upgrade to a higher plan for the following month. You will have two weeks to make a decision. You can decide to continue with a higher plan or to cancel your account at that point.
</div>
</div>
</div>
</div>
<div class="mt-8 text-center dark:text-gray-100">
Questions? <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-500") %>
</div>
<%= render("_paddle_script.html") %>

@ -7,7 +7,7 @@ During the last billing cycle (<%= PlausibleWeb.TextHelpers.format_date_range(@u
<%= if @suggested_plan == :enterprise do %>
Your usage exceeds our standard plans, so please reply back to this email for a tailored quote.
<% else %>
<%= link("Click here to upgrade your subscription", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>. We recommend you upgrade to the <%= @suggested_plan.volume %>/mo plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.
<%= link("Click here to upgrade your subscription", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>. We recommend you upgrade to the <%= @suggested_plan.volume %>/mo plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.
<% end %>
<br /><br />
Do you have questions or need help with anything? Just reply to this email. We're here to help!

@ -9,7 +9,7 @@ During the last billing cycle (<%= PlausibleWeb.TextHelpers.format_date_range(@u
<%= if @suggested_plan == :enterprise do %>
Your usage exceeds our standard plans, so please reply back to this email for a tailored quote.
<% else %>
<%= link("Click here to upgrade your subscription", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>. We recommend you upgrade to the <%= @suggested_plan.volume %>/mo plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.
<%= link("Click here to upgrade your subscription", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>. We recommend you upgrade to the <%= @suggested_plan.volume %>/mo plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.
<% end %>
<br /><br />
Do you have questions or need help with anything? Just reply to this email. We're here to help!

@ -2,6 +2,6 @@ Time flies! Your 30-day free trial of Plausible will end next week.
<br /><br />
Over the last three weeks, We hope you got to experience the potential benefits of having website stats in an easy to use dashboard while respecting the privacy of your visitors, not annoying them with the cookie and privacy notices and still having a fast loading site.
<br /><br />
In order to continue receiving valuable website traffic insights at a glance, you’ll need to <%= link("upgrade your account", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>.
In order to continue receiving valuable website traffic insights at a glance, you’ll need to <%= link("upgrade your account", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>.
<br /><br />
If you have any questions or feedback for us, feel free to reply to this email.

@ -1,6 +1,6 @@
Your free Plausible trial has now expired. Upgrade your account to continue receiving valuable website traffic insights at a glance while respecting the privacy of your visitors and still having a fast loading site. <br /><br />
<%= link("Upgrade now", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>
<%= link("Upgrade now", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>
<br /><br />
We will keep recording stats for another month to give you time to upgrade.

@ -6,7 +6,7 @@ This is more than our standard plans, so please reply back to this email to get
<% else %>
Based on that we recommend you select a <%= @suggested_plan.volume %>/mo plan.
<br /><br />
<%= link("Upgrade now", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>
<%= link("Upgrade now", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>
<br /><br />
Have a question, feedback or need some guidance? Just reply to this email to get in touch!
<% end %>

@ -1,6 +1,6 @@
Time flies! This is a reminder that your annual subscription for Plausible Analytics will expire on <%= @date %>.
<br /><br />
You need to <%= link("renew your subscription", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %> if you want to continue using Plausible to count your website stats in a privacy-friendly way.
You need to <%= link("renew your subscription", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %> if you want to continue using Plausible to count your website stats in a privacy-friendly way.
<br /><br />
If you don't want to continue your subscription, there's no action required. You will lose access to the stats on <%= @date %>.
<br /><br />

@ -7,19 +7,6 @@ defmodule PlausibleWeb.BillingControllerTest do
@v4_growth_plan "857097"
@v4_business_plan "857105"
describe "GET /upgrade" do
setup [:create_user, :log_in]
test "redirects user to enteprise plan page if they are configured with one", %{
conn: conn,
user: user
} do
insert(:enterprise_plan, user: user)
conn = get(conn, Routes.billing_path(conn, :upgrade))
assert redirected_to(conn) == Routes.billing_path(conn, :upgrade_to_enterprise_plan)
end
end
describe "GET /choose-plan" do
setup [:create_user, :log_in]
@ -31,24 +18,6 @@ defmodule PlausibleWeb.BillingControllerTest do
end
end
describe "GET /upgrade/enterprise/:plan_id (deprecated)" do
setup [:create_user, :log_in]
test "redirects to the new :upgrade_to_enterprise_plan action", %{conn: conn} do
conn = get(conn, Routes.billing_path(conn, :upgrade_enterprise_plan, "123"))
assert redirected_to(conn) == Routes.billing_path(conn, :upgrade_to_enterprise_plan)
end
end
describe "GET /change-plan/enterprise/:plan_id (deprecated)" do
setup [:create_user, :log_in]
test "redirects to the new :upgrade_to_enterprise_plan action", %{conn: conn} do
conn = get(conn, Routes.billing_path(conn, :change_enterprise_plan, "123"))
assert redirected_to(conn) == Routes.billing_path(conn, :upgrade_to_enterprise_plan)
end
end
describe "POST /change-plan" do
setup [:create_user, :log_in]

@ -141,6 +141,10 @@ defmodule PlausibleWeb.EmailTest do
"cycle before that (#{PlausibleWeb.TextHelpers.format_date_range(penultimate_cycle)}), your account used 12,300 billable pageviews"
assert html_body =~ "/billing/choose-plan\">Click here to upgrade your subscription</a>"
assert html_body =~
PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)
assert html_body =~ "/settings\">account settings</a>"
end
@ -187,6 +191,10 @@ defmodule PlausibleWeb.EmailTest do
"cycle before that (#{PlausibleWeb.TextHelpers.format_date_range(penultimate_cycle)}), the usage was 12,300 billable pageviews"
assert html_body =~ "/billing/choose-plan\">Click here to upgrade your subscription</a>"
assert html_body =~
PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)
assert html_body =~ "/settings\">account settings</a>"
end

@ -42,7 +42,6 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
conn: conn
} do
site = Plausible.Repo.preload(site, :owner)
FunWithFlags.enable(:business_tier, for_actor: site.owner)
insert(:growth_subscription, user: site.owner)
url = Routes.custom_props_url(base_uri(), :enable)
@ -67,7 +66,6 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
conn: conn
} do
site = Plausible.Repo.preload(site, :owner)
FunWithFlags.enable(:business_tier, for_actor: site.owner)
insert(:growth_subscription, user: site.owner)
url = Routes.custom_props_url(base_uri(), :enable)

@ -53,7 +53,6 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
conn: conn
} do
site = Plausible.Repo.preload(site, :owner)
FunWithFlags.enable(:business_tier, for_actor: site.owner)
insert(:growth_subscription, user: site.owner)
url = Routes.goals_url(base_uri(), :create)
@ -80,7 +79,6 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
conn: conn
} do
site = Plausible.Repo.preload(site, :owner)
FunWithFlags.enable(:business_tier, for_actor: site.owner)
insert(:growth_subscription, user: site.owner)
url = Routes.goals_url(base_uri(), :create)

@ -1,7 +1,6 @@
{:ok, _} = Application.ensure_all_started(:ex_machina)
Mox.defmock(Plausible.HTTPClient.Mock, for: Plausible.HTTPClient.Interface)
Application.ensure_all_started(:double)
FunWithFlags.enable(:business_tier)
FunWithFlags.enable(:window_time_on_page)
Ecto.Adapters.SQL.Sandbox.mode(Plausible.Repo, :manual)

Loading…
Cancel
Save