raygun4ruby 3.2.5.pre → 4.0.0.pre

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