Skip to content

Commit

Permalink
🔄 Sync from monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
mojo-machine[bot] committed May 15, 2024
1 parent 14443b7 commit 4242094
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/datahappy/datahappy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ var library = &Library{
type Client struct {
client *jsonclient.Client

ProjectID string
AuthToken string
}

func NewClient(baseURL, authToken string) *Client {
func NewClient(baseURL, projectID, authToken string) *Client {
return &Client{
client: jsonclient.NewClient(
baseURL,
httpclient.NewClient(5*time.Second, nil),
),

ProjectID: projectID,
AuthToken: authToken,
}
}
5 changes: 5 additions & 0 deletions lib/datahappy/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
)

type TrackRequest struct {
ProjectID string `json:"projectId"`
Type RequestType `json:"type"`
AnonymousID string `json:"anonymousId,omitempty"`
UserID string `json:"userId,omitempty"`
Expand All @@ -34,6 +35,10 @@ func (c *Client) Track(ctx context.Context, req *TrackRequest) error {
// ensure no mutation of the original request
req = ptr.ShallowCopy(req)

if req.ProjectID == "" {
req.ProjectID = c.ProjectID
}

if req.Type == "" {
req.Type = RequestTypeTrack
}
Expand Down

0 comments on commit 4242094

Please sign in to comment.