ratchetio 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -28,11 +28,21 @@ To confirm that it worked, run:
28
28
 
29
29
  This will raise an exception within a test request; if it works, you'll see a stacktrace in the console, and the exception will appear in the Ratchet.io dashboard.
30
30
 
31
+ ## Person tracking
32
+
33
+ Ratchet will send information about the current user (called a "person" in Ratchet parlance) along with each error report, when available. This works by trying the `current_user` and `current_member` controller methods. The return value should be an object with an `id` property and, optionally, `username` and `email` properties.
34
+
35
+ If you use different naming, add the following in your controller:
36
+
37
+ ```ruby
38
+ alias_method :my_user_method, :current_user
39
+ helper_method :my_user_method
40
+ ```
41
+
31
42
  ## Help / Support
32
43
 
33
44
  If you run into any issues, please email me at brian@ratchet.io
34
45
 
35
-
36
46
  ## Contributing
37
47
 
38
48
  1. Fork it
@@ -14,6 +14,22 @@ module Ratchetio
14
14
  }
15
15
  end
16
16
 
17
+ def ratchetio_person_data
18
+ user = begin current_user rescue current_member end
19
+ # include id, username, email if non-empty
20
+ user.attributes.select do |k, v|
21
+ if v.blank?
22
+ false
23
+ elsif ['id', 'username', 'email'].include? k
24
+ true
25
+ else
26
+ false
27
+ end
28
+ end.symbolize_keys
29
+ rescue NoMethodError, NameError
30
+ {}
31
+ end
32
+
17
33
  private
18
34
 
19
35
  def ratchetio_request_url
@@ -11,7 +11,8 @@ module Ratchetio
11
11
  begin
12
12
  controller = env['action_controller.instance']
13
13
  request_data = controller.try(:ratchetio_request_data)
14
- Ratchetio.report_request_exception(env, exception, request_data)
14
+ person_data = controller.try(:ratchetio_person_data)
15
+ Ratchetio.report_request_exception(env, exception, request_data, person_data)
15
16
  rescue Exception => exc
16
17
  # TODO use logger here?
17
18
  puts "[Ratchet.io] Exception while reporting exception to Ratchet.io: "
@@ -1,3 +1,3 @@
1
1
  module Ratchetio
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/ratchetio.rb CHANGED
@@ -19,7 +19,7 @@ module Ratchetio
19
19
  @configuration ||= Configuration.new
20
20
  end
21
21
 
22
- def report_request_exception(env, exception, request_data)
22
+ def report_request_exception(env, exception, request_data, person_data)
23
23
  data = base_data
24
24
 
25
25
  # parse backtrace
@@ -44,7 +44,8 @@ module Ratchetio
44
44
 
45
45
  data[:server] = server_data
46
46
  data[:request] = request_data
47
-
47
+ data[:person] = person_data
48
+
48
49
  payload = build_payload(data)
49
50
  send_payload(payload)
50
51
  end
@@ -116,10 +117,7 @@ module Ratchetio
116
117
  end
117
118
  data
118
119
  end
119
-
120
- def request_data
121
- {}
122
- end
120
+
123
121
  end
124
122
  end
125
123
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratchetio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-07 00:00:00.000000000 Z
12
+ date: 2012-09-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Rails plugin to catch and send exceptions to Ratchet.io
15
15
  email: