Class: BG::Common::Analytics::Intercom::Client
- Inherits:
-
Object
- Object
- BG::Common::Analytics::Intercom::Client
- Defined in:
- lib/bg/common/analytics/intercom/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(data) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #intercom ⇒ Object
- #make_intercom_call(&block) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
6 7 8 |
# File 'lib/bg/common/analytics/intercom/client.rb', line 6 def initialize @intercom = ::Intercom::Client.new token: ENV['INTERCOM_ACCESS_TOKEN'] end |
Class Method Details
.call(data) ⇒ Object
14 15 16 |
# File 'lib/bg/common/analytics/intercom/client.rb', line 14 def self.call data self.new.call data end |
Instance Method Details
#call(data) ⇒ Object
18 19 20 21 22 |
# File 'lib/bg/common/analytics/intercom/client.rb', line 18 def call data make_intercom_call do |client| client.events.create data end end |
#intercom ⇒ Object
10 11 12 |
# File 'lib/bg/common/analytics/intercom/client.rb', line 10 def intercom @intercom ||= ::Intercom::Client.new token: ENV['INTERCOM_ACCESS_TOKEN'] end |
#make_intercom_call(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/bg/common/analytics/intercom/client.rb', line 24 def make_intercom_call &block begin yield self.intercom rescue ::Intercom::IntercomError => e # TODO: report this to newrelic so we won't lose any important # errors that we might have to fix. BG::Common.logger.debug "Intercom call failed: #{e.inspect}" end end |