Class: Flame::SentryContext
- Inherits:
-
Object
- Object
- Flame::SentryContext
- Extended by:
- Memery
- Includes:
- Memery
- Defined in:
- lib/flame/sentry_context.rb,
lib/flame/sentry_context/version.rb
Overview
Class for request context initialization
Constant Summary collapse
- DEFAULT_TYPES =
{ puma: { level: :error }.freeze, server: { level: :error }.freeze, not_found: { level: :warning, message: -> { "404: #{@controller.request.path}" } }.freeze, translations: { level: :error, message: -> { "Translation missing: #{@extra[:key]}" } }.freeze, validation_errors: { level: :warning, message: -> { "Validation errors: #{@extra[:form_class]}" } }.freeze }.freeze
- VERSION =
'0.3.1'
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
- #capture_exception(exception) ⇒ Object
- #capture_message ⇒ Object
-
#initialize(type, controller: nil, env: controller&.request&.env, **extra) ⇒ SentryContext
constructor
A new instance of SentryContext.
Constructor Details
#initialize(type, controller: nil, env: controller&.request&.env, **extra) ⇒ SentryContext
Returns a new instance of SentryContext.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/flame/sentry_context.rb', line 53 def initialize( type, controller: nil, env: controller&.request&.env, **extra ) @type = type @type_data = self.class.types[@type] @controller = controller @env = env @user = extra.delete(:user) || instance_exec(&self.class.user_block) @extra = extra end |
Class Attribute Details
.user_block ⇒ Object
42 43 44 |
# File 'lib/flame/sentry_context.rb', line 42 def user_block @user_block ||= -> {} end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
51 52 53 |
# File 'lib/flame/sentry_context.rb', line 51 def exception @exception end |
Instance Method Details
#capture_exception(exception) ⇒ Object
64 65 66 67 68 |
# File 'lib/flame/sentry_context.rb', line 64 def capture_exception(exception) @extra[:sql] = exception.sql if exception.respond_to? :sql Sentry.capture_exception exception, **context end |
#capture_message ⇒ Object
70 71 72 73 74 |
# File 'lib/flame/sentry_context.rb', line 70 def = instance_exec(&@type_data[:message]) Sentry. , **context end |