Skip to content

Commit

Permalink
Ruby version & Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNaessens committed May 26, 2024
1 parent 0774b17 commit e0b7ed9
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.4
3.3.1
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ruby 3.0.4
ruby 3.3.1
yarn 1.22.19
nodejs 16.15.0
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
25 changes: 16 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -387,6 +392,7 @@ GEM
zeitwerk (2.5.4)

PLATFORMS
arm64-darwin-23
x86_64-darwin-21
x86_64-linux

Expand Down Expand Up @@ -436,6 +442,7 @@ DEPENDENCIES
sentry-ruby
spring (~> 3.0)
sqlite3 (~> 1.4)
stackprof
tqdm (~> 0.3.0)
tzinfo-data
vanilla_nested (~> 1.6)
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
24 changes: 24 additions & 0 deletions app/controllers/concerns/sentry_user_context.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions config/initializers/sentry.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e0b7ed9

Please sign in to comment.