lib/tobox/plugins/sentry.rb in tobox-0.4.2 vs lib/tobox/plugins/sentry.rb in tobox-0.4.3
- old
+ new
@@ -1,10 +1,17 @@
# frozen_string_literal: true
module Tobox
module Plugins
module Sentry
+ module ConfigurationMethods
+ def on_sentry_init(&callback)
+ (@lifecycle_events[:sentry_init] ||= []) << callback
+ self
+ end
+ end
+
class Configuration
# Set this option to true if you want Sentry to only capture the last job
# retry if it fails.
attr_accessor :report_after_retries
@@ -122,10 +129,12 @@
class << self
def load_dependencies(*)
require "uri"
require "sentry-ruby"
+ require "sentry/integrable"
+ extend ::Sentry::Integrable
end
def configure(config)
event_handler = EventHandler.new(config)
config.on_before_event(&event_handler.method(:on_start))
@@ -137,9 +146,19 @@
end
::Sentry::Configuration.attr_reader(:tobox)
::Sentry::Configuration.add_post_initialization_callback do
@tobox = Plugins::Sentry::Configuration.new
+ end
+
+ register_integration name: "tobox", version: Tobox::VERSION
+
+ config.on_start do
+ ::Sentry.init do |sentry_cfg|
+ Array(config.lifecycle_events[:sentry_init]).each do |cb|
+ cb[sentry_cfg]
+ end
+ end
end
end
end
end