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.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/raygun/configuration.rb', line 113

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.io/',
    breadcrumb_level:              :info,
    record_raw_data:               false,
    send_in_background:            false
  )
end

Instance Attribute Details

#defaultsObject (readonly)

Returns the value of attribute defaults.



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

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



136
137
138
# File 'lib/raygun/configuration.rb', line 136

def [](key)
  read_value(key)
end

#[]=(key, value) ⇒ Object



140
141
142
# File 'lib/raygun/configuration.rb', line 140

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

#affected_user_identifier_methodsObject



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

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


152
153
154
# File 'lib/raygun/configuration.rb', line 152

def breadcrumb_level
  read_value(:breadcrumb_level)
end


156
157
158
159
160
161
162
# File 'lib/raygun/configuration.rb', line 156

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



144
145
146
# File 'lib/raygun/configuration.rb', line 144

def silence_reporting
  !enable_reporting
end

#silence_reporting=(value) ⇒ Object



148
149
150
# File 'lib/raygun/configuration.rb', line 148

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