Module: Eussiror::ContextExtractor

Defined in:
lib/eussiror/context_extractor.rb

Overview

Normalizes heterogeneous Rails.error context payloads into a stable structure consumed by issue formatting.

Class Method Summary collapse

Class Method Details

.normalize(context) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/eussiror/context_extractor.rb', line 8

def normalize(context)
  ctx = context.is_a?(Hash) ? context : {}
  req = request_object(ctx)
  env = nested_hash(ctx, :env) || nested_hash(ctx, :rack)
  headers = nested_hash(ctx, :headers)

  {
    request_method: request_method(ctx, env, req),
    path: request_path(ctx, env, req),
    remote_ip: remote_ip(ctx, env, req),
    user_agent: user_agent(ctx, env, headers, req),
    user_id: user_id(ctx, env),
    user_label: user_label(ctx, env)
  }
end