Skip to content

Instantly share code, notes, and snippets.

@ryanmarshall
Created June 5, 2020 19:35
Show Gist options
  • Save ryanmarshall/f4295350d09bc516a3af5b14cca193e7 to your computer and use it in GitHub Desktop.
Save ryanmarshall/f4295350d09bc516a3af5b14cca193e7 to your computer and use it in GitHub Desktop.
Rollbar.configure do |config|
# Without configuration, Rollbar is enabled in all environments.
# To disable in specific environments, set config.enabled=false.
config.access_token = ENV['ROLLBAR_ACCESS_TOKEN'] || Rails.application.secrets.rollbar_access_token
# Here we'll disable in 'test' and 'dev':
if Rails.env.test? or Rails.env.development?
config.enabled = false
end
# By default, Rollbar will try to call the `current_user` controller method
# to fetch the logged-in user object, and then call that object's `id`,
# `username`, and `email` methods to fetch those properties. To customize:
# config.person_method = "my_current_user"
# config.person_id_method = "my_id"
# config.person_username_method = "my_username"
# config.person_email_method = "my_email"
# If you want to attach custom data to all exception and message reports,
# provide a lambda like the following. It should return a hash.
# config.custom_data_method = lambda { {:some_key => "some_value" } }
# Add exception class names to the exception_level_filters hash to
# change the level that exception is reported at. Note that if an exception
# has already been reported and logged the level will need to be changed
# via the rollbar interface.
# Valid levels: 'critical', 'error', 'warning', 'info', 'debug', 'ignore'
# 'ignore' will cause the exception to not be reported at all.
# config.exception_level_filters.merge!('MyCriticalException' => 'critical')
#
# You can also specify a callable, which will be called with the exception instance.
# config.exception_level_filters.merge!('MyCriticalException' => lambda { |e| 'critical' })
# Enable asynchronous reporting (uses girl_friday or Threading if girl_friday
# is not installed)
config.use_async = true
# Supply your own async handler:
# config.async_handler = Proc.new { |payload|
# Thread.new { Rollbar.process_from_async_handler(payload) }
# }
# Enable asynchronous reporting (using sucker_punch)
# config.use_sucker_punch
# Enable delayed reporting (using Sidekiq)
# config.use_sidekiq
# You can supply custom Sidekiq options:
# config.use_sidekiq 'queue' => 'default'
config.js_enabled = true
config.js_options = {
accessToken: Rails.application.secrets.rollbar_access_token,
captureUncaught: (Rails.env.production? ? true : false),
# captureUncaught: true,
captureUnhandledRejections: true,
payload: {
environment: Rails.env,
server: {
root: "webpack:///./app/javascript/"
},
client: {
javascript: {
# sourceMappingURL: ActionController::Base.helpers.asset_url('/packs/application.js.map'),
source_map_enabled: true, # true by default
# // -- Add this into your configuration ---
code_version: Rails.application.secrets.rollbar_code_version || `git rev-parse HEAD`.strip,
# // ---------------------------------------
# // Optionally have Rollbar guess which frames the error was
# // thrown from when the browser does not provide line
# // and column numbers.
guess_uncaught_frames: true
}
}
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment