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

Link to this function

below_limit?(usage, limit)

View Source
@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.

Link to this function

eligible_for_upgrade?(usage)

View Source
Link to this function

ensure_can_add_new_site(user)

View Source

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).

Link to this function

ensure_feature_access(usage, plan)

View Source
Link to this function

ensure_within_plan_limits(user_or_usage, plan, opts \\ [])

View Source
@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.

Link to this function

exceeded_cycles(cycles_usage, allowed_volume)

View Source
@spec exceeded_cycles(Plausible.Billing.Quota.Usage.cycles_usage(), non_neg_integer()) ::
  list()
Link to this function

exceeds_last_two_usage_cycles?(cycles_usage, allowed_volume)

View Source
@spec exceeds_last_two_usage_cycles?(
  Plausible.Billing.Quota.Usage.cycles_usage(),
  non_neg_integer()
) ::
  boolean()
Link to this function

suggest_tier(usage, highest_growth_plan, highest_business_plan)

View Source

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.

Link to this function

within_limit?(usage, limit)

View Source
@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.