Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
increase api_keys.hourly_request_limit in CE (#4200)
ruslandoga22ea56a77934
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex eee8df8830..559d559fa2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file.### Changed+- Increase hourly request limit for API keys in CE from 600 to 1000000 (practically removing the limit) plausible/analytics#4200+### Fixed## v2.1.1 - 2024-06-06diff --git a/lib/plausible/auth/api_key.ex b/lib/plausible/auth/api_key.exindex 78fa5b3a93..e52810dcf9 100644--- a/lib/plausible/auth/api_key.ex+++ b/lib/plausible/auth/api_key.ex@@ -1,4 +1,5 @@defmodule Plausible.Auth.ApiKey do+ use Plausibleuse Ecto.Schemaimport Ecto.Changeset@@ -9,7 +10,7 @@ defmodule Plausible.Auth.ApiKey doschema "api_keys" dofield :name, :stringfield :scopes, {:array, :string}, default: ["stats:read:*"]- field :hourly_request_limit, :integer, default: 600+ field :hourly_request_limit, :integer, default: on_ee(do: 600, else: 1_000_000)field :key, :string, virtual: truefield :key_hash, :stringdiff --git a/test/plausible/auth/auth_test.exs b/test/plausible/auth/auth_test.exsindex 0367dfe763..95f4ae588c 100644--- a/test/plausible/auth/auth_test.exs+++ b/test/plausible/auth/auth_test.exs@@ -57,6 +57,26 @@ defmodule Plausible.AuthTest doassert {:ok, %Auth.ApiKey{}} = Auth.create_api_key(user, "my new key", key)end+ @tag :ee_only+ test "defaults to 600 requests per hour limit in EE" do+ user = insert(:user)++ {:ok, %Auth.ApiKey{hourly_request_limit: hourly_request_limit}} =+ Auth.create_api_key(user, "my new EE key", Ecto.UUID.generate())++ assert hourly_request_limit == 600+ end++ @tag :ce_build_only+ test "defaults to 1000000 requests per hour limit in CE" do+ user = insert(:user)++ {:ok, %Auth.ApiKey{hourly_request_limit: hourly_request_limit}} =+ Auth.create_api_key(user, "my new CE key", Ecto.UUID.generate())++ assert hourly_request_limit == 1_000_000+ end+test "errors when key already exists" dou1 = insert(:user)u2 = insert(:user)