From 7ae855cda525549821ff09264d0d0c2a43d50662 Mon Sep 17 00:00:00 2001 From: Adrian Gruntkowski Date: Mon, 22 Apr 2024 15:29:13 +0200 Subject: [PATCH] Improve UI for failed import entry case (#4029) * Improve UI for failed import entry case * Make failed request debugging for UA imports on par with the one for GA4 * Refine failed import state further --- lib/plausible/google/ua/http.ex | 10 +++++++++- .../live/imports_exports_settings.ex | 20 ++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/plausible/google/ua/http.ex b/lib/plausible/google/ua/http.ex index 302c90a19..49cfad2aa 100644 --- a/lib/plausible/google/ua/http.ex +++ b/lib/plausible/google/ua/http.ex @@ -45,10 +45,18 @@ defmodule Plausible.Google.UA.HTTP do {:ok, {report, token}} else {:error, %{reason: %{status: status, body: body}}} -> + Logger.debug( + "[#{inspect(__MODULE__)}:#{report_request.view_id}] Request failed for #{report_request.dataset} with code #{status}: #{inspect(body)}" + ) + Sentry.Context.set_extra_context(%{ga_response: %{body: body, status: status}}) {:error, :request_failed} - {:error, _reason} -> + {:error, reason} -> + Logger.debug( + "[#{inspect(__MODULE__)}:#{report_request.view_id}] Request failed for #{report_request.dataset}: #{inspect(reason)}" + ) + {:error, :request_failed} end end diff --git a/lib/plausible_web/live/imports_exports_settings.ex b/lib/plausible_web/live/imports_exports_settings.ex index 548ea7edf..d29595bd1 100644 --- a/lib/plausible_web/live/imports_exports_settings.ex +++ b/lib/plausible_web/live/imports_exports_settings.ex @@ -135,8 +135,11 @@ defmodule PlausibleWeb.Live.ImportsExportsSettings do /> + + Import failed - + <%= Plausible.Imported.SiteImport.label(entry.site_import) %> (<%= PlausibleWeb.StatsView.large_number_format( @@ -147,9 +150,13 @@ defmodule PlausibleWeb.Live.ImportsExportsSettings do

From <%= format_date(entry.site_import.start_date) %> to <%= format_date( entry.site_import.end_date - ) %> (created on <%= format_date( - entry.site_import.inserted_at || entry.site_import.start_date - ) %>) + ) %> + <%= if entry.live_status == SiteImport.completed() do %> + (imported + <% else %> + (started + <% end %> + on <%= format_date(entry.site_import.inserted_at) %>)

<.button @@ -160,9 +167,12 @@ defmodule PlausibleWeb.Live.ImportsExportsSettings do class="sm:ml-3 sm:w-auto w-full" data-confirm="Are you sure you want to delete this import?" > - + Delete Import + + Discard + Cancel Import