Sha256: 5b2a2f226ec6a89729058d036ffa7ceda07d90eaca17961821911fb81f5e92dc

Contents?: true

Size: 1.19 KB

Versions: 38

Compression:

Stored size: 1.19 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
      return unless @data["action"]
      ext.set_action(@data["action"])
    end

    def set_metadata
      return unless @data["path"]
      ext.set_metadata("path", @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(0)
      ext.complete
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
appsignal-2.4.1 lib/appsignal/js_exception_transaction.rb
appsignal-2.4.0 lib/appsignal/js_exception_transaction.rb
appsignal-2.4.0.alpha.1 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.7 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.6 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.6.beta.1 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.4 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.3 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.3.beta.1 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.2 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.1 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.0 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.0.beta.3 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.0.beta.2 lib/appsignal/js_exception_transaction.rb
appsignal-2.3.0.beta.1 lib/appsignal/js_exception_transaction.rb
appsignal-2.2.1 lib/appsignal/js_exception_transaction.rb
appsignal-2.2.0 lib/appsignal/js_exception_transaction.rb
appsignal-2.2.0.beta.1 lib/appsignal/js_exception_transaction.rb