bugsnag 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 1.5.3
5
+ -----
6
+ - Deal with self-referential meta data correctly.
7
+ - Dont load the environment when performing a deploy with capistrano.
8
+
4
9
  1.5.2
5
10
  -----
6
11
  - Dont send rack.request.form_vars as it is a copy of form_hash and it may contain sensitive params.
@@ -178,4 +183,4 @@ Changelog
178
183
 
179
184
  1.1.0
180
185
  -----
181
- - First public release
186
+ - First public release
data/README.md CHANGED
@@ -188,6 +188,17 @@ at_exit do
188
188
  end
189
189
  ```
190
190
 
191
+ Testing Integration
192
+ -------------------
193
+
194
+ To test that bugsnag is properly configured, you can use the test_exception rake task like this,
195
+
196
+ ```bash
197
+ rake bugsnag:test_exception
198
+ ```
199
+
200
+ A test exception will be sent to your bugsnag dashboard if everything is configured correctly.
201
+
191
202
  Configuration
192
203
  -------------
193
204
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.2
1
+ 1.5.3
data/bugsnag.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bugsnag}
8
- s.version = "1.5.2"
8
+ s.version = "1.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Smith"]
12
- s.date = %q{2013-09-16}
12
+ s.date = %q{2013-10-07}
13
13
  s.description = %q{Ruby notifier for bugsnag.com}
14
14
  s.email = %q{james@bugsnag.com}
15
15
  s.extra_rdoc_files = [
@@ -10,22 +10,32 @@ module Bugsnag
10
10
  module Helpers
11
11
  MAX_STRING_LENGTH = 4096
12
12
 
13
- def self.cleanup_obj(obj, filters = nil)
13
+ def self.cleanup_obj(obj, filters = nil, seen=Set.new)
14
14
  return nil unless obj
15
15
 
16
+ # Protect against recursion of recursable items
17
+ if obj.is_a?(Hash) || obj.is_a?(Array) || obj.is_a?(Set)
18
+ return "[RECURSION]" if seen.include? obj
19
+
20
+ # We duplicate the seen set here so that no updates by further cleanup_obj calls
21
+ # are persisted beyond that call.
22
+ seen = seen.dup
23
+ seen << obj
24
+ end
25
+
16
26
  if obj.is_a?(Hash)
17
27
  clean_hash = {}
18
28
  obj.each do |k,v|
19
29
  if filters && filters.any? {|f| k.to_s.include?(f.to_s)}
20
30
  clean_hash[k] = "[FILTERED]"
21
31
  else
22
- clean_obj = cleanup_obj(v, filters)
32
+ clean_obj = cleanup_obj(v, filters, seen)
23
33
  clean_hash[k] = clean_obj
24
34
  end
25
35
  end
26
36
  clean_hash
27
37
  elsif obj.is_a?(Array) || obj.is_a?(Set)
28
- obj.map { |el| cleanup_obj(el, filters) }.compact
38
+ obj.map { |el| cleanup_obj(el, filters, seen) }.compact
29
39
  elsif obj.is_a?(Integer) || obj.is_a?(Float) || obj.is_a?(String)
30
40
  obj
31
41
  else
@@ -86,4 +96,4 @@ module Bugsnag
86
96
  end
87
97
  end
88
98
  end
89
- end
99
+ end
@@ -1,36 +1,53 @@
1
1
  require "bugsnag"
2
2
  require "httparty"
3
3
  require "multi_json"
4
+ require "net/http"
5
+ require "uri"
4
6
 
5
7
  namespace :bugsnag do
6
8
  desc "Notify Bugsnag of a new deploy."
7
- task :deploy => :load do
8
- # Fetch and check the api key
9
- api_key = ENV["BUGSNAG_API_KEY"] || Bugsnag.configuration.api_key
10
- raise RuntimeError.new("No API key found when notifying deploy") if !api_key || api_key.empty?
11
-
12
- # Build the deploy payload
13
- payload = {
14
- :apiKey => api_key,
15
- :releaseStage => ENV["BUGSNAG_RELEASE_STAGE"] || Bugsnag.configuration.release_stage
16
- }
17
- payload[:appVersion] = ENV["BUGSNAG_APP_VERSION"] if ENV["BUGSNAG_APP_VERSION"]
18
- payload[:revision] = ENV["BUGSNAG_REVISION"] if ENV["BUGSNAG_REVISION"]
19
- payload[:repository] = ENV["BUGSNAG_REPOSITORY"] if ENV["BUGSNAG_REPOSITORY"]
20
- payload[:branch] = ENV["BUGSNAG_BRANCH"] if ENV["BUGSNAG_BRANCH"]
21
-
9
+ task :deploy do
22
10
  # Post the deploy notification
23
11
  begin
12
+ require 'bugsnag'
13
+
14
+ api_key = ENV["BUGSNAG_API_KEY"]
15
+ releaseStage = ENV["BUGSNAG_RELEASE_STAGE"] || "production"
16
+ appVersion = ENV["BUGSNAG_APP_VERSION"]
17
+ revision = ENV["BUGSNAG_REVISION"]
18
+ repository = ENV["BUGSNAG_REPOSITORY"]
19
+ branch = ENV["BUGSNAG_BRANCH"]
20
+
21
+ begin
22
+ require Rails.root.join('config/initializers/bugsnag')
23
+ rescue Exception => e
24
+ yml_filename = Rails.root.join("config/bugsnag.yml")
25
+ config = YAML.load_file(yml_filename) if File.exists?(yml_filename)
26
+ Bugsnag.configure(config[releaseStage] ? config[releaseStage] : config) if config
27
+ end
28
+
29
+ # Fetch and check the api key
30
+ api_key ||= Bugsnag.configuration.api_key
31
+ raise RuntimeError.new("No API key found when notifying deploy") if !api_key || api_key.empty?
32
+
24
33
  endpoint = (Bugsnag.configuration.use_ssl ? "https://" : "http://") \
25
- + (Bugsnag.configuration.endpoint || Bugsnag::Notification::DEFAULT_ENDPOINT) \
26
- + "/deploy"
34
+ + (Bugsnag.configuration.endpoint || Bugsnag::Notification::DEFAULT_ENDPOINT) \
35
+ + "/deploy"
36
+ uri = URI.parse(endpoint)
37
+
38
+ parameters = {
39
+ "apiKey" => api_key,
40
+ "releaseStage" => releaseStage,
41
+ "appVersion" => appVersion,
42
+ "revision" => revision,
43
+ "repository" => repository,
44
+ "branch" => branch
45
+ }
46
+
47
+ Net::HTTP.post_form(uri, parameters)
27
48
 
28
- HTTParty.post(endpoint, {
29
- :body => Bugsnag::Helpers.dump_json(payload),
30
- :headers => {"Content-Type" => "application/json"}
31
- })
32
49
  rescue Exception => e
33
- Bugsnag.log("Deploy notification failed, #{e.inspect}")
50
+ Bugsnag.warn("Deploy notification failed, #{e.inspect}")
34
51
  end
35
52
  end
36
53
 
data/spec/helper_spec.rb CHANGED
@@ -1,6 +1,32 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bugsnag::Helpers do
4
+ it "should be able to clean up recursive hashes" do
5
+ a = {:a => {}}
6
+ a[:a][:b] = a
7
+ Bugsnag::Helpers.cleanup_obj(a).should == {:a => {:b => "[RECURSION]"}}
8
+ end
9
+
10
+ it "should be able to clean up recursive arrays" do
11
+ a = []
12
+ a << a
13
+ a << "hello"
14
+ Bugsnag::Helpers.cleanup_obj(a).should == ["[RECURSION]", "hello"]
15
+ end
16
+
17
+ it "should allow multiple copies of the same string" do
18
+ a = {:name => "bugsnag"}
19
+ a[:second] = a[:name]
20
+ Bugsnag::Helpers.cleanup_obj(a).should == {:name => "bugsnag", :second => "bugsnag"}
21
+ end
22
+
23
+ it "should allow multiple copies of the same object" do
24
+ a = []
25
+ b = ["hello"]
26
+ a << b; a << b
27
+ Bugsnag::Helpers.cleanup_obj(a).should == [["hello"], ["hello"]]
28
+ end
29
+
4
30
  it "should reduce hash size correctly" do
5
31
  meta_data = {
6
32
  :key_one => "this should not be truncated",
@@ -61,4 +87,4 @@ describe Bugsnag::Helpers do
61
87
 
62
88
  url.should == "/dir/page?param1=[FILTERED]&param2=[FILTERED]&param3=value3"
63
89
  end
64
- end
90
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 5
8
- - 2
9
- version: 1.5.2
8
+ - 3
9
+ version: 1.5.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - James Smith
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2013-09-16 00:00:00 -07:00
17
+ date: 2013-10-07 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency