Sha256: 365540e2b86b81212ba3af10fc7086a2b382b11a1c6707fbd05291046e5e2072

Contents?: true

Size: 758 Bytes

Versions: 4

Compression:

Stored size: 758 Bytes

Contents

# frozen_string_literal: true

module Sentry
  # @api private
  class Envelope
    class Item
      attr_accessor :headers, :payload

      def initialize(headers, payload)
        @headers = headers
        @payload = payload
      end

      def type
        @headers[:type] || 'event'
      end

      def to_s
        <<~ITEM
          #{JSON.generate(@headers)}
          #{JSON.generate(@payload)}
        ITEM
      end
    end

    attr_accessor :headers, :items

    def initialize(headers = {})
      @headers = headers
      @items = []
    end

    def add_item(headers, payload)
      @items << Item.new(headers, payload)
    end

    def item_types
      @items.map(&:type)
    end

    def event_id
      @headers[:event_id]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sentry-ruby-core-5.3.1 lib/sentry/envelope.rb
sentry-ruby-core-5.3.0 lib/sentry/envelope.rb
sentry-ruby-core-5.2.1 lib/sentry/envelope.rb
sentry-ruby-core-5.2.0 lib/sentry/envelope.rb