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 b58a51c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 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
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 b58a51c

Please sign in to comment.