GithubHelp home page GithubHelp logo

analytics-go's Introduction

The Customer Data Platform for Developers

Website · Documentation · Community Slack


RudderStack Go SDK

The RudderStack Go SDK lets you send customer event data from your Go applications to your specified destinations.

SDK setup requirements

Installation

You can install the Go SDK via the go get command.

It is highly recommended to use a tool like Godep to avoid any issues related to the breaking API changes introduced between the major versions of the library.

To install the SDK in the GOPATH, run the following:

go get github.com/rudderlabs/analytics-go

Using the SDK

package main

import (
    "github.com/rudderlabs/analytics-go/v4"
)

func main() {
    // Instantiates a client to use send messages to the RudderStack API.
    
    // Use your write key in the below placeholder:
    
    client := analytics.New(<WRITE_KEY>, <DATA_PLANE_URL>)

    // Enqueues a track event that will be sent asynchronously.
    client.Enqueue(analytics.Track{
        UserId: "test-user",
        Event:  "test-snippet",
    })

    // Flushes any queued messages and closes the client.
    client.Close()
}

Alternatively, you can run the following snippet:

package main

import (
    "github.com/rudderlabs/analytics-go/v4"
)

func main() {
    // Instantiates a client to use send messages to the RudderStack API.
    
    // User your write key in the below placeholder:
    
    client, _ := analytics.NewWithConfig(WRITE_KEY,
		analytics.Config{
			DataPlaneUrl: DATA_PLANE_URL,
			Interval:     30 * time.Second,
			BatchSize:    100,
			Verbose:      true,
			DisableGzip:  false  // Enables Gzip compression - set true to disable Gzip.
		})

    // Enqueues a track event that will be sent asynchronously.
    
    client.Enqueue(analytics.Track{
        UserId: "test-user",
        Event:  "test-snippet",
    })

    // Flushes any queued messages and closes the client.
    
    client.Close()
}

Gzip support

The Go SDK supports Gzip compression from version 4.1.0 and it is enabled by default. However, you can disable this feature by setting the DisableGzip parameter to true while initializing the SDK, as shown:

client, _ := analytics.NewWithConfig(WRITE_KEY,
		analytics.Config{
			DataPlaneUrl: DATA_PLANE_URL,
			Interval:     30 * time.Second,
			BatchSize:    100,
			Verbose:      true,
			DisableGzip:  false  // Enables Gzip compression - set true to disable Gzip.
		})
Note: Gzip requires rudder-server version 1.4 or later.

Sending events

Refer to the RudderStack Go SDK documentation for more information on the supported event types.

License

The RudderStack Go SDK is released under the MIT license.

analytics-go's People

Contributors

tj avatar f2prateek avatar achille-roussel avatar cisse21 avatar sajalrudderlabs avatar kalamay avatar pallabmaiti avatar arnabp92 avatar sayan-rudder avatar prayansh avatar deankarn avatar arnab-p avatar systemizer avatar hblanks avatar dipanjanb avatar corgrath avatar moumitam avatar vincepri avatar vladiacobsendgrid avatar chandumlg avatar 1abhishekpandey avatar ishachopra0401 avatar wyattjoh avatar rohitpaulk avatar parkr avatar metrue avatar mfeeneybuf avatar kke avatar jeffreylo avatar ernesto-jimenez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.