Class: PostHog::FieldParser Private
- Inherits:
-
Object
- Object
- PostHog::FieldParser
- Defined in:
- lib/posthog/field_parser.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Converts public SDK method arguments into PostHog API event payloads.
Constant Summary
Constants included from Utils
Utils::UTC_OFFSET_WITHOUT_COLON, Utils::UTC_OFFSET_WITH_COLON
Class Method Summary collapse
-
.parse_for_alias(fields) ⇒ Hash
private
In addition to the common fields, alias accepts:.
-
.parse_for_capture(fields) ⇒ Hash
private
In addition to the common fields, capture accepts:.
- .parse_for_group_identify(fields) ⇒ Hash private
-
.parse_for_identify(fields) ⇒ Hash
private
In addition to the common fields, identify accepts:.
Methods included from Logging
Methods included from Utils
convert_to_datetime, date_in_iso8601, datetime_in_iso8601, deep_symbolize_keys, formatted_offset, get_by_symbol_or_string_key, is_valid_regex, 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) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
In addition to the common fields, alias accepts:
-
“alias”
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/posthog/field_parser.rb', line 106 def parse_for_alias(fields) common = parse_common_fields(fields) distinct_id = common[:distinct_id] # must both be set and move to properties alias_field = fields[:alias] check_presence! alias_field, 'alias' common.merge( { type: 'alias', event: '$create_alias', distinct_id: distinct_id, properties: { distinct_id: distinct_id, alias: alias_field }.merge( common[:properties] || {} ) } ) end |
.parse_for_capture(fields) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
In addition to the common fields, capture accepts:
-
“event”
-
“properties”
-
“groups”
-
“uuid”
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/posthog/field_parser.rb', line 22 def parse_for_capture(fields) common = parse_common_fields(fields) event = fields[:event] properties = fields[:properties] || {} groups = fields[:groups] uuid = fields[:uuid] check_presence!(event, 'event') check_is_hash!(properties, 'properties') if groups check_is_hash!(groups, 'groups') properties['$groups'] = groups end isoify_dates! properties common['uuid'] = uuid if valid_uuid_for_event_props? uuid common.merge( { type: 'capture', event: event.to_s, properties: properties.merge(common[:properties] || {}) } ) end |
.parse_for_group_identify(fields) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/posthog/field_parser.rb', line 75 def parse_for_group_identify(fields) properties = fields[:properties] || {} group_type = fields[:group_type] group_key = fields[:group_key] check_presence!(group_type, 'group type') check_presence!(group_key, 'group_key') check_is_hash!(properties, 'properties') fields[:distinct_id] ||= "$#{group_type}_#{group_key}" common = parse_common_fields(fields) isoify_dates! properties common.merge( { event: '$groupidentify', properties: { '$group_type': group_type, '$group_key': group_key, '$group_set': properties.merge(common[:properties] || {}) } } ) end |
.parse_for_identify(fields) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
In addition to the common fields, identify accepts:
-
“properties”
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/posthog/field_parser.rb', line 55 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 |