Class: RudderAnalyticsSync::Operations::Identify

Inherits:
Operation
  • Object
show all
Defined in:
lib/rudder_analytics_sync/operations/identify.rb

Constant Summary

Constants included from Constants

Constants::BASE_URL, Constants::DEFAULT_CONTEXT, Constants::DEFAULT_HEADERS, Constants::MAX_BATCH_SIZE, Constants::MAX_MESSAGE_SIZE

Constants included from Utils

Utils::UTC_OFFSET_WITHOUT_COLON, Utils::UTC_OFFSET_WITH_COLON

Instance Method Summary collapse

Methods inherited from Operation

#initialize, #make_context

Methods included from Utils

#date_in_iso8601, #formatted_offset, included, #isoify_dates, #isoify_dates!, #maybe_datetime_in_iso8601, #seconds_to_utc_offset, #symbolize_keys, #time_in_iso8601, #uid, #valid_date?

Constructor Details

This class inherits a constructor from RudderAnalyticsSync::Operations::Operation

Instance Method Details

#build_payloadObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/rudder_analytics_sync/operations/identify.rb', line 17

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

#callObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/rudder_analytics_sync/operations/identify.rb', line 6

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