Skip to content

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

Log unhandled verification and detection cases (#5792)

RobertJoonas983e106a7c63
diff --git a/extra/lib/plausible/installation_support/detection/checks.ex b/extra/lib/plausible/installation_support/detection/checks.ex
index da9f88be2c..ffcf1df434 100644
--- a/extra/lib/plausible/installation_support/detection/checks.ex
+++ b/extra/lib/plausible/installation_support/detection/checks.ex
@@ -40,11 +40,15 @@ defmodule Plausible.InstallationSupport.Detection.Checks do
def telemetry_event_handled(), do: [:plausible, :detection, :handled]
def telemetry_event_unhandled(), do: [:plausible, :detection, :unhandled]
- def interpret_diagnostics(%State{} = state) do
- result = Detection.Diagnostics.interpret(state.diagnostics, state.url)
+ def interpret_diagnostics(%State{
+ diagnostics: diagnostics,
+ data_domain: data_domain,
+ url: url
+ }) do
+ result = Detection.Diagnostics.interpret(diagnostics, url)
case result.data do
- %{unhandled: true, diagnostics: diagnostics, url: url} ->
+ %{unhandled: true} ->
Sentry.capture_message("Unhandled case for detection",
extra: %{
message: inspect(diagnostics),
@@ -53,6 +57,10 @@ defmodule Plausible.InstallationSupport.Detection.Checks do
}
)
+ Logger.warning(
+ "[DETECTION] Unhandled case (data_domain='#{data_domain}'): #{inspect(diagnostics)}"
+ )
+
:telemetry.execute(telemetry_event_unhandled(), %{})
_ ->
diff --git a/extra/lib/plausible/installation_support/detection/diagnostics.ex b/extra/lib/plausible/installation_support/detection/diagnostics.ex
index c59180a491..40d00a8424 100644
--- a/extra/lib/plausible/installation_support/detection/diagnostics.ex
+++ b/extra/lib/plausible/installation_support/detection/diagnostics.ex
@@ -68,13 +68,12 @@ defmodule Plausible.InstallationSupport.Detection.Diagnostics do
when service_error in [:domain_not_found, :invalid_url],
do: %Result{ok?: false, data: nil, errors: [Atom.to_string(service_error)]}
- def interpret(%__MODULE__{} = diagnostics, url),
- do: unhandled_case(diagnostics, url)
+ def interpret(%__MODULE__{} = _diagnostics, _url), do: unhandled_case()
- defp unhandled_case(diagnostics, url) do
+ defp unhandled_case() do
%Result{
ok?: false,
- data: %{unhandled: true, diagnostics: diagnostics, url: url},
+ data: %{unhandled: true},
errors: ["Unhandled detection case"]
}
end
diff --git a/extra/lib/plausible/installation_support/verification/checks.ex b/extra/lib/plausible/installation_support/verification/checks.ex
index 17392ab942..d35fbeed47 100644
--- a/extra/lib/plausible/installation_support/verification/checks.ex
+++ b/extra/lib/plausible/installation_support/verification/checks.ex
@@ -41,21 +41,28 @@ defmodule Plausible.InstallationSupport.Verification.Checks do
def telemetry_event_handled(), do: [:plausible, :verification, :handled]
def telemetry_event_unhandled(), do: [:plausible, :verification, :unhandled]
- def interpret_diagnostics(%State{} = state, opts \\ []) do
+ def interpret_diagnostics(
+ %State{
+ diagnostics: diagnostics,
+ data_domain: data_domain,
+ url: url
+ },
+ opts \\ []
+ ) do
telemetry? = Keyword.get(opts, :telemetry?, true)
result =
Verification.Diagnostics.interpret(
- state.diagnostics,
- state.data_domain,
- state.url
+ diagnostics,
+ data_domain,
+ url
)
case {telemetry?, result.data} do
{false, _} ->
:skip
- {_, %{unhandled: true, diagnostics: diagnostics, url: url}} ->
+ {_, %{unhandled: true}} ->
Sentry.capture_message("Unhandled case for site verification (v2)",
extra: %{
message: inspect(diagnostics),
@@ -64,6 +71,10 @@ defmodule Plausible.InstallationSupport.Verification.Checks do
}
)
+ Logger.warning(
+ "[VERIFICATION v2] Unhandled case (data_domain='#{data_domain}'): #{inspect(diagnostics)}"
+ )
+
:telemetry.execute(telemetry_event_unhandled(), %{})
_ ->
diff --git a/extra/lib/plausible/installation_support/verification/diagnostics.ex b/extra/lib/plausible/installation_support/verification/diagnostics.ex
index c0db56a2f8..23e249c11d 100644
--- a/extra/lib/plausible/installation_support/verification/diagnostics.ex
+++ b/extra/lib/plausible/installation_support/verification/diagnostics.ex
@@ -259,9 +259,9 @@ defmodule Plausible.InstallationSupport.Verification.Diagnostics do
),
do: error_plausible_not_found(selected_installation_type)
- def interpret(%__MODULE__{} = diagnostics, _expected_domain, url) do
+ def interpret(%__MODULE__{} = diagnostics, _expected_domain, _url) do
error_plausible_not_found(diagnostics.selected_installation_type)
- |> Map.put(:data, %{unhandled: true, diagnostics: diagnostics, url: url})
+ |> Map.put(:data, %{unhandled: true})
end
@message_plausible_not_found "We couldn't detect Plausible on your site"