Class: Appsignal::JSExceptionTransaction
- Defined in:
- lib/appsignal/js_exception_transaction.rb
Instance Attribute Summary collapse
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #complete! ⇒ Object
-
#initialize(data) ⇒ JSExceptionTransaction
constructor
A new instance of JSExceptionTransaction.
- #set_action ⇒ Object
- #set_error ⇒ Object
- #set_metadata ⇒ Object
- #set_sample_data ⇒ Object
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
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
5 6 7 |
# File 'lib/appsignal/js_exception_transaction.rb', line 5 def ext @ext end |
#uuid ⇒ Object (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_action ⇒ Object
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_error ⇒ Object
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_metadata ⇒ Object
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_data ⇒ Object
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 |