Sha256: b696c447de0b4a91980967fbac2668624c2e6355ef239376b350e0cfebf4cca6

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

module Appsignal
  class JSExceptionTransaction
    attr_reader :uuid, :ext

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

      set_action
      set_metadata
      set_error
      set_sample_data
    end

    def set_action
      @ext.set_action(@data['action']) if @data['action']
    end

    def set_metadata
      @ext.set_metadata(
        'path', @data['path']
      ) if @data['path']
    end

    def set_error
      @ext.set_error(
        @data['name'],
        @data['message'] || '',
        Appsignal::Utils.data_generate(@data['backtrace'] || [])
      )
    end

    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

    def complete!
      @ext.finish
      @ext.complete
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appsignal-2.0.2 lib/appsignal/js_exception_transaction.rb
appsignal-2.0.1 lib/appsignal/js_exception_transaction.rb
appsignal-2.0.0 lib/appsignal/js_exception_transaction.rb
appsignal-2.0.0.beta.1 lib/appsignal/js_exception_transaction.rb