Documentation
¶
Overview ¶
Package amplitude is a simple client implementation of the Amplitude HTTP API.
Basic usage example:
import ( "fmt" "github.com/replaygaming/amplitude" ) func main() { apiKey := "abcdef" c := amplitude.NewClient(apiKey) e := amplitude.Event{EventType: "test", UserID: "1"} if _, err := c.Send(e); err != nil { fmt.Println(err) } }
Index ¶
Constants ¶
const ( // APIURL is the url for the HTTP-API endpoint. APIURL = "https://api.amplitude.com" // EventsPath is the url part to post/get requests for events. EventsPath = "httpapi" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultClient ¶
type DefaultClient struct { // APIKey provided by Amplitude for the account. APIKey string // URL endpoint for Amplitude HTTP-API. URL string }
DefaultClient implements the client interface and wraps the API endpoint and allows events to be sent.
func NewClient ¶
func NewClient(apiKey string) *DefaultClient
NewClient returns a default client with values for the Amplitude HTTP-API implementation.
type Device ¶
type Device struct { OSName string `json:"os_name,omitempty"` OSVersion string `json:"os_version,omitempty"` DeviceBrand string `json:"device_brand,omitempty"` DeviceManufacturer string `json:"device_manufacturer,omitempty"` DeviceModel string `json:"device_model,omitempty"` DeviceType string `json:"device_type,omitempty"` Carrier string `json:"carrier,omitempty"` }
Device fields must all be updated together. Setting any of these fields will automatically reset all of the others if they are not also set on the same event.
type Event ¶
type Event struct { UserID string `json:"user_id,omitempty"` DeviceID string `json:"device_id,omitempty"` EventType string `json:"event_type"` Time int64 `json:"time,omitempty"` EventProperties Properties `json:"event_properties,omitempty"` UserProperties Properties `json:"user_properties,omitempty"` AppVersion string `json:"app_version,omitempty"` Platform string `json:"platform,omitempty"` Language string `json:"language,omitempty"` Revenue float64 `json:"revenue,omitempty"` LocationLat float64 `json:"location_lat,omitempty"` LocationLng float64 `json:"location_lng,omitempty"` IP string `json:"ip,omitempty"` IDFA string `json:"idfa,omitempty"` ADID string `json:"adid,omitempty"` Device Location EventAugment }
Event implements the Payload interface.
type EventAugment ¶
type EventAugment struct { EventID int `json:"event_id,omitempty"` SessionID int64 `json:"session_id,omitempty"` InsertID string `json:"insert_id,omitempty"` }
EventAugment are optional keys interpreted in a special way by Amplitude.
type Events ¶
type Events []Event
Events represents a list of events. Implements the Payload interface.
type Location ¶
type Location struct { Country string `json:"country,omitempty"` Region string `json:"region,omitempty"` City string `json:"city,omitempty"` DMA string `json:"dma,omitempty"` }
Location fields must all be updated together. Setting any of these fields will automatically reset all of the others if they are not also set on the same event.
type NoopClient ¶
type NoopClient struct { }
NoopClient implements the client interface, but doesn't do anything.
type Properties ¶
type Properties map[string]*json.RawMessage
Properties is a dictionary type for both user and event properties.
type ResponseError ¶
ResponseError is a description of the error returned from Amplitude API.
func (ResponseError) Error ¶
func (e ResponseError) Error() string