Skip to content

Commit

Permalink
pass along anonymous_id only when not blank
Browse files Browse the repository at this point in the history
  • Loading branch information
hownowstephen committed Apr 25, 2022
1 parent 96437bf commit 8bb42d0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions customerio.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ func (c *CustomerIO) TrackAnonymousCtx(ctx context.Context, anonymousID, eventNa
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 8bb42d0

Please sign in to comment.