Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set_group put group_type/group_name in groups attribute #28

Merged
merged 3 commits into from
Jun 22, 2022
Merged
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
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 @@ -174,11 +174,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