diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-01-20 16:15:19 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-01-20 16:15:19 +0100 |
commit | 0ad6b44a27baa260fb94569c354f30a54cf86d13 (patch) | |
tree | 1c89d38cd5224d51fd0fc84ad648a509d9da2554 | |
parent | 7a609858f063c1089f3a6ec05f9f87a01efa909a (diff) | |
download | gitlab-ce-0ad6b44a27baa260fb94569c354f30a54cf86d13.tar.gz |
Send user context to Sentry
-rw-r--r-- | app/controllers/application_controller.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bf99b2e777d..633c3f55614 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -15,6 +15,7 @@ class ApplicationController < ActionController::Base before_action :check_password_expiration before_action :check_2fa_requirement before_action :ldap_security_check + before_action :sentry_user_context before_action :default_headers before_action :add_gon_variables before_action :configure_permitted_parameters, if: :devise_controller? @@ -41,6 +42,16 @@ class ApplicationController < ActionController::Base protected + def sentry_user_context + if Rails.env.production? && current_application_settings.sentry_enabled && current_user + Raven.user_context( + id: current_user.id, + email: current_user.email, + username: current_user.username, + ) + end + end + # From https://github.com/plataformatec/devise/wiki/How-To:-Simple-Token-Authentication-Example # https://gist.github.com/josevalim/fb706b1e933ef01e4fb6 def authenticate_user_from_token! |