rollbar 2.18.2 → 2.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -0
  3. data/.travis.yml +155 -93
  4. data/Gemfile +19 -13
  5. data/README.md +12 -0
  6. data/gemfiles/rails30.gemfile +17 -10
  7. data/gemfiles/rails31.gemfile +20 -12
  8. data/gemfiles/rails32.gemfile +16 -7
  9. data/gemfiles/rails40.gemfile +16 -5
  10. data/gemfiles/rails41.gemfile +15 -5
  11. data/gemfiles/rails42.gemfile +25 -14
  12. data/gemfiles/rails50.gemfile +15 -8
  13. data/gemfiles/rails51.gemfile +15 -8
  14. data/gemfiles/rails52.gemfile +62 -0
  15. data/gemfiles/ruby_1_8_and_1_9_2.gemfile +2 -2
  16. data/lib/rails/rollbar_runner.rb +16 -1
  17. data/lib/rollbar/capistrano.rb +71 -39
  18. data/lib/rollbar/capistrano3.rb +53 -1
  19. data/lib/rollbar/capistrano_tasks.rb +131 -0
  20. data/lib/rollbar/configuration.rb +13 -4
  21. data/lib/rollbar/delay/active_job.rb +17 -0
  22. data/lib/rollbar/delay/sidekiq.rb +3 -1
  23. data/lib/rollbar/delay/thread.rb +1 -1
  24. data/lib/rollbar/deploy.rb +69 -0
  25. data/lib/rollbar/item.rb +17 -6
  26. data/lib/rollbar/middleware/js.rb +25 -3
  27. data/lib/rollbar/middleware/js/json_value.rb +26 -0
  28. data/lib/rollbar/notifier.rb +32 -13
  29. data/lib/rollbar/plugins/active_job.rb +3 -0
  30. data/lib/rollbar/plugins/rails/controller_methods.rb +2 -1
  31. data/lib/rollbar/plugins/rails/railtie_mixin.rb +7 -1
  32. data/lib/rollbar/rake_tasks.rb +126 -67
  33. data/lib/rollbar/scrubbers/params.rb +6 -0
  34. data/lib/rollbar/util.rb +75 -45
  35. data/lib/rollbar/util/hash.rb +15 -6
  36. data/lib/rollbar/version.rb +1 -1
  37. data/rollbar.gemspec +2 -3
  38. metadata +9 -261
  39. data/lib/rollbar/tasks/rollbar.cap +0 -47
  40. data/spec/cacert.pem +0 -3988
  41. data/spec/controllers/home_controller_spec.rb +0 -480
  42. data/spec/delay/sidekiq_spec.rb +0 -61
  43. data/spec/delay/sucker_punch_spec.rb +0 -25
  44. data/spec/delayed/backend/test.rb +0 -140
  45. data/spec/delayed/serialization/test.rb +0 -0
  46. data/spec/dummyapp/.gitignore +0 -73
  47. data/spec/dummyapp/Rakefile +0 -7
  48. data/spec/dummyapp/app/assets/javascripts/application.js +0 -3
  49. data/spec/dummyapp/app/assets/stylesheets/application.css.scss +0 -37
  50. data/spec/dummyapp/app/controllers/application_controller.rb +0 -3
  51. data/spec/dummyapp/app/controllers/home_controller.rb +0 -60
  52. data/spec/dummyapp/app/controllers/users_controller.rb +0 -17
  53. data/spec/dummyapp/app/helpers/.gitkeep +0 -0
  54. data/spec/dummyapp/app/mailers/.gitkeep +0 -0
  55. data/spec/dummyapp/app/models/.gitkeep +0 -0
  56. data/spec/dummyapp/app/models/book.rb +0 -5
  57. data/spec/dummyapp/app/models/post.rb +0 -9
  58. data/spec/dummyapp/app/models/user.rb +0 -9
  59. data/spec/dummyapp/app/views/devise/registrations/edit.html.erb +0 -27
  60. data/spec/dummyapp/app/views/devise/registrations/new.html.erb +0 -20
  61. data/spec/dummyapp/app/views/devise/shared/_links.html.erb +0 -25
  62. data/spec/dummyapp/app/views/home/cause_exception.html.erb +0 -1
  63. data/spec/dummyapp/app/views/home/index.html.erb +0 -4
  64. data/spec/dummyapp/app/views/home/report_exception.html.erb +0 -1
  65. data/spec/dummyapp/app/views/js/test.html.erb +0 -1
  66. data/spec/dummyapp/app/views/layouts/_messages.html.erb +0 -5
  67. data/spec/dummyapp/app/views/layouts/_navigation.html.erb +0 -21
  68. data/spec/dummyapp/app/views/layouts/application.html.erb +0 -25
  69. data/spec/dummyapp/app/views/layouts/simple.html.erb +0 -18
  70. data/spec/dummyapp/app/views/users/index.html.erb +0 -8
  71. data/spec/dummyapp/app/views/users/show.html.erb +0 -3
  72. data/spec/dummyapp/config.ru +0 -4
  73. data/spec/dummyapp/config/application.rb +0 -59
  74. data/spec/dummyapp/config/boot.rb +0 -10
  75. data/spec/dummyapp/config/database.yml +0 -25
  76. data/spec/dummyapp/config/environment.rb +0 -5
  77. data/spec/dummyapp/config/environments/development.rb +0 -37
  78. data/spec/dummyapp/config/environments/production.rb +0 -67
  79. data/spec/dummyapp/config/environments/test.rb +0 -37
  80. data/spec/dummyapp/config/initializers/backtrace_silencers.rb +0 -7
  81. data/spec/dummyapp/config/initializers/inflections.rb +0 -15
  82. data/spec/dummyapp/config/initializers/mime_types.rb +0 -5
  83. data/spec/dummyapp/config/initializers/rollbar.rb +0 -26
  84. data/spec/dummyapp/config/initializers/secret_token.rb +0 -7
  85. data/spec/dummyapp/config/initializers/session_store.rb +0 -8
  86. data/spec/dummyapp/config/initializers/wrap_parameters.rb +0 -16
  87. data/spec/dummyapp/config/locales/devise.en.yml +0 -58
  88. data/spec/dummyapp/config/locales/en.yml +0 -5
  89. data/spec/dummyapp/config/routes.rb +0 -17
  90. data/spec/dummyapp/config/secrets.yml +0 -2
  91. data/spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb +0 -46
  92. data/spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb +0 -5
  93. data/spec/dummyapp/db/migrate/20161219184410_create_books.rb +0 -10
  94. data/spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb +0 -5
  95. data/spec/dummyapp/db/schema.rb +0 -41
  96. data/spec/dummyapp/db/seeds.rb +0 -12
  97. data/spec/dummyapp/lib/assets/.gitkeep +0 -0
  98. data/spec/dummyapp/public/404.html +0 -26
  99. data/spec/dummyapp/public/422.html +0 -26
  100. data/spec/dummyapp/public/500.html +0 -25
  101. data/spec/dummyapp/public/favicon.ico +0 -0
  102. data/spec/dummyapp/script/rails +0 -6
  103. data/spec/fixtures/file1 +0 -1
  104. data/spec/fixtures/file2 +0 -1
  105. data/spec/fixtures/payloads/message.json +0 -25
  106. data/spec/fixtures/payloads/sample.trace.json +0 -275
  107. data/spec/fixtures/payloads/sample.trace_chain.json +0 -530
  108. data/spec/fixtures/plugins/dummy1.rb +0 -5
  109. data/spec/fixtures/plugins/dummy2.rb +0 -5
  110. data/spec/generators/rollbar/rollbar_generator_rails30_spec.rb +0 -31
  111. data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -51
  112. data/spec/requests/home_spec.rb +0 -49
  113. data/spec/rollbar/configuration_spec.rb +0 -74
  114. data/spec/rollbar/delay/delayed_job_spec.rb +0 -22
  115. data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
  116. data/spec/rollbar/delay/resque_spec.rb +0 -37
  117. data/spec/rollbar/delay/shoryuken_spec.rb +0 -44
  118. data/spec/rollbar/delay/thread_spec.rb +0 -27
  119. data/spec/rollbar/encoding/encoder_spec.rb +0 -63
  120. data/spec/rollbar/item/backtrace_spec.rb +0 -26
  121. data/spec/rollbar/item/frame_spec.rb +0 -267
  122. data/spec/rollbar/item_spec.rb +0 -736
  123. data/spec/rollbar/json/oj_spec.rb +0 -18
  124. data/spec/rollbar/json_spec.rb +0 -110
  125. data/spec/rollbar/lazy_store_spec.rb +0 -99
  126. data/spec/rollbar/logger_proxy_spec.rb +0 -69
  127. data/spec/rollbar/logger_spec.rb +0 -124
  128. data/spec/rollbar/middleware/js_spec.rb +0 -428
  129. data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
  130. data/spec/rollbar/notifier_spec.rb +0 -67
  131. data/spec/rollbar/plugin_spec.rb +0 -209
  132. data/spec/rollbar/plugins/active_job_spec.rb +0 -45
  133. data/spec/rollbar/plugins/delayed_job/job_data_spec.rb +0 -48
  134. data/spec/rollbar/plugins/delayed_job_spec.rb +0 -129
  135. data/spec/rollbar/plugins/rack_spec.rb +0 -152
  136. data/spec/rollbar/plugins/rails_js_spec.rb +0 -19
  137. data/spec/rollbar/plugins/rake_spec.rb +0 -34
  138. data/spec/rollbar/plugins/resque/failure_spec.rb +0 -36
  139. data/spec/rollbar/plugins/sidekiq_spec.rb +0 -169
  140. data/spec/rollbar/plugins/validations_spec.rb +0 -56
  141. data/spec/rollbar/plugins_spec.rb +0 -68
  142. data/spec/rollbar/request_data_extractor_spec.rb +0 -321
  143. data/spec/rollbar/scrubbers/params_spec.rb +0 -598
  144. data/spec/rollbar/scrubbers/url_spec.rb +0 -240
  145. data/spec/rollbar/scrubbers_spec.rb +0 -31
  146. data/spec/rollbar/sidekig/clear_scope_spec.rb +0 -19
  147. data/spec/rollbar/truncation/frames_strategy_spec.rb +0 -70
  148. data/spec/rollbar/truncation/min_body_strategy_spec.rb +0 -57
  149. data/spec/rollbar/truncation/strings_strategy_spec.rb +0 -89
  150. data/spec/rollbar/truncation_spec.rb +0 -27
  151. data/spec/rollbar/util/hash_spec.rb +0 -22
  152. data/spec/rollbar/util/ip_anonymizer_spec.rb +0 -30
  153. data/spec/rollbar/util_spec.rb +0 -80
  154. data/spec/rollbar_bc_spec.rb +0 -380
  155. data/spec/rollbar_spec.rb +0 -1737
  156. data/spec/spec_helper.rb +0 -84
  157. data/spec/support/cause_exception.rb +0 -1
  158. data/spec/support/encoding_helpers.rb +0 -8
  159. data/spec/support/encodings/iso_8859_9 +0 -1
  160. data/spec/support/fixture_helpers.rb +0 -10
  161. data/spec/support/get_ip_raising.rb +0 -7
  162. data/spec/support/helpers.rb +0 -5
  163. data/spec/support/matchers.rb +0 -23
  164. data/spec/support/notifier_helpers.rb +0 -57
  165. data/spec/support/rollbar_api.rb +0 -57
  166. data/spec/support/secure_headers_mocks.rb +0 -83
  167. data/spec/support/shared_contexts.rb +0 -12
