Class: RudderAnalyticsSync::Operations::Track
- Defined in:
- lib/rudder_analytics_sync/operations/track.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
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_payload ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rudder_analytics_sync/operations/track.rb', line 17 def build_payload raise ArgumentError, 'event name must be present' unless [:event] properties = [:properties] && isoify_dates!([:properties]) if properties base_payload[:properties] = properties end base_payload.merge( event: [:event] ) end |
#call ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rudder_analytics_sync/operations/track.rb', line 6 def call batch = build_payload.merge( type: 'track' ) if batch.inspect.length > MAX_MESSAGE_SIZE raise ArgumentError, 'Max message size is 32 KB' end request.post('/v1/batch', batch: [batch]) end |