raygun4ruby 3.2.3 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +18 -18
- data/.rspec +1 -1
- data/.travis.yml +20 -20
- data/CHANGELOG.md +127 -124
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +420 -420
- data/Rakefile +27 -27
- data/examples/sinatras_raygun.rb +17 -17
- data/lib/generators/raygun/install_generator.rb +26 -26
- data/lib/raygun.rb +179 -179
- data/lib/raygun/affected_user.rb +59 -59
- data/lib/raygun/breadcrumbs.rb +34 -34
- data/lib/raygun/breadcrumbs/breadcrumb.rb +34 -34
- data/lib/raygun/breadcrumbs/store.rb +86 -86
- data/lib/raygun/client.rb +305 -305
- data/lib/raygun/configuration.rb +194 -194
- data/lib/raygun/error.rb +10 -10
- 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 +32 -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 +39 -39
- data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +27 -27
- data/lib/raygun/sidekiq.rb +71 -70
- data/lib/raygun/testable.rb +22 -22
- data/lib/raygun/version.rb +3 -3
- data/lib/raygun4ruby.rb +1 -1
- data/lib/resque/failure/raygun.rb +25 -25
- data/lib/tasks/raygun.tasks +7 -7
- data/raygun4ruby.gemspec +45 -45
- data/spec/dummy/.gitignore +17 -17
- data/spec/dummy/Gemfile +47 -47
- data/spec/dummy/README.rdoc +28 -28
- data/spec/dummy/Rakefile +6 -6
- data/spec/dummy/app/assets/config/manifest.js +2 -2
- data/spec/dummy/app/assets/javascripts/application.js +13 -13
- data/spec/dummy/app/assets/stylesheets/application.css +15 -15
- data/spec/dummy/app/controllers/application_controller.rb +5 -5
- data/spec/dummy/app/controllers/home_controller.rb +4 -4
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/views/home/index.html.erb +3 -3
- data/spec/dummy/app/views/home/index.json.erb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +14 -14
- data/spec/dummy/bin/bundle +3 -3
- data/spec/dummy/bin/rails +9 -9
- data/spec/dummy/bin/rake +9 -9
- data/spec/dummy/bin/setup +29 -29
- data/spec/dummy/bin/spring +17 -17
- data/spec/dummy/config.ru +4 -4
- data/spec/dummy/config/application.rb +26 -26
- data/spec/dummy/config/boot.rb +3 -3
- data/spec/dummy/config/database.yml +25 -25
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +41 -41
- data/spec/dummy/config/environments/production.rb +79 -79
- data/spec/dummy/config/environments/test.rb +42 -42
- data/spec/dummy/config/initializers/assets.rb +11 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
- data/spec/dummy/config/initializers/inflections.rb +16 -16
- data/spec/dummy/config/initializers/mime_types.rb +4 -4
- data/spec/dummy/config/initializers/session_store.rb +3 -3
- data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +10 -10
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +23 -23
- data/spec/dummy/config/routes.rb +58 -58
- data/spec/dummy/config/secrets.yml +22 -22
- data/spec/dummy/db/seeds.rb +7 -7
- data/spec/dummy/public/404.html +67 -67
- data/spec/dummy/public/422.html +67 -67
- data/spec/dummy/public/500.html +66 -66
- data/spec/dummy/public/robots.txt +5 -5
- data/spec/dummy/test/test_helper.rb +10 -10
- data/spec/features/javascript_spec.rb +48 -48
- data/spec/rails_helper.rb +4 -4
- data/spec/raygun/breadcrumbs/breadcrumb_spec.rb +171 -171
- data/spec/raygun/breadcrumbs/store_spec.rb +170 -170
- data/spec/raygun/raygun_spec.rb +47 -47
- 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/test_helper.rb +72 -72
- data/test/unit/affected_user_test.rb +136 -136
- data/test/unit/client_test.rb +792 -792
- data/test/unit/configuration_test.rb +206 -206
- data/test/unit/raygun_test.rb +25 -25
- data/test/unit/resque_failure_test.rb +24 -24
- data/test/unit/sidekiq_failure_test.rb +32 -32
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86c073be26e04ae3b6c2aa39e3a92db2b7a0755ee894f6e7e71075e04ce44f67
|
4
|
+
data.tar.gz: 3864218abdc8c3c7412bff4cd4b2639d2020e98bca6926d934068ca8cd9a4785
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e01cb2666afee5e64096c0bc21f4c0a1767d5f3fc7a6441bc8d6b5262865ce0af7cd75072016ba969ac3a4624005cc95ad89f51b9caef5f2de5c86233028d8f8
|
7
|
+
data.tar.gz: 4890df68aed5f5c2f9d46cb1cb2d1882c260b93bcf0c4772e6d349fdab3e5db723f9512c2cb8e6b9d2662d1fe6399978cb9b97d96068a1b01dff5c9410a9c3c2
|
data/.gitignore
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
spec/dummy/log
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
spec/dummy/log
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--require spec_helper
|
1
|
+
--require spec_helper
|
data/.travis.yml
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
before_install:
|
4
|
-
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
5
|
-
- gem install bundler -v '< 2'
|
6
|
-
|
7
|
-
script:
|
8
|
-
- bundle exec rake
|
9
|
-
|
10
|
-
rvm:
|
11
|
-
- 2.0.0-p648
|
12
|
-
- 2.1.0
|
13
|
-
- 2.2.10
|
14
|
-
- 2.3.8
|
15
|
-
- 2.4.5
|
16
|
-
- 2.5.3
|
17
|
-
- 2.6.1
|
18
|
-
|
19
|
-
gemfile:
|
20
|
-
- Gemfile
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
before_install:
|
4
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
5
|
+
- gem install bundler -v '< 2'
|
6
|
+
|
7
|
+
script:
|
8
|
+
- bundle exec rake
|
9
|
+
|
10
|
+
rvm:
|
11
|
+
- 2.0.0-p648
|
12
|
+
- 2.1.0
|
13
|
+
- 2.2.10
|
14
|
+
- 2.3.8
|
15
|
+
- 2.4.5
|
16
|
+
- 2.5.3
|
17
|
+
- 2.6.1
|
18
|
+
|
19
|
+
gemfile:
|
20
|
+
- Gemfile
|
data/CHANGELOG.md
CHANGED
@@ -1,124 +1,127 @@
|
|
1
|
-
## 3.2.
|
2
|
-
-
|
3
|
-
|
4
|
-
## 3.2.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
## 2.7.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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
|
-
- raygun4ruby
|
1
|
+
## 3.2.4 (11/02/2021):
|
2
|
+
- Set sidekiq tag on sidekiq errors ([#161](https://github.com/MindscapeHQ/raygun4ruby/pull/161))
|
3
|
+
|
4
|
+
## 3.2.2 (10/06/2020):
|
5
|
+
- Introduce support for Raygun APM exceptions correlation ([#154](https://github.com/MindscapeHQ/raygun4ruby/pull/154))
|
6
|
+
|
7
|
+
## 3.2.1 (25/02/2019):
|
8
|
+
Bugfix:
|
9
|
+
- Remove Ruby 2.3 syntax to retain support for Ruby >= 2.0 ([#148](https://github.com/MindscapeHQ/raygun4ruby/pull/148))
|
10
|
+
|
11
|
+
## 3.2.0 (21/02/2019):
|
12
|
+
Bugfix:
|
13
|
+
- Fix NoMethodError Exception: undefined method `include?' for nil:NilClass in `JavascriptExceptionTracking` class. Thanks @yamanaltereh for this ([#141](https://github.com/MindscapeHQ/raygun4ruby/pull/141))
|
14
|
+
- Fix ([#145](https://github.com/MindscapeHQ/raygun4ruby/issues/145)), "raygun4ruby will load pry if it is in the gem bundle". Thanks to @eoinkelly for reporting this
|
15
|
+
|
16
|
+
Feature:
|
17
|
+
- If you have recorded a large number of Breadcrumbs, or just very large ones, Raygun4Ruby will now only send up to 100KB of them instead of all of them, potentially going over the 128KB payload limit Raygun accepts ([#147](https://github.com/MindscapeHQ/raygun4ruby/pull/147))
|
18
|
+
|
19
|
+
## 3.1.1 (16/01/2019):
|
20
|
+
Bugfix:
|
21
|
+
- Don't attempt to modify response unless JS api key is present
|
22
|
+
- Don't attempt to modify response unless it responds to indexing ([])
|
23
|
+
- See PR ([#140](https://github.com/MindscapeHQ/raygun4ruby/pull/140))
|
24
|
+
|
25
|
+
## 3.1.0 (15/01/2019):
|
26
|
+
|
27
|
+
Feature:
|
28
|
+
- Ability to automatically configure Raygun4JS on the client side by injecting it into outbound HTML pages. Thanks @MikeRogers0 for this ([#138](https://github.com/MindscapeHQ/raygun4ruby/pull/138))
|
29
|
+
|
30
|
+
## 3.0.0 (18/12/2018):
|
31
|
+
Breaking changes:
|
32
|
+
Parameter filters are now applied if you are using the `filter_payload_with_whitelist` functionality. Previously if this was set to true the parameter filtering was bailed out of ([#136](https://github.com/MindscapeHQ/raygun4ruby/pull/136/files))
|
33
|
+
|
34
|
+
## 2.7.1 (11/06/2018)
|
35
|
+
This is a patch release to update the required ruby version to correctly be 2.0 or greater
|
36
|
+
|
37
|
+
## 2.7.0 (19/02/2018)
|
38
|
+
|
39
|
+
Features
|
40
|
+
- Add configuration option to control network timeouts when sending error reports, default value is 10 seconds ([#129](https://github.com/MindscapeHQ/raygun4ruby/pull/129))
|
41
|
+
|
42
|
+
## 2.6.0 (25/10/2017)
|
43
|
+
|
44
|
+
Features
|
45
|
+
- Enhanced debug logging to assist in resolving issues from support requests ([#128](https://github.com/MindscapeHQ/raygun4ruby/pull/128))
|
46
|
+
|
47
|
+
## 2.5.0 (04/10/2017)
|
48
|
+
|
49
|
+
Features
|
50
|
+
- Teach tags configuration how to handle a proc to allow dynamically settings tags ([#127](https://github.com/MindscapeHQ/raygun4ruby/pull/127))
|
51
|
+
|
52
|
+
Bugfixes
|
53
|
+
- Fix crash when recording breadcrumb with uninitialized store ([#126](https://github.com/MindscapeHQ/raygun4ruby/pull/126))
|
54
|
+
- Make raw data handling more robust and fix in unicorn ([#125](https://github.com/MindscapeHQ/raygun4ruby/pull/125))
|
55
|
+
- Backwards compatible affected_user_identifier_methods ([#120](https://github.com/MindscapeHQ/raygun4ruby/pull/120))
|
56
|
+
|
57
|
+
## 2.4.1 (29/08/2017)
|
58
|
+
|
59
|
+
Bugfixes
|
60
|
+
- Fix crash in `Client#raw_data` method when `rack.input` buffer is missing `pos` method
|
61
|
+
|
62
|
+
## 2.4.0 (31/07/2017)
|
63
|
+
|
64
|
+
Features
|
65
|
+
- Add functionality to track affected user in Sidekiq jobs, refer to the README for more information, under the "Affected User Tracking in Sidekiq" heading ([#121](https://github.com/MindscapeHQ/raygun4ruby/pull/121))
|
66
|
+
|
67
|
+
## 2.3.0 (09/05/2017)"
|
68
|
+
|
69
|
+
Bugfixes
|
70
|
+
- Fix issue preventing affected users for a crash report from showing up in the affected users page ([#119](https://github.com/MindscapeHQ/raygun4ruby/pull/119))
|
71
|
+
|
72
|
+
## 2.2.0 (05/05/2017)
|
73
|
+
|
74
|
+
Features
|
75
|
+
- Opt in support for sending exceptions in a background thread to not block web request thread during IO ([#117](https://github.com/MindscapeHQ/raygun4ruby/pull/117))
|
76
|
+
|
77
|
+
Bugfixes
|
78
|
+
- Don't attempt to read raw data during GET requests or if rack.input buffer is empty
|
79
|
+
|
80
|
+
## 2.1.0 (27/04/2017)
|
81
|
+
|
82
|
+
Features
|
83
|
+
- Ability to record breadcrumbs in your code that will be sent to Raygun along with a raised exception ([#113](https://github.com/MindscapeHQ/raygun4ruby/pull/113))
|
84
|
+
|
85
|
+
## 2.0.0 (20/04/2017)
|
86
|
+
|
87
|
+
Bugfixes:
|
88
|
+
- Fix broken handling of raw request body reading in Rack applications ([#116](https://github.com/MindscapeHQ/raygun4ruby/pull/116))
|
89
|
+
- This is a breaking change to how raw data was being read before so it requires a major version bump
|
90
|
+
- Raw request data reading is now disabled by default and can be enabled via the `record_raw_data` configuration option
|
91
|
+
|
92
|
+
Since this is a major version bump this release also deprecates ruby versions < 2.0
|
93
|
+
|
94
|
+
## 1.5.0 (16/03/2017)
|
95
|
+
|
96
|
+
Features
|
97
|
+
- Send utcOffset with Raygun payload to calculate local server time in Raygun dashboard ([#112](https://github.com/MindscapeHQ/raygun4ruby/pull/112))
|
98
|
+
|
99
|
+
## 1.4.0 (14/03/2017)
|
100
|
+
|
101
|
+
Features:
|
102
|
+
- Raygun API url is now configurable via `Configuration.api_url` ([#111](https://github.com/MindscapeHQ/raygun4ruby/pull/111))
|
103
|
+
- Added support for `Exception#cause` to be tracked as `innerError` on Raygun. Only supported on Ruby >= 2.1 ([#107](https://github.com/MindscapeHQ/raygun4ruby/pull/107))
|
104
|
+
|
105
|
+
## 1.3.0 (10/03/2017)
|
106
|
+
|
107
|
+
Features:
|
108
|
+
- Improve affected user handling to let you specify all Raygun parameters, identifier, email, first name, full name and uuid. See [README.md](https://github.com/MindscapeHQ/raygun4ruby#affected-user-tracking) for details ([#34](https://github.com/MindscapeHQ/raygun4ruby/pull/34))
|
109
|
+
- Pass a user object as the third parameter to `Raygun.track_exception` to have affected user tracking for manually tracked exceptions, see the above link for more information on configuring this ([#106](https://github.com/MindscapeHQ/raygun4ruby/pull/106))
|
110
|
+
- If the exception instance responds to `:raygun_custom_data` that method will be called and the return value merged into the `custom_data` hash sent to Raygun. For convenience a `Raygun::Error` class is provided that takes this custom data as a second argument ([#101](https://github.com/MindscapeHQ/raygun4ruby/pull/101))
|
111
|
+
- Allowed `Configuration.custom_data` to be set to a proc to allow a global custom data hook for all exceptions. It is passed as arguments the exception and the environment hash ([#108](https://github.com/MindscapeHQ/raygun4ruby/pull/108))
|
112
|
+
- Added `Configuration.debug` to enable logging the reason why an exception was not reported ([#109](https://github.com/MindscapeHQ/raygun4ruby/pull/109))
|
113
|
+
|
114
|
+
## 1.2.1 (09/03/2017)
|
115
|
+
|
116
|
+
Bugfixes:
|
117
|
+
- dup input hashes before applying whitelist filtering, previously this was modifying the contents of `action_dispatch.request.parameters` ([#105](https://github.com/MindscapeHQ/raygun4ruby/pull/105))
|
118
|
+
|
119
|
+
## 1.2.0 (09/03/2017)
|
120
|
+
|
121
|
+
Features:
|
122
|
+
- Added two new configuration options, `filter_payload_with_whitelist` and `whitelist_payload_shape` ([#100](https://github.com/MindscapeHQ/raygun4ruby/pull/100))
|
123
|
+
- See [README.md](https://github.com/MindscapeHQ/raygun4ruby#filtering-the-payload-by-whitelist) for an example of how to use them
|
124
|
+
- When raygun4ruby encounters an exception trying to track an exception it will try once to send that exception to Raygun so you are notified ([#104](https://github.com/MindscapeHQ/raygun4ruby/pull/104))
|
125
|
+
|
126
|
+
Bugfixes:
|
127
|
+
- raygun4ruby will no longer crash and suppress app exceptions when the API key is not configured ([#87](https://github.com/MindscapeHQ/raygun4ruby/pull/87))
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in raygun4ruby.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in raygun4ruby.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2013 Nik Wakelin
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2013 Nik Wakelin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,420 +1,420 @@
|
|
1
|
-
# Raygun 4 Ruby [![Build Status](https://travis-ci.org/MindscapeHQ/raygun4ruby.png?branch=master)](https://travis-ci.org/MindscapeHQ/raygun4ruby) [![Gem Version](https://badge.fury.io/rb/raygun4ruby.svg)](https://badge.fury.io/rb/raygun4ruby)
|
2
|
-
|
3
|
-
This is the Ruby adapter for the Raygun error reporter,
|
4
|
-
|
5
|
-
|
6
|
-
## Installation
|
7
|
-
|
8
|
-
Add this line to your application's Gemfile:
|
9
|
-
|
10
|
-
gem 'raygun4ruby'
|
11
|
-
|
12
|
-
And then execute:
|
13
|
-
|
14
|
-
$ bundle
|
15
|
-
|
16
|
-
Or install it yourself as:
|
17
|
-
|
18
|
-
$ gem install raygun4ruby
|
19
|
-
|
20
|
-
## Usage
|
21
|
-
|
22
|
-
### Rails 3/4/5
|
23
|
-
|
24
|
-
Run:
|
25
|
-
|
26
|
-
rails g raygun:install YOUR_API_KEY_HERE
|
27
|
-
|
28
|
-
You can find your API key
|
29
|
-
|
30
|
-
You can then test your Raygun integration by running:
|
31
|
-
|
32
|
-
rake raygun:test
|
33
|
-
|
34
|
-
You should see an "ItWorksException" appear in your Raygun dashboard. You're ready to zap those errors!
|
35
|
-
|
36
|
-
NB: Raygun4Ruby currently requires Ruby >= 2.0
|
37
|
-
|
38
|
-
Note that the generator will create a file in `config/initializers` called "raygun.rb". If you need to do any further configuration or customization of Raygun, that's the place to do it!
|
39
|
-
|
40
|
-
By default the Rails integration is set to only report Exceptions in Production. To change this behaviour, set `config.enable_reporting` to something else in `config/initializers/raygun.rb`.
|
41
|
-
|
42
|
-
### Rails 2
|
43
|
-
|
44
|
-
Raygun4Ruby doesn't currently support Rails 2. If you'd like Rails 2 support, [drop us a line](
|
45
|
-
|
46
|
-
### Sinatra
|
47
|
-
|
48
|
-
To enable exception tracking in Sinatra, just add configure Raygun and use the Rack middleware in your app:
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
require 'raygun4ruby'
|
52
|
-
Raygun.setup do |config|
|
53
|
-
config.api_key = "YOUR_API_KEY_HERE"
|
54
|
-
end
|
55
|
-
use Raygun::Middleware::RackExceptionInterceptor
|
56
|
-
```
|
57
|
-
|
58
|
-
### Standalone / Manual Exception Tracking
|
59
|
-
|
60
|
-
```ruby
|
61
|
-
|
62
|
-
require 'rubygems'
|
63
|
-
require 'raygun4ruby'
|
64
|
-
|
65
|
-
Raygun.setup do |config|
|
66
|
-
config.api_key = "YOUR_RAYGUN_API_KEY"
|
67
|
-
config.filter_parameters = [ :password, :card_number, :cvv ] # don't forget to filter out sensitive parameters
|
68
|
-
config.enable_reporting = Rails.env.production? # true to send errors, false to not log
|
69
|
-
end
|
70
|
-
|
71
|
-
begin
|
72
|
-
# your lovely code here
|
73
|
-
rescue => e
|
74
|
-
Raygun.track_exception(e)
|
75
|
-
end
|
76
|
-
|
77
|
-
# You may also pass a user object as the third argument to allow affected user tracking, like so
|
78
|
-
begin
|
79
|
-
# your lovely code here
|
80
|
-
rescue => e
|
81
|
-
# The second argument is the request environment variables
|
82
|
-
Raygun.track_exception(e, {}, user)
|
83
|
-
end
|
84
|
-
```
|
85
|
-
|
86
|
-
You can also pass a Hash as the second parameter to `track_exception`. It should look like a [Rack Env Hash](https://
|
87
|
-
|
88
|
-
### Customizing The Parameter Filtering
|
89
|
-
|
90
|
-
If you'd like to customize how parameters are filtered, you can pass a `Proc` to `filter_parameters`. Raygun4Ruby will yield the params hash to the block, and the return value will be sent along with your error.
|
91
|
-
|
92
|
-
```ruby
|
93
|
-
Raygun.setup do |config|
|
94
|
-
config.api_key = "YOUR_RAYGUN_API_KEY"
|
95
|
-
config.filter_parameters do |params|
|
96
|
-
params.slice("only", "a", "few", "keys") # note that Hash#slice is in ActiveSupport
|
97
|
-
end
|
98
|
-
end
|
99
|
-
```
|
100
|
-
|
101
|
-
### Recording Breadcrumbs
|
102
|
-
|
103
|
-
Breadcrumbs let you provide logging points in your code that will be collected and sent along with any exception sent to Raygun. This lets you have a better understanding of the events that happened in the system that lead up to the exception.
|
104
|
-
|
105
|
-
1. Include it as a module in your class
|
106
|
-
```ruby
|
107
|
-
class SomeClass
|
108
|
-
include Raygun::Breadcrumbs
|
109
|
-
|
110
|
-
def some_method
|
111
|
-
record_breadcrumb(
|
112
|
-
message: "<log message goes here>",
|
113
|
-
category: "some category to group them by, maybe authentication or external-apis for example",
|
114
|
-
level: :info, # or debug or warning etc, you can configure what level will get sent
|
115
|
-
metadata: {custom_data: 'can go here'},
|
116
|
-
)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
```
|
120
|
-
This has the added benefit of recording the class the breadcrumb was recorded from automatically
|
121
|
-
|
122
|
-
2. Call the `record_breadcrumb` method manually
|
123
|
-
```ruby
|
124
|
-
def some_method
|
125
|
-
Raygun.record_breadcrumb(
|
126
|
-
message: "<log message goes here>",
|
127
|
-
category: "some category to group them by, maybe authentication or external-apis for example",
|
128
|
-
level: :info, # or debug or warning etc, you can configure what level will get sent
|
129
|
-
metadata: {custom_data: 'can go here'},
|
130
|
-
|
131
|
-
# You can also set the class the breadcrumb was logged from
|
132
|
-
# It will only be set automatically using the included module approach
|
133
|
-
# Method and line number will get added automatically
|
134
|
-
class_name: self.class.name
|
135
|
-
)
|
136
|
-
end
|
137
|
-
```
|
138
|
-
|
139
|
-
If you are using Sinatra or another rack framework you will need to include the Breadcrumbs middleware, this is used for storing the breadcrumbs during a request
|
140
|
-
`use Raygun::Middleware::BreadcrumbsStoreInitializer`
|
141
|
-
(this must be before you `use` the `Raygun::Middleware::RackExceptionInterceptor`)
|
142
|
-
|
143
|
-
If you are using a non web based Ruby application you will have to call `Raygun::Breadcrumbs::Store.initialize` during your applications boot process. The store is per thread, but I have not tested it in a multi threaded application.
|
144
|
-
|
145
|
-
### Filtering the payload by whitelist
|
146
|
-
|
147
|
-
As an alternative to the above, you can also opt-in to the keys/values to be sent to Raygun by providing a specific whitelist of the keys you want to transmit.
|
148
|
-
|
149
|
-
This disables the blacklist filtering above (`filter_parameters`), and is applied to the entire payload (error, request, environment and custom data included), not just the request parameters.
|
150
|
-
|
151
|
-
In order to opt-in to this feature, set `filter_payload_with_whitelist` to `true`, and specify a shape of what keys you want (the default is below which is to allow everything through, this also means that the query parameters filtered out by default like password, creditcard etc will not be unless changed):
|
152
|
-
|
153
|
-
```ruby
|
154
|
-
Raygun.setup do |config|
|
155
|
-
config.api_key = "YOUR_RAYGUN_API_KEY"
|
156
|
-
config.filter_payload_with_whitelist = true
|
157
|
-
|
158
|
-
config.whitelist_payload_shape = {
|
159
|
-
machineName: true,
|
160
|
-
version: true,
|
161
|
-
error: true,
|
162
|
-
userCustomData: true,
|
163
|
-
tags: true,
|
164
|
-
request: {
|
165
|
-
hostName: true,
|
166
|
-
url: true,
|
167
|
-
httpMethod: true,
|
168
|
-
iPAddress: true,
|
169
|
-
queryString: true,
|
170
|
-
headers: true,
|
171
|
-
form: {}, # Set to empty hash so that it doesn't just filter out the whole thing, but instead filters out each individual param
|
172
|
-
rawData: true
|
173
|
-
}
|
174
|
-
}
|
175
|
-
end
|
176
|
-
```
|
177
|
-
|
178
|
-
Alternatively, provide a Proc to filter the payload using your own logic:
|
179
|
-
|
180
|
-
```ruby
|
181
|
-
Raygun.setup do |config|
|
182
|
-
config.api_key = "YOUR_RAYGUN_API_KEY"
|
183
|
-
config.filter_payload_with_whitelist = true
|
184
|
-
|
185
|
-
config.whitelist_payload_shape do |payload|
|
186
|
-
# Return the payload mutated into your desired form
|
187
|
-
payload
|
188
|
-
end
|
189
|
-
end
|
190
|
-
```
|
191
|
-
|
192
|
-
### Custom User Data
|
193
|
-
Custom data can be added to `track_exception` by passing a custom_data key in the second parameter hash.
|
194
|
-
|
195
|
-
```ruby
|
196
|
-
begin
|
197
|
-
# more lovely code
|
198
|
-
rescue Exception => e
|
199
|
-
Raygun.track_exception(e, custom_data: {my: 'custom data', goes: 'here'})
|
200
|
-
end
|
201
|
-
```
|
202
|
-
|
203
|
-
Custom data can also be specified globally either by setting `config.custom_data` to a hash
|
204
|
-
|
205
|
-
```ruby
|
206
|
-
Raygun.setup do |config|
|
207
|
-
config.api_key = "YOUR_RAYGUN_API_KEY"
|
208
|
-
config.custom_data = {custom_data: 'goes here'}
|
209
|
-
end
|
210
|
-
```
|
211
|
-
|
212
|
-
or to a proc, which gets passed the exception and environment hash
|
213
|
-
|
214
|
-
```ruby
|
215
|
-
Raygun.setup do |config|
|
216
|
-
config.api_key = "YOUR_RAYGUN_API_KEY"
|
217
|
-
config.custom_data do |e, env|
|
218
|
-
{message: e.message, server: env["SERVER_NAME"]}
|
219
|
-
end
|
220
|
-
end
|
221
|
-
```
|
222
|
-
|
223
|
-
### Ignoring Some Errors
|
224
|
-
|
225
|
-
You can ignore certain types of Exception using the `ignore` option in the setup block, like so:
|
226
|
-
|
227
|
-
```ruby
|
228
|
-
Raygun.setup do |config|
|
229
|
-
config.api_key = "MY_SWEET_API_KEY"
|
230
|
-
config.ignore << ['MyApp::AnExceptionIDontCareAbout']
|
231
|
-
end
|
232
|
-
```
|
233
|
-
|
234
|
-
The following exceptions are ignored by default:
|
235
|
-
|
236
|
-
```
|
237
|
-
ActiveRecord::RecordNotFound
|
238
|
-
ActionController::RoutingError
|
239
|
-
ActionController::InvalidAuthenticityToken
|
240
|
-
ActionDispatch::ParamsParser::ParseError
|
241
|
-
CGI::Session::CookieStore::TamperedWithCookie
|
242
|
-
ActionController::UnknownAction
|
243
|
-
AbstractController::ActionNotFound
|
244
|
-
Mongoid::Errors::DocumentNotFound
|
245
|
-
```
|
246
|
-
|
247
|
-
[You can see this here](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb#
|
248
|
-
|
249
|
-
```ruby
|
250
|
-
Raygun.setup do |config|
|
251
|
-
config.api_key = "MY_SWEET_API_KEY"
|
252
|
-
config.ignore.delete('ActionController::InvalidAuthenticityToken')
|
253
|
-
end
|
254
|
-
```
|
255
|
-
|
256
|
-
### Using a Proxy
|
257
|
-
|
258
|
-
You can pass proxy settings using the `proxy_settings` config option.
|
259
|
-
|
260
|
-
```ruby
|
261
|
-
Raygun.setup do |config|
|
262
|
-
config.api_key = "MY_SWEET_API_KEY"
|
263
|
-
config.proxy_settings = { host: "localhost", port: 8888 }
|
264
|
-
end
|
265
|
-
```
|
266
|
-
|
267
|
-
### Affected User Tracking
|
268
|
-
|
269
|
-
Raygun can now track how many users have been affected by an error.
|
270
|
-
|
271
|
-
By default, Raygun looks for a method called `current_user` on your controller, and it will populate the user's information based on a default method name mapping.
|
272
|
-
|
273
|
-
(e.g Raygun will call `email` to populate the user's email, and `first_name` for the user's first name)
|
274
|
-
|
275
|
-
You can inspect and customize this mapping using `config.affected_user_mapping`, like so:
|
276
|
-
|
277
|
-
```ruby
|
278
|
-
Raygun.setup do |config|
|
279
|
-
config.api_key = "MY_SWEET_API_KEY"
|
280
|
-
config.affected_user_method = :my_current_user # `current_user` by default
|
281
|
-
# To augment the defaults with your unique methods you can do the following
|
282
|
-
config.affected_user_mapping = Raygun::AffectedUser::DEFAULT_MAPPING.merge({
|
283
|
-
identifier: :some_custom_unique_identifier,
|
284
|
-
# If you set the key to a proc it will be passed the user object and you can construct the value your self
|
285
|
-
full_name: ->(user) { "#{user.first_name} #{user.last_name}" }
|
286
|
-
})
|
287
|
-
end
|
288
|
-
```
|
289
|
-
|
290
|
-
To see the defaults check out [affected_user.rb](https://github.com/MindscapeHQ/raygun4ruby/tree/master/lib/raygun/affected_user.rb)
|
291
|
-
|
292
|
-
If you're using Rails, most authentication systems will have this method set and you should be good to go.
|
293
|
-
|
294
|
-
The count of unique affected users will appear on the error group in the Raygun dashboard. If your user has an `Email` attribute, and that email has a Gravatar associated with that address, you will also see your user's avatar.
|
295
|
-
|
296
|
-
If you wish to keep it anonymous, you could set this identifier to something like `SecureRandom.uuid` and store that in a cookie, like so:
|
297
|
-
|
298
|
-
```ruby
|
299
|
-
class ApplicationController < ActionController::Base
|
300
|
-
|
301
|
-
def raygun_user
|
302
|
-
cookies.permanent[:raygun_user_identifier] ||= SecureRandom.uuid
|
303
|
-
end
|
304
|
-
|
305
|
-
end
|
306
|
-
```
|
307
|
-
|
308
|
-
(Remember to set `affected_user_method` to `:raygun_user` in your config block...)
|
309
|
-
|
310
|
-
### Version tracking
|
311
|
-
|
312
|
-
Raygun can attach the version of your application to its error reports. In your Raygun.setup block, set `version` to the current version of your app.
|
313
|
-
|
314
|
-
```ruby
|
315
|
-
Raygun.setup do |config|
|
316
|
-
config.version = "1.0.0.4" # you could also pull this from ENV or however you want to set it.
|
317
|
-
end
|
318
|
-
```
|
319
|
-
|
320
|
-
### Tags
|
321
|
-
|
322
|
-
Tags can be added to `track_exception` by passing a tags key in the second parameter hash.
|
323
|
-
|
324
|
-
```ruby
|
325
|
-
begin
|
326
|
-
# more lovely code
|
327
|
-
rescue Exception => e
|
328
|
-
Raygun.track_exception(e, tags: ['my', 'tags', 'go here'])
|
329
|
-
end
|
330
|
-
```
|
331
|
-
|
332
|
-
Tags can also be specified globally either by setting `config.custom_data` to an array
|
333
|
-
|
334
|
-
```ruby
|
335
|
-
Raygun.setup do |config|
|
336
|
-
config.tags = ['heroku']
|
337
|
-
end
|
338
|
-
```
|
339
|
-
|
340
|
-
or to a proc, which gets passed the exception and environment hash. This proc _must_ return an array of strings
|
341
|
-
|
342
|
-
```ruby
|
343
|
-
Raygun.setup do |config|
|
344
|
-
config.api_key = "YOUR_RAYGUN_API_KEY"
|
345
|
-
config.tags do |e, env|
|
346
|
-
[env["SERVER_NAME"]]
|
347
|
-
end
|
348
|
-
end
|
349
|
-
```
|
350
|
-
|
351
|
-
### Resque Error Tracking
|
352
|
-
|
353
|
-
Raygun4Ruby also includes a Resque failure backend. You should include it inside your Resque initializer (usually something like `config/initializers/load_resque.rb`)
|
354
|
-
|
355
|
-
```ruby
|
356
|
-
require 'resque/failure/multiple'
|
357
|
-
require 'resque/failure/raygun'
|
358
|
-
require 'resque/failure/redis'
|
359
|
-
|
360
|
-
Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Raygun]
|
361
|
-
Resque::Failure.backend = Resque::Failure::Multiple
|
362
|
-
```
|
363
|
-
|
364
|
-
### Sidekiq Error Tracking
|
365
|
-
|
366
|
-
Raygun4Ruby can track errors from Sidekiq (2.x or 3+). All you need to do is add the line:
|
367
|
-
|
368
|
-
```ruby
|
369
|
-
require 'raygun/sidekiq'
|
370
|
-
```
|
371
|
-
|
372
|
-
Either in your Raygun initializer or wherever else takes your fancy :)
|
373
|
-
|
374
|
-
#### Affected User Tracking in Sidekiq
|
375
|
-
|
376
|
-
To track affected users, define a class method on your worker class that returns a user object.
|
377
|
-
Make sure the name of this method is the same as whatever you have defined as the `affected_user_method` in your Raygun configuration and that it returns an object that fits the mappings defined in `affected_user_mapping`
|
378
|
-
If you have not changed these, refer to [Affected user tracking](#affected-user-tracking) for the defaults
|
379
|
-
|
380
|
-
```ruby
|
381
|
-
class FailingWorker
|
382
|
-
include Sidekiq::Worker
|
383
|
-
|
384
|
-
def perform(arg1, arg2)
|
385
|
-
end
|
386
|
-
|
387
|
-
# Your method must accept an array of arguments
|
388
|
-
# These will be the same as those passed to `perform`
|
389
|
-
def self.current_user(args)
|
390
|
-
arg1 = args[0]
|
391
|
-
arg2 = args[1]
|
392
|
-
|
393
|
-
user = User.find_by(name: arg1)
|
394
|
-
|
395
|
-
# Your method must return a user object
|
396
|
-
user
|
397
|
-
end
|
398
|
-
```
|
399
|
-
|
400
|
-
### Other Configuration options
|
401
|
-
|
402
|
-
For a complete list of configuration options see the [configuration.rb](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb) file
|
403
|
-
|
404
|
-
## Found a bug?
|
405
|
-
|
406
|
-
Oops! Just let us know by opening an Issue on Github.
|
407
|
-
|
408
|
-
## Contributing
|
409
|
-
|
410
|
-
1. Fork it
|
411
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
412
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
413
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
414
|
-
5. Create new Pull Request
|
415
|
-
|
416
|
-
## Building
|
417
|
-
|
418
|
-
1. Build the gem (`gem build raygun4ruby.gemspec`) - don't bother trying to build it on Windows,
|
419
|
-
the resulting Gem won't work.
|
420
|
-
2. Install the gem (`gem install raygun4ruby-VERSION.gem`)
|
1
|
+
# Raygun 4 Ruby [![Build Status](https://travis-ci.org/MindscapeHQ/raygun4ruby.png?branch=master)](https://travis-ci.org/MindscapeHQ/raygun4ruby) [![Gem Version](https://badge.fury.io/rb/raygun4ruby.svg)](https://badge.fury.io/rb/raygun4ruby)
|
2
|
+
|
3
|
+
This is the Ruby adapter for the Raygun error reporter, https://raygun.com.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'raygun4ruby'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle install
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install raygun4ruby
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
### Rails 3/4/5
|
23
|
+
|
24
|
+
Run:
|
25
|
+
|
26
|
+
rails g raygun:install YOUR_API_KEY_HERE
|
27
|
+
|
28
|
+
You can find your API key in the [Raygun app](https://app.raygun.com/)
|
29
|
+
|
30
|
+
You can then test your Raygun integration by running:
|
31
|
+
|
32
|
+
rake raygun:test
|
33
|
+
|
34
|
+
You should see an "ItWorksException" appear in your Raygun dashboard. You're ready to zap those errors!
|
35
|
+
|
36
|
+
NB: Raygun4Ruby currently requires Ruby >= 2.0
|
37
|
+
|
38
|
+
Note that the generator will create a file in `config/initializers` called "raygun.rb". If you need to do any further configuration or customization of Raygun, that's the place to do it!
|
39
|
+
|
40
|
+
By default the Rails integration is set to only report Exceptions in Production. To change this behaviour, set `config.enable_reporting` to something else in `config/initializers/raygun.rb`.
|
41
|
+
|
42
|
+
### Rails 2
|
43
|
+
|
44
|
+
Raygun4Ruby doesn't currently support Rails 2. If you'd like Rails 2 support, [drop us a line](https://raygun.com/forums).
|
45
|
+
|
46
|
+
### Sinatra
|
47
|
+
|
48
|
+
To enable exception tracking in Sinatra, just add configure Raygun and use the Rack middleware in your app:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
require 'raygun4ruby'
|
52
|
+
Raygun.setup do |config|
|
53
|
+
config.api_key = "YOUR_API_KEY_HERE"
|
54
|
+
end
|
55
|
+
use Raygun::Middleware::RackExceptionInterceptor
|
56
|
+
```
|
57
|
+
|
58
|
+
### Standalone / Manual Exception Tracking
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
|
62
|
+
require 'rubygems'
|
63
|
+
require 'raygun4ruby'
|
64
|
+
|
65
|
+
Raygun.setup do |config|
|
66
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
67
|
+
config.filter_parameters = [ :password, :card_number, :cvv ] # don't forget to filter out sensitive parameters
|
68
|
+
config.enable_reporting = Rails.env.production? # true to send errors, false to not log
|
69
|
+
end
|
70
|
+
|
71
|
+
begin
|
72
|
+
# your lovely code here
|
73
|
+
rescue => e
|
74
|
+
Raygun.track_exception(e)
|
75
|
+
end
|
76
|
+
|
77
|
+
# You may also pass a user object as the third argument to allow affected user tracking, like so
|
78
|
+
begin
|
79
|
+
# your lovely code here
|
80
|
+
rescue => e
|
81
|
+
# The second argument is the request environment variables
|
82
|
+
Raygun.track_exception(e, {}, user)
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
You can also pass a Hash as the second parameter to `track_exception`. It should look like a [Rack Env Hash](https://github.com/rack/rack/blob/master/SPEC.rdoc#label-The+Environment)
|
87
|
+
|
88
|
+
### Customizing The Parameter Filtering
|
89
|
+
|
90
|
+
If you'd like to customize how parameters are filtered, you can pass a `Proc` to `filter_parameters`. Raygun4Ruby will yield the params hash to the block, and the return value will be sent along with your error.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
Raygun.setup do |config|
|
94
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
95
|
+
config.filter_parameters do |params|
|
96
|
+
params.slice("only", "a", "few", "keys") # note that Hash#slice is in ActiveSupport
|
97
|
+
end
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
101
|
+
### Recording Breadcrumbs
|
102
|
+
|
103
|
+
Breadcrumbs let you provide logging points in your code that will be collected and sent along with any exception sent to Raygun. This lets you have a better understanding of the events that happened in the system that lead up to the exception.
|
104
|
+
|
105
|
+
1. Include it as a module in your class
|
106
|
+
```ruby
|
107
|
+
class SomeClass
|
108
|
+
include Raygun::Breadcrumbs
|
109
|
+
|
110
|
+
def some_method
|
111
|
+
record_breadcrumb(
|
112
|
+
message: "<log message goes here>",
|
113
|
+
category: "some category to group them by, maybe authentication or external-apis for example",
|
114
|
+
level: :info, # or debug or warning etc, you can configure what level will get sent
|
115
|
+
metadata: {custom_data: 'can go here'},
|
116
|
+
)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
```
|
120
|
+
This has the added benefit of recording the class the breadcrumb was recorded from automatically
|
121
|
+
|
122
|
+
2. Call the `record_breadcrumb` method manually
|
123
|
+
```ruby
|
124
|
+
def some_method
|
125
|
+
Raygun.record_breadcrumb(
|
126
|
+
message: "<log message goes here>",
|
127
|
+
category: "some category to group them by, maybe authentication or external-apis for example",
|
128
|
+
level: :info, # or debug or warning etc, you can configure what level will get sent
|
129
|
+
metadata: {custom_data: 'can go here'},
|
130
|
+
|
131
|
+
# You can also set the class the breadcrumb was logged from
|
132
|
+
# It will only be set automatically using the included module approach
|
133
|
+
# Method and line number will get added automatically
|
134
|
+
class_name: self.class.name
|
135
|
+
)
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
139
|
+
If you are using Sinatra or another rack framework you will need to include the Breadcrumbs middleware, this is used for storing the breadcrumbs during a request
|
140
|
+
`use Raygun::Middleware::BreadcrumbsStoreInitializer`
|
141
|
+
(this must be before you `use` the `Raygun::Middleware::RackExceptionInterceptor`)
|
142
|
+
|
143
|
+
If you are using a non web based Ruby application you will have to call `Raygun::Breadcrumbs::Store.initialize` during your applications boot process. The store is per thread, but I have not tested it in a multi threaded application.
|
144
|
+
|
145
|
+
### Filtering the payload by whitelist
|
146
|
+
|
147
|
+
As an alternative to the above, you can also opt-in to the keys/values to be sent to Raygun by providing a specific whitelist of the keys you want to transmit.
|
148
|
+
|
149
|
+
This disables the blacklist filtering above (`filter_parameters`), and is applied to the entire payload (error, request, environment and custom data included), not just the request parameters.
|
150
|
+
|
151
|
+
In order to opt-in to this feature, set `filter_payload_with_whitelist` to `true`, and specify a shape of what keys you want (the default is below which is to allow everything through, this also means that the query parameters filtered out by default like password, creditcard etc will not be unless changed):
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
Raygun.setup do |config|
|
155
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
156
|
+
config.filter_payload_with_whitelist = true
|
157
|
+
|
158
|
+
config.whitelist_payload_shape = {
|
159
|
+
machineName: true,
|
160
|
+
version: true,
|
161
|
+
error: true,
|
162
|
+
userCustomData: true,
|
163
|
+
tags: true,
|
164
|
+
request: {
|
165
|
+
hostName: true,
|
166
|
+
url: true,
|
167
|
+
httpMethod: true,
|
168
|
+
iPAddress: true,
|
169
|
+
queryString: true,
|
170
|
+
headers: true,
|
171
|
+
form: {}, # Set to empty hash so that it doesn't just filter out the whole thing, but instead filters out each individual param
|
172
|
+
rawData: true
|
173
|
+
}
|
174
|
+
}
|
175
|
+
end
|
176
|
+
```
|
177
|
+
|
178
|
+
Alternatively, provide a Proc to filter the payload using your own logic:
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
Raygun.setup do |config|
|
182
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
183
|
+
config.filter_payload_with_whitelist = true
|
184
|
+
|
185
|
+
config.whitelist_payload_shape do |payload|
|
186
|
+
# Return the payload mutated into your desired form
|
187
|
+
payload
|
188
|
+
end
|
189
|
+
end
|
190
|
+
```
|
191
|
+
|
192
|
+
### Custom User Data
|
193
|
+
Custom data can be added to `track_exception` by passing a custom_data key in the second parameter hash.
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
begin
|
197
|
+
# more lovely code
|
198
|
+
rescue Exception => e
|
199
|
+
Raygun.track_exception(e, custom_data: {my: 'custom data', goes: 'here'})
|
200
|
+
end
|
201
|
+
```
|
202
|
+
|
203
|
+
Custom data can also be specified globally either by setting `config.custom_data` to a hash
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
Raygun.setup do |config|
|
207
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
208
|
+
config.custom_data = {custom_data: 'goes here'}
|
209
|
+
end
|
210
|
+
```
|
211
|
+
|
212
|
+
or to a proc, which gets passed the exception and environment hash
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
Raygun.setup do |config|
|
216
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
217
|
+
config.custom_data do |e, env|
|
218
|
+
{message: e.message, server: env["SERVER_NAME"]}
|
219
|
+
end
|
220
|
+
end
|
221
|
+
```
|
222
|
+
|
223
|
+
### Ignoring Some Errors
|
224
|
+
|
225
|
+
You can ignore certain types of Exception using the `ignore` option in the setup block, like so:
|
226
|
+
|
227
|
+
```ruby
|
228
|
+
Raygun.setup do |config|
|
229
|
+
config.api_key = "MY_SWEET_API_KEY"
|
230
|
+
config.ignore << ['MyApp::AnExceptionIDontCareAbout']
|
231
|
+
end
|
232
|
+
```
|
233
|
+
|
234
|
+
The following exceptions are ignored by default:
|
235
|
+
|
236
|
+
```
|
237
|
+
ActiveRecord::RecordNotFound
|
238
|
+
ActionController::RoutingError
|
239
|
+
ActionController::InvalidAuthenticityToken
|
240
|
+
ActionDispatch::ParamsParser::ParseError
|
241
|
+
CGI::Session::CookieStore::TamperedWithCookie
|
242
|
+
ActionController::UnknownAction
|
243
|
+
AbstractController::ActionNotFound
|
244
|
+
Mongoid::Errors::DocumentNotFound
|
245
|
+
```
|
246
|
+
|
247
|
+
[You can see this here](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb#L90) and unignore them if needed by doing the following:
|
248
|
+
|
249
|
+
```ruby
|
250
|
+
Raygun.setup do |config|
|
251
|
+
config.api_key = "MY_SWEET_API_KEY"
|
252
|
+
config.ignore.delete('ActionController::InvalidAuthenticityToken')
|
253
|
+
end
|
254
|
+
```
|
255
|
+
|
256
|
+
### Using a Proxy
|
257
|
+
|
258
|
+
You can pass proxy settings using the `proxy_settings` config option.
|
259
|
+
|
260
|
+
```ruby
|
261
|
+
Raygun.setup do |config|
|
262
|
+
config.api_key = "MY_SWEET_API_KEY"
|
263
|
+
config.proxy_settings = { host: "localhost", port: 8888 }
|
264
|
+
end
|
265
|
+
```
|
266
|
+
|
267
|
+
### Affected User Tracking
|
268
|
+
|
269
|
+
Raygun can now track how many users have been affected by an error.
|
270
|
+
|
271
|
+
By default, Raygun looks for a method called `current_user` on your controller, and it will populate the user's information based on a default method name mapping.
|
272
|
+
|
273
|
+
(e.g Raygun will call `email` to populate the user's email, and `first_name` for the user's first name)
|
274
|
+
|
275
|
+
You can inspect and customize this mapping using `config.affected_user_mapping`, like so:
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
Raygun.setup do |config|
|
279
|
+
config.api_key = "MY_SWEET_API_KEY"
|
280
|
+
config.affected_user_method = :my_current_user # `current_user` by default
|
281
|
+
# To augment the defaults with your unique methods you can do the following
|
282
|
+
config.affected_user_mapping = Raygun::AffectedUser::DEFAULT_MAPPING.merge({
|
283
|
+
identifier: :some_custom_unique_identifier,
|
284
|
+
# If you set the key to a proc it will be passed the user object and you can construct the value your self
|
285
|
+
full_name: ->(user) { "#{user.first_name} #{user.last_name}" }
|
286
|
+
})
|
287
|
+
end
|
288
|
+
```
|
289
|
+
|
290
|
+
To see the defaults check out [affected_user.rb](https://github.com/MindscapeHQ/raygun4ruby/tree/master/lib/raygun/affected_user.rb)
|
291
|
+
|
292
|
+
If you're using Rails, most authentication systems will have this method set and you should be good to go.
|
293
|
+
|
294
|
+
The count of unique affected users will appear on the error group in the Raygun dashboard. If your user has an `Email` attribute, and that email has a Gravatar associated with that address, you will also see your user's avatar.
|
295
|
+
|
296
|
+
If you wish to keep it anonymous, you could set this identifier to something like `SecureRandom.uuid` and store that in a cookie, like so:
|
297
|
+
|
298
|
+
```ruby
|
299
|
+
class ApplicationController < ActionController::Base
|
300
|
+
|
301
|
+
def raygun_user
|
302
|
+
cookies.permanent[:raygun_user_identifier] ||= SecureRandom.uuid
|
303
|
+
end
|
304
|
+
|
305
|
+
end
|
306
|
+
```
|
307
|
+
|
308
|
+
(Remember to set `affected_user_method` to `:raygun_user` in your config block...)
|
309
|
+
|
310
|
+
### Version tracking
|
311
|
+
|
312
|
+
Raygun can attach the version of your application to its error reports. In your Raygun.setup block, set `version` to the current version of your app.
|
313
|
+
|
314
|
+
```ruby
|
315
|
+
Raygun.setup do |config|
|
316
|
+
config.version = "1.0.0.4" # you could also pull this from ENV or however you want to set it.
|
317
|
+
end
|
318
|
+
```
|
319
|
+
|
320
|
+
### Tags
|
321
|
+
|
322
|
+
Tags can be added to `track_exception` by passing a tags key in the second parameter hash.
|
323
|
+
|
324
|
+
```ruby
|
325
|
+
begin
|
326
|
+
# more lovely code
|
327
|
+
rescue Exception => e
|
328
|
+
Raygun.track_exception(e, tags: ['my', 'tags', 'go here'])
|
329
|
+
end
|
330
|
+
```
|
331
|
+
|
332
|
+
Tags can also be specified globally either by setting `config.custom_data` to an array
|
333
|
+
|
334
|
+
```ruby
|
335
|
+
Raygun.setup do |config|
|
336
|
+
config.tags = ['heroku']
|
337
|
+
end
|
338
|
+
```
|
339
|
+
|
340
|
+
or to a proc, which gets passed the exception and environment hash. This proc _must_ return an array of strings
|
341
|
+
|
342
|
+
```ruby
|
343
|
+
Raygun.setup do |config|
|
344
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
345
|
+
config.tags do |e, env|
|
346
|
+
[env["SERVER_NAME"]]
|
347
|
+
end
|
348
|
+
end
|
349
|
+
```
|
350
|
+
|
351
|
+
### Resque Error Tracking
|
352
|
+
|
353
|
+
Raygun4Ruby also includes a Resque failure backend. You should include it inside your Resque initializer (usually something like `config/initializers/load_resque.rb`)
|
354
|
+
|
355
|
+
```ruby
|
356
|
+
require 'resque/failure/multiple'
|
357
|
+
require 'resque/failure/raygun'
|
358
|
+
require 'resque/failure/redis'
|
359
|
+
|
360
|
+
Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Raygun]
|
361
|
+
Resque::Failure.backend = Resque::Failure::Multiple
|
362
|
+
```
|
363
|
+
|
364
|
+
### Sidekiq Error Tracking
|
365
|
+
|
366
|
+
Raygun4Ruby can track errors from Sidekiq (2.x or 3+). All you need to do is add the line:
|
367
|
+
|
368
|
+
```ruby
|
369
|
+
require 'raygun/sidekiq'
|
370
|
+
```
|
371
|
+
|
372
|
+
Either in your Raygun initializer or wherever else takes your fancy :)
|
373
|
+
|
374
|
+
#### Affected User Tracking in Sidekiq
|
375
|
+
|
376
|
+
To track affected users, define a class method on your worker class that returns a user object.
|
377
|
+
Make sure the name of this method is the same as whatever you have defined as the `affected_user_method` in your Raygun configuration and that it returns an object that fits the mappings defined in `affected_user_mapping`
|
378
|
+
If you have not changed these, refer to [Affected user tracking](#affected-user-tracking) for the defaults
|
379
|
+
|
380
|
+
```ruby
|
381
|
+
class FailingWorker
|
382
|
+
include Sidekiq::Worker
|
383
|
+
|
384
|
+
def perform(arg1, arg2)
|
385
|
+
end
|
386
|
+
|
387
|
+
# Your method must accept an array of arguments
|
388
|
+
# These will be the same as those passed to `perform`
|
389
|
+
def self.current_user(args)
|
390
|
+
arg1 = args[0]
|
391
|
+
arg2 = args[1]
|
392
|
+
|
393
|
+
user = User.find_by(name: arg1)
|
394
|
+
|
395
|
+
# Your method must return a user object
|
396
|
+
user
|
397
|
+
end
|
398
|
+
```
|
399
|
+
|
400
|
+
### Other Configuration options
|
401
|
+
|
402
|
+
For a complete list of configuration options see the [configuration.rb](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb) file
|
403
|
+
|
404
|
+
## Found a bug?
|
405
|
+
|
406
|
+
Oops! Just let us know by opening an Issue on Github.
|
407
|
+
|
408
|
+
## Contributing
|
409
|
+
|
410
|
+
1. Fork it
|
411
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
412
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
413
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
414
|
+
5. Create new Pull Request
|
415
|
+
|
416
|
+
## Building
|
417
|
+
|
418
|
+
1. Build the gem (`gem build raygun4ruby.gemspec`) - don't bother trying to build it on Windows,
|
419
|
+
the resulting Gem won't work.
|
420
|
+
2. Install the gem (`gem install raygun4ruby-VERSION.gem`)
|