Skip to content

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

Add debug loggin to GA import

Uku Tahtc4f7c9a7a06d
diff --git a/lib/plausible/google/api.ex b/lib/plausible/google/api.ex
index 44372da250..be1544bc9c 100644
--- a/lib/plausible/google/api.ex
+++ b/lib/plausible/google/api.ex
@@ -1,6 +1,7 @@
defmodule Plausible.Google.Api do
alias Plausible.Imported
use Timex
+ require Logger
@scope URI.encode_www_form(
"https://www.googleapis.com/auth/webmasters.readonly email https://www.googleapis.com/auth/analytics.readonly"
@@ -245,6 +246,8 @@ defmodule Plausible.Google.Api do
end
)
+ Logger.debug(responses)
+
case Keyword.get(responses, :error) do
nil ->
results =
@@ -304,6 +307,8 @@ defmodule Plausible.Google.Api do
pageToken: page_token
}
+ Logger.debug(report)
+
res =
HTTPoison.post!(
"https://analyticsreporting.googleapis.com/v4/reports:batchGet",
@@ -311,6 +316,8 @@ defmodule Plausible.Google.Api do
Authorization: "Bearer #{request.auth.access_token}"
)
+ Logger.debug(res.body)
+
if res.status_code == 200 do
report = List.first(Jason.decode!(res.body)["reports"])
data = report["data"]["rows"]