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 +4 -4
- data/lib/yeller/client.rb +5 -1
- data/lib/yeller/exception_formatter.rb +10 -3
- data/lib/yeller/rack.rb +14 -0
- data/lib/yeller/rails.rb +24 -2
- data/lib/yeller/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a4e42a04f98801a4d76e529ded4f2fdf1fd42c4
|
4
|
+
data.tar.gz: da8f88bd296bfee2917854fa7a780cc24b2a6b73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 736b2480db8a79173387ec92bf62394dc4aa01bdf8df0a42e739517abdf138dee1fab1d42ebddef8bad36a5781510e24718482a4ec807a5ff1a3d09c0bc70b6a
|
7
|
+
data.tar.gz: b0a53ce3f4ba1d43a30ab478e36e73d31a4e403bf179bd1ada92d1357903722a1d10d462fe7c01c31981e95533bcbdec6202bf45d479fc439f7ca511c34fc9ff
|
data/lib/yeller/client.rb
CHANGED
@@ -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,
|
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(
|
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
|
data/lib/yeller/rack.rb
CHANGED
@@ -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
|
data/lib/yeller/rails.rb
CHANGED
@@ -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
|
-
|
67
|
+
user = {"id" => id}
|
68
|
+
user.merge!(_yeller_extract_user_attributes(user))
|
69
|
+
{"user" => user}
|
48
70
|
end
|
49
71
|
end
|
50
72
|
|
data/lib/yeller/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|