rollbar-gem
rollbar-gem copied to clipboard
There is any way to disable js wrapper at controller level?
Hi, I need to disable the js inclusion for some specific actions. There is any way I could achieve this?
Thanks
@waltjones could you take a look at this?
@ngelx, There is an env key rollbar-gem uses internally to ensure the JS is never injected twice to the same response. You can put this in your controller before render, and it will skip injecting the JS for that request.
request.env['rollbar.js_is_injected'] = true
However, I should not be recommending this. It's undocumented and should be treated as subject to change. Still, it's there and that's how it works.
Maybe it would make sense to add a documented, reliable flag. I'll reply here with any update on that.
@waltjones thanks! adding a documented interface for disabling this would be amazing. In the mean time, I've abstracted like:
class ApplicationController < ActionController::Base
...
def do_not_injet_rollbar_js
request.env['rollbar.js_is_injected'] = true
end
...
end
And then, used in controller like:
before_action :do_not_injet_rollbar_js, only: :some_action
Mark as enhancement, to add a documented request.env['rollbar.skip_js_injection'] or similarly named env flag.
Thank you very much @waltjones and @ngelx!!