raygun4ruby 3.2.6 → 4.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +48 -0
- data/.gitignore +22 -21
- data/.rspec +1 -1
- data/Appraisals +19 -0
- data/CHANGELOG.md +169 -133
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +424 -420
- data/Rakefile +32 -27
- data/examples/sinatras_raygun.rb +17 -17
- data/gemfiles/rails_6.gemfile +9 -0
- data/gemfiles/rails_7.gemfile +10 -0
- data/gemfiles/rails_7_sidekiq_6.gemfile +10 -0
- data/lib/generators/raygun/install_generator.rb +26 -26
- data/lib/raygun/affected_user.rb +59 -59
- data/lib/raygun/breadcrumbs/breadcrumb.rb +34 -34
- data/lib/raygun/breadcrumbs/store.rb +86 -86
- data/lib/raygun/breadcrumbs.rb +34 -34
- data/lib/raygun/client.rb +313 -308
- data/lib/raygun/configuration.rb +197 -194
- data/lib/raygun/demo_exception.rb +22 -22
- data/lib/raygun/error.rb +10 -10
- data/lib/raygun/error_subscriber.rb +21 -0
- data/lib/raygun/javascript_tracker.rb +42 -42
- data/lib/raygun/middleware/breadcrumbs_store_initializer.rb +19 -19
- data/lib/raygun/middleware/javascript_exception_tracking.rb +40 -32
- data/lib/raygun/middleware/rack_exception_interceptor.rb +18 -18
- data/lib/raygun/middleware/rails_insert_affected_user.rb +26 -26
- data/lib/raygun/railtie.rb +47 -39
- data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +27 -27
- data/lib/raygun/sidekiq.rb +51 -71
- data/lib/raygun/version.rb +3 -3
- data/lib/raygun.rb +197 -179
- data/lib/raygun4ruby.rb +1 -1
- data/lib/resque/failure/raygun.rb +25 -25
- data/lib/tasks/raygun.tasks +7 -7
- data/raygun4ruby.gemspec +43 -45
- data/spec/features/javascript_spec.rb +48 -48
- data/spec/rails_applications/6.1.4/Gemfile +56 -0
- data/spec/{dummy/README.rdoc → rails_applications/6.1.4/README.md} +24 -28
- data/spec/{dummy → rails_applications/6.1.4}/Rakefile +6 -6
- data/spec/rails_applications/6.1.4/app/assets/config/manifest.js +2 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/assets/images/.keep +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/assets/stylesheets/application.css +15 -15
- data/spec/rails_applications/6.1.4/app/channels/application_cable/channel.rb +4 -0
- data/spec/rails_applications/6.1.4/app/channels/application_cable/connection.rb +4 -0
- data/spec/rails_applications/6.1.4/app/controllers/application_controller.rb +2 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/controllers/concerns/.keep +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/controllers/home_controller.rb +4 -4
- data/spec/{dummy → rails_applications/6.1.4}/app/helpers/application_helper.rb +2 -2
- data/spec/rails_applications/6.1.4/app/javascript/channels/consumer.js +6 -0
- data/spec/rails_applications/6.1.4/app/javascript/channels/index.js +5 -0
- data/spec/rails_applications/6.1.4/app/javascript/packs/application.js +13 -0
- data/spec/rails_applications/6.1.4/app/jobs/application_job.rb +7 -0
- data/spec/rails_applications/6.1.4/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_applications/6.1.4/app/models/application_record.rb +3 -0
- data/spec/{dummy/app/mailers → rails_applications/6.1.4/app/models/concerns}/.keep +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.html.erb +3 -3
- data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.json.erb +1 -1
- data/spec/rails_applications/6.1.4/app/views/layouts/application.html.erb +13 -0
- data/spec/rails_applications/6.1.4/app/views/layouts/mailer.html.erb +13 -0
- data/spec/rails_applications/6.1.4/app/views/layouts/mailer.text.erb +1 -0
- data/spec/rails_applications/6.1.4/bin/rails +5 -0
- data/spec/rails_applications/6.1.4/bin/rake +5 -0
- data/spec/rails_applications/6.1.4/bin/setup +36 -0
- data/spec/rails_applications/6.1.4/bin/spring +14 -0
- data/spec/rails_applications/6.1.4/bin/yarn +17 -0
- data/spec/rails_applications/6.1.4/config/application.rb +22 -0
- data/spec/rails_applications/6.1.4/config/boot.rb +3 -0
- data/spec/rails_applications/6.1.4/config/cable.yml +10 -0
- data/spec/rails_applications/6.1.4/config/credentials.yml.enc +1 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/database.yml +25 -25
- data/spec/{dummy → rails_applications/6.1.4}/config/environment.rb +5 -5
- data/spec/rails_applications/6.1.4/config/environments/development.rb +76 -0
- data/spec/rails_applications/6.1.4/config/environments/production.rb +120 -0
- data/spec/rails_applications/6.1.4/config/environments/test.rb +60 -0
- data/spec/rails_applications/6.1.4/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/rails_applications/6.1.4/config/initializers/assets.rb +14 -0
- data/spec/rails_applications/6.1.4/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/rails_applications/6.1.4/config/initializers/content_security_policy.rb +30 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/cookies_serializer.rb +5 -3
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/filter_parameter_logging.rb +6 -4
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/inflections.rb +16 -16
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/mime_types.rb +4 -4
- data/spec/rails_applications/6.1.4/config/initializers/permissions_policy.rb +11 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/wrap_parameters.rb +14 -14
- data/spec/{dummy → rails_applications/6.1.4}/config/locales/en.yml +33 -23
- data/spec/rails_applications/6.1.4/config/master.key +1 -0
- data/spec/rails_applications/6.1.4/config/puma.rb +43 -0
- data/spec/rails_applications/6.1.4/config/routes.rb +4 -0
- data/spec/rails_applications/6.1.4/config/spring.rb +6 -0
- data/spec/rails_applications/6.1.4/config/storage.yml +34 -0
- data/spec/{dummy → rails_applications/6.1.4}/config.ru +6 -4
- data/spec/rails_applications/6.1.4/db/seeds.rb +7 -0
- data/spec/{dummy → rails_applications/6.1.4}/db/test.sqlite3 +0 -0
- data/spec/{dummy/app/models → rails_applications/6.1.4/lib/assets}/.keep +0 -0
- data/spec/{dummy/app/models/concerns → rails_applications/6.1.4/lib/tasks}/.keep +0 -0
- data/spec/rails_applications/6.1.4/package.json +11 -0
- data/spec/{dummy → rails_applications/6.1.4}/public/404.html +67 -67
- data/spec/{dummy → rails_applications/6.1.4}/public/422.html +67 -67
- data/spec/{dummy → rails_applications/6.1.4}/public/500.html +66 -66
- data/spec/{dummy/lib/assets/.keep → rails_applications/6.1.4/public/apple-touch-icon-precomposed.png} +0 -0
- data/spec/{dummy/lib/tasks/.keep → rails_applications/6.1.4/public/apple-touch-icon.png} +0 -0
- data/spec/{dummy → rails_applications/6.1.4}/public/favicon.ico +0 -0
- data/spec/rails_applications/6.1.4/public/robots.txt +1 -0
- data/spec/{dummy/log → rails_applications/6.1.4/storage}/.keep +0 -0
- data/spec/rails_applications/7.1.3/.dockerignore +37 -0
- data/spec/rails_applications/7.1.3/.gitattributes +9 -0
- data/spec/rails_applications/7.1.3/.gitignore +35 -0
- data/spec/rails_applications/7.1.3/.ruby-version +1 -0
- data/spec/rails_applications/7.1.3/Dockerfile +62 -0
- data/spec/rails_applications/7.1.3/Gemfile +67 -0
- data/spec/rails_applications/7.1.3/README.md +24 -0
- data/spec/rails_applications/7.1.3/Rakefile +6 -0
- data/spec/rails_applications/7.1.3/app/assets/config/manifest.js +4 -0
- data/spec/{dummy/test/controllers → rails_applications/7.1.3/app/assets/images}/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/assets/stylesheets/application.css +15 -0
- data/spec/rails_applications/7.1.3/app/channels/application_cable/channel.rb +4 -0
- data/spec/rails_applications/7.1.3/app/channels/application_cable/connection.rb +4 -0
- data/spec/rails_applications/7.1.3/app/controllers/application_controller.rb +2 -0
- data/spec/{dummy/test/fixtures → rails_applications/7.1.3/app/controllers/concerns}/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/controllers/home_controller.rb +2 -0
- data/spec/rails_applications/7.1.3/app/helpers/application_helper.rb +2 -0
- data/spec/rails_applications/7.1.3/app/helpers/home_helper.rb +2 -0
- data/spec/rails_applications/7.1.3/app/javascript/application.js +3 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/application.js +9 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/hello_controller.js +7 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/index.js +11 -0
- data/spec/rails_applications/7.1.3/app/jobs/application_job.rb +7 -0
- data/spec/rails_applications/7.1.3/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_applications/7.1.3/app/models/application_record.rb +3 -0
- data/spec/{dummy/test/helpers → rails_applications/7.1.3/app/models/concerns}/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/views/home/index.html.erb +3 -0
- data/spec/rails_applications/7.1.3/app/views/home/index.json.erb +1 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/application.html.erb +16 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/mailer.html.erb +13 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/mailer.text.erb +1 -0
- data/spec/rails_applications/7.1.3/bin/bundle +109 -0
- data/spec/rails_applications/7.1.3/bin/docker-entrypoint +8 -0
- data/spec/rails_applications/7.1.3/bin/importmap +4 -0
- data/spec/rails_applications/7.1.3/bin/rails +4 -0
- data/spec/rails_applications/7.1.3/bin/rake +4 -0
- data/spec/rails_applications/7.1.3/bin/setup +33 -0
- data/spec/rails_applications/7.1.3/config/application.rb +27 -0
- data/spec/rails_applications/7.1.3/config/boot.rb +4 -0
- data/spec/rails_applications/7.1.3/config/cable.yml +11 -0
- data/spec/rails_applications/7.1.3/config/credentials.yml.enc +1 -0
- data/spec/rails_applications/7.1.3/config/database.yml +25 -0
- data/spec/rails_applications/7.1.3/config/environment.rb +5 -0
- data/spec/rails_applications/7.1.3/config/environments/development.rb +76 -0
- data/spec/rails_applications/7.1.3/config/environments/production.rb +97 -0
- data/spec/rails_applications/7.1.3/config/environments/test.rb +64 -0
- data/spec/rails_applications/7.1.3/config/importmap.rb +7 -0
- data/spec/rails_applications/7.1.3/config/initializers/assets.rb +12 -0
- data/spec/rails_applications/7.1.3/config/initializers/content_security_policy.rb +25 -0
- data/spec/rails_applications/7.1.3/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/rails_applications/7.1.3/config/initializers/inflections.rb +16 -0
- data/spec/rails_applications/7.1.3/config/initializers/permissions_policy.rb +13 -0
- data/spec/rails_applications/7.1.3/config/locales/en.yml +31 -0
- data/spec/rails_applications/7.1.3/config/puma.rb +35 -0
- data/spec/rails_applications/7.1.3/config/routes.rb +11 -0
- data/spec/rails_applications/7.1.3/config/storage.yml +34 -0
- data/spec/rails_applications/7.1.3/config.ru +6 -0
- data/spec/rails_applications/7.1.3/db/seeds.rb +9 -0
- data/spec/{dummy/test/integration → rails_applications/7.1.3/lib/assets}/.keep +0 -0
- data/spec/{dummy/test/mailers → rails_applications/7.1.3/lib/tasks}/.keep +0 -0
- data/spec/rails_applications/7.1.3/public/404.html +67 -0
- data/spec/rails_applications/7.1.3/public/422.html +67 -0
- data/spec/rails_applications/7.1.3/public/500.html +66 -0
- data/spec/{dummy/test/models/.keep → rails_applications/7.1.3/public/apple-touch-icon-precomposed.png} +0 -0
- data/spec/{dummy/vendor/assets/javascripts/.keep → rails_applications/7.1.3/public/apple-touch-icon.png} +0 -0
- data/spec/{dummy/vendor/assets/stylesheets/.keep → rails_applications/7.1.3/public/favicon.ico} +0 -0
- data/spec/rails_applications/7.1.3/public/robots.txt +1 -0
- data/spec/rails_applications/7.1.3/storage/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/application_system_test_case.rb +5 -0
- data/spec/rails_applications/7.1.3/test/channels/application_cable/connection_test.rb +13 -0
- data/spec/rails_applications/7.1.3/test/controllers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/controllers/home_controller_test.rb +7 -0
- data/spec/rails_applications/7.1.3/test/fixtures/files/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/helpers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/integration/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/mailers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/models/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/system/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/test_helper.rb +15 -0
- data/spec/rails_applications/7.1.3/vendor/.keep +0 -0
- data/spec/rails_applications/7.1.3/vendor/javascript/.keep +0 -0
- data/spec/rails_helper.rb +8 -4
- data/spec/raygun/breadcrumbs/breadcrumb_spec.rb +171 -171
- data/spec/raygun/breadcrumbs/store_spec.rb +170 -170
- data/spec/services/apply_whitelist_filter_to_payload_spec.rb +251 -251
- data/spec/spec_helper.rb +24 -24
- data/spec/support/fake_logger.rb +17 -17
- data/test/integration/client_test.rb +19 -19
- data/test/rails_helper.rb +6 -0
- data/test/test_helper.rb +76 -72
- data/test/unit/affected_user_test.rb +136 -136
- data/test/unit/client_test.rb +812 -812
- data/test/unit/configuration_test.rb +202 -206
- data/test/unit/error_subscriber_test.rb +43 -0
- data/test/unit/raygun_test.rb +106 -25
- data/test/unit/resque_failure_test.rb +27 -24
- data/test/unit/sidekiq_failure_test.rb +42 -32
- metadata +186 -125
- data/.travis.yml +0 -20
- data/spec/dummy/.gitignore +0 -17
- data/spec/dummy/Gemfile +0 -47
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -9
- data/spec/dummy/bin/rake +0 -9
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/bin/spring +0 -17
- data/spec/dummy/config/application.rb +0 -26
- data/spec/dummy/config/boot.rb +0 -3
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/spec/dummy/config/routes.rb +0 -58
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/public/robots.txt +0 -5
- data/spec/dummy/test/test_helper.rb +0 -10
- data/spec/raygun/raygun_spec.rb +0 -47
data/lib/raygun/configuration.rb
CHANGED
@@ -1,194 +1,197 @@
|
|
1
|
-
module Raygun
|
2
|
-
class Configuration
|
3
|
-
|
4
|
-
def self.config_option(name)
|
5
|
-
define_method(name) do
|
6
|
-
read_value(name)
|
7
|
-
end
|
8
|
-
|
9
|
-
define_method("#{name}=") do |value|
|
10
|
-
set_value(name, value)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.proc_config_option(name)
|
15
|
-
define_method(name) do |&block|
|
16
|
-
set_value(name, block) unless block == nil
|
17
|
-
read_value(name)
|
18
|
-
end
|
19
|
-
|
20
|
-
define_method("#{name}=") do |value|
|
21
|
-
set_value(name, value)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Your Raygun API Key - this can be found on your dashboard at https://app.raygun.com
|
26
|
-
config_option :api_key
|
27
|
-
|
28
|
-
# Your JS Raygun API Key - Should be different to your api_key, it's best practice to separate your errors between front end and back end.
|
29
|
-
config_option :js_api_key
|
30
|
-
|
31
|
-
# Your JS Raygun API Version, defaults to latest as found on https://raygun.com/documentation/language-guides/javascript/crash-reporting/installation/
|
32
|
-
config_option :js_api_version
|
33
|
-
|
34
|
-
# Array of exception classes to ignore
|
35
|
-
config_option :ignore
|
36
|
-
|
37
|
-
# Version to use
|
38
|
-
config_option :version
|
39
|
-
|
40
|
-
# Custom Data to send with each exception
|
41
|
-
proc_config_option :custom_data
|
42
|
-
|
43
|
-
# Tags to send with each exception
|
44
|
-
proc_config_option :tags
|
45
|
-
|
46
|
-
# Logger to use when we find an exception :)
|
47
|
-
config_option :logger
|
48
|
-
|
49
|
-
# Should we actually report exceptions to Raygun? (Usually disabled in Development mode, for instance)
|
50
|
-
config_option :enable_reporting
|
51
|
-
|
52
|
-
# Failsafe logger (for exceptions that happen when we're attempting to report exceptions)
|
53
|
-
config_option :failsafe_logger
|
54
|
-
|
55
|
-
# Which controller method should we call to find out the affected user?
|
56
|
-
config_option :affected_user_method
|
57
|
-
|
58
|
-
# Mapping of methods for the affected user object - which methods should we call for user information
|
59
|
-
config_option :affected_user_mapping
|
60
|
-
|
61
|
-
# Which parameter keys should we filter out by default?
|
62
|
-
proc_config_option :filter_parameters
|
63
|
-
|
64
|
-
# Should we switch to a white listing mode for keys instead of the default blacklist?
|
65
|
-
config_option :filter_payload_with_whitelist
|
66
|
-
|
67
|
-
# If :filter_payload_with_whitelist is true, which keys should we whitelist?
|
68
|
-
proc_config_option :whitelist_payload_shape
|
69
|
-
|
70
|
-
# Hash of proxy settings - :address, :port (defaults to 80), :username and :password (both default to nil)
|
71
|
-
config_option :proxy_settings
|
72
|
-
|
73
|
-
# Set this to true to have raygun4ruby log the reason why it skips reporting an exception
|
74
|
-
config_option :debug
|
75
|
-
|
76
|
-
# Override this if you wish to connect to a different Raygun API than the standard one
|
77
|
-
config_option :api_url
|
78
|
-
|
79
|
-
# Should Raygun include the raw request body in the payload? This will not include
|
80
|
-
# form submissions and will not be filtered by the blacklist
|
81
|
-
config_option :record_raw_data
|
82
|
-
|
83
|
-
# Should the exceptions to Raygun be sent asynchronously?
|
84
|
-
config_option :send_in_background
|
85
|
-
|
86
|
-
# How long to wait for the POST request to the API server before timing out
|
87
|
-
config_option :error_report_send_timeout
|
88
|
-
|
89
|
-
#
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
'
|
95
|
-
'ActionController::
|
96
|
-
'
|
97
|
-
'
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
@
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
end
|
1
|
+
module Raygun
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
def self.config_option(name)
|
5
|
+
define_method(name) do
|
6
|
+
read_value(name)
|
7
|
+
end
|
8
|
+
|
9
|
+
define_method("#{name}=") do |value|
|
10
|
+
set_value(name, value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.proc_config_option(name)
|
15
|
+
define_method(name) do |&block|
|
16
|
+
set_value(name, block) unless block == nil
|
17
|
+
read_value(name)
|
18
|
+
end
|
19
|
+
|
20
|
+
define_method("#{name}=") do |value|
|
21
|
+
set_value(name, value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Your Raygun API Key - this can be found on your dashboard at https://app.raygun.com
|
26
|
+
config_option :api_key
|
27
|
+
|
28
|
+
# Your JS Raygun API Key - Should be different to your api_key, it's best practice to separate your errors between front end and back end.
|
29
|
+
config_option :js_api_key
|
30
|
+
|
31
|
+
# Your JS Raygun API Version, defaults to latest as found on https://raygun.com/documentation/language-guides/javascript/crash-reporting/installation/
|
32
|
+
config_option :js_api_version
|
33
|
+
|
34
|
+
# Array of exception classes to ignore
|
35
|
+
config_option :ignore
|
36
|
+
|
37
|
+
# Version to use
|
38
|
+
config_option :version
|
39
|
+
|
40
|
+
# Custom Data to send with each exception
|
41
|
+
proc_config_option :custom_data
|
42
|
+
|
43
|
+
# Tags to send with each exception
|
44
|
+
proc_config_option :tags
|
45
|
+
|
46
|
+
# Logger to use when we find an exception :)
|
47
|
+
config_option :logger
|
48
|
+
|
49
|
+
# Should we actually report exceptions to Raygun? (Usually disabled in Development mode, for instance)
|
50
|
+
config_option :enable_reporting
|
51
|
+
|
52
|
+
# Failsafe logger (for exceptions that happen when we're attempting to report exceptions)
|
53
|
+
config_option :failsafe_logger
|
54
|
+
|
55
|
+
# Which controller method should we call to find out the affected user?
|
56
|
+
config_option :affected_user_method
|
57
|
+
|
58
|
+
# Mapping of methods for the affected user object - which methods should we call for user information
|
59
|
+
config_option :affected_user_mapping
|
60
|
+
|
61
|
+
# Which parameter keys should we filter out by default?
|
62
|
+
proc_config_option :filter_parameters
|
63
|
+
|
64
|
+
# Should we switch to a white listing mode for keys instead of the default blacklist?
|
65
|
+
config_option :filter_payload_with_whitelist
|
66
|
+
|
67
|
+
# If :filter_payload_with_whitelist is true, which keys should we whitelist?
|
68
|
+
proc_config_option :whitelist_payload_shape
|
69
|
+
|
70
|
+
# Hash of proxy settings - :address, :port (defaults to 80), :username and :password (both default to nil)
|
71
|
+
config_option :proxy_settings
|
72
|
+
|
73
|
+
# Set this to true to have raygun4ruby log the reason why it skips reporting an exception
|
74
|
+
config_option :debug
|
75
|
+
|
76
|
+
# Override this if you wish to connect to a different Raygun API than the standard one
|
77
|
+
config_option :api_url
|
78
|
+
|
79
|
+
# Should Raygun include the raw request body in the payload? This will not include
|
80
|
+
# form submissions and will not be filtered by the blacklist
|
81
|
+
config_option :record_raw_data
|
82
|
+
|
83
|
+
# Should the exceptions to Raygun be sent asynchronously?
|
84
|
+
config_option :send_in_background
|
85
|
+
|
86
|
+
# How long to wait for the POST request to the API server before timing out
|
87
|
+
config_option :error_report_send_timeout
|
88
|
+
|
89
|
+
# Should we register an error handler with [Rails' built in API](https://edgeguides.rubyonrails.org/error_reporting.html)
|
90
|
+
config_option :register_rails_error_handler
|
91
|
+
|
92
|
+
# Exception classes to ignore by default
|
93
|
+
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
94
|
+
'ActionController::RoutingError',
|
95
|
+
'ActionController::InvalidAuthenticityToken',
|
96
|
+
'ActionDispatch::ParamsParser::ParseError',
|
97
|
+
'CGI::Session::CookieStore::TamperedWithCookie',
|
98
|
+
'ActionController::UnknownAction',
|
99
|
+
'AbstractController::ActionNotFound',
|
100
|
+
'Mongoid::Errors::DocumentNotFound']
|
101
|
+
|
102
|
+
DEFAULT_FILTER_PARAMETERS = [ :password, :card_number, :cvv ]
|
103
|
+
|
104
|
+
DEFAULT_WHITELIST_PAYLOAD_SHAPE_REQUEST = {
|
105
|
+
hostName: true,
|
106
|
+
url: true,
|
107
|
+
httpMethod: true,
|
108
|
+
iPAddress: true,
|
109
|
+
queryString: true,
|
110
|
+
headers: true,
|
111
|
+
form: {}, # Set to empty hash so that it doesn't just filter out the whole thing, but instead filters out each individual param
|
112
|
+
rawData: true
|
113
|
+
}.freeze
|
114
|
+
DEFAULT_WHITELIST_PAYLOAD_SHAPE = {
|
115
|
+
machineName: true,
|
116
|
+
version: true,
|
117
|
+
error: true,
|
118
|
+
userCustomData: true,
|
119
|
+
tags: true,
|
120
|
+
request: DEFAULT_WHITELIST_PAYLOAD_SHAPE_REQUEST
|
121
|
+
}.freeze
|
122
|
+
|
123
|
+
attr_reader :defaults
|
124
|
+
|
125
|
+
def initialize
|
126
|
+
@config_values = {}
|
127
|
+
|
128
|
+
# set default attribute values
|
129
|
+
@defaults = OpenStruct.new(
|
130
|
+
ignore: IGNORE_DEFAULT,
|
131
|
+
custom_data: {},
|
132
|
+
tags: [],
|
133
|
+
enable_reporting: true,
|
134
|
+
affected_user_method: :current_user,
|
135
|
+
affected_user_mapping: AffectedUser::DEFAULT_MAPPING,
|
136
|
+
filter_parameters: DEFAULT_FILTER_PARAMETERS,
|
137
|
+
filter_payload_with_whitelist: false,
|
138
|
+
whitelist_payload_shape: DEFAULT_WHITELIST_PAYLOAD_SHAPE,
|
139
|
+
proxy_settings: {},
|
140
|
+
debug: false,
|
141
|
+
api_url: 'https://api.raygun.com/',
|
142
|
+
breadcrumb_level: :info,
|
143
|
+
record_raw_data: false,
|
144
|
+
send_in_background: false,
|
145
|
+
error_report_send_timeout: 10
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
def [](key)
|
150
|
+
read_value(key)
|
151
|
+
end
|
152
|
+
|
153
|
+
def []=(key, value)
|
154
|
+
set_value(key, value)
|
155
|
+
end
|
156
|
+
|
157
|
+
def silence_reporting
|
158
|
+
!enable_reporting
|
159
|
+
end
|
160
|
+
|
161
|
+
def silence_reporting=(value)
|
162
|
+
self.enable_reporting = !value
|
163
|
+
end
|
164
|
+
|
165
|
+
def breadcrumb_level
|
166
|
+
read_value(:breadcrumb_level)
|
167
|
+
end
|
168
|
+
|
169
|
+
def breadcrumb_level=(value)
|
170
|
+
if Raygun::Breadcrumbs::BREADCRUMB_LEVELS.include?(value)
|
171
|
+
set_value(:breadcrumb_level, value)
|
172
|
+
elsif read_value(:debug)
|
173
|
+
Raygun.log("[Raygun.configuration] unknown breadcrumb level: #{value} not setting")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def affected_user_identifier_methods
|
178
|
+
Raygun.deprecation_warning("Please note: You should now user config.affected_user_method_mapping.Identifier instead of config.affected_user_identifier_methods")
|
179
|
+
read_value(:affected_user_mapping)[:identifier]
|
180
|
+
end
|
181
|
+
|
182
|
+
private
|
183
|
+
|
184
|
+
def read_value(name)
|
185
|
+
if @config_values.has_key?(name)
|
186
|
+
@config_values[name]
|
187
|
+
else
|
188
|
+
@defaults.send(name)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def set_value(name, value)
|
193
|
+
@config_values[name] = value
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
module Raygun
|
2
|
-
|
3
|
-
class ItWorksException < StandardError; end
|
4
|
-
|
5
|
-
module DemoException
|
6
|
-
|
7
|
-
def track_test_exception
|
8
|
-
Raygun.configuration.silence_reporting = false
|
9
|
-
raise ItWorksException.new("Woohoo! Your Raygun<->Ruby connection is set up correctly")
|
10
|
-
rescue ItWorksException => e
|
11
|
-
response = Raygun.track_exception(e)
|
12
|
-
|
13
|
-
if response.success?
|
14
|
-
puts "Success! Now go check your Raygun Dashboard"
|
15
|
-
else
|
16
|
-
puts "Oh-oh, something went wrong - double check your API key"
|
17
|
-
puts "API Key - " << Raygun.configuration.api_key << ")"
|
18
|
-
puts "API Response - " << response
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
1
|
+
module Raygun
|
2
|
+
|
3
|
+
class ItWorksException < StandardError; end
|
4
|
+
|
5
|
+
module DemoException
|
6
|
+
|
7
|
+
def track_test_exception
|
8
|
+
Raygun.configuration.silence_reporting = false
|
9
|
+
raise ItWorksException.new("Woohoo! Your Raygun<->Ruby connection is set up correctly")
|
10
|
+
rescue ItWorksException => e
|
11
|
+
response = Raygun.track_exception(e)
|
12
|
+
|
13
|
+
if response.success?
|
14
|
+
puts "Success! Now go check your Raygun Dashboard"
|
15
|
+
else
|
16
|
+
puts "Oh-oh, something went wrong - double check your API key"
|
17
|
+
puts "API Key - " << Raygun.configuration.api_key << ")"
|
18
|
+
puts "API Response - " << response
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
23
|
end
|
data/lib/raygun/error.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
module Raygun
|
2
|
-
class Error < StandardError
|
3
|
-
attr_reader :raygun_custom_data
|
4
|
-
|
5
|
-
def initialize(message, raygun_custom_data = {})
|
6
|
-
super(message)
|
7
|
-
@raygun_custom_data = raygun_custom_data
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module Raygun
|
2
|
+
class Error < StandardError
|
3
|
+
attr_reader :raygun_custom_data
|
4
|
+
|
5
|
+
def initialize(message, raygun_custom_data = {})
|
6
|
+
super(message)
|
7
|
+
@raygun_custom_data = raygun_custom_data
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Subscribes to errors using Rails' error reporting API
|
2
|
+
# https://edgeguides.rubyonrails.org/error_reporting.html
|
3
|
+
class Raygun::ErrorSubscriber
|
4
|
+
def report(error, handled:, severity:, context:, source: nil)
|
5
|
+
tags = context.delete(:tags) if context.is_a?(Hash)
|
6
|
+
|
7
|
+
data = {
|
8
|
+
custom_data: {
|
9
|
+
"rails.error": {
|
10
|
+
handled: handled,
|
11
|
+
severity: severity,
|
12
|
+
context: context,
|
13
|
+
source: source
|
14
|
+
},
|
15
|
+
},
|
16
|
+
tags: ["rails_error_reporter", *tags].compact
|
17
|
+
}
|
18
|
+
|
19
|
+
Raygun.track_exception(error, data)
|
20
|
+
end
|
21
|
+
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
# Client for injecting JavaScript code for tracking front end exceptions
|
2
|
-
# https://raygun.com/docs/languages/javascript
|
3
|
-
module Raygun
|
4
|
-
class JavaScriptTracker
|
5
|
-
def head_html
|
6
|
-
return unless js_api_key?
|
7
|
-
[
|
8
|
-
'<script type="text/javascript">',
|
9
|
-
'!function(a,b,c,d,e,f,g,h){a.RaygunObject=e,a[e]=a[e]||function(){',
|
10
|
-
'(a[e].o=a[e].o||[]).push(arguments)},f=b.createElement(c),g=b.getElementsByTagName(c)[0],',
|
11
|
-
'f.async=1,f.src=d,g.parentNode.insertBefore(f,g),h=a.onerror,a.onerror=function(b,c,d,f,g){',
|
12
|
-
'h&&h(b,c,d,f,g),g||(g=new Error(b)),a[e].q=a[e].q||[],a[e].q.push({',
|
13
|
-
'e:g})}}(window,document,"script","//cdn.raygun.io/raygun4js/' + js_api_version + 'raygun.min.js","rg4js");',
|
14
|
-
'</script>'
|
15
|
-
].join('').html_safe
|
16
|
-
end
|
17
|
-
|
18
|
-
def body_html
|
19
|
-
return unless js_api_key?
|
20
|
-
[
|
21
|
-
'<script type="text/javascript">',
|
22
|
-
"rg4js('apiKey', '#{js_api_key}');",
|
23
|
-
"rg4js('enableCrashReporting', true);",
|
24
|
-
'</script>'
|
25
|
-
].join('').html_safe
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def js_api_key
|
31
|
-
@js_api_key ||= Raygun.configuration.js_api_key
|
32
|
-
end
|
33
|
-
|
34
|
-
def js_api_version
|
35
|
-
@js_api_version ||= Raygun.configuration.js_api_version ? "#{Raygun.configuration.js_api_version}/" : ''
|
36
|
-
end
|
37
|
-
|
38
|
-
def js_api_key?
|
39
|
-
js_api_key.present?
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
1
|
+
# Client for injecting JavaScript code for tracking front end exceptions
|
2
|
+
# https://raygun.com/docs/languages/javascript
|
3
|
+
module Raygun
|
4
|
+
class JavaScriptTracker
|
5
|
+
def head_html
|
6
|
+
return unless js_api_key?
|
7
|
+
[
|
8
|
+
'<script type="text/javascript">',
|
9
|
+
'!function(a,b,c,d,e,f,g,h){a.RaygunObject=e,a[e]=a[e]||function(){',
|
10
|
+
'(a[e].o=a[e].o||[]).push(arguments)},f=b.createElement(c),g=b.getElementsByTagName(c)[0],',
|
11
|
+
'f.async=1,f.src=d,g.parentNode.insertBefore(f,g),h=a.onerror,a.onerror=function(b,c,d,f,g){',
|
12
|
+
'h&&h(b,c,d,f,g),g||(g=new Error(b)),a[e].q=a[e].q||[],a[e].q.push({',
|
13
|
+
'e:g})}}(window,document,"script","//cdn.raygun.io/raygun4js/' + js_api_version + 'raygun.min.js","rg4js");',
|
14
|
+
'</script>'
|
15
|
+
].join('').html_safe
|
16
|
+
end
|
17
|
+
|
18
|
+
def body_html
|
19
|
+
return unless js_api_key?
|
20
|
+
[
|
21
|
+
'<script type="text/javascript">',
|
22
|
+
"rg4js('apiKey', '#{js_api_key}');",
|
23
|
+
"rg4js('enableCrashReporting', true);",
|
24
|
+
'</script>'
|
25
|
+
].join('').html_safe
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def js_api_key
|
31
|
+
@js_api_key ||= Raygun.configuration.js_api_key
|
32
|
+
end
|
33
|
+
|
34
|
+
def js_api_version
|
35
|
+
@js_api_version ||= Raygun.configuration.js_api_version ? "#{Raygun.configuration.js_api_version}/" : ''
|
36
|
+
end
|
37
|
+
|
38
|
+
def js_api_key?
|
39
|
+
js_api_key.present?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
module Raygun
|
2
|
-
module Middleware
|
3
|
-
class BreadcrumbsStoreInitializer
|
4
|
-
def initialize(app)
|
5
|
-
@app = app
|
6
|
-
end
|
7
|
-
|
8
|
-
def call(env)
|
9
|
-
Breadcrumbs::Store.initialize
|
10
|
-
|
11
|
-
begin
|
12
|
-
@app.call(env)
|
13
|
-
ensure
|
14
|
-
Breadcrumbs::Store.clear
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
1
|
+
module Raygun
|
2
|
+
module Middleware
|
3
|
+
class BreadcrumbsStoreInitializer
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
Breadcrumbs::Store.initialize
|
10
|
+
|
11
|
+
begin
|
12
|
+
@app.call(env)
|
13
|
+
ensure
|
14
|
+
Breadcrumbs::Store.clear
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|