@@ -0,0 +1,62 @@
1
+ require 'rubygems/version'
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
6
+
7
+ gem 'appraisal'
8
+ gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
9
+ gem 'jruby-openssl', :platform => :jruby
10
+ gem 'rails', '~> 5.2.0'
11
+ gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
12
+
13
+ gem 'rspec-core', '~> 3.8.0'
14
+ gem 'rspec-rails', '~> 3.8.0'
15
+ gem 'rspec-support', '~> 3.8.0'
16
+ gem 'rspec-expectations', '~> 3.8.0'
17
+ gem 'rspec-mocks', '~> 3.8.0'
18
+
19
+ gem 'rake'
20
+
21
+ unless is_jruby
22
+ if RUBY_VERSION >= '2.5'
23
+ gem 'oj'
24
+ elsif RUBY_VERSION >= '2.4.0'
25
+ gem 'oj', '~> 2.16.1'
26
+ else
27
+ gem 'oj', '~> 2.12.14'
28
+ end
29
+ end
30
+
31
+ gem 'sidekiq', '>= 2.13.0'
32
+
33
+ platforms :rbx do
34
+ gem 'minitest'
35
+ gem 'racc'
36
+ gem 'rubinius-developer_tools'
37
+ gem 'rubysl', '~> 2.0' unless RUBY_VERSION.start_with?('1')
38
+ end
39
+
40
+ gem 'sucker_punch', '~> 2.0'
41
+
42
+ # We need last sinatra that uses rack 2.x
43
+ gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
44
+
45
+ gem 'database_cleaner'
46
+ gem 'codacy-coverage'
47
+ gem 'delayed_job', :require => false
48
+ gem 'generator_spec'
49
+ gem 'girl_friday', '>= 0.11.1'
50
+ gem 'rspec-command'
51
+ gem 'redis'
52
+ gem 'resque'
53
+ gem 'simplecov'
54
+
55
+ gem 'mime-types'
56
+
57
+ gem 'webmock', :require => false
58
+
59
+ gem 'aws-sdk-sqs'
60
+ gem 'shoryuken'
61
+
62
+ gemspec :path => '../'
@@ -11,7 +11,7 @@ gem 'jruby-openssl', :platform => :jruby
11
11
  gem 'rails', '3.0.20'
