Method: Segment::Analytics::Client#identify
- Defined in:
- lib/segment/analytics/client.rb
#identify(attrs) ⇒ Object
public: Identifies a user
attrs - Hash
:anonymous_id - String of the user's id when you don't know who they are yet. (optional but you must provide either an anonymous_id or user_id. See: https://segment.io/docs/tracking - api/track/#user - id)
:context - Hash of context. (optional)
:integrations - Hash specifying what integrations this event goes to. (optional)
:options - Hash specifying options such as user traits. (optional)
:timestamp - Time of when the event occurred. (optional)
:traits - Hash of user traits. (optional)
:user_id - String of the user id
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/segment/analytics/client.rb', line 98 def identify attrs symbolize_keys! attrs check_user_id! attrs traits = attrs[:traits] || {} = attrs[:timestamp] || Time.new context = attrs[:context] || {} fail ArgumentError, 'Must supply traits as a hash' unless traits.is_a? Hash isoify_dates! traits add_context context enqueue({ :userId => attrs[:user_id], :anonymousId => attrs[:anonymous_id], :integrations => attrs[:integrations], :context => context, :traits => traits, :options => attrs[:options], :timestamp => datetime_in_iso8601(), :type => 'identify' }) end |