Class: Sentiero::Reporter::ReportContext

Inherits:
Object
  • Object
show all
Defined in:
lib/sentiero/reporter/report_context.rb

Overview

Splits a Context into the reserved keys that become top-level fields on an error report (session_id, window_id) and the remaining metadata that goes under the report's "context".

Constant Summary collapse

RESERVED =
%w[session_id window_id].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ReportContext

Returns a new instance of ReportContext.



11
12
13
14
15
16
17
18
19
# File 'lib/sentiero/reporter/report_context.rb', line 11

def initialize(context)
  data = context.to_h
  @reserved = {}
  RESERVED.each do |key|
    value = data.delete(key)
    @reserved[key] = value unless value.nil?
  end
  @metadata = data
end

Instance Attribute Details

#metadataObject (readonly)

Mutable so the caller can inject environment/release before scrubbing.



26
27
28
# File 'lib/sentiero/reporter/report_context.rb', line 26

def 
  @metadata
end

Instance Method Details

#session_idObject



21
# File 'lib/sentiero/reporter/report_context.rb', line 21

def session_id = @reserved["session_id"]

#window_idObject



23
# File 'lib/sentiero/reporter/report_context.rb', line 23

def window_id = @reserved["window_id"]