File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ gem 'reverse_markdown'
5050gem 'rss'
5151gem 'sass-rails'
5252gem 'sassc-rails'
53+ gem 'sentry-rails'
54+ gem 'sentry-ruby'
55+ gem 'sentry-sidekiq'
5356gem 'sidekiq'
5457gem 'sidekiq-status'
5558gem 'simple_form'
Original file line number Diff line number Diff line change 614614 sprockets-rails
615615 tilt
616616 scanf (1.0.0 )
617+ sentry-rails (5.11.0 )
618+ railties (>= 5.0 )
619+ sentry-ruby (~> 5.11.0 )
620+ sentry-ruby (5.11.0 )
621+ concurrent-ruby (~> 1.0 , >= 1.0.2 )
622+ sentry-sidekiq (5.11.0 )
623+ sentry-ruby (~> 5.11.0 )
624+ sidekiq (>= 3.0 )
617625 shacl (0.3.0 )
618626 json-ld (~> 3.2 )
619627 rdf (~> 3.2 , >= 3.2.8 )
@@ -817,6 +825,9 @@ DEPENDENCIES
817825 rubocop
818826 sass-rails
819827 sassc-rails
828+ sentry-rails
829+ sentry-ruby
830+ sentry-sidekiq
820831 sidekiq
821832 sidekiq-status
822833 simple_form
Original file line number Diff line number Diff line change @@ -107,6 +107,9 @@ def user_not_authorized(exception)
107107
108108 def set_current_user
109109 User . current_user = current_user
110+ if TeSS ::Config . sentry_enabled?
111+ Sentry . set_user ( current_user ? { id : current_user . id , username : current_user . username } : { } )
112+ end
110113 end
111114
112115 protected
Original file line number Diff line number Diff line change @@ -94,6 +94,14 @@ def analytics_enabled
9494 def map_enabled
9595 !feature [ 'disabled' ] . include? ( 'events_map' ) && Rails . application . secrets . google_maps_api_key . present?
9696 end
97+
98+ def _sentry_dsn
99+ ENV . fetch ( 'SENTRY_DSN' ) { sentry_dsn }
100+ end
101+
102+ def sentry_enabled?
103+ _sentry_dsn . present? && Rails . env . production?
104+ end
97105 end
98106
99107 Config = TessConfig . new ( tess_config )
Original file line number Diff line number Diff line change 1+ Rails . configuration . after_initialize do
2+ if TeSS ::Config . sentry_enabled?
3+ Sentry . init do |config |
4+ config . dsn = TeSS ::Config . _sentry_dsn
5+ config . breadcrumbs_logger = [ :active_support_logger , :http_logger ]
6+ config . excluded_exceptions += [ 'ActionController::RoutingError' , 'ActiveRecord::RecordNotFound' ]
7+ filter = ActiveSupport ::ParameterFilter . new ( Rails . application . config . filter_parameters )
8+ config . before_send = lambda do |event , hint |
9+ filter . filter ( event . to_hash )
10+ end
11+ git_rev = `git rev-parse --short HEAD` &.chomp ( "\n " )
12+ config . release = git_rev if git_rev . present?
13+ end
14+ Sentry . configure_scope do |scope |
15+ scope . set_context ( 'app' , {
16+ app_name : TeSS ::Config . site [ 'title_short' ] ,
17+ app_version : APP_VERSION
18+ } )
19+ end
20+ end
21+ end
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ default: &default
1515 require_cookie_consent : true
1616 blocked_domains :
1717 - !ruby/regexp ' /bad-domain\.example/'
18+ sentry_dsn :
1819 site :
1920 title : ' TeSS (Training eSupport System)'
2021 title_short : TeSS
You can’t perform that action at this time.
0 commit comments