Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Prevent error reports from being sent with short feedback (#2635)
Adam Rutkowskif678cfab25b5
diff --git a/lib/plausible_web/controllers/error_report_controller.ex b/lib/plausible_web/controllers/error_report_controller.exindex 7d48f1a57c..b830047765 100644--- a/lib/plausible_web/controllers/error_report_controller.ex+++ b/lib/plausible_web/controllers/error_report_controller.ex@@ -6,10 +6,12 @@ defmodule PlausibleWeb.ErrorReportController dodef 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)+ endthanks(conn)enddiff --git a/test/plausible_web/controllers/error_report_controller_test.exs b/test/plausible_web/controllers/error_report_controller_test.exsindex fe269837fc..fd97957d20 100644--- a/test/plausible_web/controllers/error_report_controller_test.exs+++ b/test/plausible_web/controllers/error_report_controller_test.exs@@ -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} doaction_path = Routes.error_report_path(Endpoint, :submit_error_report)