Closed davidcarlin-ap closed 1 year ago
Could be something like this
module Stoplight
module Notifier
# @see Base
class Sentry < Base
DEFAULT_OPTIONS = {
extra: {}
}.freeze
# @return [::Sentry]
attr_reader :sentry
# @return [Proc]
attr_reader :formatter
# @return [Hash{Symbol => Object}]
attr_reader :options
# @param api_key [String]
# @param formatter [Proc, nil]
# @param options [Hash{Symbol => Object}]
# @option options [Hash] :extra
def initialize(sentry, formatter = nil, options = {})
@sentry = sentry
@formatter = formatter || Default::FORMATTER
@options = DEFAULT_OPTIONS.merge(options)
end
def notify(light, from_color, to_color, error)
message = formatter.call(light, from_color, to_color, error)
h = options.merge(
backtrace: error&.backtrace
)
sentry.capture_message(message, **h)
message
end
end
end
end
Note that it doesn't take the configuration as an option and we need to double splat the option hash (**h)
I think it's time to reconsider the future of notifiers https://github.com/bolshakov/stoplight/issues/163
It's done. I've just dropped all the notifiers from the Stoplight codebase. https://github.com/bolshakov/stoplight/pull/174
However, we plan to provide stoplight-sentry
gem as an example of an external notifier.
See: https://github.com/getsentry/sentry-ruby#migrate-from-sentry-raven
Can we please get a notifier for Sentry?