From bc315c5c2884a2684004497eadc6de604c05e125 Mon Sep 17 00:00:00 2001 From: b0ink <40929320+b0ink@users.noreply.github.com> Date: Wed, 13 May 2026 13:33:10 +1000 Subject: [PATCH 1/2] feat: enable sentry error logging --- Gemfile | 3 +++ Gemfile.lock | 9 +++++++++ app/api/api_root.rb | 1 + config/initializers/sentry.rb | 12 ++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 config/initializers/sentry.rb diff --git a/Gemfile b/Gemfile index 90b4021f63..69ca22f0ba 100644 --- a/Gemfile +++ b/Gemfile @@ -120,3 +120,6 @@ gem 'pdf-reader' gem 'oauth2' gem "sys-filesystem" + +gem "sentry-rails" +gem "sentry-ruby" diff --git a/Gemfile.lock b/Gemfile.lock index 6bb903f2a6..8bc4f19b3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -456,6 +456,13 @@ GEM ruby2_keywords (0.0.5) rubyzip (2.4.1) securerandom (0.4.1) + sentry-rails (6.5.0) + railties (>= 5.2.0) + sentry-ruby (~> 6.5.0) + sentry-ruby (6.5.0) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + logger set (1.1.1) sexp_processor (4.17.3) shellwords (0.2.2) @@ -613,6 +620,8 @@ DEPENDENCIES ruby-lsp ruby-saml rubyzip + sentry-rails + sentry-ruby shellwords sidekiq sidekiq-cron diff --git a/app/api/api_root.rb b/app/api/api_root.rb index e36e21226e..b30f0d8102 100644 --- a/app/api/api_root.rb +++ b/app/api/api_root.rb @@ -47,6 +47,7 @@ class ApiRoot < Grape::API message = "Sorry... something went wrong with your request." status = 500 end + Sentry.capture_exception(e) Rack::Response.new({ error: message }.to_json, status, { 'Content-type' => 'text/error' }) end diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb new file mode 100644 index 0000000000..9026ccbed4 --- /dev/null +++ b/config/initializers/sentry.rb @@ -0,0 +1,12 @@ +if ENV["SENTRY_DSN"].present? + Sentry.init do |config| + config.dsn = ENV.fetch("SENTRY_DSN", nil) + # get breadcrumbs from logs + config.breadcrumbs_logger = [:active_support_logger, :http_logger] + config.environment = Rails.env + config.release = ENV["SENTRY_RELEASE"] if ENV["SENTRY_RELEASE"].present? + # Add data like request headers and IP for users, if applicable; + # see https://docs.sentry.io/platforms/ruby/data-management/data-collected/ for more info + config.send_default_pii = false + end +end From d3cf4f4cbd4c6ba941a1a7cad937c2112a3b4320 Mon Sep 17 00:00:00 2001 From: b0ink <40929320+b0ink@users.noreply.github.com> Date: Wed, 13 May 2026 14:12:43 +1000 Subject: [PATCH 2/2] chore: allow manual environment set --- config/initializers/sentry.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 9026ccbed4..1cb50372f7 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -3,7 +3,7 @@ config.dsn = ENV.fetch("SENTRY_DSN", nil) # get breadcrumbs from logs config.breadcrumbs_logger = [:active_support_logger, :http_logger] - config.environment = Rails.env + config.environment = ENV.fetch("SENTRY_ENVIRONMENT", Rails.env) config.release = ENV["SENTRY_RELEASE"] if ENV["SENTRY_RELEASE"].present? # Add data like request headers and IP for users, if applicable; # see https://docs.sentry.io/platforms/ruby/data-management/data-collected/ for more info