@@ -41,8 +41,15 @@ type Mixpanel interface {
4141 Import (distinctId , eventName string , e * Event ) error
4242
4343 // Set properties for a mixpanel user.
44+ // Deprecated: Use UpdateUser instead
4445 Update (distinctId string , u * Update ) error
4546
47+ // Set properties for a mixpanel user.
48+ UpdateUser (distinctId string , u * Update ) error
49+
50+ // Set properties for a mixpanel group.
51+ UpdateGroup (groupKey , groupId string , u * Update ) error
52+
4653 // Create an alias for an existing distinct id
4754 Alias (distinctId , newId string ) error
4855}
@@ -158,7 +165,14 @@ func (m *mixpanel) Import(distinctId, eventName string, e *Event) error {
158165
159166// Update updates a user in mixpanel. See
160167// https://mixpanel.com/help/reference/http#people-analytics-updates
168+ // Deprecated: Use UpdateUser instead
161169func (m * mixpanel ) Update (distinctId string , u * Update ) error {
170+ return m .UpdateUser (distinctId , u )
171+ }
172+
173+ // UpdateUser: Updates a user in mixpanel. See
174+ // https://mixpanel.com/help/reference/http#people-analytics-updates
175+ func (m * mixpanel ) UpdateUser (distinctId string , u * Update ) error {
162176 params := map [string ]interface {}{
163177 "$token" : m .Token ,
164178 "$distinct_id" : distinctId ,
@@ -180,6 +194,20 @@ func (m *mixpanel) Update(distinctId string, u *Update) error {
180194 return m .send ("engage" , params , autoGeolocate )
181195}
182196
197+ // UpdateGroup: Updates a group in mixpanel. See
198+ // https://api.mixpanel.com/groups#group-set
199+ func (m * mixpanel ) UpdateGroup (groupKey , groupId string , u * Update ) error {
200+ params := map [string ]interface {}{
201+ "$token" : m .Token ,
202+ "$group_id" : groupId ,
203+ "$group_key" : groupKey ,
204+ }
205+
206+ params [u .Operation ] = u .Properties
207+
208+ return m .send ("groups" , params , false )
209+ }
210+
183211func (m * mixpanel ) to64 (data []byte ) string {
184212 return base64 .StdEncoding .EncodeToString (data )
185213}
0 commit comments