yeller_ruby 0.2.4 → 0.3.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: 19e06cab83f0c9c9e1291b6b0d1cc02c4a9ffba9
4
- data.tar.gz: efd7901015fbbce7dc32854a39d420e8b6d46e65
3
+ metadata.gz: 8a4e42a04f98801a4d76e529ded4f2fdf1fd42c4
4
+ data.tar.gz: da8f88bd296bfee2917854fa7a780cc24b2a6b73
5
5
  SHA512:
6
- metadata.gz: 65e84e7483e8262d47ca4211de7cfe5994fa89ed5ddba021d4e09e7c40faf72995a85fd51e0e6b341d8bb3c87ef48b07eede4b58aae7917b541a44d3e7ce359b
7
- data.tar.gz: 5a15a6d490cd32bbbb6529198dfeecbe6dc6bfdee0b50c20eeb9295fea746c226939231d0fe613fc1dc35284285ff94f6a66f3dbf12ac356d98b3d7f01f9431a
6
+ metadata.gz: 736b2480db8a79173387ec92bf62394dc4aa01bdf8df0a42e739517abdf138dee1fab1d42ebddef8bad36a5781510e24718482a4ec807a5ff1a3d09c0bc70b6a
7
+ data.tar.gz: b0a53ce3f4ba1d43a30ab478e36e73d31a4e403bf179bd1ada92d1357903722a1d10d462fe7c01c31981e95533bcbdec6202bf45d479fc439f7ca511c34fc9ff
@@ -11,6 +11,10 @@ module Yeller
11
11
  @error_handler = error_handler
12
12
  @skip_exceptions = skip_exceptions
13
13
  @reported_error = false
14
+ @headers = {
15
+ "Content-Type" => "application/json",
16
+ "User-Agent" => @startup_params.fetch(:"client-version")
17
+ }
14
18
  end
15
19
 
16
20
  def report(exception, options={})
@@ -22,7 +26,7 @@ module Yeller
22
26
  end
23
27
 
24
28
  def report_with_roundtrip(serialized, error_count)
25
- response = next_server.client.post("/#{@token}", serialized, {"Content-Type" => "application/json"})
29
+ response = next_server.client.post("/#{@token}", serialized, @headers)
26
30
  if response.code.to_i >= 200 && response.code.to_i <= 300
27
31
  Yeller::VerifyLog.reported_to_api!
28
32
  @reported_error ||= true
@@ -2,7 +2,6 @@ module Yeller
2
2
  class ExceptionFormatter
3
3
  BACKTRACE_FORMAT = %r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$}.freeze
4
4
 
5
-
6
5
  class IdentityBacktraceFilter
7
6
  def filter(trace)
8
7
  trace
@@ -15,15 +14,23 @@ module Yeller
15
14
 
16
15
  attr_reader :type, :options, :backtrace_filter
17
16
 
18
- def initialize(exception, backtrace_filter, options)
17
+ def initialize(e, backtrace_filter, options)
18
+ exception = unwrap_nested_exception(e)
19
19
  @type = exception.class.name
20
20
  @message = exception.message
21
21
  @backtrace = exception.backtrace
22
22
  @options = options
23
-
24
23
  @backtrace_filter = backtrace_filter
25
24
  end
26
25
 
26
+ def unwrap_nested_exception(e)
27
+ if e.respond_to?(:cause) && e.cause
28
+ e.cause
29
+ else
30
+ e
31
+ end
32
+ end
33
+
27
34
  def message
28
35
  # If a message is not given, rubby will set message to the class name
29
36
  @message == type ? nil : @message
@@ -44,7 +44,21 @@ module Yeller
44
44
  :custom_data => {
45
45
  :params => request.params,
46
46
  :session => env.fetch('rack.session', {}),
47
+ :"http-request" => Yeller::Rack.yeller_http_request_data(request),
47
48
  })
48
49
  end
50
+
51
+ def self.yeller_http_request_data(request)
52
+ out = {
53
+ :"request-method" => request.request_method,
54
+ }
55
+ if request.user_agent
56
+ out[:"user-agent"] = request.user_agent
57
+ end
58
+ if request.referer
59
+ out[:referrer] = request.referer
60
+ end
61
+ out
62
+ end
49
63
  end
50
64
  end
@@ -30,7 +30,8 @@ module Yeller
30
30
  def _yeller_custom_data
31
31
  out = {
32
32
  :params => params,
33
- :session => request.env.fetch('rack.session', {})
33
+ :session => request.env.fetch('rack.session', {}),
34
+ :"http-request" => Yeller::Rack.yeller_http_request_data(request),
34
35
  }
35
36
  out.merge!(yeller_user_data || {})
36
37
  if respond_to?(:yeller_custom_data)
@@ -39,12 +40,33 @@ module Yeller
39
40
  out
40
41
  end
41
42
 
43
+ YELLER_IGNORED_USER_ATTRIBUTES = [
44
+ 'password',
45
+ 'card',
46
+ 'secret',
47
+ ]
48
+
49
+ def _yeller_extract_user_attributes(current_user)
50
+ user = {}
51
+ if current_user.respond_to?(:attributes) && current_user.attributes.is_a?(Hash)
52
+ current_user.attributes.each do |k, v|
53
+ unless YELLER_IGNORED_USER_ATTRIBUTES.any? {|a| k.to_s.include?(a) }
54
+ user[k.to_s] = String(v)
55
+ end
56
+ end
57
+ else
58
+ {}
59
+ end
60
+ end
61
+
42
62
  def yeller_user_data
43
63
  return {} unless respond_to?(:current_user)
44
64
  return {} unless current_user.respond_to?(:id)
45
65
  id = current_user.id
46
66
  return {} unless id.is_a?(Integer)
47
- {"user" => {"id" => id}}
67
+ user = {"id" => id}
68
+ user.merge!(_yeller_extract_user_attributes(user))
69
+ {"user" => user}
48
70
  end
49
71
  end
50
72
 
@@ -1,3 +1,3 @@
1
1
  module Yeller
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeller_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Crayford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-14 00:00:00.000000000 Z
11
+ date: 2015-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler