diff --git a/.ruby-version b/.ruby-version index b0f2dcb3..bea438e9 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.0.4 +3.3.1 diff --git a/.tool-versions b/.tool-versions index 6e624cf0..f76d2631 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -ruby 3.0.4 +ruby 3.3.1 yarn 1.22.19 nodejs 16.15.0 diff --git a/Gemfile b/Gemfile index b2afbe5e..b6ee5894 100644 --- a/Gemfile +++ b/Gemfile @@ -72,6 +72,7 @@ gem "httparty", "~> 0.20.0" gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw] # Sentry +gem "stackprof" gem "sentry-rails" gem "sentry-ruby" diff --git a/Gemfile.lock b/Gemfile.lock index a16051fa..77029255 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -193,10 +193,12 @@ GEM net-ssh (>= 2.6.5, < 7.0.0) net-ssh (6.1.0) netrc (0.11.0) - nio4r (2.5.8) - nokogiri (1.13.6-x86_64-darwin) + nio4r (2.7.3) + nokogiri (1.16.5-arm64-darwin) racc (~> 1.4) - nokogiri (1.13.6-x86_64-linux) + nokogiri (1.16.5-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.5-x86_64-linux) racc (~> 1.4) oauth2 (1.4.9) faraday (>= 0.17.3, < 3.0) @@ -220,12 +222,12 @@ GEM parallel (1.22.1) parser (3.1.2.0) ast (~> 2.4.1) - psych (4.0.3) + psych (5.1.2) stringio public_suffix (4.0.7) puma (5.5.2) nio4r (~> 2.0) - racc (1.6.0) + racc (1.8.0) rack (2.2.3.1) rack-protection (2.2.0) rack @@ -268,7 +270,7 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - rdoc (6.4.0) + rdoc (6.7.0) psych (>= 4.0.0) regexp_parser (2.4.0) responders (3.0.1) @@ -324,7 +326,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - sdoc (2.4.0) + sdoc (2.6.1) rdoc (>= 5.0) semantic_range (3.0.0) sentry-rails (5.5.0) @@ -345,11 +347,14 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.4.2) + sqlite3 (1.7.3-arm64-darwin) + sqlite3 (1.7.3-x86_64-darwin) + sqlite3 (1.7.3-x86_64-linux) sshkit (1.21.2) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - stringio (3.0.2) + stackprof (0.2.26) + stringio (3.1.0) sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) @@ -387,6 +392,7 @@ GEM zeitwerk (2.5.4) PLATFORMS + arm64-darwin-23 x86_64-darwin-21 x86_64-linux @@ -436,6 +442,7 @@ DEPENDENCIES sentry-ruby spring (~> 3.0) sqlite3 (~> 1.4) + stackprof tqdm (~> 0.3.0) tzinfo-data vanilla_nested (~> 1.6) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e7c56778..f6dabf6a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,6 +2,9 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception + + include SentryUserContext + skip_before_action :verify_authenticity_token, if: :api_request? before_action :authenticate_user_from_token! before_action :authenticate_user! diff --git a/app/controllers/concerns/sentry_user_context.rb b/app/controllers/concerns/sentry_user_context.rb new file mode 100644 index 00000000..f13a693a --- /dev/null +++ b/app/controllers/concerns/sentry_user_context.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module SentryUserContext + extend ActiveSupport::Concern + + included do + before_action :set_sentry_context + end + + private + + def sentry_user_context + {}.tap do |user| + next unless current_user + + user[:id] = current_user.id + user[:name] = current_user.name + end + end + + def set_sentry_context + Sentry.set_user(sentry_user_context) + end +end diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 5c4cdb4d..08738dca 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -1,6 +1,7 @@ Sentry.init do |config| config.dsn = ENV["SENTRY_DSN"] config.breadcrumbs_logger = [:active_support_logger, :http_logger] + config.enable_tracing = true config.enabled_environments = %w[production] end