Skip to content

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

Parse build information

Uku Taht892133d03686
diff --git a/lib/plausible_web/controllers/api/external_controller.ex b/lib/plausible_web/controllers/api/external_controller.ex
index 1303f566c1..6ed4a0771f 100644
--- a/lib/plausible_web/controllers/api/external_controller.ex
+++ b/lib/plausible_web/controllers/api/external_controller.ex
@@ -56,16 +56,6 @@ defmodule PlausibleWeb.Api.ExternalController do
end
def info(conn, _params) do
- version_file = Application.app_dir(:plausible, "priv/version.json")
-
- version =
- with {:ok, file} <- File.read(version_file),
- {:ok, json} <- Jason.decode(file) do
- json
- else
- _ -> %{}
- end
-
build_metadata = System.get_env("BUILD_METADATA", "{}") |> Jason.decode!()
geo_database =
@@ -77,11 +67,15 @@ defmodule PlausibleWeb.Api.ExternalController do
"(not configured)"
end
- info =
- Map.merge(version, %{
- geo_database: geo_database,
- build: build_metadata
- })
+ info = %{
+ geo_database: geo_database,
+ build: %{
+ version: get_in(build_metadata, ["labels", "org.opencontainers.image.version"]),
+ commit: get_in(build_metadata, ["labels", "org.opencontainers.image.revision"]),
+ created: get_in(build_metadata, ["labels", "org.opencontainers.image.created"]),
+ tags: get_in(build_metadata, ["tags"])
+ }
+ }
json(conn, info)
end
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index ac04b287da..fd2ac76151 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -114,6 +114,8 @@ defmodule PlausibleWeb.Router do
get "/error", Api.ExternalController, :error
get "/health", Api.ExternalController, :health
get "/info", Api.ExternalController, :info
+ get "/system/metadata", Api.ExternalController, :info
+ get "/system/health", Api.ExternalController, :health
post "/paddle/webhook", Api.PaddleController, :webhook