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',
'Sidekiq::JobRetry::Skip']
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.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/raygun/configuration.rb', line 126

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_mapping:         AffectedUser::DEFAULT_MAPPING,
    filter_parameters:             DEFAULT_FILTER_PARAMETERS,
    filter_payload_with_whitelist: false,
    whitelist_payload_shape:       DEFAULT_WHITELIST_PAYLOAD_SHAPE,
    proxy_settings:                {},
    debug:                         false,
    api_url:                       'https://api.raygun.com/',
    breadcrumb_level:              :info,
    record_raw_data:               false,
    send_in_background:            false,
    error_report_send_timeout:     10
  )
end

Instance Attribute Details

#defaultsObject (readonly)

Returns the value of attribute defaults.



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

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

.proc_config_option(name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/raygun/configuration.rb', line 14

def self.proc_config_option(name)
  define_method(name) do |&block|
    set_value(name, block) unless block == nil
    read_value(name)
  end

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

Instance Method Details

#[](key) ⇒ Object



150
151
152
# File 'lib/raygun/configuration.rb', line 150

def [](key)
  read_value(key)
end

#[]=(key, value) ⇒ Object



154
155
156
# File 'lib/raygun/configuration.rb', line 154

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

#affected_user_identifier_methodsObject



178
179
180
181
# File 'lib/raygun/configuration.rb', line 178

def affected_user_identifier_methods
  Raygun.deprecation_warning("Please note: You should now user config.affected_user_method_mapping.Identifier instead of config.affected_user_identifier_methods")
  read_value(:affected_user_mapping)[:identifier]
end


166
167
168
# File 'lib/raygun/configuration.rb', line 166

def breadcrumb_level
  read_value(:breadcrumb_level)
end


170
171
172
173
174
175
176
# File 'lib/raygun/configuration.rb', line 170

def breadcrumb_level=(value)
  if Raygun::Breadcrumbs::BREADCRUMB_LEVELS.include?(value)
    set_value(:breadcrumb_level, value)
  elsif read_value(:debug)
    Raygun.log("[Raygun.configuration] unknown breadcrumb level: #{value} not setting")
  end
end

#silence_reportingObject



158
159
160
# File 'lib/raygun/configuration.rb', line 158

def silence_reporting
  !enable_reporting
end

#silence_reporting=(value) ⇒ Object



162
163
164
# File 'lib/raygun/configuration.rb', line 162

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