Skip to content

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

Fix crash when you have no google properties

Uku Tahtccbc04f6bd97
diff --git a/lib/plausible/google/api.ex b/lib/plausible/google/api.ex
index d1fa0962c4..21a7d1fc42 100644
--- a/lib/plausible/google/api.ex
+++ b/lib/plausible/google/api.ex
@@ -19,7 +19,7 @@ defmodule Plausible.Google.Api do
auth = refresh_if_needed(auth)
res = HTTPoison.get!("https://www.googleapis.com/webmasters/v3/sites",["Content-Type": "application/json", "Authorization": "Bearer #{auth.access_token}"])
Jason.decode!(res.body)
- |> Map.get("siteEntry")
+ |> Map.get("siteEntry", [])
|> Enum.filter(fn site -> site["permissionLevel"] in @verified_permission_levels end)
|> Enum.map(fn site -> site["siteUrl"] end)
|> Enum.map(fn url -> String.trim_trailing(url, "/") end)