mirror of
https://github.com/plausible/analytics.git
synced 2024-11-26 00:24:44 +03:00
Prevent error reports from being sent with short feedback (#2635)
This commit is contained in:
parent
061cb6ec83
commit
f678cfab25
@ -6,10 +6,12 @@ defmodule PlausibleWeb.ErrorReportController do
|
||||
def submit_error_report(conn, %{
|
||||
"error" => %{"trace_id" => trace_id, "user_feedback" => feedback}
|
||||
}) do
|
||||
reported_by = "#{conn.assigns.current_user.name} <#{conn.assigns.current_user.email}>"
|
||||
email_template = PlausibleWeb.Email.error_report(reported_by, trace_id, feedback)
|
||||
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)
|
||||
Plausible.Mailer.deliver_later(email_template)
|
||||
end
|
||||
|
||||
thanks(conn)
|
||||
end
|
||||
|
@ -68,6 +68,22 @@ defmodule PlausibleWeb.ErrorReportControllerTest do
|
||||
})
|
||||
end
|
||||
|
||||
test "short feedback is not sent", %{conn: conn} do
|
||||
action_path = Routes.error_report_path(Endpoint, :submit_error_report)
|
||||
|
||||
conn =
|
||||
post(conn, action_path, %{
|
||||
"error" => %{"trace_id" => "some-trace-id", "user_feedback" => "short"}
|
||||
})
|
||||
|
||||
assert html = html_response(conn, 200)
|
||||
assert html =~ "Your report has been submitted"
|
||||
|
||||
refute_email_delivered_with(%{
|
||||
subject: "Feedback to Sentry Trace some-trace-id"
|
||||
})
|
||||
end
|
||||
|
||||
test "submitting no feedback for authenticated user", %{conn: conn} do
|
||||
action_path = Routes.error_report_path(Endpoint, :submit_error_report)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user