class Honeybadger::Backend::Server
Constants
- CHECK_IN_ENDPOINT
- ENDPOINTS
- EVENTS_ENDPOINT
- HTTP_ERRORS
Public Class Methods
new(config)
click to toggle source
Calls superclass method
Honeybadger::Backend::Base::new
# File lib/honeybadger/backend/server.rb, line 21 def initialize(config) @http = Util::HTTP.new(config) super end
Public Instance Methods
check_in(id)
click to toggle source
Does a check in using the input id.
@param [String] id The unique check_in
id.
@return [Response]
# File lib/honeybadger/backend/server.rb, line 44 def check_in(id) Response.new(@http.get("#{CHECK_IN_ENDPOINT}/#{id}")) rescue *HTTP_ERRORS => e Response.new(:error, nil, "HTTP Error: #{e.class}") end
event(payload)
click to toggle source
Send event @example backend.event([{event_type: “email_received”, ts: “2023-03-04T12:12:00+1:00”, subject: ‘Re: Aquisition’ }})
@param [Array] payload array of event hashes to send @return [Response]
# File lib/honeybadger/backend/server.rb, line 56 def event(payload) Response.new(@http.post_newline_delimited(EVENTS_ENDPOINT, payload)) rescue *HTTP_ERRORS => e Response.new(:error, nil, "HTTP Error: #{e.class}") end
notify(feature, payload)
click to toggle source
Post payload to endpoint for feature.
@param [Symbol] feature The feature which is being notified. @param [#to_json] payload The JSON payload to send.
@return [Response]
# File lib/honeybadger/backend/server.rb, line 32 def notify(feature, payload) ENDPOINTS[feature] or raise(BackendError, "Unknown feature: #{feature}") Response.new(@http.post(ENDPOINTS[feature], payload, payload_headers(payload))) rescue *HTTP_ERRORS => e Response.new(:error, nil, "HTTP Error: #{e.class}") end
Private Instance Methods
payload_headers(payload)
click to toggle source
# File lib/honeybadger/backend/server.rb, line 64 def payload_headers(payload) if payload.respond_to?(:api_key) && payload.api_key { 'X-API-Key' => payload.api_key } end end