Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Send errors reported through Rails.error to Sentry (#5810)

Josh Sanders0fe378ab2577
diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb
index 8e31567d49..55661be1b9 100644
--- a/config/initializers/sentry.rb
+++ b/config/initializers/sentry.rb
@@ -5,6 +5,9 @@ if ENV["SENTRY_DSN"].present?
config.breadcrumbs_logger = [ :active_support_logger, :http_logger ]
config.enabled_environments = %w[production]
+ # Send what Rails.error reports: off by default in sentry-rails, so handled errors reached no one.
+ config.rails.register_error_subscriber = true
+
# Enable sending logs to Sentry
config.enable_logs = true
# Patch Ruby logger to forward logs
diff --git a/test/initializers/sentry_test.rb b/test/initializers/sentry_test.rb
new file mode 100644
index 0000000000..45a7c3aa4a
--- /dev/null
+++ b/test/initializers/sentry_test.rb
@@ -0,0 +1,14 @@
+require "test_helper"
+
+class SentryTest < ActiveSupport::TestCase
+ test "errors reported through Rails.error go to Sentry" do
+ config = Sentry::Configuration.new
+ Sentry.stubs(:init).yields(config)
+
+ with_env_overrides("SENTRY_DSN" => "https://[email protected]/1") do
+ load Rails.root.join("config/initializers/sentry.rb")
+ end
+
+ assert config.rails.register_error_subscriber
+ end
+end