commit
95c4a47fd9
8 changed files with 30 additions and 21 deletions
|
@ -118,16 +118,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_raven_context
|
def set_raven_context
|
||||||
user = logged_user
|
Raven.user_context(sentry_user)
|
||||||
|
|
||||||
context = {
|
|
||||||
ip_address: request.ip,
|
|
||||||
id: user&.id,
|
|
||||||
email: user&.email,
|
|
||||||
roles: logged_user_roles
|
|
||||||
}.compact
|
|
||||||
|
|
||||||
Raven.user_context(context)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def append_info_to_payload(payload)
|
def append_info_to_payload(payload)
|
||||||
|
@ -202,16 +193,19 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sentry_user
|
||||||
|
user = logged_user
|
||||||
|
{ id: user&.id, role: user&.class&.name || 'Guest' }.compact
|
||||||
|
end
|
||||||
|
|
||||||
def sentry_config
|
def sentry_config
|
||||||
sentry = Rails.application.secrets.sentry
|
sentry = Rails.application.secrets.sentry
|
||||||
|
|
||||||
{
|
{
|
||||||
key: sentry[:client_key],
|
key: sentry[:client_key],
|
||||||
enabled: sentry[:enabled],
|
enabled: sentry[:enabled],
|
||||||
user: {
|
environment: sentry[:environment],
|
||||||
id: current_user&.id,
|
user: sentry_user
|
||||||
email: current_email
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
function TypeDeChampDropDownOptions({ isVisible, value, handler }) {
|
function TypeDeChampDropDownOptions({ isVisible, handler }) {
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
return (
|
return (
|
||||||
<div className="cell">
|
<div className="cell">
|
||||||
|
@ -9,7 +9,7 @@ function TypeDeChampDropDownOptions({ isVisible, value, handler }) {
|
||||||
<textarea
|
<textarea
|
||||||
id={handler.id}
|
id={handler.id}
|
||||||
name={handler.name}
|
name={handler.name}
|
||||||
value={value}
|
value={handler.value}
|
||||||
onChange={handler.onChange}
|
onChange={handler.onChange}
|
||||||
rows={3}
|
rows={3}
|
||||||
cols={40}
|
cols={40}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import * as Sentry from '@sentry/browser';
|
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
|
// We need to check for key presence here as we do not have a dsn for browser yet
|
||||||
if (enabled && key) {
|
if (enabled && key) {
|
||||||
Sentry.init({ dsn: key });
|
Sentry.init({ dsn: key, environment });
|
||||||
|
|
||||||
if (user.email) {
|
if (user.email) {
|
||||||
Sentry.configureScope(scope => {
|
Sentry.configureScope(scope => {
|
||||||
|
|
|
@ -38,6 +38,7 @@ HELPSCOUT_CLIENT_SECRET=""
|
||||||
HELPSCOUT_WEBHOOK_SECRET=""
|
HELPSCOUT_WEBHOOK_SECRET=""
|
||||||
|
|
||||||
SENTRY_ENABLED="disabled"
|
SENTRY_ENABLED="disabled"
|
||||||
|
SENTRY_CURRENT_ENV="development"
|
||||||
SENTRY_DSN_RAILS=""
|
SENTRY_DSN_RAILS=""
|
||||||
SENTRY_DSN_JS=""
|
SENTRY_DSN_JS=""
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,6 @@ if ENV['SENTRY_ENABLED'] == 'enabled'
|
||||||
|
|
||||||
Raven.configure do |config|
|
Raven.configure do |config|
|
||||||
config.dsn = ENV['SENTRY_DSN_RAILS']
|
config.dsn = ENV['SENTRY_DSN_RAILS']
|
||||||
|
config.environments = ['production', 'staging']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,6 +60,7 @@ defaults: &defaults
|
||||||
sentry:
|
sentry:
|
||||||
enabled: <%= ENV['SENTRY_ENABLED'] == 'enabled' %>
|
enabled: <%= ENV['SENTRY_ENABLED'] == 'enabled' %>
|
||||||
client_key: <%= ENV['SENTRY_DSN_JS'] %>
|
client_key: <%= ENV['SENTRY_DSN_JS'] %>
|
||||||
|
environment: <%= ENV['SENTRY_CURRENT_ENV'] %>
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
|
@ -34,7 +34,7 @@ describe ApplicationController, type: :controller do
|
||||||
context 'when no one is logged in' do
|
context 'when no one is logged in' do
|
||||||
it do
|
it do
|
||||||
expect(Raven).to have_received(:user_context)
|
expect(Raven).to have_received(:user_context)
|
||||||
.with({ ip_address: '0.0.0.0', roles: 'Guest' })
|
.with({ role: 'Guest' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
|
@ -53,7 +53,7 @@ describe ApplicationController, type: :controller do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(Raven).to have_received(:user_context)
|
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
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
|
@ -77,7 +77,7 @@ describe ApplicationController, type: :controller do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(Raven).to have_received(:user_context)
|
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
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
|
|
|
@ -133,4 +133,16 @@ feature 'As an administrateur I can edit types de champ', js: true do
|
||||||
expect(page).not_to have_content('Cadastres')
|
expect(page).not_to have_content('Cadastres')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "Add dropdown champ" do
|
||||||
|
select('Menu déroulant', from: 'champ-0-type_champ')
|
||||||
|
fill_in 'champ-0-libelle', with: 'libellé de champ menu déroulant'
|
||||||
|
blur
|
||||||
|
fill_in 'champ-0-drop_down_list_value', with: 'Un menu'
|
||||||
|
expect(page).to have_content('Formulaire enregistré')
|
||||||
|
|
||||||
|
page.refresh
|
||||||
|
|
||||||
|
expect(page).to have_content('Un menu')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue