Class: Bugsnag::Breadcrumbs::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/bugsnag/breadcrumbs/validator.rb

Overview

Validates a given breadcrumb before it is stored

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Validator

Returns a new instance of Validator.

Parameters:



7
8
9
# File 'lib/bugsnag/breadcrumbs/validator.rb', line 7

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#validate(breadcrumb) ⇒ Object

Validates a given breadcrumb.

Parameters:



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bugsnag/breadcrumbs/validator.rb', line 15

def validate(breadcrumb)
  # Check type is valid, set to manual otherwise
  unless Bugsnag::Breadcrumbs::VALID_BREADCRUMB_TYPES.include?(breadcrumb.type)
    @configuration.debug("Invalid type: #{breadcrumb.type} for breadcrumb: #{breadcrumb.name}, defaulting to #{Bugsnag::Breadcrumbs::MANUAL_BREADCRUMB_TYPE}")
    breadcrumb.type = Bugsnag::Breadcrumbs::MANUAL_BREADCRUMB_TYPE
  end

  # If auto is true, check type is in enabled_automatic_breadcrumb_types
  return unless breadcrumb.auto && !@configuration.enabled_automatic_breadcrumb_types.include?(breadcrumb.type)

  @configuration.debug("Automatic breadcrumb of type #{breadcrumb.type} ignored: #{breadcrumb.name}")
  breadcrumb.ignore!
end