diff --git a/.env.sample b/.env.sample index 39c032f..75050fd 100644 --- a/.env.sample +++ b/.env.sample @@ -2,3 +2,4 @@ AWS_BUCKET= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= EXECJS_RUNTIME=Node +SENTRY_DSN= diff --git a/Gemfile b/Gemfile index 5fc1289..91f8546 100644 --- a/Gemfile +++ b/Gemfile @@ -76,4 +76,12 @@ group :development do gem "spring-watcher-listen", "~> 2.1.0" end +# Exception tracking. Reports unhandled exceptions to Sentry in production; +# the DSN is supplied via the SENTRY_DSN env var (see .env.sample). sentry-rails +# auto-installs the Rack/Rails middleware, so no controller changes are needed. +group :production do + gem "sentry-ruby" + gem "sentry-rails" +end + gem "tzinfo-data", platforms: [:windows, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 0e41380..dd9ad73 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -368,6 +368,13 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + sentry-rails (6.6.2) + railties (>= 5.2.0) + sentry-ruby (~> 6.6.2) + sentry-ruby (6.6.2) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + logger spring (4.7.0) spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) @@ -438,6 +445,8 @@ DEPENDENCIES rubocop-rails-omakase sass-rails (~> 6.0) selenium-webdriver + sentry-rails + sentry-ruby spring spring-watcher-listen (~> 2.1.0) terser diff --git a/Gemfile.next.lock b/Gemfile.next.lock index 0e41380..dd9ad73 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -368,6 +368,13 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + sentry-rails (6.6.2) + railties (>= 5.2.0) + sentry-ruby (~> 6.6.2) + sentry-ruby (6.6.2) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + logger spring (4.7.0) spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) @@ -438,6 +445,8 @@ DEPENDENCIES rubocop-rails-omakase sass-rails (~> 6.0) selenium-webdriver + sentry-rails + sentry-ruby spring spring-watcher-listen (~> 2.1.0) terser diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb new file mode 100644 index 0000000..f5d87dc --- /dev/null +++ b/config/initializers/sentry.rb @@ -0,0 +1,10 @@ +if Rails.env.production? && ENV["SENTRY_DSN"].present? + Sentry.init do |config| + config.dsn = ENV["SENTRY_DSN"] + config.breadcrumbs_logger = [:active_support_logger, :http_logger] + + # Capture 100% of transactions for performance tracing. Lower this if the + # volume becomes noisy or the Sentry quota gets tight. + config.traces_sample_rate = 1.0 + end +end