mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 11:02:52 +03:00
257fa16cdc
* 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
31 lines
825 B
Elixir
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
|