From 6627efd6b48e70a572149865bd4196e6f711f9de Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Wed, 1 May 2019 15:23:11 -0300 Subject: Allow Sentry client-side DSN to be passed on gitlab.yml --- app/models/application_setting_implementation.rb | 2 +- app/views/admin/application_settings/_logging.html.haml | 1 - config/gitlab.yml.example | 1 + config/initializers/1_settings.rb | 1 + spec/support/shared_examples/application_setting_examples.rb | 4 +++- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb index 557215ff4dc..ee12a1d09f3 100644 --- a/app/models/application_setting_implementation.rb +++ b/app/models/application_setting_implementation.rb @@ -196,7 +196,7 @@ module ApplicationSettingImplementation end def clientside_sentry_dsn - Gitlab.config.sentry.dsn || read_attribute(:clientside_sentry_dsn) + Gitlab.config.sentry.clientside_dsn || read_attribute(:clientside_sentry_dsn) end def performance_bar_allowed_group diff --git a/app/views/admin/application_settings/_logging.html.haml b/app/views/admin/application_settings/_logging.html.haml index 006ebf09576..1da5f6fccd6 100644 --- a/app/views/admin/application_settings/_logging.html.haml +++ b/app/views/admin/application_settings/_logging.html.haml @@ -5,7 +5,6 @@ %strong NOTE: These settings will be removed from the UI in a GitLab 12.0 release and made available within gitlab.yml. - The specific client side DSN setting is already handled as a component from a Sentry perspective and will be removed. In addition, you will be able to define a Sentry Environment to differentiate between multiple deployments. For example, development, staging, and production. %fieldset diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 06530194907..2f822805b25 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -320,6 +320,7 @@ production: &base sentry: # enabled: false # dsn: https://@sentry.io/ + # clientside_dsn: https://@sentry.io/ # environment: 'production' # e.g. development, staging, production # diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 154de3bc1b0..d56bd7654af 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -224,6 +224,7 @@ Settings['sentry'] ||= Settingslogic.new({}) Settings.sentry['enabled'] ||= false Settings.sentry['dsn'] ||= nil Settings.sentry['environment'] ||= nil +Settings.sentry['clientside_dsn'] ||= nil # # Pages diff --git a/spec/support/shared_examples/application_setting_examples.rb b/spec/support/shared_examples/application_setting_examples.rb index d8f7ba1185e..421303c97be 100644 --- a/spec/support/shared_examples/application_setting_examples.rb +++ b/spec/support/shared_examples/application_setting_examples.rb @@ -260,6 +260,7 @@ RSpec.shared_examples 'application settings examples' do allow(Gitlab.config.sentry).to receive(:enabled).and_return(false) allow(Gitlab.config.sentry).to receive(:dsn).and_return(nil) + allow(Gitlab.config.sentry).to receive(:clientside_dsn).and_return(nil) expect(setting.sentry_enabled).to eq true expect(setting.sentry_dsn).to eq 'https://b44a0828b72421a6d8e99efd68d44fa8@example.com/40' @@ -277,12 +278,13 @@ RSpec.shared_examples 'application settings examples' do allow(Gitlab.config.sentry).to receive(:enabled).and_return(true) allow(Gitlab.config.sentry).to receive(:dsn).and_return('https://b44a0828b72421a6d8e99efd68d44fa8@example.com/42') + allow(Gitlab.config.sentry).to receive(:clientside_dsn).and_return('https://b44a0828b72421a6d8e99efd68d44fa8@example.com/43') expect(setting).not_to receive(:read_attribute) expect(setting.sentry_enabled).to eq true expect(setting.sentry_dsn).to eq 'https://b44a0828b72421a6d8e99efd68d44fa8@example.com/42' expect(setting.clientside_sentry_enabled).to eq true - expect(setting.clientside_sentry_dsn). to eq 'https://b44a0828b72421a6d8e99efd68d44fa8@example.com/42' + expect(setting.clientside_sentry_dsn). to eq 'https://b44a0828b72421a6d8e99efd68d44fa8@example.com/43' end end end -- cgit v1.2.1