Sha256: efc764399d0b389e822ff515cab356467d67f3e2b37affe4cc3b5de245132fcd

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

require 'bugsnag/breadcrumbs/breadcrumbs'

module Bugsnag::Breadcrumbs
  ##
  # Validates a given breadcrumb before it is stored
  class Validator
    ##
    # @param configuration [Bugsnag::Configuration] The current configuration
    def initialize(configuration)
      @configuration = configuration
    end

    ##
    # Validates a given breadcrumb.
    #
    # @param breadcrumb [Bugsnag::Breadcrumbs::Breadcrumb] the breadcrumb to be validated
    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
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
bugsnag-6.26.4 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.26.3 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.26.2 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.26.1 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.26.0 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.25.2 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.25.1 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.25.0 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.24.2 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.24.1 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.24.0 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.23.0 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.22.1 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.21.0 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.20.0 lib/bugsnag/breadcrumbs/validator.rb
bugsnag-6.19.0 lib/bugsnag/breadcrumbs/validator.rb