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:



9
10
11
# File 'lib/bugsnag/breadcrumbs/validator.rb', line 9

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#validate(breadcrumb) ⇒ Object

Validates a given breadcrumb.

Parameters:



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

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