rollbar 2.10.0 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -2
  3. data/CHANGELOG.md +20 -0
  4. data/README.md +73 -16
  5. data/docs/configuration.md +10 -0
  6. data/gemfiles/rails30.gemfile +2 -0
  7. data/gemfiles/rails31.gemfile +2 -0
  8. data/gemfiles/rails32.gemfile +2 -0
  9. data/gemfiles/rails40.gemfile +2 -0
  10. data/gemfiles/rails41.gemfile +2 -0
  11. data/gemfiles/rails42.gemfile +2 -0
  12. data/gemfiles/rails50.gemfile +2 -0
  13. data/gemfiles/ruby_1_8_and_1_9_2.gemfile +43 -0
  14. data/lib/rollbar.rb +139 -353
  15. data/lib/rollbar/configuration.rb +4 -0
  16. data/lib/rollbar/item.rb +225 -0
  17. data/lib/rollbar/item/backtrace.rb +97 -0
  18. data/lib/rollbar/js.rb +0 -28
  19. data/lib/rollbar/language_support.rb +10 -0
  20. data/lib/rollbar/{js/middleware.rb → middleware/js.rb} +3 -4
  21. data/lib/rollbar/plugin.rb +63 -0
  22. data/lib/rollbar/plugins.rb +41 -0
  23. data/lib/rollbar/{active_job.rb → plugins/active_job.rb} +0 -0
  24. data/lib/rollbar/plugins/basic_socket.rb +16 -0
  25. data/lib/rollbar/plugins/delayed_job.rb +12 -0
  26. data/lib/rollbar/plugins/delayed_job/job_data.rb +16 -0
  27. data/lib/rollbar/{delayed_job.rb → plugins/delayed_job/plugin.rb} +1 -17
  28. data/lib/rollbar/plugins/goalie.rb +46 -0
  29. data/lib/rollbar/plugins/rack.rb +16 -0
  30. data/lib/rollbar/plugins/rails.rb +77 -0
  31. data/lib/rollbar/{rails → plugins/rails}/controller_methods.rb +0 -0
  32. data/lib/rollbar/plugins/rails/railtie30.rb +17 -0
  33. data/lib/rollbar/plugins/rails/railtie32.rb +18 -0
  34. data/lib/rollbar/plugins/rails/railtie_mixin.rb +33 -0
  35. data/lib/rollbar/plugins/rake.rb +45 -0
  36. data/lib/rollbar/plugins/sidekiq.rb +35 -0
  37. data/lib/rollbar/{sidekiq.rb → plugins/sidekiq/plugin.rb} +0 -18
  38. data/lib/rollbar/plugins/thread.rb +13 -0
  39. data/lib/rollbar/plugins/validations.rb +33 -0
  40. data/lib/rollbar/request_data_extractor.rb +30 -18
  41. data/lib/rollbar/scrubbers/params.rb +4 -2
  42. data/lib/rollbar/scrubbers/url.rb +30 -28
  43. data/lib/rollbar/util.rb +10 -0
  44. data/lib/rollbar/version.rb +1 -1
  45. data/spec/controllers/home_controller_spec.rb +4 -3
  46. data/spec/dummyapp/app/models/post.rb +9 -0
  47. data/spec/dummyapp/app/models/user.rb +2 -0
  48. data/spec/dummyapp/config/initializers/rollbar.rb +1 -0
  49. data/spec/fixtures/plugins/dummy1.rb +5 -0
  50. data/spec/fixtures/plugins/dummy2.rb +5 -0
  51. data/spec/rollbar/item_spec.rb +635 -0
  52. data/spec/rollbar/logger_proxy_spec.rb +4 -0
  53. data/spec/rollbar/{js/middleware_spec.rb → middleware/js_spec.rb} +32 -3
  54. data/spec/rollbar/plugin_spec.rb +147 -0
  55. data/spec/rollbar/{active_job_spec.rb → plugins/active_job_spec.rb} +0 -1
  56. data/spec/rollbar/{delayed_job → plugins/delayed_job}/job_data.rb +0 -0
  57. data/spec/rollbar/{delayed_job_spec.rb → plugins/delayed_job_spec.rb} +3 -6
  58. data/spec/rollbar/{middleware/rack/builder_spec.rb → plugins/rack_spec.rb} +2 -1
  59. data/spec/rollbar/{js/frameworks/rails_spec.rb → plugins/rails_js_spec.rb} +1 -1
  60. data/spec/rollbar/{rake_spec.rb → plugins/rake_spec.rb} +2 -1
  61. data/spec/rollbar/{sidekiq_spec.rb → plugins/sidekiq_spec.rb} +2 -1
  62. data/spec/rollbar/plugins/validations_spec.rb +43 -0
  63. data/spec/rollbar/plugins_spec.rb +68 -0
  64. data/spec/rollbar/request_data_extractor_spec.rb +56 -10
  65. data/spec/rollbar/scrubbers/params_spec.rb +13 -10
  66. data/spec/rollbar/scrubbers/url_spec.rb +17 -12
  67. data/spec/rollbar/sidekig/clear_scope_spec.rb +2 -1
  68. data/spec/rollbar/util_spec.rb +61 -0
  69. data/spec/rollbar_bc_spec.rb +10 -10
  70. data/spec/rollbar_spec.rb +57 -706
  71. data/spec/spec_helper.rb +8 -0
  72. data/spec/support/notifier_helpers.rb +1 -0
  73. data/spec/support/rollbar_api.rb +57 -0
  74. metadata +57 -33
  75. data/lib/rollbar/active_record_extension.rb +0 -14
  76. data/lib/rollbar/core_ext/basic_socket.rb +0 -7
  77. data/lib/rollbar/core_ext/thread.rb +0 -9
  78. data/lib/rollbar/goalie.rb +0 -33
  79. data/lib/rollbar/js/frameworks.rb +0 -6
  80. data/lib/rollbar/js/frameworks/rails.rb +0 -49
  81. data/lib/rollbar/js/version.rb +0 -5
  82. data/lib/rollbar/rack.rb +0 -9
  83. data/lib/rollbar/railtie.rb +0 -46
  84. data/lib/rollbar/rake.rb +0 -40
data/spec/spec_helper.rb CHANGED
@@ -20,6 +20,12 @@ require File.expand_path('../dummyapp/config/environment', __FILE__)
20
20
  require 'rspec/rails'
21
21
  require 'database_cleaner'
22
22
 
23
+ begin
24
+ require 'webmock/rspec'
25
+ WebMock.disable_net_connect!(:allow => 'codeclimate.com')
26
+ rescue LoadError
27
+ end
28
+
23
29
  namespace :dummy do
24
30
  load 'spec/dummyapp/Rakefile'
25
31
  end
@@ -60,6 +66,8 @@ RSpec.configure do |config|
60
66
  DatabaseCleaner.start
61
67
  DatabaseCleaner.clean
62
68
  Rollbar.reset_notifier!
69
+
70
+ stub_request(:any, /api.rollbar.com/).to_rack(RollbarAPI.new) if defined?(WebMock)
63
71
  end
64
72
 
65
73
  config.after(:each) do
@@ -6,6 +6,7 @@ module NotifierHelpers
6
6
  config.logger = ::Rails.logger
7
7
  config.root = ::Rails.root
8
8
  config.framework = "Rails: #{::Rails::VERSION::STRING}"
9
+ config.open_timeout = 60
9
10
  config.request_timeout = 60
10
11
  end
11
12
  end
@@ -0,0 +1,57 @@
1
+ require 'rack/request'
2
+
3
+ class RollbarAPI
4
+ def call(env)
5
+ request = Rack::Request.new(env)
6
+ json = JSON.parse(request.body.read)
7
+
8
+ return bad_request(json) unless access_token?(json)
9
+
10
+ success(json)
11
+ end
12
+
13
+ private
14
+
15
+ def response_headers
16
+ {
17
+ 'Content-Type' => 'application/json'
18
+ }
19
+ end
20
+
21
+ def access_token?(json)
22
+
23
+ !!json['access_token']
24
+ end
25
+
26
+ def bad_request(json)
27
+ # We don't have for now any test doing bad requests
28
+ # so raise here in order to detect that scenario
29
+ raise
30
+
31
+
32
+ [400, response_headers, [bad_request_body]]
33
+ end
34
+
35
+ def success(json)
36
+ [200, response_headers, [success_body(json)]]
37
+ end
38
+
39
+ def bad_request_body
40
+ result(1, nil, 'bad request')
41
+ end
42
+
43
+ def success_body(json)
44
+ result(0, {
45
+ :id => rand(1_000_000),
46
+ :uuid => json['data']['uuid']
47
+ }, nil)
48
+ end
49
+
50
+ def result(err, body, message)
51
+ {
52
+ :err => err,
53
+ :result => body,
54
+ :message => message
55
+ }.to_json
56
+ end
57
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-21 00:00:00.000000000 Z
11
+ date: 2016-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -56,35 +56,28 @@ files:
56
56
  - gemfiles/rails41.gemfile
57
57
  - gemfiles/rails42.gemfile
58
58
  - gemfiles/rails50.gemfile
59
+ - gemfiles/ruby_1_8_and_1_9_2.gemfile
59
60
  - lib/generators/rollbar/rollbar_generator.rb
60
61
  - lib/generators/rollbar/templates/initializer.rb
61
62
  - lib/rails/rollbar_runner.rb
62
63
  - lib/rollbar.rb
63
- - lib/rollbar/active_job.rb
64
- - lib/rollbar/active_record_extension.rb
65
64
  - lib/rollbar/capistrano.rb
66
65
  - lib/rollbar/capistrano3.rb
67
66
  - lib/rollbar/configuration.rb
68
- - lib/rollbar/core_ext/basic_socket.rb
69
- - lib/rollbar/core_ext/thread.rb
70
67
  - lib/rollbar/delay/delayed_job.rb
71
68
  - lib/rollbar/delay/girl_friday.rb
72
69
  - lib/rollbar/delay/resque.rb
73
70
  - lib/rollbar/delay/sidekiq.rb
74
71
  - lib/rollbar/delay/sucker_punch.rb
75
72
  - lib/rollbar/delay/thread.rb
76
- - lib/rollbar/delayed_job.rb
77
73
  - lib/rollbar/encoding.rb
78
74
  - lib/rollbar/encoding/encoder.rb
79
75
  - lib/rollbar/encoding/legacy_encoder.rb
80
76
  - lib/rollbar/exception_reporter.rb
81
77
  - lib/rollbar/exceptions.rb
82
- - lib/rollbar/goalie.rb
78
+ - lib/rollbar/item.rb
79
+ - lib/rollbar/item/backtrace.rb
83
80
  - lib/rollbar/js.rb
84
- - lib/rollbar/js/frameworks.rb
85
- - lib/rollbar/js/frameworks/rails.rb
86
- - lib/rollbar/js/middleware.rb
87
- - lib/rollbar/js/version.rb
88
81
  - lib/rollbar/json.rb
89
82
  - lib/rollbar/json/default.rb
90
83
  - lib/rollbar/json/oj.rb
@@ -92,22 +85,37 @@ files:
92
85
  - lib/rollbar/lazy_store.rb
93
86
  - lib/rollbar/logger.rb
94
87
  - lib/rollbar/logger_proxy.rb
88
+ - lib/rollbar/middleware/js.rb
95
89
  - lib/rollbar/middleware/rack/builder.rb
96
90
  - lib/rollbar/middleware/rack/test_session.rb
97
91
  - lib/rollbar/middleware/rails/rollbar.rb
98
92
  - lib/rollbar/middleware/rails/show_exceptions.rb
99
93
  - lib/rollbar/middleware/sinatra.rb
100
- - lib/rollbar/rack.rb
94
+ - lib/rollbar/plugin.rb
95
+ - lib/rollbar/plugins.rb
96
+ - lib/rollbar/plugins/active_job.rb
97
+ - lib/rollbar/plugins/basic_socket.rb
98
+ - lib/rollbar/plugins/delayed_job.rb
99
+ - lib/rollbar/plugins/delayed_job/job_data.rb
100
+ - lib/rollbar/plugins/delayed_job/plugin.rb
101
+ - lib/rollbar/plugins/goalie.rb
102
+ - lib/rollbar/plugins/rack.rb
103
+ - lib/rollbar/plugins/rails.rb
104
+ - lib/rollbar/plugins/rails/controller_methods.rb
105
+ - lib/rollbar/plugins/rails/railtie30.rb
106
+ - lib/rollbar/plugins/rails/railtie32.rb
107
+ - lib/rollbar/plugins/rails/railtie_mixin.rb
108
+ - lib/rollbar/plugins/rake.rb
109
+ - lib/rollbar/plugins/sidekiq.rb
110
+ - lib/rollbar/plugins/sidekiq/plugin.rb
111
+ - lib/rollbar/plugins/thread.rb
112
+ - lib/rollbar/plugins/validations.rb
101
113
  - lib/rollbar/rails.rb
102
- - lib/rollbar/rails/controller_methods.rb
103
- - lib/rollbar/railtie.rb
104
- - lib/rollbar/rake.rb
105
114
  - lib/rollbar/rake_tasks.rb
106
115
  - lib/rollbar/request_data_extractor.rb
107
116
  - lib/rollbar/scrubbers.rb
108
117
  - lib/rollbar/scrubbers/params.rb
109
118
  - lib/rollbar/scrubbers/url.rb
110
- - lib/rollbar/sidekiq.rb
111
119
  - lib/rollbar/tasks/rollbar.cap
112
120
  - lib/rollbar/truncation.rb
113
121
  - lib/rollbar/truncation/frames_strategy.rb
@@ -137,6 +145,7 @@ files:
137
145
  - spec/dummyapp/app/helpers/.gitkeep
138
146
  - spec/dummyapp/app/mailers/.gitkeep
139
147
  - spec/dummyapp/app/models/.gitkeep
148
+ - spec/dummyapp/app/models/post.rb
140
149
  - spec/dummyapp/app/models/user.rb
141
150
  - spec/dummyapp/app/views/devise/registrations/edit.html.erb
142
151
  - spec/dummyapp/app/views/devise/registrations/new.html.erb
@@ -185,34 +194,40 @@ files:
185
194
  - spec/fixtures/payloads/message.json
186
195
  - spec/fixtures/payloads/sample.trace.json
187
196
  - spec/fixtures/payloads/sample.trace_chain.json
197
+ - spec/fixtures/plugins/dummy1.rb
198
+ - spec/fixtures/plugins/dummy2.rb
188
199
  - spec/generators/rollbar/rollbar_generator_rails30_spec.rb
189
200
  - spec/generators/rollbar/rollbar_generator_spec.rb
190
201
  - spec/requests/home_spec.rb
191
- - spec/rollbar/active_job_spec.rb
192
202
  - spec/rollbar/configuration_spec.rb
193
203
  - spec/rollbar/delay/delayed_job_spec.rb
194
204
  - spec/rollbar/delay/girl_friday_spec.rb
195
205
  - spec/rollbar/delay/resque_spec.rb
196
206
  - spec/rollbar/delay/thread_spec.rb
197
- - spec/rollbar/delayed_job/job_data.rb
198
- - spec/rollbar/delayed_job_spec.rb
199
207
  - spec/rollbar/encoding/encoder_spec.rb
200
- - spec/rollbar/js/frameworks/rails_spec.rb
201
- - spec/rollbar/js/middleware_spec.rb
208
+ - spec/rollbar/item_spec.rb
202
209
  - spec/rollbar/json/oj_spec.rb
203
210
  - spec/rollbar/json_spec.rb
204
211
  - spec/rollbar/lazy_store_spec.rb
205
212
  - spec/rollbar/logger_proxy_spec.rb
206
213
  - spec/rollbar/logger_spec.rb
207
- - spec/rollbar/middleware/rack/builder_spec.rb
214
+ - spec/rollbar/middleware/js_spec.rb
208
215
  - spec/rollbar/middleware/sinatra_spec.rb
209
- - spec/rollbar/rake_spec.rb
216
+ - spec/rollbar/plugin_spec.rb
217
+ - spec/rollbar/plugins/active_job_spec.rb
218
+ - spec/rollbar/plugins/delayed_job/job_data.rb
219
+ - spec/rollbar/plugins/delayed_job_spec.rb
220
+ - spec/rollbar/plugins/rack_spec.rb
221
+ - spec/rollbar/plugins/rails_js_spec.rb
222
+ - spec/rollbar/plugins/rake_spec.rb
223
+ - spec/rollbar/plugins/sidekiq_spec.rb
224
+ - spec/rollbar/plugins/validations_spec.rb
225
+ - spec/rollbar/plugins_spec.rb
210
226
  - spec/rollbar/request_data_extractor_spec.rb
211
227
  - spec/rollbar/scrubbers/params_spec.rb
212
228
  - spec/rollbar/scrubbers/url_spec.rb
213
229
  - spec/rollbar/scrubbers_spec.rb
214
230
  - spec/rollbar/sidekig/clear_scope_spec.rb
215
- - spec/rollbar/sidekiq_spec.rb
216
231
  - spec/rollbar/truncation/frames_strategy_spec.rb
217
232
  - spec/rollbar/truncation/min_body_strategy_spec.rb
218
233
  - spec/rollbar/truncation/strings_strategy_spec.rb
@@ -230,6 +245,7 @@ files:
230
245
  - spec/support/helpers.rb
231
246
  - spec/support/matchers.rb
232
247
  - spec/support/notifier_helpers.rb
248
+ - spec/support/rollbar_api.rb
233
249
  - spec/support/shared_contexts.rb
234
250
  homepage: https://rollbar.com
235
251
  licenses:
@@ -272,6 +288,7 @@ test_files:
272
288
  - spec/dummyapp/app/helpers/.gitkeep
273
289
  - spec/dummyapp/app/mailers/.gitkeep
274
290
  - spec/dummyapp/app/models/.gitkeep
291
+ - spec/dummyapp/app/models/post.rb
275
292
  - spec/dummyapp/app/models/user.rb
276
293
  - spec/dummyapp/app/views/devise/registrations/edit.html.erb
277
294
  - spec/dummyapp/app/views/devise/registrations/new.html.erb
@@ -320,34 +337,40 @@ test_files:
320
337
  - spec/fixtures/payloads/message.json
321
338
  - spec/fixtures/payloads/sample.trace.json
322
339
  - spec/fixtures/payloads/sample.trace_chain.json
340
+ - spec/fixtures/plugins/dummy1.rb
341
+ - spec/fixtures/plugins/dummy2.rb
323
342
  - spec/generators/rollbar/rollbar_generator_rails30_spec.rb
324
343
  - spec/generators/rollbar/rollbar_generator_spec.rb
325
344
  - spec/requests/home_spec.rb
326
- - spec/rollbar/active_job_spec.rb
327
345
  - spec/rollbar/configuration_spec.rb
328
346
  - spec/rollbar/delay/delayed_job_spec.rb
329
347
  - spec/rollbar/delay/girl_friday_spec.rb
330
348
  - spec/rollbar/delay/resque_spec.rb
331
349
  - spec/rollbar/delay/thread_spec.rb
332
- - spec/rollbar/delayed_job/job_data.rb
333
- - spec/rollbar/delayed_job_spec.rb
334
350
  - spec/rollbar/encoding/encoder_spec.rb
335
- - spec/rollbar/js/frameworks/rails_spec.rb
336
- - spec/rollbar/js/middleware_spec.rb
351
+ - spec/rollbar/item_spec.rb
337
352
  - spec/rollbar/json/oj_spec.rb
338
353
  - spec/rollbar/json_spec.rb
339
354
  - spec/rollbar/lazy_store_spec.rb
340
355
  - spec/rollbar/logger_proxy_spec.rb
341
356
  - spec/rollbar/logger_spec.rb
342
- - spec/rollbar/middleware/rack/builder_spec.rb
357
+ - spec/rollbar/middleware/js_spec.rb
343
358
  - spec/rollbar/middleware/sinatra_spec.rb
344
- - spec/rollbar/rake_spec.rb
359
+ - spec/rollbar/plugin_spec.rb
360
+ - spec/rollbar/plugins/active_job_spec.rb
361
+ - spec/rollbar/plugins/delayed_job/job_data.rb
362
+ - spec/rollbar/plugins/delayed_job_spec.rb
363
+ - spec/rollbar/plugins/rack_spec.rb
364
+ - spec/rollbar/plugins/rails_js_spec.rb
365
+ - spec/rollbar/plugins/rake_spec.rb
366
+ - spec/rollbar/plugins/sidekiq_spec.rb
367
+ - spec/rollbar/plugins/validations_spec.rb
368
+ - spec/rollbar/plugins_spec.rb
345
369
  - spec/rollbar/request_data_extractor_spec.rb
346
370
  - spec/rollbar/scrubbers/params_spec.rb
347
371
  - spec/rollbar/scrubbers/url_spec.rb
348
372
  - spec/rollbar/scrubbers_spec.rb
349
373
  - spec/rollbar/sidekig/clear_scope_spec.rb
350
- - spec/rollbar/sidekiq_spec.rb
351
374
  - spec/rollbar/truncation/frames_strategy_spec.rb
352
375
  - spec/rollbar/truncation/min_body_strategy_spec.rb
353
376
  - spec/rollbar/truncation/strings_strategy_spec.rb
@@ -365,4 +388,5 @@ test_files:
365
388
  - spec/support/helpers.rb
366
389
  - spec/support/matchers.rb
367
390
  - spec/support/notifier_helpers.rb
391
+ - spec/support/rollbar_api.rb
368
392
  - spec/support/shared_contexts.rb
@@ -1,14 +0,0 @@
1
- module Rollbar
2
- module ActiveRecordExtension
3
- extend ActiveSupport::Concern
4
-
5
- def report_validation_errors_to_rollbar
6
- self.errors.full_messages.each do |error|
7
- Rollbar.log_info "[Rollbar] Reporting form validation error: #{error} for #{self.to_s}"
8
- Rollbar.warning("Form Validation Error: #{error} for #{self.to_s}")
9
- end
10
- end
11
- end
12
- end
13
-
14
- ActiveRecord::Base.send(:include, Rollbar::ActiveRecordExtension)
@@ -1,7 +0,0 @@
1
- require 'socket'
2
-
3
- class BasicSocket
4
- def as_json
5
- to_s
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- class Thread
2
- def initialize_with_rollbar(*args, &block)
3
- self[:_rollbar_notifier] ||= Rollbar.notifier.scope
4
- initialize_without_rollbar(*args, &block)
5
- end
6
-
7
- alias_method :initialize_without_rollbar, :initialize
8
- alias_method :initialize, :initialize_with_rollbar
9
- end
@@ -1,33 +0,0 @@
1
- module Goalie
2
- class CustomErrorPages
3
- alias_method :orig_render_exception, :render_exception
4
-
5
- private
6
-
7
- def render_exception(env, exception)
8
- exception_data = nil
9
- begin
10
- controller = env['action_controller.instance']
11
- request_data = controller.rollbar_request_data rescue nil
12
- person_data = controller.rollbar_person_data rescue nil
13
- exception_data = Rollbar.scope(:request => request_data, :person => person_data).error(exception, :use_exception_level_filters => true)
14
- rescue => e
15
- Rollbar.log_warning "[Rollbar] Exception while reporting exception to Rollbar: #{e}"
16
- end
17
-
18
- # if an exception was reported, save uuid in the env
19
- # so it can be displayed to the user on the error page
20
- if exception_data.is_a?(Hash)
21
- env['rollbar.exception_uuid'] = exception_data[:uuid]
22
- Rollbar.log_info "[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
23
- elsif exception_data == 'disabled'
24
- Rollbar.log_info "[Rollbar] Exception not reported because Rollbar is disabled"
25
- elsif exception_data == 'ignored'
26
- Rollbar.log_info "[Rollbar] Exception not reported because it was ignored"
27
- end
28
-
29
- # now continue as normal
30
- orig_render_exception(env, exception)
31
- end
32
- end
33
- end
@@ -1,6 +0,0 @@
1
- module Rollbar
2
- module Js
3
- module Frameworks
4
- end
5
- end
6
- end
@@ -1,49 +0,0 @@
1
- module Rollbar
2
- module Js
3
- module Frameworks
4
- class Rails
5
- attr_accessor :prepared
6
-
7
- alias prepared? prepared
8
-
9
- def prepare
10
- return if prepared?
11
-
12
- if secure_headers?
13
- insert_middleware_after_secure_headers
14
- else
15
- insert_middleware
16
- end
17
-
18
- self.prepared = true
19
- end
20
-
21
- def insert_middleware_after_secure_headers
22
- instance = self
23
-
24
- Rollbar::Railtie.initializer 'rollbar.js.frameworks.rails', :after => 'secure_headers.middleware' do |_app|
25
- instance.insert_middleware
26
- end
27
- end
28
-
29
- def insert_middleware
30
- require 'rollbar/js/middleware'
31
-
32
- config = {
33
- :options => Rollbar.configuration.js_options,
34
- :enabled => Rollbar.configuration.js_enabled
35
- }
36
- rails_config.middleware.use(::Rollbar::Js::Middleware, config)
37
- end
38
-
39
- def secure_headers?
40
- defined?(::SecureHeaders)
41
- end
42
-
43
- def rails_config
44
- ::Rails.configuration
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,5 +0,0 @@
1
- module Rollbar
2
- module Js
3
- VERSION = "0.1.0"
4
- end
5
- end