Readme.md
1
2## Installation
3
4The package can be simply installed via "go get", we recommend that you use a tool like
5Godep to avoid issues related to API breaking changes introduced between major
6versions of the library.
7
8To install it in the GOPATH:
9```
10go get github.com/rudderlabs/analytics-go
11```
12
13
14## Usage
15
16```go
17package main
18
19import (
20 "github.com/rudderlabs/analytics-go"
21)
22
23func main() {
24 // Instantiates a client to use send messages to the Rudder API.
25 // User your WRITE KEY in below placeholder "RUDDER WRITE KEY"
26 client := analytics.New(<WRITE_KEY>, <DATA_PLANE_URL>)
27
28 // Enqueues a track event that will be sent asynchronously.
29 client.Enqueue(analytics.Track{
30 UserId: "test-user",
31 Event: "test-snippet",
32 })
33
34 // Flushes any queued messages and closes the client.
35 client.Close()
36}
37```
38OR
39```go
40package main
41
42import (
43 "github.com/rudderlabs/analytics-go"
44)
45
46func main() {
47 // Instantiates a client to use send messages to the Rudder API.
48 // User your WRITE KEY in below placeholder "RUDDER WRITE KEY"
49 client, _ := analytics.NewWithConfig(<WRITE_KEY>, <DATA_PLANE_URL>,
50 analytics.Config{
51 Interval: 30 * time.Second,
52 BatchSize: 100,
53 Verbose: true,
54 })
55
56 // Enqueues a track event that will be sent asynchronously.
57 client.Enqueue(analytics.Track{
58 UserId: "test-user",
59 Event: "test-snippet",
60 })
61
62 // Flushes any queued messages and closes the client.
63 client.Close()
64}
65```
66
67
68## License
69
70The library is released under the [MIT license](License.md).
71