Class: PostHog::MCP::UserIdentity

Inherits:
Struct
  • Object
show all
Defined in:
lib/posthog/mcp/options.rb

Overview

Resolved identity for a session. distinct_id becomes the event's distinct id, properties go to $set, groups ({group_type => group_key}) are stamped on every event as $groups.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#distinct_id ⇒ Object

Returns the value of attribute distinct_id

Returns:

  • (Object) —

    the current value of distinct_id



20
21
22
# File 'lib/posthog/mcp/options.rb', line 20

def distinct_id
  @distinct_id
end

#groups ⇒ Object

Returns the value of attribute groups

Returns:

  • (Object) —

    the current value of groups



20
21
22
# File 'lib/posthog/mcp/options.rb', line 20

def groups
  @groups
end

#properties ⇒ Object

Returns the value of attribute properties

Returns:

  • (Object) —

    the current value of properties



20
21
22
# File 'lib/posthog/mcp/options.rb', line 20

def properties
  @properties
end

Class Method Details

.coerce(value) ⇒ Object

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.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/posthog/mcp/options.rb', line 22

def self.coerce(value)
  case value
  when UserIdentity then value
  when Hash
    distinct_id = value[:distinct_id] || value['distinct_id'] || value[:distinctId] || value['distinctId']
    return nil if distinct_id.nil? || distinct_id.to_s.empty?

    new(
      distinct_id: distinct_id.to_s,
      properties: value[:properties] || value['properties'],
      groups: value[:groups] || value['groups']
    )
  end
end