Sentry should send environment information
This commit is contained in:
parent
697eefc7a0
commit
b9be186d2c
6 changed files with 16 additions and 19 deletions
|
@ -118,16 +118,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def set_raven_context
|
||||
user = logged_user
|
||||
|
||||
context = {
|
||||
ip_address: request.ip,
|
||||
id: user&.id,
|
||||
email: user&.email,
|
||||
roles: logged_user_roles
|
||||
}.compact
|
||||
|
||||
Raven.user_context(context)
|
||||
Raven.user_context(sentry_user)
|
||||
end
|
||||
|
||||
def append_info_to_payload(payload)
|
||||
|
@ -202,16 +193,19 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def sentry_user
|
||||
user = logged_user
|
||||
{ id: user&.id, role: user&.class&.name || 'Guest' }.compact
|
||||
end
|
||||
|
||||
def sentry_config
|
||||
sentry = Rails.application.secrets.sentry
|
||||
|
||||
{
|
||||
key: sentry[:client_key],
|
||||
enabled: sentry[:enabled],
|
||||
user: {
|
||||
id: current_user&.id,
|
||||
email: current_email
|
||||
}
|
||||
environment: sentry[:environment],
|
||||
user: sentry_user
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import * as Sentry from '@sentry/browser';
|
||||
|
||||
const { key, enabled, user } = gon.sentry || {};
|
||||
const { key, enabled, user, environment } = gon.sentry || {};
|
||||
|
||||
// We need to check for key presence here as we do not have a dsn for browser yet
|
||||
if (enabled && key) {
|
||||
Sentry.init({ dsn: key });
|
||||
Sentry.init({ dsn: key, environment });
|
||||
|
||||
if (user.email) {
|
||||
Sentry.configureScope(scope => {
|
||||
|
|
|
@ -38,6 +38,7 @@ HELPSCOUT_CLIENT_SECRET=""
|
|||
HELPSCOUT_WEBHOOK_SECRET=""
|
||||
|
||||
SENTRY_ENABLED="disabled"
|
||||
SENTRY_CURRENT_ENV="development"
|
||||
SENTRY_DSN_RAILS=""
|
||||
SENTRY_DSN_JS=""
|
||||
|
||||
|
|
|
@ -3,5 +3,6 @@ if ENV['SENTRY_ENABLED'] == 'enabled'
|
|||
|
||||
Raven.configure do |config|
|
||||
config.dsn = ENV['SENTRY_DSN_RAILS']
|
||||
config.environments = ['production', 'staging']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,6 +60,7 @@ defaults: &defaults
|
|||
sentry:
|
||||
enabled: <%= ENV['SENTRY_ENABLED'] == 'enabled' %>
|
||||
client_key: <%= ENV['SENTRY_DSN_JS'] %>
|
||||
environment: <%= ENV['SENTRY_CURRENT_ENV'] %>
|
||||
|
||||
development:
|
||||
<<: *defaults
|
||||
|
|
|
@ -34,7 +34,7 @@ describe ApplicationController, type: :controller do
|
|||
context 'when no one is logged in' do
|
||||
it do
|
||||
expect(Raven).to have_received(:user_context)
|
||||
.with({ ip_address: '0.0.0.0', roles: 'Guest' })
|
||||
.with({ role: 'Guest' })
|
||||
end
|
||||
|
||||
it do
|
||||
|
@ -53,7 +53,7 @@ describe ApplicationController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(Raven).to have_received(:user_context)
|
||||
.with({ ip_address: '0.0.0.0', email: current_user.email, id: current_user.id, roles: 'User' })
|
||||
.with({ id: current_user.id, role: 'User' })
|
||||
end
|
||||
|
||||
it do
|
||||
|
@ -77,7 +77,7 @@ describe ApplicationController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(Raven).to have_received(:user_context)
|
||||
.with({ ip_address: '0.0.0.0', email: current_user.email, id: current_user.id, roles: 'User, Gestionnaire, Administrateur, Administration' })
|
||||
.with({ id: current_user.id, role: 'User' })
|
||||
end
|
||||
|
||||
it do
|
||||
|
|
Loading…
Reference in a new issue