Send browser support information and format user id
This commit is contained in:
parent
8e6e730c80
commit
4fb889f10a
3 changed files with 7 additions and 5 deletions
|
@ -195,7 +195,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def sentry_user
|
||||
user = logged_user
|
||||
{ id: user&.id, role: user&.class&.name || 'Guest' }.compact
|
||||
{ id: user ? "#{user.class.name}##{user.id}" : 'Guest' }
|
||||
end
|
||||
|
||||
def sentry_config
|
||||
|
@ -205,6 +205,7 @@ class ApplicationController < ActionController::Base
|
|||
key: sentry[:client_key],
|
||||
enabled: sentry[:enabled],
|
||||
environment: sentry[:environment],
|
||||
browser: { modern: browser.modern? },
|
||||
user: sentry_user
|
||||
}
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as Sentry from '@sentry/browser';
|
||||
|
||||
const { key, enabled, user, environment } = gon.sentry || {};
|
||||
const { key, enabled, user, environment, browser } = gon.sentry || {};
|
||||
|
||||
// We need to check for key presence here as we do not have a dsn for browser yet
|
||||
if (enabled && key) {
|
||||
|
@ -8,5 +8,6 @@ if (enabled && key) {
|
|||
|
||||
Sentry.configureScope(scope => {
|
||||
scope.setUser(user);
|
||||
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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({ role: 'Guest' })
|
||||
.with({ id: 'Guest' })
|
||||
end
|
||||
|
||||
it do
|
||||
|
@ -53,7 +53,7 @@ describe ApplicationController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(Raven).to have_received(:user_context)
|
||||
.with({ id: current_user.id, role: 'User' })
|
||||
.with({ id: "User##{current_user.id}" })
|
||||
end
|
||||
|
||||
it do
|
||||
|
@ -77,7 +77,7 @@ describe ApplicationController, type: :controller do
|
|||
|
||||
it do
|
||||
expect(Raven).to have_received(:user_context)
|
||||
.with({ id: current_user.id, role: 'User' })
|
||||
.with({ id: "User##{current_user.id}" })
|
||||
end
|
||||
|
||||
it do
|
||||
|
|
Loading…
Reference in a new issue