Skip to content

Commit

Permalink
feat: add support for invite-type anonymous event tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
hownowstephen authored Apr 26, 2022
2 parents 58967c8 + 8bb42d0 commit 7320010
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions customerio.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,20 @@ func (c *CustomerIO) Track(customerID string, eventName string, data map[string]

// TrackAnonymousCtx sends a single event to Customer.io for the anonymous user
func (c *CustomerIO) TrackAnonymousCtx(ctx context.Context, anonymousID, eventName string, data map[string]interface{}) error {
if anonymousID == "" {
return ParamError{Param: "anonymousID"}
}
if eventName == "" {
return ParamError{Param: "eventName"}
}
return c.request(ctx, "POST",
fmt.Sprintf("%s/api/v1/events", c.URL),
map[string]interface{}{
"name": eventName,
"anonymous_id": anonymousID,
"data": data,
})

payload := map[string]interface{}{
"name": eventName,
"data": data,
}

if anonymousID != "" {
payload["anonymous_id"] = anonymousID
}

return c.request(ctx, "POST", fmt.Sprintf("%s/api/v1/events", c.URL), payload)
}

// TrackAnonymous sends a single event to Customer.io for the anonymous user
Expand Down

0 comments on commit 7320010

Please sign in to comment.