Module: SentryControllerLogging

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController, SignIn::ApplicationController, SignIn::ServiceAccountApplicationController
Defined in:
app/controllers/concerns/sentry_controller_logging.rb

Instance Method Summary collapse

Instance Method Details

#set_tags_and_extra_contextObject (private)



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/concerns/sentry_controller_logging.rb', line 10

def set_tags_and_extra_context
  RequestStore.store['request_id'] = request.uuid
  RequestStore.store['additional_request_attributes'] = {
    'remote_ip' => request.remote_ip,
    'user_agent' => request.user_agent,
    'user_uuid' => current_user&.uuid,
    'source' => request.headers['Source-App-Name']
  }
  Sentry.set_extras(request_uuid: request.uuid)
  Sentry.set_user(user_context) if current_user
  Sentry.set_tags(tags_context)
end

#tags_contextObject (private)



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/concerns/sentry_controller_logging.rb', line 32

def tags_context
  { controller_name: }.tap do |tags|
    if current_user.present?
       = current_user.respond_to?(:identity) ? current_user.identity. : current_user.
      tags[:sign_in_method] = [:service_name]
      # account_type is filtered by sentry, becasue in other contexts it refers to a bank account type
      tags[:sign_in_acct_type] = [:account_type]
    else
      tags[:sign_in_method] = 'not-signed-in'
    end
    tags[:source] = request.headers['Source-App-Name'] if request.headers['Source-App-Name']
  end
end

#user_contextObject (private)



23
24
25
26
27
28
29
30
# File 'app/controllers/concerns/sentry_controller_logging.rb', line 23

def user_context
  {
    id: current_user&.uuid,
    authn_context: current_user&.authn_context,
    loa: current_user&.loa,
    mhv_icn: current_user&.mhv_icn
  }
end