Class: Appsignal::JSExceptionTransaction

Inherits:
Object
  • Object
show all
Defined in:
lib/appsignal/js_exception_transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ JSExceptionTransaction

Returns a new instance of JSExceptionTransaction.



7
8
9
10
11
12
13
14
15
16
# File 'lib/appsignal/js_exception_transaction.rb', line 7

def initialize(data)
  @data = data
  @uuid = SecureRandom.uuid
  @ext = Appsignal::Extension.start_transaction(@uuid, Appsignal::Transaction::FRONTEND, 0)

  set_action
  
  set_error
  set_sample_data
end

Instance Attribute Details

#extObject (readonly)

Returns the value of attribute ext.



5
6
7
# File 'lib/appsignal/js_exception_transaction.rb', line 5

def ext
  @ext
end

#uuidObject (readonly)

Returns the value of attribute uuid.



5
6
7
# File 'lib/appsignal/js_exception_transaction.rb', line 5

def uuid
  @uuid
end

Instance Method Details

#complete!Object



51
52
53
54
# File 'lib/appsignal/js_exception_transaction.rb', line 51

def complete!
  ext.finish(0)
  ext.complete
end

#set_actionObject



18
19
20
21
# File 'lib/appsignal/js_exception_transaction.rb', line 18

def set_action
  return unless @data["action"]
  ext.set_action(@data["action"])
end

#set_errorObject



28
29
30
31
32
33
34
# File 'lib/appsignal/js_exception_transaction.rb', line 28

def set_error
  ext.set_error(
    @data["name"],
    @data["message"] || "",
    Appsignal::Utils::Data.generate(@data["backtrace"] || [])
  )
end

#set_metadataObject



23
24
25
26
# File 'lib/appsignal/js_exception_transaction.rb', line 23

def 
  return unless @data["path"]
  ext.("path", @data["path"])
end

#set_sample_dataObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/appsignal/js_exception_transaction.rb', line 36

def set_sample_data
  {
    :params       => @data["params"],
    :session_data => @data["session_data"],
    :environment  => @data["environment"],
    :tags         => @data["tags"]
  }.each do |key, data|
    next unless data.is_a?(Array) || data.is_a?(Hash)
    ext.set_sample_data(
      key.to_s,
      Appsignal::Utils::Data.generate(data)
    )
  end
end