bugsnag 4.2.1 → 6.27.1
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 +5 -5
- data/.yardopts +12 -0
- data/CHANGELOG.md +814 -0
- data/README.md +21 -25
- data/VERSION +1 -1
- data/bugsnag.gemspec +19 -8
- data/lib/bugsnag/breadcrumb_type.rb +14 -0
- data/lib/bugsnag/breadcrumbs/breadcrumb.rb +109 -0
- data/lib/bugsnag/breadcrumbs/breadcrumbs.rb +13 -0
- data/lib/bugsnag/breadcrumbs/on_breadcrumb_callback_list.rb +48 -0
- data/lib/bugsnag/breadcrumbs/validator.rb +29 -0
- data/lib/bugsnag/cleaner.rb +170 -59
- data/lib/bugsnag/code_extractor.rb +137 -0
- data/lib/bugsnag/configuration.rb +670 -45
- data/lib/bugsnag/delivery/synchronous.rb +31 -14
- data/lib/bugsnag/delivery/thread_queue.rb +23 -6
- data/lib/bugsnag/delivery.rb +13 -0
- data/lib/bugsnag/endpoint_configuration.rb +11 -0
- data/lib/bugsnag/endpoint_validator.rb +80 -0
- data/lib/bugsnag/error.rb +25 -0
- data/lib/bugsnag/event.rb +5 -0
- data/lib/bugsnag/feature_flag.rb +74 -0
- data/lib/bugsnag/helpers.rb +121 -25
- data/lib/bugsnag/integrations/delayed_job.rb +51 -0
- data/lib/bugsnag/integrations/mailman.rb +43 -0
- data/lib/bugsnag/integrations/mongo.rb +133 -0
- data/lib/bugsnag/integrations/que.rb +53 -0
- data/lib/bugsnag/integrations/rack.rb +83 -0
- data/lib/bugsnag/integrations/rails/active_job.rb +100 -0
- data/lib/bugsnag/{rails → integrations/rails}/active_record_rescue.rb +10 -1
- data/lib/bugsnag/{rails → integrations/rails}/controller_methods.rb +1 -9
- data/lib/bugsnag/integrations/rails/rails_breadcrumbs.rb +115 -0
- data/lib/bugsnag/integrations/railtie.rb +153 -0
- data/lib/bugsnag/integrations/rake.rb +74 -0
- data/lib/bugsnag/integrations/resque.rb +94 -0
- data/lib/bugsnag/integrations/shoryuken.rb +50 -0
- data/lib/bugsnag/integrations/sidekiq.rb +68 -0
- data/lib/bugsnag/meta_data.rb +1 -0
- data/lib/bugsnag/middleware/active_job.rb +18 -0
- data/lib/bugsnag/middleware/breadcrumbs.rb +21 -0
- data/lib/bugsnag/middleware/callbacks.rb +6 -8
- data/lib/bugsnag/middleware/classify_error.rb +50 -0
- data/lib/bugsnag/middleware/clearance_user.rb +33 -0
- data/lib/bugsnag/middleware/delayed_job.rb +93 -0
- data/lib/bugsnag/middleware/discard_error_class.rb +30 -0
- data/lib/bugsnag/middleware/exception_meta_data.rb +42 -0
- data/lib/bugsnag/middleware/ignore_error_class.rb +26 -0
- data/lib/bugsnag/middleware/mailman.rb +6 -4
- data/lib/bugsnag/middleware/rack_request.rb +126 -30
- data/lib/bugsnag/middleware/rails3_request.rb +15 -17
- data/lib/bugsnag/middleware/rake.rb +7 -5
- data/lib/bugsnag/middleware/session_data.rb +25 -0
- data/lib/bugsnag/middleware/sidekiq.rb +9 -4
- data/lib/bugsnag/middleware/suggestion_data.rb +34 -0
- data/lib/bugsnag/middleware/warden_user.rb +11 -6
- data/lib/bugsnag/middleware_stack.rb +62 -9
- data/lib/bugsnag/on_error_callbacks.rb +33 -0
- data/lib/bugsnag/report.rb +516 -0
- data/lib/bugsnag/session_tracker.rb +182 -0
- data/lib/bugsnag/stacktrace.rb +82 -0
- data/lib/bugsnag/tasks/bugsnag.rake +2 -70
- data/lib/bugsnag/utility/circular_buffer.rb +62 -0
- data/lib/bugsnag/utility/duplicator.rb +124 -0
- data/lib/bugsnag/utility/feature_data_store.rb +41 -0
- data/lib/bugsnag/utility/feature_flag_delegate.rb +89 -0
- data/lib/bugsnag/utility/metadata_delegate.rb +102 -0
- data/lib/bugsnag.rb +528 -80
- metadata +61 -123
- data/.document +0 -5
- data/.gitignore +0 -52
- data/.rspec +0 -3
- data/.travis.yml +0 -14
- data/CONTRIBUTING.md +0 -47
- data/Gemfile +0 -2
- data/Rakefile +0 -29
- data/lib/bugsnag/capistrano.rb +0 -7
- data/lib/bugsnag/capistrano2.rb +0 -32
- data/lib/bugsnag/delay/resque.rb +0 -21
- data/lib/bugsnag/delayed_job.rb +0 -57
- data/lib/bugsnag/deploy.rb +0 -34
- data/lib/bugsnag/mailman.rb +0 -28
- data/lib/bugsnag/middleware/rails2_request.rb +0 -52
- data/lib/bugsnag/notification.rb +0 -459
- data/lib/bugsnag/rack.rb +0 -53
- data/lib/bugsnag/rails/action_controller_rescue.rb +0 -62
- data/lib/bugsnag/rails.rb +0 -66
- data/lib/bugsnag/railtie.rb +0 -80
- data/lib/bugsnag/rake.rb +0 -25
- data/lib/bugsnag/resque.rb +0 -40
- data/lib/bugsnag/sidekiq.rb +0 -42
- data/lib/bugsnag/tasks/bugsnag.cap +0 -48
- data/rails/init.rb +0 -7
- data/spec/cleaner_spec.rb +0 -138
- data/spec/code_spec.rb +0 -86
- data/spec/fixtures/crashes/end_of_file.rb +0 -9
- data/spec/fixtures/crashes/short_file.rb +0 -1
- data/spec/fixtures/crashes/start_of_file.rb +0 -9
- data/spec/fixtures/middleware/internal_info_setter.rb +0 -11
- data/spec/fixtures/middleware/public_info_setter.rb +0 -11
- data/spec/fixtures/tasks/Rakefile +0 -15
- data/spec/helper_spec.rb +0 -163
- data/spec/integration_spec.rb +0 -132
- data/spec/middleware_spec.rb +0 -181
- data/spec/notification_spec.rb +0 -877
- data/spec/rack_spec.rb +0 -56
- data/spec/spec_helper.rb +0 -53
data/lib/bugsnag/railtie.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# Rails 3.x hooks
|
2
|
-
|
3
|
-
require "rails"
|
4
|
-
require "bugsnag"
|
5
|
-
require "bugsnag/middleware/rails3_request"
|
6
|
-
require "bugsnag/middleware/rack_request"
|
7
|
-
|
8
|
-
module Bugsnag
|
9
|
-
class Railtie < Rails::Railtie
|
10
|
-
cattr_accessor :running_as_dependency
|
11
|
-
|
12
|
-
rake_tasks do
|
13
|
-
require "bugsnag/rake"
|
14
|
-
load "bugsnag/tasks/bugsnag.rake"
|
15
|
-
end
|
16
|
-
|
17
|
-
# send notifications if a command fails in a 'rails runner' call
|
18
|
-
if self.respond_to? :runner
|
19
|
-
runner do
|
20
|
-
at_exit do
|
21
|
-
if $!
|
22
|
-
Bugsnag.auto_notify($!)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
config.before_initialize do
|
29
|
-
# Configure bugsnag rails defaults
|
30
|
-
Bugsnag.configure do |config|
|
31
|
-
config.logger = ::Rails.logger
|
32
|
-
config.release_stage = ::Rails.env.to_s
|
33
|
-
config.project_root = ::Rails.root.to_s
|
34
|
-
config.middleware.insert_before Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::Rails3Request
|
35
|
-
end
|
36
|
-
|
37
|
-
# Auto-load configuration settings from config/bugsnag.yml if it exists
|
38
|
-
config_file = ::Rails.root.join("config", "bugsnag.yml")
|
39
|
-
config = YAML.load_file(config_file) if File.exists?(config_file)
|
40
|
-
Bugsnag.configure(config[::Rails.env] ? config[::Rails.env] : config) if config
|
41
|
-
|
42
|
-
if defined?(::ActionController::Base)
|
43
|
-
require "bugsnag/rails/controller_methods"
|
44
|
-
::ActionController::Base.send(:include, Bugsnag::Rails::ControllerMethods)
|
45
|
-
end
|
46
|
-
if defined?(ActionController::API)
|
47
|
-
ActionController::API.send(:include, Bugsnag::Rails::ControllerMethods)
|
48
|
-
end
|
49
|
-
if defined?(ActiveRecord::Base)
|
50
|
-
require "bugsnag/rails/active_record_rescue"
|
51
|
-
ActiveRecord::Base.send(:include, Bugsnag::Rails::ActiveRecordRescue)
|
52
|
-
end
|
53
|
-
|
54
|
-
Bugsnag.configuration.app_type = "rails" unless Bugsnag::Railtie.running_as_dependency
|
55
|
-
end
|
56
|
-
|
57
|
-
# Configure params_filters after initialization, so that rails initializers
|
58
|
-
# may set filter_parameters which will be picked up by Bugsnag.
|
59
|
-
config.after_initialize do
|
60
|
-
Bugsnag.configure do |config|
|
61
|
-
config.params_filters += ::Rails.configuration.filter_parameters.map do |filter|
|
62
|
-
case filter
|
63
|
-
when String, Symbol
|
64
|
-
/\A#{filter}\z/
|
65
|
-
else
|
66
|
-
filter
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
initializer "bugsnag.use_rack_middleware" do |app|
|
73
|
-
begin
|
74
|
-
app.config.middleware.insert_after ActionDispatch::DebugExceptions, Bugsnag::Rack
|
75
|
-
rescue
|
76
|
-
app.config.middleware.use Bugsnag::Rack
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
data/lib/bugsnag/rake.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'bugsnag'
|
2
|
-
|
3
|
-
Rake::TaskManager.record_task_metadata = true
|
4
|
-
|
5
|
-
class Rake::Task
|
6
|
-
|
7
|
-
def execute_with_bugsnag(args=nil)
|
8
|
-
Bugsnag.configuration.app_type = "rake"
|
9
|
-
old_task = Bugsnag.configuration.request_data[:bugsnag_running_task]
|
10
|
-
Bugsnag.set_request_data :bugsnag_running_task, self
|
11
|
-
|
12
|
-
execute_without_bugsnag(args)
|
13
|
-
|
14
|
-
rescue Exception => ex
|
15
|
-
Bugsnag.auto_notify(ex)
|
16
|
-
raise
|
17
|
-
ensure
|
18
|
-
Bugsnag.set_request_data :bugsnag_running_task, old_task
|
19
|
-
end
|
20
|
-
|
21
|
-
alias_method :execute_without_bugsnag, :execute
|
22
|
-
alias_method :execute, :execute_with_bugsnag
|
23
|
-
end
|
24
|
-
|
25
|
-
Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::Rake)
|
data/lib/bugsnag/resque.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require "resque"
|
2
|
-
require "resque/failure/multiple"
|
3
|
-
|
4
|
-
module Bugsnag
|
5
|
-
class Resque < ::Resque::Failure::Base
|
6
|
-
def self.configure(&block)
|
7
|
-
add_failure_backend
|
8
|
-
Bugsnag.configure(&block)
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.add_failure_backend
|
12
|
-
return if ::Resque::Failure.backend == self
|
13
|
-
|
14
|
-
# Ensure resque is using a "Multiple" failure backend
|
15
|
-
unless ::Resque::Failure.backend < ::Resque::Failure::Multiple
|
16
|
-
original_backend = ::Resque::Failure.backend
|
17
|
-
::Resque::Failure.backend = ::Resque::Failure::Multiple
|
18
|
-
::Resque::Failure.backend.classes ||= []
|
19
|
-
::Resque::Failure.backend.classes << original_backend
|
20
|
-
end
|
21
|
-
|
22
|
-
# Add Bugsnag failure backend
|
23
|
-
unless ::Resque::Failure.backend.classes.include?(self)
|
24
|
-
::Resque::Failure.backend.classes << self
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def save
|
29
|
-
Bugsnag.auto_notify(exception, {:context => "#{payload['class']}@#{queue}", :payload => payload, :delivery_method => :synchronous})
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# For backwards compatibility
|
35
|
-
Resque::Failure::Bugsnag = Bugsnag::Resque
|
36
|
-
|
37
|
-
# Auto-load the failure backend
|
38
|
-
Bugsnag::Resque.add_failure_backend
|
39
|
-
|
40
|
-
Bugsnag.configuration.app_type = "resque"
|
data/lib/bugsnag/sidekiq.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'sidekiq'
|
2
|
-
|
3
|
-
module Bugsnag
|
4
|
-
class Sidekiq
|
5
|
-
def call(worker, msg, queue)
|
6
|
-
begin
|
7
|
-
|
8
|
-
# store msg/queue in thread local state to be read by Bugsnag::Middleware::Sidekiq
|
9
|
-
Bugsnag.set_request_data :sidekiq, { :msg => msg, :queue => queue }
|
10
|
-
|
11
|
-
yield
|
12
|
-
rescue Exception => ex
|
13
|
-
raise ex if [Interrupt, SystemExit, SignalException].include? ex.class
|
14
|
-
Bugsnag.auto_notify(ex)
|
15
|
-
raise
|
16
|
-
ensure
|
17
|
-
Bugsnag.clear_request_data
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
if ::Sidekiq::VERSION < '3'
|
24
|
-
::Sidekiq.configure_server do |config|
|
25
|
-
config.server_middleware do |chain|
|
26
|
-
chain.add ::Bugsnag::Sidekiq
|
27
|
-
end
|
28
|
-
end
|
29
|
-
else
|
30
|
-
::Sidekiq.configure_server do |config|
|
31
|
-
config.error_handlers << lambda do |ex, ctx|
|
32
|
-
Bugsnag.auto_notify(ex, :sidekiq => ctx, :context => "#{ctx['class']}@#{ctx['queue']}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::Sidekiq)
|
38
|
-
Bugsnag.configuration.app_type = "sidekiq"
|
39
|
-
|
40
|
-
if defined?(::Sidekiq::CLI) && defined?(Bugsnag::Railtie)
|
41
|
-
Bugsnag::Railtie.running_as_dependency = true
|
42
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
namespace :load do
|
2
|
-
|
3
|
-
task :defaults do
|
4
|
-
|
5
|
-
set :bugsnag_default_hooks, ->{ true }
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
namespace :deploy do
|
12
|
-
|
13
|
-
before :starting, :bugsnag_hooks do
|
14
|
-
invoke 'bugsnag:add_default_hooks' if fetch(:bugsnag_default_hooks)
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
namespace :bugsnag do
|
20
|
-
|
21
|
-
task :add_default_hooks do
|
22
|
-
after 'deploy:published', 'bugsnag:deploy'
|
23
|
-
end
|
24
|
-
|
25
|
-
desc 'Notify Bugsnag that new production code has been deployed'
|
26
|
-
task :deploy do
|
27
|
-
run_locally do
|
28
|
-
begin
|
29
|
-
Bugsnag::Deploy.notify({
|
30
|
-
:api_key => fetch(:bugsnag_api_key, ENV["BUGSNAG_API_KEY"]),
|
31
|
-
:release_stage => fetch(:bugsnag_env) || fetch(:rails_env) || fetch(:stage) || ENV["BUGSNAG_RELEASE_STAGE"] || "production",
|
32
|
-
:revision => fetch(:current_revision, ENV["BUGSNAG_REVISION"]),
|
33
|
-
:repository => fetch(:repo_url, ENV["BUGSNAG_REPOSITORY"]),
|
34
|
-
:branch => fetch(:branch, ENV["BUGSNAG_BRANCH"]),
|
35
|
-
:app_version => fetch(:app_version, ENV["BUGSNAG_APP_VERSION"]),
|
36
|
-
:endpoint => fetch(:bugsnag_endpoint, Bugsnag::Configuration::DEFAULT_ENDPOINT),
|
37
|
-
:use_ssl => fetch(:bugsnag_use_ssl, true)
|
38
|
-
})
|
39
|
-
rescue
|
40
|
-
error "Bugsnag deploy notification failed, #{$!.inspect}"
|
41
|
-
end
|
42
|
-
|
43
|
-
info 'Bugsnag deploy notification complete.'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
# vi:ft=ruby
|
data/rails/init.rb
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# On Rails 2.x GEM_ROOT/rails/init.rb is auto loaded for all gems
|
2
|
-
# so this is the place to initialize Rails 2.x plugin support
|
3
|
-
if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("3.0")
|
4
|
-
require "bugsnag/rails"
|
5
|
-
else
|
6
|
-
Bugsnag.warn "Blocked attempt to initialize legacy Rails 2.x extensions"
|
7
|
-
end
|
data/spec/cleaner_spec.rb
DELETED
@@ -1,138 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Bugsnag::Cleaner do
|
6
|
-
subject { described_class.new(nil) }
|
7
|
-
|
8
|
-
describe "#clean_object" do
|
9
|
-
it "cleans up recursive hashes" do
|
10
|
-
a = {:a => {}}
|
11
|
-
a[:a][:b] = a
|
12
|
-
expect(subject.clean_object(a)).to eq({:a => {:b => "[RECURSION]"}})
|
13
|
-
end
|
14
|
-
|
15
|
-
it "cleans up recursive arrays" do
|
16
|
-
a = []
|
17
|
-
a << a
|
18
|
-
a << "hello"
|
19
|
-
expect(subject.clean_object(a)).to eq(["[RECURSION]", "hello"])
|
20
|
-
end
|
21
|
-
|
22
|
-
it "allows multiple copies of the same string" do
|
23
|
-
a = {:name => "bugsnag"}
|
24
|
-
a[:second] = a[:name]
|
25
|
-
expect(subject.clean_object(a)).to eq({:name => "bugsnag", :second => "bugsnag"})
|
26
|
-
end
|
27
|
-
|
28
|
-
it "allows multiple copies of the same object" do
|
29
|
-
a = []
|
30
|
-
b = ["hello"]
|
31
|
-
a << b; a << b
|
32
|
-
expect(subject.clean_object(a)).to eq([["hello"], ["hello"]])
|
33
|
-
end
|
34
|
-
|
35
|
-
it "cleans up UTF8 strings properly" do
|
36
|
-
obj = "André"
|
37
|
-
expect(subject.clean_object(obj)).to eq("André")
|
38
|
-
end
|
39
|
-
|
40
|
-
it "cleans up binary strings properly" do
|
41
|
-
if RUBY_VERSION > "1.9"
|
42
|
-
obj = "Andr\xc7\xff"
|
43
|
-
if obj.respond_to? :force_encoding
|
44
|
-
obj = obj.force_encoding('BINARY')
|
45
|
-
end
|
46
|
-
expect(subject.clean_object(obj)).to eq("Andr��")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it "cleans up strings returned from #to_s properly" do
|
51
|
-
if RUBY_VERSION > "1.9"
|
52
|
-
str = "Andr\xc7\xff"
|
53
|
-
if str.respond_to? :force_encoding
|
54
|
-
str = str.force_encoding('BINARY')
|
55
|
-
end
|
56
|
-
obj = RuntimeError.new(str)
|
57
|
-
expect(subject.clean_object(obj)).to eq("Andr��")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it "filters by string inclusion" do
|
62
|
-
expect(described_class.new(['f']).clean_object({ :foo => 'bar' })).to eq({ :foo => '[FILTERED]' })
|
63
|
-
expect(described_class.new(['b']).clean_object({ :foo => 'bar' })).to eq({ :foo => 'bar' })
|
64
|
-
end
|
65
|
-
|
66
|
-
it "filters by regular expression" do
|
67
|
-
expect(described_class.new([/fb?/]).clean_object({ :foo => 'bar' })).to eq({ :foo => '[FILTERED]' })
|
68
|
-
expect(described_class.new([/fb+/]).clean_object({ :foo => 'bar' })).to eq({ :foo => 'bar' })
|
69
|
-
end
|
70
|
-
|
71
|
-
it "filters deeply nested keys" do
|
72
|
-
params = {:foo => {:bar => "baz"}}
|
73
|
-
expect(described_class.new([/^foo\.bar/]).clean_object(params)).to eq({:foo => {:bar => '[FILTERED]'}})
|
74
|
-
end
|
75
|
-
|
76
|
-
it "filters deeply nested request parameters" do
|
77
|
-
params = {:request => {:params => {:foo => {:bar => "baz"}}}}
|
78
|
-
expect(described_class.new([/^foo\.bar/]).clean_object(params)).to eq({:request => {:params => {:foo => {:bar => '[FILTERED]'}}}})
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "#clean_url" do
|
83
|
-
let(:filters) { [] }
|
84
|
-
subject { described_class.new(filters).clean_url(url) }
|
85
|
-
|
86
|
-
context "with no filters configured" do
|
87
|
-
let(:url) { "/dir/page?param1=value1¶m2=value2" }
|
88
|
-
it { should eq "/dir/page?param1=value1¶m2=value2" }
|
89
|
-
end
|
90
|
-
|
91
|
-
context "with no get params" do
|
92
|
-
let(:url) { "/dir/page" }
|
93
|
-
it { should eq "/dir/page" }
|
94
|
-
end
|
95
|
-
|
96
|
-
context "with no matching parameters" do
|
97
|
-
let(:filters) { ["param3"] }
|
98
|
-
let(:url) { "/dir/page?param1=value1¶m2=value2" }
|
99
|
-
it { should eq "/dir/page?param1=value1¶m2=value2" }
|
100
|
-
end
|
101
|
-
|
102
|
-
context "with a single matching parameter" do
|
103
|
-
let(:filters) { ["param1"] }
|
104
|
-
let(:url) { "/dir/page?param1=value1¶m2=value2" }
|
105
|
-
it { should eq "/dir/page?param1=[FILTERED]¶m2=value2" }
|
106
|
-
end
|
107
|
-
|
108
|
-
context "with partially matching parameters" do
|
109
|
-
let(:filters) { ["param"] }
|
110
|
-
let(:url) { "/dir/page?param1=value1¶m2=value2&bla=yes" }
|
111
|
-
it { should eq "/dir/page?param1=[FILTERED]¶m2=[FILTERED]&bla=yes" }
|
112
|
-
end
|
113
|
-
|
114
|
-
context "with multiple matching filters" do
|
115
|
-
let(:filters) { ["param1", "param2"] }
|
116
|
-
let(:url) { "/dir/page?param1=value1¶m2=value2¶m3=value3" }
|
117
|
-
it { should eq "/dir/page?param1=[FILTERED]¶m2=[FILTERED]¶m3=value3" }
|
118
|
-
end
|
119
|
-
|
120
|
-
context "with both string and regexp filters" do
|
121
|
-
let(:filters) { ["param1", /param2/] }
|
122
|
-
let(:url) { "/dir/page?param1=value1¶m2=value2¶m3=value3" }
|
123
|
-
it { should eq "/dir/page?param1=[FILTERED]¶m2=[FILTERED]¶m3=value3" }
|
124
|
-
end
|
125
|
-
|
126
|
-
context "with matching regexp filters" do
|
127
|
-
let(:filters) { [/\Aaccess_token\z/] }
|
128
|
-
let(:url) { "https://host.example/sessions?access_token=abc123" }
|
129
|
-
it { should eq "https://host.example/sessions?access_token=[FILTERED]" }
|
130
|
-
end
|
131
|
-
|
132
|
-
context "with partially-matching regexp filters" do
|
133
|
-
let(:filters) { [/token/] }
|
134
|
-
let(:url) { "https://host.example/sessions?access_token=abc123" }
|
135
|
-
it { should eq "https://host.example/sessions?access_token=[FILTERED]" }
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
data/spec/code_spec.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bugsnag::Notification do
|
4
|
-
it "includes code in the stack trace" do
|
5
|
-
_a = 1
|
6
|
-
_b = 2
|
7
|
-
_c = 3
|
8
|
-
notify_test_exception
|
9
|
-
_d = 4
|
10
|
-
_e = 5
|
11
|
-
_f = 6
|
12
|
-
|
13
|
-
expect(Bugsnag).to have_sent_notification{ |payload|
|
14
|
-
exception = get_exception_from_payload(payload)
|
15
|
-
starting_line = __LINE__ - 10
|
16
|
-
expect(exception["stacktrace"][1]["code"]).to eq({
|
17
|
-
(starting_line + 0).to_s => " _a = 1",
|
18
|
-
(starting_line + 1).to_s => " _b = 2",
|
19
|
-
(starting_line + 2).to_s => " _c = 3",
|
20
|
-
(starting_line + 3).to_s => " notify_test_exception",
|
21
|
-
(starting_line + 4).to_s => " _d = 4",
|
22
|
-
(starting_line + 5).to_s => " _e = 5",
|
23
|
-
(starting_line + 6).to_s => " _f = 6"
|
24
|
-
})
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
it "allows you to disable sending code" do
|
29
|
-
Bugsnag.configuration.send_code = false
|
30
|
-
|
31
|
-
notify_test_exception
|
32
|
-
|
33
|
-
expect(Bugsnag).to have_sent_notification{ |payload|
|
34
|
-
exception = get_exception_from_payload(payload)
|
35
|
-
expect(exception["stacktrace"][1]["code"]).to eq(nil)
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should send the first 7 lines of the file for exceptions near the top' do
|
40
|
-
load 'spec/fixtures/crashes/start_of_file.rb' rescue Bugsnag.notify $!
|
41
|
-
|
42
|
-
expect(Bugsnag).to have_sent_notification{ |payload|
|
43
|
-
exception = get_exception_from_payload(payload)
|
44
|
-
|
45
|
-
expect(exception["stacktrace"][0]["code"]).to eq({
|
46
|
-
"1" => "#",
|
47
|
-
"2" => "raise 'hell'",
|
48
|
-
"3" => "#",
|
49
|
-
"4" => "#",
|
50
|
-
"5" => "#",
|
51
|
-
"6" => "#",
|
52
|
-
"7" => "#"
|
53
|
-
})
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should send the last 7 lines of the file for exceptions near the bottom' do
|
58
|
-
load 'spec/fixtures/crashes/end_of_file.rb' rescue Bugsnag.notify $!
|
59
|
-
|
60
|
-
expect(Bugsnag).to have_sent_notification{ |payload|
|
61
|
-
exception = get_exception_from_payload(payload)
|
62
|
-
|
63
|
-
expect(exception["stacktrace"][0]["code"]).to eq({
|
64
|
-
"3" => "#",
|
65
|
-
"4" => "#",
|
66
|
-
"5" => "#",
|
67
|
-
"6" => "#",
|
68
|
-
"7" => "#",
|
69
|
-
"8" => "raise 'hell'",
|
70
|
-
"9" => "#"
|
71
|
-
})
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should send the last 7 lines of the file for exceptions near the bottom' do
|
76
|
-
load 'spec/fixtures/crashes/short_file.rb' rescue Bugsnag.notify $!
|
77
|
-
|
78
|
-
expect(Bugsnag).to have_sent_notification{ |payload|
|
79
|
-
exception = get_exception_from_payload(payload)
|
80
|
-
|
81
|
-
expect(exception["stacktrace"][0]["code"]).to eq({
|
82
|
-
"1" => "raise 'hell'"
|
83
|
-
})
|
84
|
-
}
|
85
|
-
end
|
86
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
raise 'hell'
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "bugsnag/rake"
|
2
|
-
|
3
|
-
namespace :test do
|
4
|
-
desc "used by integration_spec to test that Bugsnag::Middleware::Rake runs properly"
|
5
|
-
task :crash do
|
6
|
-
port = ENV['BUGSNAG_TEST_SERVER_PORT']
|
7
|
-
Bugsnag.configure do |config|
|
8
|
-
config.endpoint = "localhost:#{port}"
|
9
|
-
config.api_key = "0" * 32
|
10
|
-
config.use_ssl = false
|
11
|
-
end
|
12
|
-
|
13
|
-
raise
|
14
|
-
end
|
15
|
-
end
|