Class: ActionReporter::SentryReporter

Inherits:
Base
  • Object
show all
Defined in:
lib/action_reporter/sentry_reporter.rb

Instance Method Summary collapse

Methods inherited from Base

class_accessor, #merge_context_updates, #resolve_check_in_id, #resolve_user_id, #transform_context

Instance Method Details

#context(args) ⇒ Object



17
18
19
# File 'lib/action_reporter/sentry_reporter.rb', line 17

def context(args)
  apply_reporter_context(merge_context_updates(current_reporter_context, args))
end

#current_user=(user) ⇒ Object



25
26
27
28
# File 'lib/action_reporter/sentry_reporter.rb', line 25

def current_user=(user)
  id = resolve_user_id(user)
  sentry_class.set_user(id: id)
end

#notify(error, context: {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/action_reporter/sentry_reporter.rb', line 5

def notify(error, context: {})
  sentry_class.with_scope do |temp_scope|
    temp_scope.set_context("context", transform_context(context))

    if error.is_a?(StandardError)
      sentry_class.capture_exception(error)
    else
      sentry_class.capture_message(error)
    end
  end
end

#reset_contextObject



21
22
23
# File 'lib/action_reporter/sentry_reporter.rb', line 21

def reset_context
  apply_reporter_context({})
end

#transaction_id=(transaction_id) ⇒ Object



30
31
32
# File 'lib/action_reporter/sentry_reporter.rb', line 30

def transaction_id=(transaction_id)
  sentry_class.set_tags(transaction_id: transaction_id)
end

#transaction_name=(transaction_name) ⇒ Object



34
35
36
37
38
# File 'lib/action_reporter/sentry_reporter.rb', line 34

def transaction_name=(transaction_name)
  sentry_class.configure_scope do |scope|
    scope.set_transaction_name(transaction_name)
  end
end