Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/amplitude_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ def track(*events)

# ==== Identification related methods

def send_identify(user_id, device_id, user_properties = {})
def send_identify(user_id, device_id, user_properties = {}, groups = [])
identification = AmplitudeAPI::Identification.new(
user_id: user_id,
device_id: device_id,
user_properties: user_properties
user_properties: user_properties,
groups: groups
)
identify(identification)
end
Expand Down
12 changes: 9 additions & 3 deletions lib/amplitude_api/identification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ class Identification
# @!attribute [ rw ] user_properties
# @return [ String ] the user_properties to be attached to the Amplitude Identify
attr_accessor :user_properties
# @!attribute [ rw ] groups
# @return [ String ] the groups to be attached to the Amplitude Identify
attr_accessor :groups

# Create a new Identification
#
# @param [ String ] user_id a user_id to associate with the identification
# @param [ String ] device_id a device_id to associate with the identification
# @param [ Hash ] user_properties various properties to attach to the user identification
def initialize(user_id: "", device_id: nil, user_properties: {})
def initialize(user_id: "", device_id: nil, user_properties: {}, groups: [])
self.user_id = user_id
self.device_id = device_id if device_id
self.device_id = device_id
self.user_properties = user_properties
self.groups = groups
end

def user_id=(value)
Expand All @@ -39,8 +43,10 @@ def user_id=(value)
def to_hash
{
user_id: user_id,
device_id: device_id,
groups: groups,
user_properties: user_properties
}.tap { |hsh| hsh[:device_id] = device_id if device_id }
}.compact
end

# @return [ true, false ]
Expand Down