Skip to content

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

Improve UI for failed import entry case (#4029)

Adrian Gruntkowski7ae855cda525
diff --git a/lib/plausible/google/ua/http.ex b/lib/plausible/google/ua/http.ex
index 302c90a195..49cfad2aaf 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 548ea7edf6..d29595bd1a 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
/>
<Heroicons.exclamation_triangle
:if={entry.live_status == SiteImport.failed()}
- class="inline-block h-6 w-5 text-indigo-600 dark:text-green-600"
+ class="inline-block h-6 w-5 text-red-700 dark:text-red-700"
/>
+ <span :if={entry.live_status == SiteImport.failed()}>
+ Import failed -
+ </span>
<%= Plausible.Imported.SiteImport.label(entry.site_import) %>
<span :if={entry.live_status == SiteImport.completed()} class="text-xs font-normal">
(<%= PlausibleWeb.StatsView.large_number_format(
@@ -147,9 +150,13 @@ defmodule PlausibleWeb.Live.ImportsExportsSettings do
<p class="text-sm leading-5 text-gray-500 dark:text-gray-200">
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) %>)
</p>
</div>
<.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?"
>
- <span :if={entry.live_status in [SiteImport.completed(), SiteImport.failed()]}>
+ <span :if={entry.live_status == SiteImport.completed()}>
Delete Import
</span>
+ <span :if={entry.live_status == SiteImport.failed()}>
+ Discard
+ </span>
<span :if={entry.live_status not in [SiteImport.completed(), SiteImport.failed()]}>
Cancel Import
</span>