12
12
  gem 'rake', '< 11'
13
13
  gem 'rspec-rails', '>= 2.14.0'
14
- gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
14
+ gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
15
15
 
16
16
  gem 'oj', '~> 2.12.14' unless is_jruby
17
17
  if RUBY_VERSION > '1.8.7' && RUBY_VERSION < '2.2.2'
@@ -37,7 +37,7 @@ gem 'delayed_job', '4.1.3', :require => false
37
37
  gem 'genspec', '= 0.2.8'
38
38
  gem 'girl_friday', '>= 0.11.1'
39
39
  gem 'redis', '< 3.3.5'
40
- gem 'resque'
40
+ gem 'resque', '< 2.0.0'
41
41
  gem 'sinatra'
42
42
 
43
43
  ruby_version = RUBY_VERSION.dup
@@ -1,7 +1,10 @@
1
1
  require 'rails'
2
2
  require 'rollbar'
3
3
 
4
- APP_PATH = File.expand_path('config/application', Dir.pwd)
4
+ # Rails.root is not present here.
5
+ # RSpec needs ENV['DUMMYAPP_PATH'] in order to have a valid path.
6
+ # Dir.pwd is used in normal operation.
7
+ APP_PATH = File.expand_path('config/application', (ENV['DUMMYAPP_PATH'] || Dir.pwd))
5
8
 
