raygun4ruby 3.2.6 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +48 -0
  3. data/.gitignore +22 -21
  4. data/.rspec +1 -1
  5. data/Appraisals +19 -0
  6. data/CHANGELOG.md +169 -133
  7. data/Gemfile +4 -4
  8. data/LICENSE.txt +22 -22
  9. data/README.md +426 -420
  10. data/Rakefile +32 -27
  11. data/examples/sinatras_raygun.rb +17 -17
  12. data/gemfiles/rails_6.gemfile +9 -0
  13. data/gemfiles/rails_7.gemfile +10 -0
  14. data/gemfiles/rails_7_sidekiq_6.gemfile +10 -0
  15. data/lib/generators/raygun/install_generator.rb +26 -26
  16. data/lib/raygun/affected_user.rb +59 -59
  17. data/lib/raygun/breadcrumbs/breadcrumb.rb +34 -34
  18. data/lib/raygun/breadcrumbs/store.rb +86 -86
  19. data/lib/raygun/breadcrumbs.rb +34 -34
  20. data/lib/raygun/client.rb +313 -308
  21. data/lib/raygun/configuration.rb +198 -194
  22. data/lib/raygun/demo_exception.rb +22 -22
  23. data/lib/raygun/error.rb +10 -10
  24. data/lib/raygun/error_subscriber.rb +21 -0
  25. data/lib/raygun/javascript_tracker.rb +42 -42
  26. data/lib/raygun/middleware/breadcrumbs_store_initializer.rb +19 -19
  27. data/lib/raygun/middleware/javascript_exception_tracking.rb +40 -32
  28. data/lib/raygun/middleware/rack_exception_interceptor.rb +18 -18
  29. data/lib/raygun/middleware/rails_insert_affected_user.rb +26 -26
  30. data/lib/raygun/railtie.rb +47 -39
  31. data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +27 -27
  32. data/lib/raygun/sidekiq.rb +51 -71
  33. data/lib/raygun/version.rb +3 -3
  34. data/lib/raygun.rb +197 -179
  35. data/lib/raygun4ruby.rb +1 -1
  36. data/lib/resque/failure/raygun.rb +25 -25
  37. data/lib/tasks/raygun.tasks +7 -7
  38. data/raygun4ruby.gemspec +43 -45
  39. data/spec/features/javascript_spec.rb +48 -48
  40. data/spec/rails_applications/6.1.4/Gemfile +56 -0
  41. data/spec/{dummy/README.rdoc → rails_applications/6.1.4/README.md} +24 -28
  42. data/spec/{dummy → rails_applications/6.1.4}/Rakefile +6 -6
  43. data/spec/rails_applications/6.1.4/app/assets/config/manifest.js +2 -0
  44. data/spec/{dummy → rails_applications/6.1.4}/app/assets/images/.keep +0 -0
  45. data/spec/{dummy → rails_applications/6.1.4}/app/assets/stylesheets/application.css +15 -15
  46. data/spec/rails_applications/6.1.4/app/channels/application_cable/channel.rb +4 -0
  47. data/spec/rails_applications/6.1.4/app/channels/application_cable/connection.rb +4 -0
  48. data/spec/rails_applications/6.1.4/app/controllers/application_controller.rb +2 -0
  49. data/spec/{dummy → rails_applications/6.1.4}/app/controllers/concerns/.keep +0 -0
  50. data/spec/{dummy → rails_applications/6.1.4}/app/controllers/home_controller.rb +4 -4
  51. data/spec/{dummy → rails_applications/6.1.4}/app/helpers/application_helper.rb +2 -2
  52. data/spec/rails_applications/6.1.4/app/javascript/channels/consumer.js +6 -0
  53. data/spec/rails_applications/6.1.4/app/javascript/channels/index.js +5 -0
  54. data/spec/rails_applications/6.1.4/app/javascript/packs/application.js +13 -0
  55. data/spec/rails_applications/6.1.4/app/jobs/application_job.rb +7 -0
  56. data/spec/rails_applications/6.1.4/app/mailers/application_mailer.rb +4 -0
  57. data/spec/rails_applications/6.1.4/app/models/application_record.rb +3 -0
  58. data/spec/{dummy/app/mailers → rails_applications/6.1.4/app/models/concerns}/.keep +0 -0
  59. data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.html.erb +3 -3
  60. data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.json.erb +1 -1
  61. data/spec/rails_applications/6.1.4/app/views/layouts/application.html.erb +13 -0
  62. data/spec/rails_applications/6.1.4/app/views/layouts/mailer.html.erb +13 -0
  63. data/spec/rails_applications/6.1.4/app/views/layouts/mailer.text.erb +1 -0
  64. data/spec/rails_applications/6.1.4/bin/rails +5 -0
  65. data/spec/rails_applications/6.1.4/bin/rake +5 -0
  66. data/spec/rails_applications/6.1.4/bin/setup +36 -0
  67. data/spec/rails_applications/6.1.4/bin/spring +14 -0
  68. data/spec/rails_applications/6.1.4/bin/yarn +17 -0
  69. data/spec/rails_applications/6.1.4/config/application.rb +22 -0
  70. data/spec/rails_applications/6.1.4/config/boot.rb +3 -0
  71. data/spec/rails_applications/6.1.4/config/cable.yml +10 -0
  72. data/spec/rails_applications/6.1.4/config/credentials.yml.enc +1 -0
  73. data/spec/{dummy → rails_applications/6.1.4}/config/database.yml +25 -25
  74. data/spec/{dummy → rails_applications/6.1.4}/config/environment.rb +5 -5
  75. data/spec/rails_applications/6.1.4/config/environments/development.rb +76 -0
  76. data/spec/rails_applications/6.1.4/config/environments/production.rb +120 -0
  77. data/spec/rails_applications/6.1.4/config/environments/test.rb +60 -0
  78. data/spec/rails_applications/6.1.4/config/initializers/application_controller_renderer.rb +8 -0
  79. data/spec/rails_applications/6.1.4/config/initializers/assets.rb +14 -0
  80. data/spec/rails_applications/6.1.4/config/initializers/backtrace_silencers.rb +8 -0
  81. data/spec/rails_applications/6.1.4/config/initializers/content_security_policy.rb +30 -0
  82. data/spec/{dummy → rails_applications/6.1.4}/config/initializers/cookies_serializer.rb +5 -3
  83. data/spec/{dummy → rails_applications/6.1.4}/config/initializers/filter_parameter_logging.rb +6 -4
  84. data/spec/{dummy → rails_applications/6.1.4}/config/initializers/inflections.rb +16 -16
  85. data/spec/{dummy → rails_applications/6.1.4}/config/initializers/mime_types.rb +4 -4
  86. data/spec/rails_applications/6.1.4/config/initializers/permissions_policy.rb +11 -0
  87. data/spec/{dummy → rails_applications/6.1.4}/config/initializers/wrap_parameters.rb +14 -14
  88. data/spec/{dummy → rails_applications/6.1.4}/config/locales/en.yml +33 -23
  89. data/spec/rails_applications/6.1.4/config/master.key +1 -0
  90. data/spec/rails_applications/6.1.4/config/puma.rb +43 -0
  91. data/spec/rails_applications/6.1.4/config/routes.rb +4 -0
  92. data/spec/rails_applications/6.1.4/config/spring.rb +6 -0
  93. data/spec/rails_applications/6.1.4/config/storage.yml +34 -0
  94. data/spec/{dummy → rails_applications/6.1.4}/config.ru +6 -4
  95. data/spec/rails_applications/6.1.4/db/seeds.rb +7 -0
  96. data/spec/{dummy → rails_applications/6.1.4}/db/test.sqlite3 +0 -0
  97. data/spec/{dummy/app/models → rails_applications/6.1.4/lib/assets}/.keep +0 -0
  98. data/spec/{dummy/app/models/concerns → rails_applications/6.1.4/lib/tasks}/.keep +0 -0
  99. data/spec/rails_applications/6.1.4/package.json +11 -0
  100. data/spec/{dummy → rails_applications/6.1.4}/public/404.html +67 -67
  101. data/spec/{dummy → rails_applications/6.1.4}/public/422.html +67 -67
  102. data/spec/{dummy → rails_applications/6.1.4}/public/500.html +66 -66
  103. data/spec/{dummy/lib/assets/.keep → rails_applications/6.1.4/public/apple-touch-icon-precomposed.png} +0 -0
  104. data/spec/{dummy/lib/tasks/.keep → rails_applications/6.1.4/public/apple-touch-icon.png} +0 -0
  105. data/spec/{dummy → rails_applications/6.1.4}/public/favicon.ico +0 -0
  106. data/spec/rails_applications/6.1.4/public/robots.txt +1 -0
  107. data/spec/{dummy/log → rails_applications/6.1.4/storage}/.keep +0 -0
  108. data/spec/rails_applications/7.1.3/.dockerignore +37 -0
  109. data/spec/rails_applications/7.1.3/.gitattributes +9 -0
  110. data/spec/rails_applications/7.1.3/.gitignore +35 -0
  111. data/spec/rails_applications/7.1.3/.ruby-version +1 -0
  112. data/spec/rails_applications/7.1.3/Dockerfile +62 -0
  113. data/spec/rails_applications/7.1.3/Gemfile +67 -0
  114. data/spec/rails_applications/7.1.3/README.md +24 -0
  115. data/spec/rails_applications/7.1.3/Rakefile +6 -0
  116. data/spec/rails_applications/7.1.3/app/assets/config/manifest.js +4 -0
  117. data/spec/{dummy/test/controllers → rails_applications/7.1.3/app/assets/images}/.keep +0 -0
  118. data/spec/rails_applications/7.1.3/app/assets/stylesheets/application.css +15 -0
  119. data/spec/rails_applications/7.1.3/app/channels/application_cable/channel.rb +4 -0
  120. data/spec/rails_applications/7.1.3/app/channels/application_cable/connection.rb +4 -0
  121. data/spec/rails_applications/7.1.3/app/controllers/application_controller.rb +2 -0
  122. data/spec/{dummy/test/fixtures → rails_applications/7.1.3/app/controllers/concerns}/.keep +0 -0
  123. data/spec/rails_applications/7.1.3/app/controllers/home_controller.rb +2 -0
  124. data/spec/rails_applications/7.1.3/app/helpers/application_helper.rb +2 -0
  125. data/spec/rails_applications/7.1.3/app/helpers/home_helper.rb +2 -0
  126. data/spec/rails_applications/7.1.3/app/javascript/application.js +3 -0
  127. data/spec/rails_applications/7.1.3/app/javascript/controllers/application.js +9 -0
  128. data/spec/rails_applications/7.1.3/app/javascript/controllers/hello_controller.js +7 -0
  129. data/spec/rails_applications/7.1.3/app/javascript/controllers/index.js +11 -0
  130. data/spec/rails_applications/7.1.3/app/jobs/application_job.rb +7 -0
  131. data/spec/rails_applications/7.1.3/app/mailers/application_mailer.rb +4 -0
  132. data/spec/rails_applications/7.1.3/app/models/application_record.rb +3 -0
  133. data/spec/{dummy/test/helpers → rails_applications/7.1.3/app/models/concerns}/.keep +0 -0
  134. data/spec/rails_applications/7.1.3/app/views/home/index.html.erb +3 -0
  135. data/spec/rails_applications/7.1.3/app/views/home/index.json.erb +1 -0
  136. data/spec/rails_applications/7.1.3/app/views/layouts/application.html.erb +16 -0
  137. data/spec/rails_applications/7.1.3/app/views/layouts/mailer.html.erb +13 -0
  138. data/spec/rails_applications/7.1.3/app/views/layouts/mailer.text.erb +1 -0
  139. data/spec/rails_applications/7.1.3/bin/bundle +109 -0
  140. data/spec/rails_applications/7.1.3/bin/docker-entrypoint +8 -0
  141. data/spec/rails_applications/7.1.3/bin/importmap +4 -0
  142. data/spec/rails_applications/7.1.3/bin/rails +4 -0
  143. data/spec/rails_applications/7.1.3/bin/rake +4 -0
  144. data/spec/rails_applications/7.1.3/bin/setup +33 -0
  145. data/spec/rails_applications/7.1.3/config/application.rb +27 -0
  146. data/spec/rails_applications/7.1.3/config/boot.rb +4 -0
  147. data/spec/rails_applications/7.1.3/config/cable.yml +11 -0
  148. data/spec/rails_applications/7.1.3/config/credentials.yml.enc +1 -0
  149. data/spec/rails_applications/7.1.3/config/database.yml +25 -0
  150. data/spec/rails_applications/7.1.3/config/environment.rb +5 -0
  151. data/spec/rails_applications/7.1.3/config/environments/development.rb +76 -0
  152. data/spec/rails_applications/7.1.3/config/environments/production.rb +97 -0
  153. data/spec/rails_applications/7.1.3/config/environments/test.rb +64 -0
  154. data/spec/rails_applications/7.1.3/config/importmap.rb +7 -0
  155. data/spec/rails_applications/7.1.3/config/initializers/assets.rb +12 -0
  156. data/spec/rails_applications/7.1.3/config/initializers/content_security_policy.rb +25 -0
  157. data/spec/rails_applications/7.1.3/config/initializers/filter_parameter_logging.rb +8 -0
  158. data/spec/rails_applications/7.1.3/config/initializers/inflections.rb +16 -0
  159. data/spec/rails_applications/7.1.3/config/initializers/permissions_policy.rb +13 -0
  160. data/spec/rails_applications/7.1.3/config/locales/en.yml +31 -0
  161. data/spec/rails_applications/7.1.3/config/puma.rb +35 -0
  162. data/spec/rails_applications/7.1.3/config/routes.rb +11 -0
  163. data/spec/rails_applications/7.1.3/config/storage.yml +34 -0
  164. data/spec/rails_applications/7.1.3/config.ru +6 -0
  165. data/spec/rails_applications/7.1.3/db/seeds.rb +9 -0
  166. data/spec/{dummy/test/integration → rails_applications/7.1.3/lib/assets}/.keep +0 -0
  167. data/spec/{dummy/test/mailers → rails_applications/7.1.3/lib/tasks}/.keep +0 -0
  168. data/spec/rails_applications/7.1.3/public/404.html +67 -0
  169. data/spec/rails_applications/7.1.3/public/422.html +67 -0
  170. data/spec/rails_applications/7.1.3/public/500.html +66 -0
  171. data/spec/{dummy/test/models/.keep → rails_applications/7.1.3/public/apple-touch-icon-precomposed.png} +0 -0
  172. data/spec/{dummy/vendor/assets/javascripts/.keep → rails_applications/7.1.3/public/apple-touch-icon.png} +0 -0
  173. data/spec/{dummy/vendor/assets/stylesheets/.keep → rails_applications/7.1.3/public/favicon.ico} +0 -0
  174. data/spec/rails_applications/7.1.3/public/robots.txt +1 -0
  175. data/spec/rails_applications/7.1.3/storage/.keep +0 -0
  176. data/spec/rails_applications/7.1.3/test/application_system_test_case.rb +5 -0
  177. data/spec/rails_applications/7.1.3/test/channels/application_cable/connection_test.rb +13 -0
  178. data/spec/rails_applications/7.1.3/test/controllers/.keep +0 -0
  179. data/spec/rails_applications/7.1.3/test/controllers/home_controller_test.rb +7 -0
  180. data/spec/rails_applications/7.1.3/test/fixtures/files/.keep +0 -0
  181. data/spec/rails_applications/7.1.3/test/helpers/.keep +0 -0
  182. data/spec/rails_applications/7.1.3/test/integration/.keep +0 -0
  183. data/spec/rails_applications/7.1.3/test/mailers/.keep +0 -0
  184. data/spec/rails_applications/7.1.3/test/models/.keep +0 -0
  185. data/spec/rails_applications/7.1.3/test/system/.keep +0 -0
  186. data/spec/rails_applications/7.1.3/test/test_helper.rb +15 -0
  187. data/spec/rails_applications/7.1.3/vendor/.keep +0 -0
  188. data/spec/rails_applications/7.1.3/vendor/javascript/.keep +0 -0
  189. data/spec/rails_helper.rb +8 -4
  190. data/spec/raygun/breadcrumbs/breadcrumb_spec.rb +171 -171
  191. data/spec/raygun/breadcrumbs/store_spec.rb +170 -170
  192. data/spec/services/apply_whitelist_filter_to_payload_spec.rb +251 -251
  193. data/spec/spec_helper.rb +24 -24
  194. data/spec/support/fake_logger.rb +17 -17
  195. data/test/integration/client_test.rb +19 -19
  196. data/test/rails_helper.rb +6 -0
  197. data/test/test_helper.rb +76 -72
  198. data/test/unit/affected_user_test.rb +136 -136
  199. data/test/unit/client_test.rb +812 -812
  200. data/test/unit/configuration_test.rb +202 -206
  201. data/test/unit/error_subscriber_test.rb +43 -0
  202. data/test/unit/raygun_test.rb +106 -25
  203. data/test/unit/resque_failure_test.rb +27 -24
  204. data/test/unit/sidekiq_failure_test.rb +42 -32
  205. metadata +186 -125
  206. data/.travis.yml +0 -20
  207. data/spec/dummy/.gitignore +0 -17
  208. data/spec/dummy/Gemfile +0 -47
  209. data/spec/dummy/app/assets/config/manifest.js +0 -3
  210. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  211. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  212. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  213. data/spec/dummy/bin/bundle +0 -3
  214. data/spec/dummy/bin/rails +0 -9
  215. data/spec/dummy/bin/rake +0 -9
  216. data/spec/dummy/bin/setup +0 -29
  217. data/spec/dummy/bin/spring +0 -17
  218. data/spec/dummy/config/application.rb +0 -26
  219. data/spec/dummy/config/boot.rb +0 -3
  220. data/spec/dummy/config/environments/development.rb +0 -41
  221. data/spec/dummy/config/environments/production.rb +0 -79
  222. data/spec/dummy/config/environments/test.rb +0 -42
  223. data/spec/dummy/config/initializers/assets.rb +0 -11
  224. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  225. data/spec/dummy/config/initializers/session_store.rb +0 -3
  226. data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +0 -10
  227. data/spec/dummy/config/routes.rb +0 -58
  228. data/spec/dummy/config/secrets.yml +0 -22
  229. data/spec/dummy/db/seeds.rb +0 -7
  230. data/spec/dummy/public/robots.txt +0 -5
  231. data/spec/dummy/test/test_helper.rb +0 -10
  232. data/spec/raygun/raygun_spec.rb +0 -47
