Class: Lapsoss::Adapters::InsightHubAdapter
- Defined in:
- lib/lapsoss/adapters/insight_hub_adapter.rb
Direct Known Subclasses
Constant Summary collapse
- API_URI =
"https://notify.bugsnag.com"
Constants inherited from Base
Base::JSON_CONTENT_TYPE, Base::USER_AGENT
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #capabilities ⇒ Object
- #capture(event) ⇒ Object
-
#initialize(name, settings = {}) ⇒ InsightHubAdapter
constructor
A new instance of InsightHubAdapter.
- #validate! ⇒ Object
Methods inherited from Base
#disable!, #enable!, #enabled?, #flush, #shutdown, #supports?
Methods included from Validators
logger, validate_api_key!, validate_callable!, validate_dsn!, validate_environment!, validate_presence!, validate_retries!, validate_sample_rate!, validate_timeout!, validate_url!
Constructor Details
#initialize(name, settings = {}) ⇒ InsightHubAdapter
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lapsoss/adapters/insight_hub_adapter.rb', line 10 def initialize(name, settings = {}) super @api_key = settings[:api_key] || ENV.fetch("INSIGHT_HUB_API_KEY", nil) if @api_key.blank? Lapsoss.configuration.logger&.warn "[Lapsoss::InsightHubAdapter] No API key provided, adapter disabled" @enabled = false return else validate_api_key!(@api_key, "Insight Hub API key", format: :alphanumeric) end @client = create_http_client(API_URI) @backtrace_processor = BacktraceProcessor.new end |
Instance Method Details
#capabilities ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/lapsoss/adapters/insight_hub_adapter.rb', line 47 def capabilities super.merge( breadcrumbs: true, user_tracking: true, custom_context: true, release_tracking: true, sessions: true ) end |
#capture(event) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lapsoss/adapters/insight_hub_adapter.rb', line 26 def capture(event) return unless enabled? payload = build_payload(event) return unless payload headers = default_headers( content_type: json_content_type, extra: { "Bugsnag-Api-Key" => @api_key, "Bugsnag-Payload-Version" => "5" } ) response = @client.post("/", body: ActiveSupport::JSON.encode(payload), headers: headers) handle_response(response, event) rescue StandardError => e handle_delivery_error(e) end |
#validate! ⇒ Object
57 58 59 60 |
# File 'lib/lapsoss/adapters/insight_hub_adapter.rb', line 57 def validate! validate_settings! true end |