@nuux/sentry

Initialize Sentry from a meta tag

Usage no npm install needed!

<script type="module">
  import nuuxSentry from 'https://cdn.skypack.dev/@nuux/sentry';
</script>

README

Nuux::Sentry

Automatically configures Sentry for your Rails application including webpacker.

Installation

Add this line to your application's Gemfile:

gem "nuux-sentry", git: "https://user:password@git.nuux.de/gems/nuux-sentry.git"

And then execute:

$ bundle

Install npm package:

$ yarn add @nuux/sentry

Configuration

Rails

Define SENTRY_DSN as environment variable.

Default configuration

Nuux::Sentry.configure do |config|
  config.environments = %w[staging production]

  config.user = -> { try(:current_user) }  
  config.user_attributes = %i[id username]
  config.browser_user_attributes = config.user_attributes

  config.user_context = -> { { ip_address: request.remote_ip } }
  config.extra_context = -> { { params: params.to_unsafe_h, url: request.url } }
end

Browser

  • Add sentry_meta_tag into the application layout.
  • Add import "@nuux/sentry" in javascripts/packs/application.js as first line.

License

The gem is available as open source under the terms of the MIT License.