New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add helper to inject Rollbar.js configuration and snippet #569
Comments
@tisba is in our roadmap improving the rollbar.js integration in the gem, but we'd like continuing with this automatic injection. We can provide eventually a flag to add or not automatically and then use a helper, yes. |
scary/fragile indeed; 👍 for being able to control this |
👍 I've stumbled upon this issue while trying to find how to even put that snipet there. |
I ran into this as well. I need to do some munging of I hacked a helper to inject the snippet, but would love an official way to include the snippet that doesn't rely on Rollbar's private internals 😬 For reference, here's my helper: require 'rollbar/middleware/js'
module RollbarHelper
def rollbar_js_snippet
Rollbar::Middleware::Js::SNIPPET.html_safe
end
end (If you use this helper I'd recommend writing an accompanying test/spec to make sure that nothing breaks when upgrading Rollbar, since the helper relies on an unofficial API). |
I am curious what cannot be accomplished in the initializer? So you are handling the config injection yourself, and then using this helper method in your view to put the snippet after your definition of _rollbarConfig? We can probably just expose essentially this helper of yours and make the injection configurable. |
I'd like to use the <script>
var _rollbarConfig = {
accessToken: "<%= ENV['rollbar_client_token'] %>",
captureUncaught: true,
payload: {
environment: "<%= Rails.env %>"
},
hostWhiteList: ['<%= request.host %>'] // 👈 Dynamically set hostWhiteList
};
<%= rollbar_js_snippet %>
</script> Another solution would be to allow a
That — and/or support for procs in the initializer — would be cool 👍 |
Hi there, I’m closing out all issues opened before 2018 that haven’t had any activity on them since the start of this year. If this is still an issue for you, please comment here and we can reopen this. Thanks! |
The magic that is used in the middleware is quite scary and does not allow where the snippets gets injected. We wrote a very simple application helper to have more control over when and how the code for Rollbar.js gets injected.
It would be nice, if the
rollbar-gem
could provide a helper itself to do that.The text was updated successfully, but these errors were encountered: