Skip to content

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

Show database library in info endpoint

Uku Taht32116fe2c984
diff --git a/lib/plausible_web/controllers/api/external_controller.ex b/lib/plausible_web/controllers/api/external_controller.ex
index 7b13eb90be..070d776307 100644
--- a/lib/plausible_web/controllers/api/external_controller.ex
+++ b/lib/plausible_web/controllers/api/external_controller.ex
@@ -55,6 +55,34 @@ defmodule PlausibleWeb.Api.ExternalController do
})
end
+ def info(conn, _params) do
+ version_file = Application.app_dir(:plausible, "priv/static/version.json")
+
+ version =
+ with {:ok, file} <- File.read(version_file),
+ {:ok, json} <- Jason.decode(file) do
+ json
+ else
+ _ -> %{}
+ end
+
+ geo_database =
+ case Geolix.metadata([:geolocation]) do
+ %{geolocation: %{database_type: type}} ->
+ type
+
+ _ ->
+ "(not configured)"
+ end
+
+ info =
+ Map.merge(version, %{
+ geo_database: geo_database
+ })
+
+ json(conn, info)
+ end
+
defp parse_user_agent(conn) do
user_agent = Plug.Conn.get_req_header(conn, "user-agent") |> List.first()
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index a66abf7b2d..ac04b287da 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -113,6 +113,7 @@ defmodule PlausibleWeb.Router do
post "/event", Api.ExternalController, :event
get "/error", Api.ExternalController, :error
get "/health", Api.ExternalController, :health
+ get "/info", Api.ExternalController, :info
post "/paddle/webhook", Api.PaddleController, :webhook