data/README.md CHANGED
@@ -1,420 +1,426 @@
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 customers, 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 Customers
268
-
269
- Raygun can now track how many customers 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 customer's information based on a default method name mapping.
272
-
273
- (e.g Raygun will call `email` to populate the customer's email, and `first_name` for the customer'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 customers will appear on the error group in the Raygun dashboard. If your customer has an `Email` attribute, and that email has a Gravatar associated with that address, you will also see your customer'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 Customers in Sidekiq
375
-
376
- To track affected customers, 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 customers](#affected-customers) 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://github.com/MindscapeHQ/raygun4ruby/actions/workflows/tests.yml/badge.svg) [![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
+ ## Installation
6
+
7
+ Add to your application's Gemfile:
8
+
9
+ $ bundle add raygun4ruby
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ ## Usage
16
+
17
+ ### Rails 6+
18
+
19
+ #### Step 1
20
+
21
+ Run:
22
+
23
+ rails g raygun:install YOUR_API_KEY_HERE
24
+
25
+ You can find your API key in the [Raygun app](https://app.raygun.com/) under "Application Settings".
26
+
27
+ #### Step 2
28
+
29
+ You can then test your Raygun integration by running:
30
+
31
+ rails raygun:test
32
+
33
+ You should see an "ItWorksException" appear in your Raygun Crash Reporting dashboard. You're ready to zap those errors! :zap:
34
+
35
+ #### Step 3 (optional)
36
+
37
+ 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!
38
+
39
+ By default the Rails integration is set to only report Exceptions in the `production` environment. To change this behaviour, set `config.enable_reporting` to something else in `config/initializers/raygun.rb`.
40
+
41
+ #### Version Support
42
+
43
+ Raygun4Ruby currently supports Rails 6 or later running on Ruby >= 3.0. If you're using an older version of Ruby or Rails please use an [older version of Raygun4Ruby](https://github.com/MindscapeHQ/raygun4ruby/releases)
44
+
45
+ ### Sinatra
46
+
47
+ To enable exception tracking in Sinatra, just add configure Raygun and use the Rack middleware in your app:
48
+
49
+ ```ruby
50
+ require 'raygun4ruby'
51
+ Raygun.setup do |config|
52
+ config.api_key = "YOUR_API_KEY_HERE"
53
+ end
54
+ use Raygun::Middleware::RackExceptionInterceptor
55
+ ```
56
+
57
+ ### Standalone / Manual Exception Tracking
58
+
59
+ ```ruby
60
+
61
+ require 'rubygems'
62
+ require 'raygun4ruby'
63
+
64
+ Raygun.setup do |config|
65
+ config.api_key = "YOUR_RAYGUN_API_KEY"
66
+ config.filter_parameters = [ :password, :card_number, :cvv ] # don't forget to filter out sensitive parameters
67
+ config.enable_reporting = Rails.env.production? # true to send errors, false to not log
68
+ end
69
+
70
+ begin
71
+ # your lovely code here
72
+ rescue => e
73
+ Raygun.track_exception(e)
74
+ end
75
+
76
+ # You may also pass a user object as the third argument to allow affected customers, like so
77
+ begin
78
+ # your lovely code here
79
+ rescue => e
80
+ # The second argument is the request environment variables
81
+ Raygun.track_exception(e, {}, user)
82
+ end
83
+ ```
84
+
85
+ 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)
86
+
87
+ ### Customizing Parameter Filtering
88
+
89
+ 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.
90
+
91
+ ```ruby
92
+ Raygun.setup do |config|
93
+ config.api_key = "YOUR_RAYGUN_API_KEY"
94
+ config.filter_parameters do |params|
95
+ params.slice("only", "a", "few", "keys") # note that Hash#slice is in ActiveSupport
96
+ end
97
+ end
98
+ ```
99
+
100
+ ### Recording Breadcrumbs
101
+
102
+ 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.
103
+
104
+ 1. Include it as a module in your class
105
+
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
+
121
+ This has the added benefit of recording the class the breadcrumb was recorded from automatically
122
+
123
+ 2. Call the `record_breadcrumb` method manually
124
+
125
+ ```ruby
126
+ def some_method
127
+ Raygun.record_breadcrumb(
128
+ message: "<log message goes here>",
129
+ category: "some category to group them by, maybe authentication or external-apis for example",
130
+ level: :info, # or debug or warning etc, you can configure what level will get sent
131
+ metadata: {custom_data: 'can go here'},
132
+
133
+ # You can also set the class the breadcrumb was logged from
134
+ # It will only be set automatically using the included module approach
135
+ # Method and line number will get added automatically
136
+ class_name: self.class.name
137
+ )
138
+ end
139
+ ```
140
+
141
+ 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
142
+ `use Raygun::Middleware::BreadcrumbsStoreInitializer`
143
+ (this must be before you `use` the `Raygun::Middleware::RackExceptionInterceptor`)
144
+
145
+ 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.
146
+
147
+ ### Filtering the enire payload using a whitelist
148
+
149
+ 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.
150
+
151
+ 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.
152
+
153
+ 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):
154
+
155
+ ```ruby
156
+ Raygun.setup do |config|
157
+ config.api_key = "YOUR_RAYGUN_API_KEY"
158
+ config.filter_payload_with_whitelist = true
159
+
160
+ config.whitelist_payload_shape = {
161
+ machineName: true,
162
+ version: true,
163
+ error: true,
164
+ userCustomData: true,
165
+ tags: true,
166
+ request: {
167
+ hostName: true,
168
+ url: true,
169
+ httpMethod: true,
170
+ iPAddress: true,
171
+ queryString: true,
172
+ headers: true,
173
+ form: {}, # Set to empty hash so that it doesn't just filter out the whole thing, but instead filters out each individual param
174
+ rawData: true
175
+ }
176
+ }
177
+ end
178
+ ```
179
+
180
+ Alternatively, provide a Proc to filter the payload using your own logic:
181
+
182
+ ```ruby
183
+ Raygun.setup do |config|
184
+ config.api_key = "YOUR_RAYGUN_API_KEY"
185
+ config.filter_payload_with_whitelist = true
186
+
187
+ config.whitelist_payload_shape do |payload|
188
+ # Return the payload mutated into your desired form
189
+ payload
190
+ end
191
+ end
192
+ ```
193
+
194
+ ### Custom User Data
195
+
196
+ Custom data can be added to `track_exception` by passing a custom_data key in the second parameter hash.
197
+
198
+ ```ruby
199
+ begin
200
+ # more lovely code
201
+ rescue Exception => e
202
+ Raygun.track_exception(e, custom_data: {my: 'custom data', goes: 'here'})
203
+ end
204
+ ```
205
+
206
+ Custom data can also be specified globally either by setting `config.custom_data` to a hash
207
+
208
+ ```ruby
209
+ Raygun.setup do |config|
210
+ config.api_key = "YOUR_RAYGUN_API_KEY"
211
+ config.custom_data = {custom_data: 'goes here'}
212
+ end
213
+ ```
214
+
215
+ or to a proc, which gets passed the exception and environment hash
216
+
217
+ ```ruby
218
+ Raygun.setup do |config|
219
+ config.api_key = "YOUR_RAYGUN_API_KEY"
220
+ config.custom_data do |e, env|
221
+ {message: e.message, server: env["SERVER_NAME"]}
222
+ end
223
+ end
224
+ ```
225
+
226
+ ### Ignoring Some Errors
227
+
228
+ You can ignore certain types of Exception using the `ignore` option in the setup block, like so:
229
+
230
+ ```ruby
231
+ Raygun.setup do |config|
232
+ config.api_key = "MY_SWEET_API_KEY"
233
+ config.ignore << ['MyApp::AnExceptionIDontCareAbout']
234
+ end
235
+ ```
236
+
237
+ The following exceptions are ignored by default:
238
+
239
+ ```
240
+ ActiveRecord::RecordNotFound
241
+ ActionController::RoutingError
242
+ ActionController::InvalidAuthenticityToken
243
+ ActionDispatch::ParamsParser::ParseError
244
+ CGI::Session::CookieStore::TamperedWithCookie
245
+ ActionController::UnknownAction
246
+ AbstractController::ActionNotFound
247
+ Mongoid::Errors::DocumentNotFound
248
+ ```
249
+
250
+ [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:
251
+
252
+ ```ruby
253
+ Raygun.setup do |config|
254
+ config.api_key = "MY_SWEET_API_KEY"
255
+ config.ignore.delete('ActionController::InvalidAuthenticityToken')
256
+ end
257
+ ```
258
+
259
+ ### Using a Proxy
260
+
261
+ You can pass proxy settings using the `proxy_settings` config option.
262
+
263
+ ```ruby
264
+ Raygun.setup do |config|
265
+ config.api_key = "MY_SWEET_API_KEY"
266
+ config.proxy_settings = { address: "localhost", port: 8888 }
267
+ end
268
+ ```
269
+
270
+ ### Affected Customers
271
+
272
+ Raygun can track how many customers have been affected by an error.
273
+
274
+ By default, Raygun looks for a method called `current_user` on your controller, and it will populate the customer's information based on a default method name mapping.
275
+
276
+ (e.g Raygun will call `email` to populate the customer's email, and `first_name` for the customer's first name)
277
+
278
+ You can inspect and customize this mapping using `config.affected_user_mapping`, like so:
279
+
280
+ ```ruby
281
+ Raygun.setup do |config|
282
+ config.api_key = "MY_SWEET_API_KEY"
283
+ config.affected_user_method = :my_current_user # `current_user` by default
284
+ # To augment the defaults with your unique methods you can do the following
285
+ config.affected_user_mapping = Raygun::AffectedUser::DEFAULT_MAPPING.merge({
286
+ identifier: :some_custom_unique_identifier,
287
+ # If you set the key to a proc it will be passed the user object and you can construct the value your self
288
+ full_name: ->(user) { "#{user.first_name} #{user.last_name}" }
289
+ })
290
+ end
291
+ ```
292
+
293
+ To see the defaults check out [affected_user.rb](https://github.com/MindscapeHQ/raygun4ruby/tree/master/lib/raygun/affected_user.rb)
294
+
295
+ If you're using Rails, most authentication systems will have this method set and you should be good to go.
296
+
297
+ The count of unique affected customers will appear on the error group in Raygun Crash Reporting. If your customer has an `email` attribute, and that email has a Gravatar associated with that address, you will also see your customer's avatar.
298
+
299
+ 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:
300
+
301
+ ```ruby
302
+ class ApplicationController < ActionController::Base
303
+
304
+ def raygun_user
305
+ cookies.permanent[:raygun_user_identifier] ||= SecureRandom.uuid
306
+ end
307
+
308
+ end
309
+ ```
310
+
311
+ (Remember to set `affected_user_method` to `:raygun_user` in your config block...)
312
+
313
+ ### Version Tracking
314
+
315
+ 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.
316
+
317
+ ```ruby
318
+ Raygun.setup do |config|
319
+ config.version = "1.0.0.4" # you could also pull this from ENV or however you want to set it.
320
+ end
321
+ ```
322
+
323
+ ### Tags
324
+
325
+ Tags can be added to `track_exception` by passing a tags key in the second parameter hash.
326
+
327
+ ```ruby
328
+ begin
329
+ # more lovely code
330
+ rescue Exception => e
331
+ Raygun.track_exception(e, tags: ['my', 'tags', 'go here'])
332
+ end
333
+ ```
334
+
335
+ Tags can also be specified globally either by setting `config.tags` to an array
336
+
337
+ ```ruby
338
+ Raygun.setup do |config|
339
+ config.tags = ['heroku']
340
+ end
341
+ ```
342
+
343
+ or to a Proc, which gets passed the exception and environment hash. This proc _must_ return an array of strings
344
+
345
+ ```ruby
346
+ Raygun.setup do |config|
347
+ config.api_key = "YOUR_RAYGUN_API_KEY"
348
+ config.tags do |e, env|
349
+ [env["SERVER_NAME"]]
350
+ end
351
+ end
352
+ ```
353
+
354
+ ### Background Jobs
355
+
356
+ #### Resque
357
+
358
+ Raygun4Ruby also includes a Resque failure backend. You should include it inside your Resque initializer (usually something like `config/initializers/load_resque.rb`)
359
+
360
+ ```ruby
361
+ require 'resque/failure/multiple'
362
+ require 'resque/failure/raygun'
363
+ require 'resque/failure/redis'
364
+
365
+ Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Raygun]
366
+ Resque::Failure.backend = Resque::Failure::Multiple
367
+ ```
368
+
369
+ #### Sidekiq
370
+
371
+ Raygun4Ruby can track errors from Sidekiq (we test on 6+ but there's no reason it shouldn't work on older versions). All you need to do is add the line:
372
+
373
+ ```ruby
374
+ require 'raygun/sidekiq'
375
+ ```
376
+
377
+ Either in your Raygun initializer or wherever else takes your fancy :simple_smile:
378
+
379
+ ##### Affected Customers in Sidekiq
380
+
381
+ To track affected customers, define a class method on your worker class that returns a user object.
382
+ 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`
383
+ If you have not changed these, refer to [Affected customers](#affected-customers) for the defaults
384
+
385
+ ```ruby
386
+ class FailingWorker
387
+ include Sidekiq::Worker
388
+
389
+ def perform(arg1, arg2)
390
+ end
391
+
392
+ # Your method must accept an array of arguments
393
+ # These will be the same as those passed to `perform`
394
+ def self.current_user(args)
395
+ arg1 = args[0]
396
+ arg2 = args[1]
397
+
398
+ user = User.find_by(name: arg1)
399
+
400
+ # Your method must return a user object
401
+ user
402
+ end
403
+ ```
404
+
405
+ ### Other Configuration options
406
+
407
+ For a complete list of configuration options see the [configuration.rb](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb) file
408
+
409
+ ## Found a bug?
410
+
411
+ Oops! Just let us know by opening an Issue on Github.
412
+
413
+ ## Contributing
414
+
415
+ 1. Fork the repo, and install dependencies (`bundle install`)
416
+ 2. Create your feature branch and write your code (`git checkout -b my-new-feature`)
417
+ 3. Write some tests, and make them pass (`bundle exec rake`)
418
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
419
+ 5. Push to the branch (`git push origin my-new-feature`)
420
+ 6. Create a new Pull Request. Thank you! :sparkles:
421
+
422
+ ## Building
423
+
424
+ 1. Build the gem (`gem build raygun4ruby.gemspec`) - don't bother trying to build it on Windows,
425
+ the resulting Gem won't work.
426
+ 2. Install the gem (`gem install raygun4ruby-VERSION.gem`)