Sha256: 6c95623af2ac65f8562d662dd55d12c2b2c05705eed7b8797df37245bdd97fb9

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

module RudderAnalyticsSync
  module Operations
    class Identify < Operation
      def call
        batch = build_payload.merge(
          type: 'identify'
        )
        if batch.inspect.length > MAX_MESSAGE_SIZE
          raise ArgumentError, 'Max message size is 32 KB'
        end

        request.post('/v1/batch', { 'batch' => [batch] })
      end

      def build_payload
        merged_payload = base_payload
        if options[:traits]
          merged_payload = merged_payload.merge(
            traits: options[:traits] && isoify_dates!(options[:traits])
          )
          merged_payload[:context][:traits] = options[:traits] && isoify_dates!(options[:traits])
        end
        merged_payload
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rudder_analytics_sync-2.0.1 lib/rudder_analytics_sync/operations/identify.rb