localytics

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GoDoc Build Status Go Report Card Taylor Swift Volkswagen License

go-localytics

go-localytics is a Go library for the Localytics REST API.

Features

  • Query Reports
  • Query Apps
  • Query App
  • Query Attributes

Documentation

You can find the documentation hosted on godoc.org.

Install

go get github.com/Onefootball/go-localytics

Development

Download modules to local cache.

go mod download

License

Apache 2.0

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

func Auth

func Auth(key string, secret string) func(o *Opts)

Auth configures the API Access Key and API Secret Key.

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

func New(httpClient *http.Client, opts ...Opt) *Client

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)

func (*Client) App

func (c *Client) App(appID string) (*App, error)

App retrives information about a specific app by its ID.

func (*Client) Apps

func (c *Client) Apps() ([]*App, error)

Apps fetches all the Apps in Localytics.

func (*Client) Attributes

func (c *Client) Attributes(appID string) (*Attributes, error)

Attributes fetches the attributes of an App by its ID.

func (*Client) Query

func (c *Client) Query(q *Query) (*Report, error)

Query is querying the Localytics API. There are limitations to the API.

type CustomDimensions

type CustomDimensions map[string]string

CustomDimensions ...

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 Opt

type Opt func(*Opts)

Opt is an option for the client.

type Opts

type Opts struct {
	ApiKey    string
	ApiSecret string
}

Opts holds alls the options for the client.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL