diff options
author | Stan Hu <stanhu@gmail.com> | 2016-08-19 03:06:33 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-08-24 22:09:51 +0300 |
commit | 170885edd6f3ea52792511586778e0dce8021cf7 (patch) | |
tree | 4e7b04f41722dd4b369ecc7ed55285845e1e536f /app/helpers/sentry_helper.rb | |
parent | 7b0b2417491e28e5536688e0fca96829a4cb7900 (diff) |
Add Sentry logging to API calls
Closes #21043
Diffstat (limited to 'app/helpers/sentry_helper.rb')
-rw-r--r-- | app/helpers/sentry_helper.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/helpers/sentry_helper.rb b/app/helpers/sentry_helper.rb new file mode 100644 index 00000000000..f8cccade15b --- /dev/null +++ b/app/helpers/sentry_helper.rb @@ -0,0 +1,27 @@ +module SentryHelper + def sentry_enabled? + Rails.env.production? && current_application_settings.sentry_enabled? + end + + def sentry_context + return unless sentry_enabled? + + if current_user + Raven.user_context( + id: current_user.id, + email: current_user.email, + username: current_user.username, + ) + end + + Raven.tags_context(program: sentry_program_context) + end + + def sentry_program_context + if Sidekiq.server? + 'sidekiq' + else + 'rails' + end + end +end |