diff options
Diffstat (limited to 'app/models/error_tracking/project_error_tracking_setting.rb')
-rw-r--r-- | app/models/error_tracking/project_error_tracking_setting.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb index c729b002852..c5a77427588 100644 --- a/app/models/error_tracking/project_error_tracking_setting.rb +++ b/app/models/error_tracking/project_error_tracking_setting.rb @@ -31,12 +31,13 @@ module ErrorTracking validates :api_url, length: { maximum: 255 }, public_url: { enforce_sanitization: true, ascii_only: true }, allow_nil: true validates :enabled, inclusion: { in: [true, false] } + validates :integrated, inclusion: { in: [true, false] } - validates :api_url, presence: { message: 'is a required field' }, if: :enabled - - validate :validate_api_url_path, if: :enabled - - validates :token, presence: { message: 'is a required field' }, if: :enabled + with_options if: :sentry_enabled do + validates :api_url, presence: { message: 'is a required field' } + validates :token, presence: { message: 'is a required field' } + validate :validate_api_url_path + end attr_encrypted :token, mode: :per_attribute_iv, @@ -45,6 +46,14 @@ module ErrorTracking after_save :clear_reactive_cache! + def sentry_enabled + enabled && !integrated_client? + end + + def integrated_client? + integrated && ::Feature.enabled?(:integrated_error_tracking, project) + end + def api_url=(value) super clear_memoization(:api_url_slugs) @@ -79,7 +88,7 @@ module ErrorTracking def sentry_client strong_memoize(:sentry_client) do - ErrorTracking::SentryClient.new(api_url, token) + ::ErrorTracking::SentryClient.new(api_url, token) end end |