class Suspenders::Production::ErrorReportingGenerator

Public Instance Methods

add_sentry() click to toggle source
# File lib/suspenders/generators/production/error_reporting_generator.rb, line 7
def add_sentry
  gem "sentry-raven"
  Bundler.with_clean_env { run "bundle install" }
end
configure_sentry_context() click to toggle source
# File lib/suspenders/generators/production/error_reporting_generator.rb, line 16
def configure_sentry_context
  inject_into_class(
    "app/controllers/application_controller.rb",
    'ApplicationController',
    context_configuration
  )
end
env_vars() click to toggle source
# File lib/suspenders/generators/production/error_reporting_generator.rb, line 24
def env_vars
  expand_json(
    "app.json",
    env: {
      SENTRY_DSN: { required: true },
      SENTRY_ENV: { required: true }
    }
  )
end
set_up_sentry() click to toggle source
# File lib/suspenders/generators/production/error_reporting_generator.rb, line 12
def set_up_sentry
  copy_file "sentry.rb", "config/initializers/sentry.rb"
end

Private Instance Methods

context_configuration() click to toggle source
# File lib/suspenders/generators/production/error_reporting_generator.rb, line 36
      def context_configuration
        <<-RUBY
  before_action :set_raven_context

  private

  def set_raven_context
    Raven.user_context(id: session[:current_user_id])
    Raven.extra_context(params: params.to_unsafe_h, url: request.url)
  end
        RUBY
      end