6
9
  module Rails
7
10
  class RollbarRunner
@@ -36,6 +39,14 @@ module Rails
36
39
  end
37
40
 
38
41
  def eval_runner
42
+ if Rails.version >= '5.0.0'
43
+ rails5_runner
44
+ else
45
+ legacy_runner
46
+ end
47
+ end
48
+
49
+ def legacy_runner
39
50
  string_to_eval = File.read(runner_path)
40
51
 
41
52
  ::Rails.module_eval(<<-EOL, __FILE__, __LINE__ + 2)
@@ -43,6 +54,10 @@ module Rails
43
54
  EOL
44
55
  end
45
56
 
57
+ def rails5_runner
58
+ Rails::Command.invoke 'runner', ARGV
59
+ end
60
+
46
61
  def rollbar_managed
47
62
  yield
48
63
  rescue => e
@@ -1,43 +1,77 @@
1
+ # This is a tasks file to use with Capistrano 2
2
+
1
3
  require 'capistrano'
4
+ require 'rollbar/deploy'
5
+ require 'net/http'
6
+ require 'rubygems'
7
+ require 'json'
8
+ require 'rollbar/capistrano_tasks'
2
9
 
3
10
  module Rollbar
4
- module Capistrano
5
- def self.load_into(configuration)
6
- configuration.load do
7
- after 'deploy', 'rollbar:deploy'
8
- after 'deploy:migrations', 'rollbar:deploy'
9
- after 'deploy:cold', 'rollbar:deploy'
10
-
11
- namespace :rollbar do
12
- desc 'Send the deployment notification to Rollbar.'
13
- task :deploy, :except => { :no_release => true } do
14
- require 'net/http'
15
- require 'rubygems'
16
- require 'json'
17
-
18
- _cset(:rollbar_user) { ENV['USER'] || ENV['USERNAME'] }
19
- _cset(:rollbar_env) { fetch(:rails_env, 'production') }
20
- _cset(:rollbar_token) { abort("Please specify the Rollbar access token, set :rollbar_token, 'your token'") }
21
-
22
- unless configuration.dry_run
23
- uri = URI.parse('https://api.rollbar.com/api/1/deploy/')
24
-
25
- params = {
26
- :local_username => rollbar_user,
27
- :access_token => rollbar_token,
28
- :environment => rollbar_env,
29
- :revision => current_revision
30
- }
31
-
32
- request = Net::HTTP::Post.new(uri.request_uri)
33
- request.body = ::JSON.dump(params)
34
-
35
- Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
36
- http.request(request)
37
- end
38
- end
11
+ # Module for loading Rollbar Capistrano tasks into Capistrano 2
12
+ module Capistrano2
13
+ class << self
14
+ def load_into(configuration)
15
+ load_tasks(configuration)
16
+ load_tasks_flow(configuration)
17
+ load_properties(configuration)
18
+ end
19
+
20
+ private
21
+
22
+ def load_tasks_flow(configuration)
23
+ configuration.load do
24
+ before 'deploy', 'rollbar:deploy_started'
25
+
26
+ after 'deploy', 'rollbar:deploy_succeeded'
27
+ after 'deploy:migrations', 'rollbar:deploy_succeeded'
28
+ after 'deploy:cold', 'rollbar:deploy_succeeded'
29
+ end
30
+ end
31
+
32
+ def load_properties(configuration)
33
+ configuration.load do
34
+ _cset(:rollbar_role) { :app }
35
+ _cset(:rollbar_user) { ENV['USER'] || ENV['USERNAME'] }
36
+ _cset(:rollbar_env) { fetch(:rails_env, 'production') }
37
+ _cset(:rollbar_token) { abort("Please specify the Rollbar access token, set :rollbar_token, 'your token'") }
38
+ _cset(:rollbar_revision) { current_revision }
39
+ _cset(:rollbar_comment) { nil }
40
+ end
41
+ end
39
42
 
40
- logger.info('Rollbar notification complete')
43
+ def load_tasks(configuration)
44
+ load_deploy_started(configuration)
45
+ load_deploy_succeeded(configuration)
46
+ end
47
+
48
+ def load_deploy_started(configuration)
49
+ load_task(
50
+ :desc => 'Send deployment started notification to Rollbar.',
51
+ :task => :deploy_started,
52
+ :configuration => configuration
53
+ ) do
54
+ ::Rollbar::CapistranoTasks.deploy_started(configuration, configuration.logger, configuration.dry_run)
55
+ end
56
+ end
57
+
58
+ def load_deploy_succeeded(configuration)
59
+ load_task(
60
+ :desc => 'Send deployment succeeded notification to Rollbar.',
61
+ :task => :deploy_succeeded,
62
+ :configuration => configuration
63
+ ) do
64
+ ::Rollbar::CapistranoTasks.deploy_succeeded(configuration, configuration.logger, configuration.dry_run)
65
+ end
66
+ end
67
+
68
+ def load_task(configuration:, desc:, task:)
69
+ configuration.load do
70
+ namespace :rollbar do
71
+ desc(desc)
72
+ task(task) do
73
+ yield
74
+ end
41
75
  end
42
76
  end
43
77
  end
@@ -45,6 +79,4 @@ module Rollbar
45
79
  end
46
80
  end
47
81
 
48
- if Capistrano::Configuration.instance
49
- Rollbar::Capistrano.load_into(Capistrano::Configuration.instance)
50
- end
82
+ Rollbar::Capistrano2.load_into(Capistrano::Configuration.instance) if Capistrano::Configuration.instance
@@ -1 +1,53 @@
1
- load File.expand_path('../tasks/rollbar.cap', __FILE__)
1
+ # This is a tasks file to use with Capistrano 3
2
+
3
+ require 'net/http'
4
+ require 'rubygems'
5
+ require 'json'
6
+ require 'rollbar/deploy'
7
+ require 'rollbar/capistrano_tasks'
8
+
9
+ namespace :rollbar do
10
+ desc 'Send deployment started notification to Rollbar.'
11
+ task :deploy_started do
12
+ on primary fetch(:rollbar_role) do
13
+ ::Rollbar::CapistranoTasks.deploy_started(self, self, dry_run?)
14
+ end
15
+ end
16
+
17
+ desc 'Send deployment succeeded notification to Rollbar.'
18
+ task :deploy_succeeded do
19
+ on primary fetch(:rollbar_role) do
20
+ ::Rollbar::CapistranoTasks.deploy_succeeded(self, self, dry_run?)
21
+ end
22
+ end
23
+
24
+ desc 'Send deployment failed notification to Rollbar.'
25
+ task :deploy_failed do
26
+ on primary fetch(:rollbar_role) do
27
+ ::Rollbar::CapistranoTasks.deploy_failed(self, self, dry_run?)
28
+ end
29
+ end
30
+
31
+ task :fail do
32
+ raise StandardError
33
+ end
34
+ end
35
+
36
+ namespace :deploy do
37
+ after 'deploy:set_current_revision', 'rollbar:deploy_started'
38
+ after 'deploy:finished', 'rollbar:deploy_succeeded'
39
+ after 'deploy:failed', 'rollbar:deploy_failed'
40
+
41
+ # Used for testing :deploy_failed task
42
+ # after 'rollbar:deploy_started', 'rollbar:fail'
43
+ end
44
+
45
+ namespace :load do
46
+ task :defaults do
47
+ set :rollbar_user, (proc { fetch :local_user, ENV['USER'] || ENV['USERNAME'] })
48
+ set :rollbar_env, (proc { fetch :rails_env, 'production' })
49
+ set :rollbar_token, (proc { abort "Please specify the Rollbar access token, set :rollbar_token, 'your token'" })
50
+ set :rollbar_role, (proc { :app })
51
+ set :rollbar_revision, (proc { fetch :current_revision })
52
+ end
53
+ end
@@ -0,0 +1,131 @@
1
+ require 'capistrano'
2
+ require 'capistrano/version'
3
+ require 'rollbar/deploy'
4
+
5
+ module Rollbar
6
+ # Module containing the logic of Capistrano tasks for deploy tracking
7
+ module CapistranoTasks
8
+ class << self
9
+ def deploy_started(capistrano, logger, dry_run)
10
+ deploy_task(logger, :desc => 'Notifying Rollbar of deployment start') do
11
+ result = report_deploy_started(capistrano, dry_run)
12
+
13
+ info_request_response(logger, result)
14
+
15
+ capistrano.set(:rollbar_deploy_id, 123) if dry_run
16
+
17
+ skip_in_dry_run(logger, dry_run) do
18
+ if (deploy_id = result[:data][:deploy_id])
19
+ capistrano.set :rollbar_deploy_id, deploy_id
20
+ else
21
+ logger.error 'Unable to report deploy to Rollbar'
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ def deploy_succeeded(capistrano, logger, dry_run)
28
+ deploy_update(capistrano, logger, dry_run, :desc => 'Setting deployment status to `succeeded` in Rollbar') do
29
+ report_deploy_succeeded(capistrano, dry_run)
30
+ end
31
+ end
32
+
33
+ def deploy_failed(capistrano, logger, dry_run)
34
+ deploy_update(capistrano, logger, dry_run, :desc => 'Setting deployment status to `failed` in Rollbar') do
35
+ report_deploy_failed(capistrano, dry_run)
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def deploy_task(logger, opts = {})
42
+ capistrano_300_warning(logger)
43
+ logger.info opts[:desc] if opts[:desc]
44
+ yield
45
+ end
46
+
47
+ def deploy_update(capistrano, logger, dry_run, opts = {})
48
+ deploy_task(logger, opts) do
49
+ depend_on_deploy_id(capistrano, logger) do
50
+ result = yield
51
+
52
+ info_request_response(logger, result)
53
+
54
+ skip_in_dry_run(logger, dry_run) do
55
+ if result[:response].is_a?(Net::HTTPSuccess)
56
+ logger.info 'Updated deploy status in Rollbar'
57
+ else
58
+ logger.error 'Unable to update deploy status in Rollbar'
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ def capistrano_300_warning(logger)
66
+ logger.warn("You need to upgrade capistrano to '>= 3.1' version in order to correctly report deploys to Rollbar. (On 3.0, the reported revision will be incorrect.)") if ::Capistrano::VERSION =~ /^3\.0/
67
+ end
68
+
69
+ def report_deploy_started(capistrano, dry_run)
70
+ ::Rollbar::Deploy.report(
71
+ {
72
+ :rollbar_username => capistrano.fetch(:rollbar_user),
73
+ :local_username => capistrano.fetch(:rollbar_user),
74
+ :comment => capistrano.fetch(:rollbar_comment),
75
+ :status => :started,
76
+ :proxy => :ENV,
77
+ :dry_run => dry_run
78
+ },
79
+ :access_token => capistrano.fetch(:rollbar_token),
80
+ :environment => capistrano.fetch(:rollbar_env),
81
+ :revision => capistrano.fetch(:rollbar_revision)
82
+ )
83
+ end
84
+
85
+ def report_deploy_succeeded(capistrano, dry_run)
86
+ ::Rollbar::Deploy.update(
87
+ {
88
+ :proxy => :ENV,
89
+ :dry_run => dry_run
90
+ },
91
+ :access_token => capistrano.fetch(:rollbar_token),
92
+ :deploy_id => capistrano.fetch(:rollbar_deploy_id),
93
+ :status => :succeeded
94
+ )
95
+ end
96
+
97
+ def report_deploy_failed(capistrano, dry_run)
98
+ ::Rollbar::Deploy.update(
99
+ {
100
+ :proxy => :ENV,
101
+ :dry_run => dry_run
102
+ },
103
+ :access_token => capistrano.fetch(:rollbar_token),
104
+ :deploy_id => capistrano.fetch(:rollbar_deploy_id),
105
+ :status => :failed
106
+ )
107
+ end
108
+
109
+ def depend_on_deploy_id(capistrano, logger)
110
+ if capistrano.fetch(:rollbar_deploy_id)
111
+ yield
112
+ else
113
+ logger.error 'Failed to update the deploy in Rollbar. No deploy id available.'
114
+ end
115
+ end
116
+
117
+ def skip_in_dry_run(logger, dry_run)
118
+ if dry_run
119
+ logger.info 'Skipping sending HTTP requests to Rollbar in dry run.'
120
+ else
121
+ yield
122
+ end
123
+ end
124
+
125
+ def info_request_response(logger, result)
126
+ logger.info result[:request_info]
127
+ logger.info result[:response_info] if result[:response_info]
128
+ end
129
+ end
130
+ end
131
+ end
@@ -107,7 +107,7 @@ module Rollbar
107
107
  @js_options = {}
108
108
  @scrub_fields = [:passwd, :password, :password_confirmation, :secret,
109
109
  :confirm_password, :password_confirmation, :secret_token,
110
- :api_key, :access_token]
110
+ :api_key, :access_token, :session_id]
111
111
  @scrub_user = true
112
112
  @scrub_password = true
113
113
  @randomize_scrub_length = true
@@ -130,7 +130,7 @@ module Rollbar
130
130
  @anonymize_user_ip = false
131
131
  @hooks = {
132
132
  :on_error_response => nil, # params: response
133
- :on_report_internal_error => nil, #params: exception
133
+ :on_report_internal_error => nil, # params: exception
134
134
  }
135
135
  end
136
136
 
@@ -161,6 +161,15 @@ module Rollbar
161
161
  self
162
162
  end
163
163
 
164
+ def use_active_job(options = {})
165
+ require 'rollbar/delay/active_job'
166
+
167
+ Rollbar::Delay::ActiveJob.queue_as(options[:queue] || Rollbar::Delay::ActiveJob.default_queue_name)
168
+
169
+ @use_async = true
170
+ @async_handler = Rollbar::Delay::ActiveJob
171
+ end
172
+
164
173
  def use_delayed_job(options = {})
165
174
  require 'rollbar/delay/delayed_job'
166
175
 
@@ -263,7 +272,7 @@ module Rollbar
263
272
  def logger
264
273
  @logger ||= default_logger.call
265
274
  end
266
-
275
+
267
276
  def hook(symbol, &block)
268
277
  if @hooks.has_key?(symbol)
269
278
  if block_given?
@@ -275,7 +284,7 @@ module Rollbar
275
284
  raise StandardError.new "Hook :" + symbol.to_s + " is not supported by Rollbar SDK."
276
285
  end
277
286
  end
278
-
287
+
279
288
  def execute_hook(symbol, *args)
280
289
  hook(symbol).call(*args) if hook(symbol).is_a?(Proc)
281
290
  end