Class: Raygun::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/raygun/configuration.rb

Constant Summary collapse

IGNORE_DEFAULT =

Exception classes to ignore by default

['ActiveRecord::RecordNotFound',
'ActionController::RoutingError',
'ActionController::InvalidAuthenticityToken',
'ActionDispatch::ParamsParser::ParseError',
'CGI::Session::CookieStore::TamperedWithCookie',
'ActionController::UnknownAction',
'AbstractController::ActionNotFound',
'Mongoid::Errors::DocumentNotFound']
DEFAULT_FILTER_PARAMETERS =
[ :password, :card_number, :cvv ]
DEFAULT_WHITELIST_PAYLOAD_SHAPE_REQUEST =
{
  hostName: true,
  url: true,
  httpMethod: true,
  iPAddress: true,
  queryString: true,
  headers: true,
  form: {}, # Set to empty hash so that it doesn't just filter out the whole thing, but instead filters out each individual param
  rawData: true
}.freeze
DEFAULT_WHITELIST_PAYLOAD_SHAPE =
{
  machineName: true,
  version: true,
  error: true,
  userCustomData: true,
  tags: true,
  request: DEFAULT_WHITELIST_PAYLOAD_SHAPE_REQUEST
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/raygun/configuration.rb', line 89

def initialize
  @config_values = {}

  # set default attribute values
  @defaults = OpenStruct.new({
    ignore:                           IGNORE_DEFAULT,
    custom_data:                      {},
    tags:                             [],
    enable_reporting:                 true,
    affected_user_method:             :current_user,
    affected_user_identifier_methods: [ :email, :username, :id ],
    filter_parameters:                DEFAULT_FILTER_PARAMETERS,
    filter_payload_with_whitelist:    false,
    whitelist_payload_shape:          DEFAULT_WHITELIST_PAYLOAD_SHAPE,
    proxy_settings:                   {}
  })
end

Instance Attribute Details

#defaultsObject (readonly)

Returns the value of attribute defaults.



87
88
89
# File 'lib/raygun/configuration.rb', line 87

def defaults
  @defaults
end

Class Method Details

.config_option(name) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/raygun/configuration.rb', line 4

def self.config_option(name)
  define_method(name) do
    read_value(name)
  end

  define_method("#{name}=") do |value|
    set_value(name, value)
  end
end

Instance Method Details

#[](key) ⇒ Object



107
108
109
# File 'lib/raygun/configuration.rb', line 107

def [](key)
  read_value(key)
end

#[]=(key, value) ⇒ Object



111
112
113
# File 'lib/raygun/configuration.rb', line 111

def []=(key, value)
  set_value(key, value)
end

#filter_parameters(&filter_proc) ⇒ Object



123
124
125
126
# File 'lib/raygun/configuration.rb', line 123

def filter_parameters(&filter_proc)
  set_value(:filter_parameters, filter_proc) if block_given?
  read_value(:filter_parameters)
end

#silence_reportingObject



115
116
117
# File 'lib/raygun/configuration.rb', line 115

def silence_reporting
  !enable_reporting
end

#silence_reporting=(value) ⇒ Object



119
120
121
# File 'lib/raygun/configuration.rb', line 119

def silence_reporting=(value)
  self.enable_reporting = !value
end

#whitelist_payload_shape(&filter_proc) ⇒ Object



128
129
130
131
# File 'lib/raygun/configuration.rb', line 128

def whitelist_payload_shape(&filter_proc)
  set_value(:whitelist_payload_shape, filter_proc) if block_given?
  read_value(:whitelist_payload_shape)
end