View Source Plausible.Billing.Quota (Plausible v0.0.1)
This module provides functions to work with plans usage and limits.
Summary
Functions
Returns whether the usage is below the limit or not. Returns false if usage is equal to the limit.
Enterprise plans are always allowed to add more sites (even when
over limit) to avoid service disruption. Their usage is checked
in a background job instead (see check_usage.ex
).
Ensures that the given user (or the usage map) is within the limits of the given plan.
Suggests a suitable tier (Growth or Business) for the given usage map.
Returns whether the usage is within the limit or not. Returns true if usage is equal to the limit.
Functions
@spec below_limit?(non_neg_integer(), non_neg_integer() | :unlimited) :: boolean()
Returns whether the usage is below the limit or not. Returns false if usage is equal to the limit.
Enterprise plans are always allowed to add more sites (even when
over limit) to avoid service disruption. Their usage is checked
in a background job instead (see check_usage.ex
).
@spec ensure_within_plan_limits( Plausible.Auth.User.t() | map(), struct() | atom() | nil, Keyword.t() ) :: :ok | {:error, Plausible.Billing.Quota.Limits.over_limits_error()}
Ensures that the given user (or the usage map) is within the limits of the given plan.
An opts
argument can be passed with ignore_pageview_limit: true
which bypasses the pageview limit check and returns :ok
as long as
the other limits are not exceeded.
@spec exceeded_cycles(Plausible.Billing.Quota.Usage.cycles_usage(), non_neg_integer()) :: list()
@spec exceeds_last_two_usage_cycles?( Plausible.Billing.Quota.Usage.cycles_usage(), non_neg_integer() ) :: boolean()
Suggests a suitable tier (Growth or Business) for the given usage map.
If even the highest Business plan does not accommodate the usage, then
:custom
is returned. This means that this kind of usage should get on
a custom plan.
nil
is returned if the usage is not eligible for upgrade.
@spec within_limit?(non_neg_integer(), non_neg_integer() | :unlimited) :: boolean()
Returns whether the usage is within the limit or not. Returns true if usage is equal to the limit.