Sha256: 02e7279558fc82d69f9f2e41c5bcde8edb1db1027b915f45cc5078414c612ec4

Contents?: true

Size: 516 Bytes

Versions: 9

Compression:

Stored size: 516 Bytes

Contents

# frozen_string_literal: true

module Sentry
  # @api private
  class Envelope
    def initialize(headers)
      @headers = headers
      @items = []
    end

    def add_item(headers, payload)
      @items << [headers, payload]
    end

    def to_s
      payload = @items.map do |item_headers, item_payload|
        <<~ENVELOPE
          #{JSON.generate(item_headers)}
          #{JSON.generate(item_payload)}
        ENVELOPE
      end.join("\n")

      "#{JSON.generate(@headers)}\n#{payload}"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sentry-ruby-core-5.1.0 lib/sentry/envelope.rb
sentry-ruby-core-5.0.2 lib/sentry/envelope.rb
sentry-ruby-core-5.0.1 lib/sentry/envelope.rb
sentry-ruby-core-5.0.0 lib/sentry/envelope.rb
sentry-ruby-core-4.9.2 lib/sentry/envelope.rb
sentry-ruby-core-4.9.1 lib/sentry/envelope.rb
sentry-ruby-core-4.9.0 lib/sentry/envelope.rb
sentry-ruby-core-4.8.3 lib/sentry/envelope.rb
sentry-ruby-core-4.8.2 lib/sentry/envelope.rb