* Include ApiKey functions in Auth context
* Make feature notice work without %Site{}
Previously the extra feature notice required a %Site{} in order to check
the owner plan. However, not every feature is scoped by site, for
example the Stats API. For features like this, a %User{} is required,
and not a %Site{}.
This commit replaces the `:site` param with `:billable_user`, which is
common to both site and user-scoped features.
* Add stats_api to the list of extra features
* Limit API Key creation based on user plan
@ -28,10 +28,10 @@ defmodule PlausibleWeb.Components.Billing do
private_preview?->
"#{assigns.feature_mod.display_name()} is an upcoming premium functionality that's free-to-use during the private preview. Pricing will be announced soon."
"#{assigns.feature_mod.display_name()} is part of the Plausible Business plan. You can access it during your trial, but you'll need to subscribe to the Business plan to retain access after the trial ends."
@ -39,7 +39,7 @@ defmodule PlausibleWeb.Components.Billing do
</.link>totheBusinessplan.
"""
nothas_access?&¬owner? ->
nothas_access?&¬display_upgrade_link? ->
"#{assigns.feature_mod.display_name()} is part of the Plausible Business plan. To get access to it, please reach out to the site owner to upgrade your subscription to the Business plan."
@ -41,6 +41,12 @@ defmodule PlausibleWeb.AuthorizeStatsApiPlug do
"Invalid API key or site ID. Please make sure you're using a valid API key with access to the site you've requested."
)
{:error,:upgrade_required}->
H.payment_required(
conn,
"#{Plausible.Billing.Feature.StatsAPI.display_name()} is part of the Plausible Business plan. To get access to this feature, please upgrade your account."
)
{:error,:site_locked}->
H.payment_required(
conn,
@ -61,10 +67,20 @@ defmodule PlausibleWeb.AuthorizeStatsApiPlug do