Skip to content
Snippets Groups Projects
Commit 3b6db16c authored by Miguel Rincon's avatar Miguel Rincon
Browse files

Use sentry configuration from UI settings

This change uses Gitlab::CurrentSettings to configure sentry on client
when `enable_new_sentry_clientside_integration` is enabled.

Conversely, it also allows users to disable the old integration sentry
by disabling `enable_old_sentry_clientside_integration`.

When both options are enabled, settings take precedence over config.
parent 889a4fdc
No related branches found
No related tags found
1 merge request!102650Use sentry configuration from UI settings
---
name: enable_new_sentry_clientside_integration
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/102650
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/344832
milestone: '15.6'
type: development
group: group::runner
default_enabled: false
---
name: enable_old_sentry_clientside_integration
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/102650
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/344832
milestone: '15.6'
type: development
group: group::runner
default_enabled: true
......@@ -17,11 +17,18 @@ def add_gon_variables
gon.markdown_surround_selection = current_user&.markdown_surround_selection
gon.markdown_automatic_lists = current_user&.markdown_automatic_lists
if Gitlab.config.sentry.enabled
# Support for Sentry setup via configuration will be removed in 16.0
# in favor of Gitlab::CurrentSettings.
if Feature.enabled?(:enable_old_sentry_clientside_integration) && Gitlab.config.sentry.enabled
gon.sentry_dsn = Gitlab.config.sentry.clientside_dsn
gon.sentry_environment = Gitlab.config.sentry.environment
end
if Feature.enabled?(:enable_new_sentry_clientside_integration) && Gitlab::CurrentSettings.sentry_enabled
gon.sentry_dsn = Gitlab::CurrentSettings.sentry_clientside_dsn
gon.sentry_environment = Gitlab::CurrentSettings.sentry_environment
end
gon.recaptcha_api_server_url = ::Recaptcha.configuration.api_server_url
gon.recaptcha_sitekey = Gitlab::CurrentSettings.recaptcha_site_key
gon.gitlab_url = Gitlab.config.gitlab.url
......
......@@ -39,6 +39,72 @@ def current_user
helper.add_gon_variables
end
end
describe 'sentry configuration' do
let(:legacy_clientside_dsn) { 'https://xxx@sentry-legacy.example.com/1' }
let(:clientside_dsn) { 'https://xxx@sentry.example.com/1' }
let(:environment) { 'production' }
context 'with enable_old_sentry_clientside_integration enabled' do
before do
stub_feature_flags(
enable_old_sentry_clientside_integration: true,
enable_new_sentry_clientside_integration: false
)
stub_config(sentry: { enabled: true, clientside_dsn: legacy_clientside_dsn, environment: environment })
end
it 'sets sentry dsn and environment from config' do
expect(gon).to receive(:sentry_dsn=).with(legacy_clientside_dsn)
expect(gon).to receive(:sentry_environment=).with(environment)
helper.add_gon_variables
end
end
context 'with enable_new_sentry_clientside_integration enabled' do
before do
stub_feature_flags(
enable_old_sentry_clientside_integration: false,
enable_new_sentry_clientside_integration: true
)
stub_application_setting(sentry_enabled: true)
stub_application_setting(sentry_clientside_dsn: clientside_dsn)
stub_application_setting(sentry_environment: environment)
end
it 'sets sentry dsn and environment from application settings' do
expect(gon).to receive(:sentry_dsn=).with(clientside_dsn)
expect(gon).to receive(:sentry_environment=).with(environment)
helper.add_gon_variables
end
end
context 'with enable_old_sentry_clientside_integration and enable_new_sentry_clientside_integration enabled' do
before do
stub_feature_flags(
enable_old_sentry_clientside_integration: true,
enable_new_sentry_clientside_integration: true
)
stub_config(sentry: { enabled: true, clientside_dsn: legacy_clientside_dsn, environment: environment })
stub_application_setting(sentry_enabled: true)
stub_application_setting(sentry_clientside_dsn: clientside_dsn)
stub_application_setting(sentry_environment: environment)
end
it 'sets sentry dsn and environment from application settings' do
expect(gon).to receive(:sentry_dsn=).with(clientside_dsn)
expect(gon).to receive(:sentry_environment=).with(environment)
helper.add_gon_variables
end
end
end
end
describe '#push_frontend_feature_flag' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment