From 2e97ed387eb9ebb01caa913f18e9e688ccb76ccd Mon Sep 17 00:00:00 2001 From: Niklas Haeusele Date: Thu, 4 Jan 2024 23:08:34 +0100 Subject: [PATCH 1/8] Show backtrace in table and show severity in email subject --- .../error_mailer/_frame.html.erb | 4 +- .../error_mailer/_no_backtrace.html.erb | 2 +- .../error_mailer/error.html.erb | 4 +- lib/email_error_reporter/error_mailer.rb | 8 ++- .../email_error_reporter/error_mailer/error | 4 +- .../error_mailer/error_with_backtrace | 10 +++- test/error_mailer_test.rb | 50 ++++++++++++------- 7 files changed, 58 insertions(+), 24 deletions(-) diff --git a/app/views/email_error_reporter/error_mailer/_frame.html.erb b/app/views/email_error_reporter/error_mailer/_frame.html.erb index 09b067d..02508e4 100644 --- a/app/views/email_error_reporter/error_mailer/_frame.html.erb +++ b/app/views/email_error_reporter/error_mailer/_frame.html.erb @@ -1 +1,3 @@ -
  • <%= frame %>
  • + + <%= frame %> + diff --git a/app/views/email_error_reporter/error_mailer/_no_backtrace.html.erb b/app/views/email_error_reporter/error_mailer/_no_backtrace.html.erb index bd21d8e..0917dbd 100644 --- a/app/views/email_error_reporter/error_mailer/_no_backtrace.html.erb +++ b/app/views/email_error_reporter/error_mailer/_no_backtrace.html.erb @@ -1 +1 @@ -

    No backtrace available

    +No backtrace available diff --git a/app/views/email_error_reporter/error_mailer/error.html.erb b/app/views/email_error_reporter/error_mailer/error.html.erb index 933579c..a39445a 100644 --- a/app/views/email_error_reporter/error_mailer/error.html.erb +++ b/app/views/email_error_reporter/error_mailer/error.html.erb @@ -2,5 +2,7 @@

    <%= @error.message %>

    -<%= render(partial: "frame", collection: @backtrace) || render("no_backtrace") -%> + + <%= render(partial: "frame", collection: @backtrace) || render("no_backtrace") -%> +
    diff --git a/lib/email_error_reporter/error_mailer.rb b/lib/email_error_reporter/error_mailer.rb index 4ca233b..c560523 100644 --- a/lib/email_error_reporter/error_mailer.rb +++ b/lib/email_error_reporter/error_mailer.rb @@ -9,8 +9,14 @@ def error(error, handled:, severity:, context:, source: nil) @backtrace = Array.wrap(error.backtrace) + severity_to_emoji = { + error: "🔥", + warning: "⚠️", + info: "ℹ️" + } + mail( - subject: "#{error.class}", + subject: "#{severity_to_emoji.fetch(@severity)} #{error.class}", to: Rails.application.config.email_error_reporter.to ) end diff --git a/test/dummy/test/fixtures/email_error_reporter/error_mailer/error b/test/dummy/test/fixtures/email_error_reporter/error_mailer/error index 0075809..0af7d98 100644 --- a/test/dummy/test/fixtures/email_error_reporter/error_mailer/error +++ b/test/dummy/test/fixtures/email_error_reporter/error_mailer/error @@ -2,5 +2,7 @@

    some message

    -

    No backtrace available

    + + +
    No backtrace available
    diff --git a/test/dummy/test/fixtures/email_error_reporter/error_mailer/error_with_backtrace b/test/dummy/test/fixtures/email_error_reporter/error_mailer/error_with_backtrace index 40363cc..301ba6b 100644 --- a/test/dummy/test/fixtures/email_error_reporter/error_mailer/error_with_backtrace +++ b/test/dummy/test/fixtures/email_error_reporter/error_mailer/error_with_backtrace @@ -2,6 +2,12 @@

    some message

    -
  • foo
  • -
  • bar
  • + + + + + + + +
    foo
    bar
    diff --git a/test/error_mailer_test.rb b/test/error_mailer_test.rb index d52a175..24ac906 100644 --- a/test/error_mailer_test.rb +++ b/test/error_mailer_test.rb @@ -1,30 +1,46 @@ require "test_helper" class EmailErrorReporter::ErrorMailerTest < ActionMailer::TestCase + setup do + @exception = Exception.new("some message") + end + test "renders the template correctly" do - exception = Exception.new("some message") - email = EmailErrorReporter::ErrorMailer.error( - exception, - handled: true, - severity: :info, - context: {} - ) - assert_equal [], email.to - assert_equal "Exception", email.subject - assert_equal read_fixture("error").join, email.body.to_s + assert_equal [], error_mail.to + assert_equal read_fixture("error").join, error_mail.body.to_s end test "renders a backtrace" do - exception = Exception.new("some message") - exception.set_backtrace(["foo", "bar"]) + @exception.set_backtrace(["foo", "bar"]) + + assert_equal [], error_mail.to + assert_equal read_fixture("error_with_backtrace").join, error_mail.body.to_s + end + + test "severity: error" do + email = error_mail(severity: :error) + assert_equal "🔥" + " Exception", email.subject + end + + test "severity: warning" do + email = error_mail(severity: :warning) + assert_equal "⚠️" + " Exception", email.subject + end + + test "severity: info" do + email = error_mail(severity: :info) + assert_equal "ℹ️" + " Exception", email.subject + end + + private + + def error_mail(**kwargs) email = EmailErrorReporter::ErrorMailer.error( - exception, + @exception, handled: true, severity: :info, - context: {} + context: {}, + **kwargs ) - assert_equal [], email.to - assert_equal "Exception", email.subject - assert_equal read_fixture("error_with_backtrace").join, email.body.to_s end end From 383d17b3898a7f4a779990e2a732e83390740e31 Mon Sep 17 00:00:00 2001 From: Niklas Haeusele Date: Thu, 4 Jan 2024 23:38:10 +0100 Subject: [PATCH 2/8] HTML template --- Gemfile | 2 ++ .../error_mailer/_frame.html.erb | 2 +- .../error_mailer/error.html.erb | 30 +++++++++++++----- test/dummy/config/application.rb | 1 + test/dummy/config/environments/test.rb | 2 ++ test/error_mailer_test.rb | 31 ++++++++++++------- 6 files changed, 47 insertions(+), 21 deletions(-) diff --git a/Gemfile b/Gemfile index 2e27125..f1fe10a 100644 --- a/Gemfile +++ b/Gemfile @@ -10,3 +10,5 @@ gem "sqlite3" # Start debugger with binding.b [https://github.com/ruby/debug] gem "debug", ">= 1.0.0" + +gem "rails-dom-testing" diff --git a/app/views/email_error_reporter/error_mailer/_frame.html.erb b/app/views/email_error_reporter/error_mailer/_frame.html.erb index 02508e4..f1c6bfa 100644 --- a/app/views/email_error_reporter/error_mailer/_frame.html.erb +++ b/app/views/email_error_reporter/error_mailer/_frame.html.erb @@ -1,3 +1,3 @@ - <%= frame %> + <%= frame %> diff --git a/app/views/email_error_reporter/error_mailer/error.html.erb b/app/views/email_error_reporter/error_mailer/error.html.erb index a39445a..3d46366 100644 --- a/app/views/email_error_reporter/error_mailer/error.html.erb +++ b/app/views/email_error_reporter/error_mailer/error.html.erb @@ -1,8 +1,22 @@ -

    <%= @error.class %>

    -

    <%= @error.message %>

    - -
    - - <%= render(partial: "frame", collection: @backtrace) || render("no_backtrace") -%> -
    -
    + + +

    <%= @error.class %>

    +

    <%= @error.message %>

    + +

    Source: <%= @source ? @source : "No source present" %>

    +

    Handled: <%= @handled ? "✅" : "❌" %>

    + +
    + Stacktrace + + + <%= render(partial: "frame", collection: @backtrace) || render("no_backtrace") -%> +
    +
    + +
    + Context +
    <%= @context %>
    +
    + + diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index ef2ca87..5295e62 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -22,5 +22,6 @@ class Application < Rails::Application # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") + config.action_mailer.default_options = { from: 'no-reply@example.com' } end end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index adbb4a6..ee40759 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -61,4 +61,6 @@ # Raise error when a before_action's only/except options reference missing actions config.action_controller.raise_on_missing_callback_actions = true + + config.email_error_reporter.to = ["test@example.com"] end diff --git a/test/error_mailer_test.rb b/test/error_mailer_test.rb index 24ac906..4f56c8c 100644 --- a/test/error_mailer_test.rb +++ b/test/error_mailer_test.rb @@ -5,18 +5,6 @@ class EmailErrorReporter::ErrorMailerTest < ActionMailer::TestCase @exception = Exception.new("some message") end - test "renders the template correctly" do - assert_equal [], error_mail.to - assert_equal read_fixture("error").join, error_mail.body.to_s - end - - test "renders a backtrace" do - @exception.set_backtrace(["foo", "bar"]) - - assert_equal [], error_mail.to - assert_equal read_fixture("error_with_backtrace").join, error_mail.body.to_s - end - test "severity: error" do email = error_mail(severity: :error) assert_equal "🔥" + " Exception", email.subject @@ -32,6 +20,21 @@ class EmailErrorReporter::ErrorMailerTest < ActionMailer::TestCase assert_equal "ℹ️" + " Exception", email.subject end + test "email content" do + @exception.set_backtrace(["foo", "bar"]) + email = error_mail(handled: true, severity: :info).deliver_now + assert_dom_email do + assert_dom "h1", "Exception" + assert_dom "h2", "some message" + assert_dom test_id("source"), "Source: No source present" + assert_dom test_id("handled"), "Handled: ✅" + assert_dom test_id("context"), "{}" + assert_dom "table" do + assert_dom "tr", 2 + end + end + end + private def error_mail(**kwargs) @@ -43,4 +46,8 @@ def error_mail(**kwargs) **kwargs ) end + + def test_id(value) + "[data-test-id='#{value}']" + end end From 6403a334c6dfb49328a0615125864a8aecb44cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=A4usele?= Date: Thu, 11 Jan 2024 19:36:25 +0100 Subject: [PATCH 3/8] Add CI for 7.0 and 7.1 (#7) * Add CI for 7.0 and 7.1 --- .github/workflows/ruby.yml | 13 +++----- Appraisals | 7 +++++ Gemfile | 2 ++ email_error_reporter.gemspec | 3 +- gemfiles/rails_7.0.gemfile | 12 +++++++ gemfiles/rails_7.1.gemfile | 12 +++++++ test/dummy/config/application.rb | 3 +- test/dummy/config/environments/development.rb | 2 +- test/dummy/config/environments/test.rb | 2 +- test/subscriber_test.rb | 31 ++++++++++++++----- 10 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 Appraisals create mode 100644 gemfiles/rails_7.0.gemfile create mode 100644 gemfiles/rails_7.1.gemfile diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 1a40cb0..f9ff3bf 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -7,11 +7,7 @@ name: Tests -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] +on: [push, pull_request] permissions: contents: read @@ -23,13 +19,14 @@ jobs: strategy: matrix: ruby-version: ['3.1', '3.2', '3.3'] + rails-version: ['gemfiles/rails_7.0.gemfile', 'gemfiles/rails_7.1.gemfile'] + + env: + BUNDLE_GEMFILE: ${{ matrix.rails-version }} steps: - uses: actions/checkout@v3 - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): - # uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} diff --git a/Appraisals b/Appraisals new file mode 100644 index 0000000..6548bad --- /dev/null +++ b/Appraisals @@ -0,0 +1,7 @@ +appraise "rails-7.0" do + gem "rails", "~> 7.0.0" +end + +appraise "rails-7.1" do + gem "rails", "~> 7.1.0" +end diff --git a/Gemfile b/Gemfile index f1fe10a..e231bf5 100644 --- a/Gemfile +++ b/Gemfile @@ -12,3 +12,5 @@ gem "sqlite3" gem "debug", ">= 1.0.0" gem "rails-dom-testing" +gem "appraisal" + diff --git a/email_error_reporter.gemspec b/email_error_reporter.gemspec index 72c9a47..a10548b 100644 --- a/email_error_reporter.gemspec +++ b/email_error_reporter.gemspec @@ -22,5 +22,6 @@ Gem::Specification.new do |spec| Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] end - spec.add_dependency "rails", ">= 7.1.2" + spec.required_ruby_version = '>= 3.1.0' + spec.add_dependency "rails", ">= 7.0.0" end diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile new file mode 100644 index 0000000..ec6188e --- /dev/null +++ b/gemfiles/rails_7.0.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org/" + +gem "puma" +gem "sqlite3" +gem "debug", ">= 1.0.0" +gem "rails-dom-testing" +gem "appraisal", group: :development +gem "rails", "~> 7.0.0" + +gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile new file mode 100644 index 0000000..1cce9dc --- /dev/null +++ b/gemfiles/rails_7.1.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org/" + +gem "puma" +gem "sqlite3" +gem "debug", ">= 1.0.0" +gem "rails-dom-testing" +gem "appraisal", group: :development +gem "rails", "~> 7.1.0" + +gemspec path: "../" diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 5295e62..8dfe5e0 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -13,7 +13,8 @@ class Application < Rails::Application # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. # Common ones are `templates`, `generators`, or `middleware`, for example. - config.autoload_lib(ignore: %w(assets tasks)) + + # config.autoload_lib(ignore: %w(assets tasks)) # Configuration for the application, engines, and railties goes here. # diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 84e2859..21a448d 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -72,7 +72,7 @@ # config.action_cable.disable_request_forgery_protection = true # Raise error when a before_action's only/except options reference missing actions - config.action_controller.raise_on_missing_callback_actions = true + # config.action_controller.raise_on_missing_callback_actions = true config.email_error_reporter.to = ["test@example.com"] end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index ee40759..afe54f6 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -60,7 +60,7 @@ # config.action_view.annotate_rendered_view_with_filenames = true # Raise error when a before_action's only/except options reference missing actions - config.action_controller.raise_on_missing_callback_actions = true + # config.action_controller.raise_on_missing_callback_actions = true config.email_error_reporter.to = ["test@example.com"] end diff --git a/test/subscriber_test.rb b/test/subscriber_test.rb index c9c4fbd..27b4016 100644 --- a/test/subscriber_test.rb +++ b/test/subscriber_test.rb @@ -11,13 +11,28 @@ class SubscriberTest < ActiveSupport::TestCase end rescue TestError => e - assert_enqueued_email_with EmailErrorReporter::ErrorMailer, :error, args: ->(args) { - # TODO: find out, why args.first == e is false - [ - args.first.message == e.message, - args.first.backtrace == e.backtrace, - args.first.class == e.class - ].all? - } + # matcher + assert_enqueued_with( + job: ActionMailer::MailDeliveryJob, + args: ->(j) { + [ + "EmailErrorReporter::ErrorMailer" == j[0], + "error" == j[1], + "deliver_now" == j[2], + e.class == j[3][:args][0].class, + { handled: false, context: {}, severity: :error, source: rails_default_source } == j[3][:args][1], + ].all? + } + ) + end + + private + + def rails_default_source + if Gem::Version.new(Rails.version) >= Gem::Version.new("7.1.0") + "application" + else + nil + end end end From 0e26f5a974890689d6cc25d288529b77352d8e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=A4usele?= Date: Thu, 11 Jan 2024 23:21:45 +0100 Subject: [PATCH 4/8] Set a default from address to avoid errors (#9) --- README.md | 9 +++++++++ lib/email_error_reporter/engine.rb | 1 + lib/email_error_reporter/error_mailer.rb | 1 + 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 36b5bf1..8fed9e0 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,15 @@ All exceptions are reported automatically. No additional code required. Please consult the [official guides](https://guides.rubyonrails.org/error_reporting.html) for an introduction to the error reporting API. +## Optional configuration + +Set a custom from address. + +```ruby +# default: "no-reply@example.com" +config.email_error_reporter.from = "your-custom-email@example.com" +``` + ## Test your setup You can use the built-in rake task `rake email_error_reporter:check` to check if everything works correctly in your setup. diff --git a/lib/email_error_reporter/engine.rb b/lib/email_error_reporter/engine.rb index b914d07..b0d84c2 100644 --- a/lib/email_error_reporter/engine.rb +++ b/lib/email_error_reporter/engine.rb @@ -4,6 +4,7 @@ class Engine < ::Rails::Engine config.email_error_reporter = ActiveSupport::OrderedOptions.new config.email_error_reporter.to = [] + config.email_error_reporter.from = "no-reply@example.com" initializer "email_error_reporter.error_subscribe" do Rails.error.subscribe(Subscriber.new) diff --git a/lib/email_error_reporter/error_mailer.rb b/lib/email_error_reporter/error_mailer.rb index c560523..0df2c2a 100644 --- a/lib/email_error_reporter/error_mailer.rb +++ b/lib/email_error_reporter/error_mailer.rb @@ -17,6 +17,7 @@ def error(error, handled:, severity:, context:, source: nil) mail( subject: "#{severity_to_emoji.fetch(@severity)} #{error.class}", + from: Rails.application.config.email_error_reporter.from, to: Rails.application.config.email_error_reporter.to ) end From 46d7b7e9f620e7fbc311a95240109c2c952aacd0 Mon Sep 17 00:00:00 2001 From: Niklas Haeusele Date: Thu, 11 Jan 2024 23:23:18 +0100 Subject: [PATCH 5/8] bump 0.2.0 --- lib/email_error_reporter/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/email_error_reporter/version.rb b/lib/email_error_reporter/version.rb index b0651e7..e8e661b 100644 --- a/lib/email_error_reporter/version.rb +++ b/lib/email_error_reporter/version.rb @@ -1,3 +1,3 @@ module EmailErrorReporter - VERSION = "0.1.0.pre" + VERSION = "0.2.0" end From 4b99a976db1552a111a9aafc335e0a8cfc0cd8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20H=C3=A4usele?= Date: Mon, 15 Jan 2024 22:45:23 +0100 Subject: [PATCH 6/8] Add .enabled configuration (#10) --- README.md | 10 +++++++++- lib/email_error_reporter/engine.rb | 7 +++++-- test/subscriber_test.rb | 25 +++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8fed9e0..f43e6bc 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Add the gem: ```bash -bundle add email_error_reporter && bundle install +bundle add email_error_reporter ``` and configure the email addresses that should receive an email in the case of an exception: @@ -37,6 +37,14 @@ Set a custom from address. config.email_error_reporter.from = "your-custom-email@example.com" ``` +Disables the email reports for specific environments. Mails are enabled by default on all envs. + +```ruby +# e.g. in development.rb +# default: true +config.email_error_reporter.enabled = false +``` + ## Test your setup You can use the built-in rake task `rake email_error_reporter:check` to check if everything works correctly in your setup. diff --git a/lib/email_error_reporter/engine.rb b/lib/email_error_reporter/engine.rb index b0d84c2..d6a2ea4 100644 --- a/lib/email_error_reporter/engine.rb +++ b/lib/email_error_reporter/engine.rb @@ -5,9 +5,12 @@ class Engine < ::Rails::Engine config.email_error_reporter = ActiveSupport::OrderedOptions.new config.email_error_reporter.to = [] config.email_error_reporter.from = "no-reply@example.com" + config.email_error_reporter.enabled = true - initializer "email_error_reporter.error_subscribe" do - Rails.error.subscribe(Subscriber.new) + initializer "email_error_reporter.error_subscribe" do |app| + if app.config.email_error_reporter.enabled + Rails.error.subscribe(Subscriber.new) + end end # ActiveJob cannot (de)-serialize exceptions by default diff --git a/test/subscriber_test.rb b/test/subscriber_test.rb index 27b4016..ce3df2c 100644 --- a/test/subscriber_test.rb +++ b/test/subscriber_test.rb @@ -26,6 +26,31 @@ class SubscriberTest < ActiveSupport::TestCase ) end + test "enqueues no mail if disabled" do + old_config = Rails.application.config.email_error_reporter.enabled + Rails.application.config.email_error_reporter.enabled = false + Rails.error.record(TestError) do + raise TestError + end + + rescue TestError => e + # matcher + assert_enqueued_with( + job: ActionMailer::MailDeliveryJob, + args: ->(j) { + [ + "EmailErrorReporter::ErrorMailer" == j[0], + "error" == j[1], + "deliver_now" == j[2], + e.class == j[3][:args][0].class, + { handled: false, context: {}, severity: :error, source: rails_default_source } == j[3][:args][1], + ].all? + } + ) + ensure + Rails.application.config.email_error_reporter.enabled = old_config + end + private def rails_default_source From a7674ffa5a45e0bef20d940ad1fe6795563d2af8 Mon Sep 17 00:00:00 2001 From: Niklas Haeusele Date: Mon, 15 Jan 2024 22:50:11 +0100 Subject: [PATCH 7/8] bump 0.3.0 --- lib/email_error_reporter/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/email_error_reporter/version.rb b/lib/email_error_reporter/version.rb index e8e661b..917bf46 100644 --- a/lib/email_error_reporter/version.rb +++ b/lib/email_error_reporter/version.rb @@ -1,3 +1,3 @@ module EmailErrorReporter - VERSION = "0.2.0" + VERSION = "0.3.0" end From c4f983e303531d9f3bbcd8b0bad5fba21766de7e Mon Sep 17 00:00:00 2001 From: Niklas Haeusele Date: Mon, 15 Jan 2024 22:59:02 +0100 Subject: [PATCH 8/8] README fixes --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f43e6bc..ea12783 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,9 @@ Set a custom from address. config.email_error_reporter.from = "your-custom-email@example.com" ``` -Disables the email reports for specific environments. Mails are enabled by default on all envs. +--- + +Disables the email reports for specific environments. ```ruby # e.g. in development.rb @@ -51,10 +53,12 @@ You can use the built-in rake task `rake email_error_reporter:check` to check if If you're using Kamal, you can run the following command to test the setup in production: -``` +```sh kamal app exec -p 'bundle exec rake email_error_reporter:test_email' ``` +If everything is setup correctly, this rake task will send a demo email to your configured `to` address with a sample exception. + ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).