modulepackage
3.3.0
Repository: https://github.com/segmentio/analytics-go.git
Documentation: pkg.go.dev
# README
analytics-go

Segment analytics client for Go.
Installation
The package can be simply installed via go get, we recommend that you use a package version management system like the Go vendor directory or a tool like Godep to avoid issues related to API breaking changes introduced between major versions of the library.
To install it in the GOPATH:
go get https://github.com/segmentio/analytics-go
Documentation
The links bellow should provide all the documentation needed to make the best use of the library and the Segment API:
Usage
package main
import (
"os"
"github.com/segmentio/analytics-go"
)
func main() {
// Instantiates a client to use send messages to the segment API.
client := analytics.New(os.Getenv("SEGMENT_WRITE_KEY"))
// 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()
}
License
The library is released under the MIT license.
# Functions
Instantiate a new client that uses the write key passed as first argument to send messages to the backend.
No description provided by the author
No description provided by the author
No description provided by the author
Instantiate a new client that uses the write key and configuration passed as arguments to send messages to the backend.
This function instantiate an object that statisfies the analytics.Logger interface and send logs to standard logger passed as argument.
No description provided by the author
# Constants
This constant sets the default batch size used by client instances if none was explicitly set.
This constant sets the default endpoint to which client instances send messages if none was explictly set.
This constant sets the default flush interval used by client instances if none was explicitly set.
Version of the client.
# Variables
This error is returned by methods of the `Client` interface when they are called after the client was already closed.
This error is used to notify the client callbacks that a message send failed because the JSON representation of a message exceeded the upper limit.
This error is used to notify the application that too many requests are already being sent and no more messages can be accepted.
# Structs
This type represents object sent in a alias call as described in https://segment.com/docs/libraries/http/#alias.
This type provides the representation of the `context.app` object as defined in https://segment.com/docs/spec/common/#context.
This type provides the representation of the `context.campaign` object as defined in https://segment.com/docs/spec/common/#context.
Instances of this type carry the different configuration options that may be set when instantiating a client.
Returned by the `NewWithConfig` function when the one of the configuration fields was set to an impossible value (like a negative duration).
This type provides the representation of the `context` object as defined in https://segment.com/docs/spec/common/#context.
This type provides the representation of the `context.device` object as defined in https://segment.com/docs/spec/common/#context.
Instances of this type are used to represent errors returned when a field was no initialize properly in a structure passed as argument to one of the functions of this package.
This type represents object sent in a group call as described in https://segment.com/docs/libraries/http/#group.
This type represents object sent in an identify call as described in https://segment.com/docs/libraries/http/#identify.
This type provides the representation of the `context.library` object as defined in https://segment.com/docs/spec/common/#context.
This type provides the representation of the `context.location` object as defined in https://segment.com/docs/spec/common/#context.
This type provides the representation of the `context.network` object as defined in https://segment.com/docs/spec/common/#context.
This type provides the representation of the `context.os` object as defined in https://segment.com/docs/spec/common/#context.
This type represents object sent in a page call as described in https://segment.com/docs/libraries/http/#page.
This type provides the representation of the `context.page` object as defined in https://segment.com/docs/spec/common/#context.
This type represents products in the E-commerce API.
This type provides the representation of the `context.referrer` object as defined in https://segment.com/docs/spec/common/#context.
This type represents object sent in a screen call as described in https://segment.com/docs/libraries/http/#screen.
This type provides the representation of the `context.screen` object as defined in https://segment.com/docs/spec/common/#context.
This type represents object sent in a track call as described in https://segment.com/docs/libraries/http/#track.
# Interfaces
Values implementing this interface are used by analytics clients to notify the application when a message send succeeded or failed.
This interface is the main API exposed by the analytics package.
No description provided by the author
Instances of types implementing this interface can be used to define where the analytics client logs are written.
This interface is used to represent analytics objects that can be sent via a client.
# Type aliases
This type is used to represent integrations in messages that support it.
This type is used to represent properties in messages that support it.
This type is used to represent traits in messages that support it.