Import Oban error handling

pull/1783/head
Uku Taht 5 years ago
parent a9879de1f4
commit 1fb39957a6

@ -296,8 +296,6 @@ defmodule Plausible.Google.Api do
pageToken: page_token
}
Logger.debug(report)
res =
HTTPoison.post!(
"https://analyticsreporting.googleapis.com/v4/reports:batchGet",
@ -305,8 +303,6 @@ 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"]

@ -83,9 +83,15 @@
<div class="py-2"></div>
<span class="text-gray-700 dark:text-gray-300">Linked Google account: <b><%= @site.google_auth.email %></b></span>
<%= if @imported_data && @imported_data.status == "error" do %>
<div class="mt-1 text-red-600">
Your last GA import resulted in an error. You can try again below.
</div>
<% end %>
<%= case @google_profiles do %>
<% {:ok, profiles} -> %>
<p class="text-gray-700 dark:text-gray-300 mt-6">
<p class="text-gray-700 dark:text-gray-300 mt-1">
Select the Google Analytics view id you would like to import data from.
</p>

@ -5,10 +5,20 @@ defmodule ErrorReporter do
|> Map.take([:id, :args, :meta, :queue, :worker])
|> Map.merge(measure)
maybe_log_import_error(job)
Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: extra)
end
def handle_event([:oban, :circuit, :trip], _measure, meta, _) do
Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: meta)
end
defp maybe_log_import_error(job) do
site = Plausible.Repo.get(Plausible.Site, job.args["site_id"])
if site do
Plausible.Site.import_failure(site) |> Plausible.Repo.update!()
end
end
end

Loading…
Cancel
Save