analytics/lib/plausible_web/controllers/error_report_controller.ex
Vini Brasil 257fa16cdc
Simplify Phoenix error template (#2913)
* Simplify Phoenix error template

* Test tracking script is not included in error pages

* Test tracking script is not rendered in error templates

* Rename error layout and remove unnecessary HTML boilerplate

* Add layout setting to errors rendered without exceptions

* Add skip_plausible_tracking option to more pages
2023-05-16 10:52:17 +02:00

31 lines
825 B
Elixir

defmodule PlausibleWeb.ErrorReportController do
use PlausibleWeb, :controller
plug PlausibleWeb.RequireAccountPlug
def submit_error_report(conn, %{
"error" => %{"trace_id" => trace_id, "user_feedback" => feedback}
}) do
if String.length(String.trim(feedback)) > 5 do
reported_by = "#{conn.assigns.current_user.name} <#{conn.assigns.current_user.email}>"
email_template = PlausibleWeb.Email.error_report(reported_by, trace_id, feedback)
Plausible.Mailer.deliver_later(email_template)
end
thanks(conn)
end
def submit_error_report(conn, _params) do
thanks(conn)
end
defp thanks(conn) do
conn
|> put_view(PlausibleWeb.ErrorView)
|> render("server_error_report_thanks.html",
layout: {PlausibleWeb.LayoutView, "base_error.html"}
)
end
end