Class: Sqreen::RequestRecord

Inherits:
Event
  • Object
show all
Defined in:
lib/sqreen/events/request_record.rb

Overview

When a request is deeemed worthy of being sent to the backend

Instance Attribute Summary collapse

Attributes inherited from Event

#payload, #time

Instance Method Summary collapse

Methods inherited from Event

#to_s

Constructor Details

#initialize(payload, redactor = nil) ⇒ RequestRecord

Returns a new instance of RequestRecord.

Parameters:



20
21
22
23
# File 'lib/sqreen/events/request_record.rb', line 20

def initialize(payload, redactor = nil)
  @redactor = redactor
  super(payload)
end

Instance Attribute Details

#redactorObject (readonly)

Returns the value of attribute redactor.



16
17
18
# File 'lib/sqreen/events/request_record.rb', line 16

def redactor
  @redactor
end

Instance Method Details

#last_identify_argsObject



29
30
31
32
33
34
35
36
37
# File 'lib/sqreen/events/request_record.rb', line 29

def last_identify_args
  return nil unless observed[:sdk]

  observed[:sdk].reverse_each do |meth, _time, *args|
    next unless meth == :identify
    return args
  end
  nil
end

#observedObject



25
26
27
# File 'lib/sqreen/events/request_record.rb', line 25

def observed
  (payload && payload[:observed]) || {}
end

#processed_sdk_callsObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sqreen/events/request_record.rb', line 39

def processed_sdk_calls
  return [] unless observed[:sdk]
  auth_keys = last_identify_id

  observed[:sdk].map do |meth, time, *args|
    {
      :name => meth,
      :time => time,
      :args => inject_identifiers(args, meth, auth_keys),
    }
  end
end