Class: Mixpanel::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/mixpanel-ruby/error.rb

Overview

The default behavior of the gem is to silence all errors thrown in the consumer. If you wish to handle MixpanelErrors yourself you can pass an instance of a class that extends Mixpanel::ErrorHandler to Mixpanel::Tracker on initialize.

require 'logger'

class MyErrorHandler < Mixpanel::ErrorHandler

  def initialize
    @logger = Logger.new('mylogfile.log')
    @logger.level = Logger::ERROR
  end

  def handle(error)
    logger.error "#{error.inspect}\n Backtrace: #{error.backtrace}"
  end

end

my_error_handler = MyErrorHandler.new
tracker = Mixpanel::Tracker.new(YOUR_MIXPANEL_TOKEN, my_error_handler)

Instance Method Summary collapse

Instance Method Details

#handle(error) ⇒ Object

Override #handle to customize error handling



42
43
44
# File 'lib/mixpanel-ruby/error.rb', line 42

def handle(error)
  false
end