bugloco 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fef7785321fdce820ab8e7fbc512b25f7cfc170
4
- data.tar.gz: 569b05df812831ee54b908174052193ee7b68074
3
+ metadata.gz: 620a8abfc5db039673d1e1d2f839613e6f89c7a7
4
+ data.tar.gz: 542dea7518cba073ff850e239b79f46e7816a95c
5
5
  SHA512:
6
- metadata.gz: f2f44a7e327d5485e73d65941e22da138d0488b11131b1b7cd51e7376639687f8dd71c840c22578903219b716bf1f6dccf8d453c6f97567764cf742d5c3c0b2e
7
- data.tar.gz: 35d6cf0754ec224d11a0820fca5a976db4cc2f46d12d07a0dcf95a0d31f4d462f3d2262abb9e171839521cbf64cf4b5dafda34af8c72914c3d706d72ae47f8d3
6
+ metadata.gz: 7209e52c1deb733a06f1d9ae64980cb7a13875211e2c87bab4f41391b8971e367519dc466d0fd9edd8b7785ff3d44abb7e4e2cdbe0da4d856ca60699d5e33fb6
7
+ data.tar.gz: 1c9270bb5e710aa891c05b2ccbd0382155523d31d71d4a17d033b9a4e3cb764de550f90aab6f8c06e1a40a06adccbbd5d9720d95c9996f3bc59dbb10328e241c
@@ -20,16 +20,20 @@ module Bugloco
20
20
  Errno::ECONNREFUSED,
21
21
  OpenSSL::SSL::SSLError].freeze
22
22
 
23
- def report_notice(exception, options = {})
24
- # TODO: We need to inform the user if api_key/project_id were not given
25
- encoded_notice = Bugloco::Notice.new(exception, options).to_pb
26
- encoded_response = send_notice(encoded_notice, options)
23
+ def report_notice_or_ignore(exception, options = {})
24
+ notice = Bugloco::Notice.new(exception, options)
25
+ report_notice(notice) unless notice.ignore?
26
+ end
27
+
28
+ def report_notice(notice)
29
+ encoded_notice = notice.to_pb
30
+ encoded_response = send_notice(encoded_notice)
27
31
 
28
32
  if encoded_response
29
33
  response = Bugloco::Proto::Response.new.
30
34
  parse_from_string(encoded_response)
31
35
 
32
- response.notice_id if response.status == Bugloco::Proto::Status::SUCCESS
36
+ response
33
37
  else
34
38
  nil
35
39
  end
@@ -43,12 +47,10 @@ module Bugloco
43
47
 
44
48
  private
45
49
 
46
- def send_notice(encoded_notice, options = {})
50
+ def send_notice(encoded_notice)
47
51
  response = http_connection.post(api_url.path, encoded_notice, headers)
48
52
  response.body
49
53
  rescue *HTTP_ERRORS => e
50
- # log e
51
-
52
54
  nil
53
55
  end
54
56
 
@@ -6,7 +6,7 @@ module Bugloco
6
6
  def initialize(hash = {})
7
7
  super
8
8
 
9
- self.api_url = "https://bugloco.com/api/v1/notices"
9
+ self.api_url = "https://bugloco.com/api/v1/notices.pb"
10
10
  end
11
11
 
12
12
  def configured?
@@ -7,6 +7,16 @@ module Bugloco
7
7
 
8
8
  EXCEPTION_REGEX = /^(?<path>[^:]*):(?<line_number>[0-9]*):in `(?<function_name>[^']*)'$/
9
9
 
10
+ IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
11
+ 'ActionController::RoutingError',
12
+ 'ActionController::InvalidAuthenticityToken',
13
+ 'CGI::Session::CookieStore::TamperedWithCookie',
14
+ 'ActionController::UnknownHttpMethod',
15
+ 'ActionController::UnknownAction',
16
+ 'AbstractController::ActionNotFound',
17
+ 'Mongoid::Errors::DocumentNotFound',
18
+ 'ActionController::UnknownFormat']
19
+
10
20
  def initialize(exception, options = {})
11
21
  @exception = exception
12
22
  @options = options
@@ -18,6 +28,10 @@ module Bugloco
18
28
  @pb ||= proto_message.serialize_to_string
19
29
  end
20
30
 
31
+ def ignore?
32
+ IGNORE_DEFAULT.include?(@exception.class.to_s)
33
+ end
34
+
21
35
  def proto_message
22
36
  return @proto_message unless @proto_message.nil?
23
37
 
@@ -9,14 +9,29 @@ module Bugloco
9
9
  response = @app.call(env)
10
10
 
11
11
  if framework_exception = env["action_dispatch.exception"]
12
- env["bugloco.error_id"] = Bugloco.report_notice(framework_exception, rack_env: env)
12
+ env["bugloco.error_id"] = report_exception_or_ignore(framework_exception, env)
13
13
  end
14
14
 
15
15
  response
16
16
  rescue Exception => exception
17
- env["bugloco.error_id"] = Bugloco.report_notice(exception, rack_env: env)
17
+ env["bugloco.error_id"] = report_exception_or_ignore(exception, env)
18
+
18
19
  raise exception
19
20
  end
21
+
22
+ private
23
+
24
+ def report_exception_or_ignore(exception, env)
25
+ response = Bugloco.report_notice_or_ignore(exception, rack_env: env)
26
+
27
+ if response
28
+ if response.status == Bugloco::Proto::Status::SUCCESS
29
+ response.notice_id
30
+ else
31
+ # Report the issue
32
+ end
33
+ end
34
+ end
20
35
  end
21
36
  end
22
37
  end
@@ -1,3 +1,3 @@
1
1
  module Bugloco
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -43,15 +43,20 @@ describe Bugloco::Notice do
43
43
  }
44
44
 
45
45
  @rack_env_extra = {}
46
-
47
-
48
-
49
46
  end
50
47
 
51
48
  after do
52
49
  @extra_env.each {|k, _| ENV[k] = nil}
53
50
  end
54
51
 
52
+ it "should ignore ActiveRecord::RecordNotFound" do
53
+ module ::ActiveRecord; class RecordNotFound < Exception; end; end
54
+ exception = ::ActiveRecord::RecordNotFound.new
55
+
56
+ notice = Bugloco::Notice.new(exception)
57
+ expect(notice.ignore?).to be_truthy
58
+ end
59
+
55
60
  it "should include the company" do
56
61
  @api_key = "secret_key"
57
62
  Bugloco.config do |config|
@@ -14,7 +14,7 @@ describe Bugloco do
14
14
  end
15
15
 
16
16
  it "should include the API url" do
17
- expect(Bugloco.config.api_url).to eq("https://bugloco.com/api/v1/notices")
17
+ expect(Bugloco.config.api_url).to eq("https://bugloco.com/api/v1/notices.pb")
18
18
  end
19
19
  end
20
20
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugloco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wael M. Nasreddine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-12 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler