Skip to content
Open
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
17 changes: 8 additions & 9 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ versions of the library.

To install it in the GOPATH:
```
go get https://github.com/dreamdata-io/analytics-go
go get github.com/dreamdata-io/analytics-go
```

## Usage
Expand All @@ -21,18 +21,17 @@ package main

import (
"os"
"golang.org/x/sync/errgroup"

"github.com/dreamdata-io/analytics-go"
)

func main() {
// Instantiates a client to send messages to the dreamdata API.
client := analytics.New(os.Getenv("DREAMDATA_WRITE_KEY"))
client := analytics.New(os.Getenv("DREAMDATA_API_KEY"))

var err error

err = c.Enqueue(analytics.Identify{
err = client.Enqueue(analytics.Identify{
UserId: "019mr8mf4r",
Traits: analytics.NewTraits().
SetEmail("user@dreamdata.io").
Expand All @@ -43,7 +42,7 @@ func main() {
// do something with your err
}

err = c.Enqueue(analytics.Track{
err = client.Enqueue(analytics.Track{
UserId: "019mr8mf4r",
Event: "Song Played",
Properties: analytics.NewProperties().
Expand All @@ -54,7 +53,7 @@ func main() {
// do something with your err
}

err = c.Enqueue(analytics.Identify{
err = client.Enqueue(analytics.Identify{
UserId: "971mj8mk7p",
Traits: analytics.NewTraits().
SetEmail("user2@dreamdata.io").
Expand All @@ -65,7 +64,7 @@ func main() {
// do something with your err
}

err = c.Enqueue(analytics.Track{
err = client.Enqueue(analytics.Track{
UserId: "971mj8mk7p",
Event: "Song Played",
Properties: analytics.NewProperties().
Expand All @@ -86,13 +85,13 @@ Every method you call does not result in an HTTP request, but is queued in memor

By default, our library will flush:

- Every 20 messages (controlled by `Config.BatchSize`).
- Every 250 messages (controlled by `Config.BatchSize`).
- If 5 seconds has passed since the last flush (controlled by `Config.Interval`)
- There is a maximum of 500KB per batch request and 32KB per call.

If you don’t want to batch messages, you can turn batching off by setting the BatchSize option to 1, like so:
```go
c, err := analytics.NewWithConfig(os.Getenv("DREAMDATA_WRITE_KEY"), analytics.Config{BatchSize: 1})
client, err := analytics.NewWithConfig(os.Getenv("DREAMDATA_API_KEY"), analytics.Config{BatchSize: 1})
```

## Disclaimer
Expand Down
Loading