amplitude / analytics-go

Go Amplitude Analytics SDK
MIT License
12 stars 7 forks source link


[![Build](https://github.com/amplitude/analytics-go/actions/workflows/build.yml/badge.svg)](https://github.com/amplitude/analytics-go/actions/workflows/build.yml) [![go-doc](https://pkg.go.dev/badge/github.com/amplitude/analytics-go?utm_source=godoc)](https://pkg.go.dev/github.com/amplitude/analytics-go)

Announcement 📣

Amplitude is introducing Go SDK. Compared to plain HTTP V2 API, it provides improved developer experience, helps users instrument data more seamlessly and provides more control over data being instrumented using custom plugins.

To learn more about the new SDK, here are some useful links:

Official Amplitude Go SDK

This is Amplitude's latest and official version of Go SDK.

Installation

Install analytics-go using go get:

go get github.com/amplitude/analytics-go

Usage

package main

import (
    "github.com/amplitude/analytics-go/amplitude"
)

func main() {

    config := amplitude.NewConfig("your-api-key")

    client := amplitude.NewClient(config)

    // Track a basic event
    // One of UserID and DeviceID is required
    client.Track(amplitude.Event{
        EventType: "type-of-event",
        UserID:    "user-id",
    })

    // Flushed queued events and shutdown the client
    client.Shutdown()
}

Need Help?

If you have any issues using our SDK, feel free to create a GitHub issue or submit a request on Amplitude Help.