Class: Honeybadger::Backend::Server Private

Inherits:
Base
  • Object
show all
Defined in:
lib/honeybadger/backend/server.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

ENDPOINTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  notices: '/v1/notices'.freeze,
  deploys: '/v1/deploys'.freeze,
}.freeze
CHECK_IN_ENDPOINT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'/v1/check_in'.freeze
EVENTS_ENDPOINT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'/v1/events'.freeze
HTTP_ERRORS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Util::HTTP::ERRORS

Instance Method Summary collapse

Methods inherited from Base

#track_deployment

Constructor Details

#initialize(config) ⇒ Server

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Server.



21
22
23
24
# File 'lib/honeybadger/backend/server.rb', line 21

def initialize(config)
  @http = Util::HTTP.new(config)
  super
end

Instance Method Details

#check_in(id) ⇒ Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Does a check in using the input id.

Parameters:

  • id (String)

    The unique check_in id.

Returns:



44
45
46
47
48
# 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) ⇒ Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Send event

Examples:

backend.event([{event_type: "email_received", ts: "2023-03-04T12:12:00+1:00", subject: 'Re: Aquisition' }})

Parameters:

  • payload (Array)

    array of event hashes to send

Returns:



56
57
58
59
60
# 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) ⇒ Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Post payload to endpoint for feature.

Parameters:

  • feature (Symbol)

    The feature which is being notified.

  • payload (#to_json)

    The JSON payload to send.

Returns:



32
33
34
35
36
37
# 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