raygun4ruby 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff2e858a57edda6f5d225855e17ab54988203d8c
4
- data.tar.gz: 30844792347a2415d14596d9c6a81fff79ea0b81
3
+ metadata.gz: 30c96f5c697418070d9887e7bd698f3d560c50ea
4
+ data.tar.gz: 3320b9b575ddbc04a06e61b26bb848b30d4e4c7e
5
5
  SHA512:
6
- metadata.gz: 4874e0568ff22d99fa5caf329b7edd5d222c5e1bfec57c89210055633e5fbe07024915e147c1e24501603f1d1b4d29e0698632f4909ddd6e6fb677e06710c85d
7
- data.tar.gz: f0006b1a6634515963ad336505f65741f13c4a078bd30849d5b101464395b5a1f55d653084e9441e85d2ef4deb0902d1331c26dc74bc4292e7134cbb7d30a3a4
6
+ metadata.gz: ef94e8d1e90c14929c84b5d13bfa3ecd868379c422113f94b0116f109273a5c2c97182001e2eb52bc9f4898233df4420d4ab28fa14cf77acfed34273fa5f01d6
7
+ data.tar.gz: ebf0bd808d57af7b29fac0326f8b79b380461bede714f9db014845b8dbf78933f354559a31d8158e6a18c831667689a0960180b3776e8232425ab7abedea071e
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## 2.3.0 (09/05/2017)
1
+ ## 2.4.0 (31/07/2017)
2
+
3
+ Features
4
+ - Add functionality to track affected user in Sidekiq jobs, refer to the README for more information, under the "Affected User Tracking in Sidekiq" heading ([#121](https://github.com/MindscapeHQ/raygun4ruby/pull/121))
5
+ ## 2.3.0 (09/05/2017)"
2
6
 
3
7
  Bugfixes
4
8
  - Fix issue preventing affected users for a crash report from showing up in the affected users page ([#119](https://github.com/MindscapeHQ/raygun4ruby/pull/119))
data/README.md CHANGED
@@ -352,6 +352,32 @@ Raygun4Ruby can track errors from Sidekiq (2.x or 3+). All you need to do is add
352
352
 
353
353
  Either in your Raygun initializer or wherever else takes your fancy :)
354
354
 
355
+ #### Affected User Tracking in Sidekiq
356
+
357
+ To track affected users, define a class method on your worker class that returns a user object.
358
+ 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`
359
+ If you have not changed these, refer to [Affected user tracking](#affected-user-tracking) for the defaults
360
+
361
+ ```ruby
362
+ class FailingWorker
363
+ include Sidekiq::Worker
364
+
365
+ def perform(arg1, arg2)
366
+ end
367
+
368
+ # Your method must accept an array of arguments
369
+ # These will be the same as those passed to `perform`
370
+ def self.current_user(args)
371
+ arg1 = args[0]
372
+ arg2 = args[1]
373
+
374
+ user = User.find_by(name: arg1)
375
+
376
+ # Your method must return a user object
377
+ user
378
+ end
379
+ ```
380
+
355
381
  ### Other Configuration options
356
382
 
357
383
  For a complete list of configuration options see the [configuration.rb](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb) file
@@ -19,12 +19,38 @@ module Raygun
19
19
 
20
20
  class SidekiqReporter
21
21
  def self.call(exception, context_hash)
22
- ::Raygun.track_exception(exception,
23
- custom_data: {
24
- sidekiq_context: context_hash
25
- }
22
+ user = affected_user(context_hash)
23
+ data = {
24
+ custom_data: {
25
+ sidekiq_context: context_hash
26
+ }
27
+ }
28
+ ::Raygun.track_exception(
29
+ exception,
30
+ data,
31
+ user
26
32
  )
27
33
  end
34
+
35
+ # Extracts affected user information out of a Sidekiq worker class
36
+ def self.affected_user(context_hash)
37
+ job = context_hash[:job]
38
+
39
+ return if job.nil? || job['class'].nil? || !Module.const_defined?(job['class'])
40
+
41
+ worker_class = Module.const_get(job['class'])
42
+ affected_user_method = Raygun.configuration.affected_user_method
43
+
44
+ return if worker_class.nil? || !worker_class.respond_to?(affected_user_method)
45
+
46
+ worker_class.send(affected_user_method, job['args'])
47
+ rescue => e
48
+ return unless Raygun.configuration.failsafe_logger
49
+
50
+ failsafe_log("Problem in sidekiq affected user tracking: #{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}")
51
+
52
+ nil
53
+ end
28
54
  end
29
55
  end
30
56
 
@@ -38,4 +64,4 @@ else
38
64
  Sidekiq.configure_server do |config|
39
65
  config.error_handlers << Raygun::SidekiqReporter
40
66
  end
41
- end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module Raygun
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raygun4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindscape
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-08 00:00:00.000000000 Z
12
+ date: 2017-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty