rollbar-gem
rollbar-gem copied to clipboard
v3.3.1 - Causes breaking change - RollbarJS no longer loading
We upgraded from v3.3.0 to v3.3.1 and this caused the rollbar js to stop being loaded by Rails (that is the embed script is never added).
Reverting to v3.3.0 solved this.
We get this error in our logs
E, [2022-07-17T23:25:26.700460 #25] ERROR -- : [364578a8-5ed5-4186-8bda-d4cc5f59f7b7] [Rollbar] Rollbar.js could not be added because uninitialized constant Rollbar::JSON::JsOptionsState exception
It appears to have been introduced by @waltjones in https://github.com/rollbar/rollbar-gem/pull/1089
For reference, your rollbar.rb file looks like
if defined? Rollbar
Rollbar.configure do |config|
config.access_token = ENV['ROLLBAR_ACCESS_TOKEN']
config.enabled = false if Rails.env.test?
config.js_enabled = true
config.js_options = {
accessToken: ENV['ROLLBAR_ACCESS_TOKEN'],
captureUncaught: true,
payload: {
environment: ENV['ROLLBAR_ENV'] || Rails.env
},
autoInstrument: {
contentSecurityPolicy: true,
errorOnContentSecurityPolicy: true
}
}
config.person_username_method = 'account_name'
config.person_email_method = 'email'
config.custom_data_method = -> { { account: defined?(current_account) ? current_account.unique_id : 'unknown' } }
config.exception_level_filters['ActionController::RoutingError'] = 'ignore'
config.environment = ENV['ROLLBAR_ENV'] || Rails.env
config.scrub_fields |= ['sess', '__Host-sess']
end
end
Try to change from:
config.js_options = {
accessToken: ENV['ROLLBAR_ACCESS_TOKEN']
To:
config.js_options = {
accessToken: ENV['POST_CLIENT_ITEM_TOKEN']
You can find post client item token in your rollbar interface
Same problem here, with an almost vanilla config.
config.js_enabled = true
config.js_options = {
accessToken: ENV["ROLLBAR_POST_CLIENT_ITEM_ACCESS_TOKEN"],
captureUncaught: true,
payload: {
environment: config.environment
}
Reverting to 3.3.0 makes it work again.
I think I've tracked this down.
In line 144 of lib/rollbar/middleware/js.rb, it calls Rollbar::JSON::JsOptionsState.new, in my environment (Ruby 3.1.0, Rails 6.1.6.1), this throws with a NameError because it can't find the constant.
We just noticed this recently, as we haven't been getting js errors in a while when we should have been.
You can add require 'rollbar/middleware/js/json_value' to the top of config/initializers/rollbar.rb for the time being.
Here is the exact line (with rev) that @scottb found this problem to be: https://github.com/rollbar/rollbar-gem/compare/v3.3.0...v3.3.1#diff-d5202929c8268c54895def2587ba3efc829245c433997334366a16462d57bad7R144
(We have the issue too and are rolling back).
Hello Rollbar team, is there an option to fix it somehow/revert changes causing this issue and put it in the newest release? As the users of this gem wanting to keep up-to-date with the changes, we don't have an option to use one important feature of Rollbar this way - the feature convincing some of us to use higher plans or paying more (because of higher limits of handled occurrences), I don't know how is it possible such problem has not been fixed/noticed by Rollbar for 3 months?!
@waltjones could you look at it? 🥺
Apologies for the delay. Will have an update out asap.
This fix is released in v3.3.3.
Thanks @waltjones