Documentation ¶
Overview ¶
Package localytics provides a Client for the Localytics API
Index ¶
Examples ¶
Constants ¶
View Source
const ( // RootURL for the Localytics API RootURL = "https://api.localytics.com/v1/" // QueryPath is the path to the query API. // This will prefix the RootURL on these URLs QueryPath = "query" // Apps is the path to get info about an app, or list the apps available AppsPath = "apps" // Attributes is the path to get the current attributes AttributesPath = "attributes" )
Variables ¶
View Source
var ( // ErrRateLimitExeceed shows that the request limit has been exceeded. // See https://docs.localytics.com/dev/query-api.html#query-api-overview-limits ErrRateLimitExeceed = errors.New("localytics: rate limit has been exceeded") )
Functions ¶
Types ¶
type App ¶
type App struct { // Name ... Name string `json:"name"` // AppID ... AppID string `json:"app_id"` // IconURL ... IconURL string `json:"icon_url"` // CustomDimensions CustomDimensions CustomDimensions `json:"custom_dimensions"` // CreatedAt ... CreatedAt string `json:"created_at"` // Stats ... Stats Stats `json:"stats"` }
App are the information about a Localytics app.
type Attributes ¶
type Attributes struct { // Events ... Events []*Event `json:"events"` }
Attributes ...
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client holds the client for localytics
func New ¶
New returns a new instance of the client. See /examples for the use
httpClient := &http.Client{} client := localytics.New(httpClient, localytics.Auth(apiKey, apiSecret)) res, err := client.Apps()
Example ¶
httpClient := &http.Client{} // create client client := New(httpClient, Auth("apiKey", "apiSecret")) // query the app res, err := client.App("appID") if err != nil { panic(err) } b, err := json.Marshal(res) if err != nil { panic(err) } fmt.Printf("received app: %v", b)
Output:
func (*Client) Attributes ¶
func (c *Client) Attributes(appID string) (*Attributes, error)
Attributes fetches the attributes of an App by its ID.
type Event ¶
type Event struct { // EventName ... EventName string `json:"event_name"` // Attributes ... Attributes []string `json:"attributes"` // HighCardinalityAttributes ... HighCardinalityAttributes []string `json:"high_cardinality_attributes"` }
Event ...
type LocalyticsError ¶
type LocalyticsError struct { // Message is the error message from the API Message string `json:"error"` // DocURL is the url to the documentation DocURL string `json:"documentation_path"` }
LocalyticsError is an error that is returned from the API in form of JSN response.
func (LocalyticsError) Error ¶
func (l LocalyticsError) Error() string
Error is returning a string to confirm to the error interface
type Query ¶
type Query struct { // AppIds is are IDs of the applications to query. AppIDs []string `json:"app_id" toml:"app_ids"` // Metrics is the list of query metrics Metrics []string `json:"metrics" toml:"metrics"` // Dimensions is the list of query dimensions Dimensions []string `json:"dimensions" toml:"dimensions"` // Conditions are the query conditions keyed on metric or dimension name. Conditions map[string][]string `json:"conditions,omitempty" toml:"conditions"` // Days are the number of days in the past Days int `json:"days,omitempty" toml:"days"` // Order is the the query results Order []string `json:"order,omitempty" toml:"order"` // Limit the maximum of records to return Limit int `json:"limit,omitempty" toml:"limit"` // Comment is an optional comment for the returned results Comment string `json:"comment,omitempty" toml:"comment"` // Translate is the translation of some keys Translate map[string]string `json:"translate,omitempty" toml:"translate"` // ProfileDBID is the id for the database queries ProfileDBID []int `json:"profiledb_id,omitempty" toml:"profile_db_id"` // SamplingRatio is the accuracy of the response SamplingRatio float64 `json:"sampling_ratio,omitempty" toml:"sampling_ratio"` }
Query holds information about a query for the Query API of Localytics.
type Report ¶
type Report struct { // Results ... Results []map[string]interface{} `json:"results"` // AppIDs... AppIDs []string `json:"app_id"` // Comment is an optional comment for the returned results Comment string `json:"comment"` // Query ... Query *Query `json:"query"` // Truncated ... Truncated bool `json:"truncated"` // CreatedAt ... CreatedAt string `json:"created_at"` // ExpiresAt ... ExpiresAt string `json:"expires_at"` }
Report is the response to a Localytics query.
type Stats ¶
type Stats struct { // Sessions ... Sessions int `json:"sessions"` // Closes ... Closes int `json:"closes"` // Users ... Users int `json:"users"` // Events ... Events int `json:"events"` // DataPoings ... DataPoints int `json:"data_points"` // Platforms ... Platforms []string `json:"platforms"` // ClientLibraries ... ClientLibraries []string `json:"client_libraries"` // BeginDate ... BeginDate string `json:"begin_date"` // EndDate ... EndDate string `json:"end_date"` }
Stats are the statistics of a fetched app.
Click to show internal directories.
Click to hide internal directories.