Class: PostHog::FieldParser
- Inherits:
-
Object
- Object
- PostHog::FieldParser
- Extended by:
- Utils
- Defined in:
- lib/posthog/field_parser.rb
Constant Summary
Constants included from Utils
Utils::UTC_OFFSET_WITHOUT_COLON, Utils::UTC_OFFSET_WITH_COLON
Class Method Summary collapse
-
.parse_for_alias(fields) ⇒ Object
In addition to the common fields, alias accepts:.
-
.parse_for_capture(fields) ⇒ Object
In addition to the common fields, capture accepts:.
-
.parse_for_identify(fields) ⇒ Object
In addition to the common fields, identify accepts:.
Methods included from Utils
date_in_iso8601, datetime_in_iso8601, formatted_offset, isoify_dates, isoify_dates!, seconds_to_utc_offset, stringify_keys, symbolize_keys, symbolize_keys!, time_in_iso8601, uid
Class Method Details
.parse_for_alias(fields) ⇒ Object
In addition to the common fields, alias accepts:
-
“alias”
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/posthog/field_parser.rb', line 50 def parse_for_alias(fields) common = parse_common_fields(fields) distinct_id = common[:distinct_id] # must move to properties... alias_field = fields[:alias] check_presence! alias_field, 'alias' common.merge({ :type => 'alias', :event => '$create_alias', :distinct_id => nil, :properties => { :distinct_id => distinct_id, :alias => alias_field, }.merge(common[:properties] || {}) }) end |
.parse_for_capture(fields) ⇒ Object
In addition to the common fields, capture accepts:
-
“event”
-
“properties”
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/posthog/field_parser.rb', line 10 def parse_for_capture(fields) common = parse_common_fields(fields) event = fields[:event] properties = fields[:properties] || {} check_presence!(event, 'event') check_is_hash!(properties, 'properties') isoify_dates! properties common.merge({ :type => 'capture', :event => event.to_s, :properties => properties.merge(common[:properties] || {}) }) end |
.parse_for_identify(fields) ⇒ Object
In addition to the common fields, identify accepts:
-
“properties”
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/posthog/field_parser.rb', line 31 def parse_for_identify(fields) common = parse_common_fields(fields) properties = fields[:properties] || {} check_is_hash!(properties, 'properties') isoify_dates! properties common.merge({ :type => 'identify', :event => '$identify', :'$set' => properties, :properties => properties.merge(common[:properties] || {}) }) end |