Sha256: 23cb6216c438c095656b947d63cb5c15a535550bc618a350869c0aadf00a7621

Contents?: true

Size: 1.22 KB

Versions: 146

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

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

146 entries across 146 versions & 1 rubygems

Version Path
appsignal-2.11.10-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.10 lib/appsignal/js_exception_transaction.rb
appsignal-2.11.9-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.9 lib/appsignal/js_exception_transaction.rb
appsignal-2.11.8-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.8 lib/appsignal/js_exception_transaction.rb
appsignal-2.11.7 lib/appsignal/js_exception_transaction.rb
appsignal-2.11.7-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.6 lib/appsignal/js_exception_transaction.rb
appsignal-2.11.6-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.5-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.5 lib/appsignal/js_exception_transaction.rb
appsignal-2.11.4-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.4 lib/appsignal/js_exception_transaction.rb
appsignal-2.11.3-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.3 lib/appsignal/js_exception_transaction.rb
appsignal-2.11.2-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.2 lib/appsignal/js_exception_transaction.rb
appsignal-2.11.1-java lib/appsignal/js_exception_transaction.rb
appsignal-2.11.1 lib/appsignal/js_exception_transaction.rb