Sha256: f699f9d6bb63b175b5e1d7243536c26ac407a636e0595f987e4e453c155edaba

Contents?: true

Size: 621 Bytes

Versions: 2

Compression:

Stored size: 621 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

2 entries across 2 versions & 1 rubygems

Version Path
pages_core-3.14.0 app/controllers/concerns/pages_core/error_reporting.rb
pages_core-3.13.0 app/controllers/concerns/pages_core/error_reporting.rb