Sha256: 6f0b45ebeb7e0733e011489e43c44f0d33a3181a345ef741b20de3ef87905732

Contents?: true

Size: 620 Bytes

Versions: 5

Compression:

Stored size: 620 Bytes

Contents

# frozen_string_literal: true

module PagesCore
  module ErrorReporting
    extend ActiveSupport::Concern

    included do
      before_action :configure_sentry_scope
    end

    protected

    def configure_sentry_scope
      return if Rails.env.test? || !Object.const_defined?(:Sentry)

      Sentry.set_context("params", params.to_unsafe_h)
      Sentry.set_tags(locale: params[:locale] || I18n.default_locale.to_s)
      Sentry.set_user(current_user_context)
    end

    def current_user_context
      return {} unless logged_in?

      { id: current_user.id,
        email: current_user.email }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pages_core-3.15.5 app/controllers/concerns/pages_core/error_reporting.rb
pages_core-3.15.4 app/controllers/concerns/pages_core/error_reporting.rb
pages_core-3.15.3 app/controllers/concerns/pages_core/error_reporting.rb
pages_core-3.15.2 app/controllers/concerns/pages_core/error_reporting.rb
pages_core-3.15.1 app/controllers/concerns/pages_core/error_reporting.rb