Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

improve stats api upgrade required error message (#3747)

RobertJoonas51f0e406a05d
diff --git a/lib/plausible_web/plugs/authorize_stats_api.ex b/lib/plausible_web/plugs/authorize_stats_api.ex
index c099191879..b45c41de9b 100644
--- a/lib/plausible_web/plugs/authorize_stats_api.ex
+++ b/lib/plausible_web/plugs/authorize_stats_api.ex
@@ -45,7 +45,7 @@ defmodule PlausibleWeb.AuthorizeStatsApiPlug do
{: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."
+ "The account that owns this API key does not have access to Stats API. Please make sure you're using the API key of a subscriber account and that the subscription plan includes Stats API"
)
{:error, :site_locked} ->
diff --git a/test/plausible_web/controllers/api/external_stats_controller/auth_test.exs b/test/plausible_web/controllers/api/external_stats_controller/auth_test.exs
index 0a88373106..e8ca4804d5 100644
--- a/test/plausible_web/controllers/api/external_stats_controller/auth_test.exs
+++ b/test/plausible_web/controllers/api/external_stats_controller/auth_test.exs
@@ -163,7 +163,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController.AuthTest do
|> get("/api/v1/stats/aggregate", %{"site_id" => site.domain, "metrics" => "pageviews"})
|> assert_error(
402,
- "Stats API is part of the Plausible Business plan. To get access to this feature, please upgrade your account."
+ "The account that owns this API key does not have access to Stats API."
)
end