Skip to content

Commit

Permalink
fix: set_group put group_type/group_name in groups attribute (#28)
Browse files Browse the repository at this point in the history
Put group_type and group_name in groups attributes of IdentifyEvent instead of user_properties.
  • Loading branch information
bohan-amplitude authored Jun 22, 2022
1 parent 33d4c5c commit 828040e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/amplitude/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def set_group(self, group_type: str, group_name: Union[str, List[str]], event_op
event_options (amplitude.event.EventOptions): Provide additional information for event
like user_id.
"""
identify_obj = Identify()
identify_obj.set(group_type, group_name)
self.identify(identify_obj, event_options)
event = IdentifyEvent(groups={group_type: group_name})
event.load_event_options(event_options)
self.track(event)

def flush(self):
"""Flush all event waiting to be sent in the buffer
Expand Down
4 changes: 2 additions & 2 deletions src/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ def test_amplitude_set_group_success(self):
def callback_func(event, code, message=None):
self.assertEqual(200, code)
self.assertTrue(isinstance(event, IdentifyEvent))
self.assertTrue("user_properties" in event)
self.assertTrue("groups" in event)
self.assertEqual("$identify", event["event_type"])
self.assertEqual("test_user_id", event["user_id"])
self.assertEqual("test_device_id", event["device_id"])
self.assertEqual({"$set": {"type": ["test_group", "test_group_2"]}}, event.user_properties)
self.assertEqual({"type": ["test_group", "test_group_2"]}, event.groups)

self.client.configuration.callback = callback_func
for use_batch in (True, False):
Expand Down

0 comments on commit 828040e

Please sign in to comment.