mixpanel

package module
v0.0.0-...-a53406b Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2015 License: Apache-2.0 Imports: 13 Imported by: 1

README

go-mixpanel

Golang client for Mixpanel API

Getting Started

package main

import (
	"fmt"

	mixpanel "github.com/austinchau/go-mixpanel"
)

func main() {
	mp := mixpanel.NewMixpanel()

	params := map[string]string{
		"from_date": "2015-01-01",
		"to_date":   "2015-01-01",
		"event":     "EventA,EventB", // omit "event" to retrieve all events
	}

	result, err := mp.ExportQuery(params)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v", result)
}

Install Commandline Tool

go install github.com/austinchau/go-mixpanel/mixpanelexport
mixpanelexport -start=2015-01-01 -end=2015-01-01 -event="EventA,EventB"

Expects mixpanel api credentials to be exported as environment variables.

export MIXPANEL_API_KEY="YOUR_KEY"
export MIXPANEL_SECRET="YOUR_SECRET"

Documentation

Index

Constants

View Source
const (
	DEFAULT_EXPIRE_IN_DAYS int64 = 5
)

Variables

This section is empty.

Functions

func ExpireInDays

func ExpireInDays(days int64) int64

func ExpireInHours

func ExpireInHours(hours int64) int64

Types

type CommonEventsResult

type CommonEventsResult []string

type EventQueryResult

type EventQueryResult struct {
	LegendSize int `json:"legend_size"`
	Data       struct {
		Series []string                  `json:"series"`
		Values map[string]map[string]int `json:"values"`
	} `json:data`
}

type ExportQueryResult

type ExportQueryResult struct {
	Event      string                 `json:event`
	Properties map[string]interface{} `json:properties`
}

type Mixpanel

type Mixpanel struct {
	*MixpanelAuth
	Format  string
	BaseUrl string
}

func NewMixpanel

func NewMixpanel(key string, secret string) *Mixpanel

func (*Mixpanel) AddExpire

func (m *Mixpanel) AddExpire(params *map[string]string)

func (*Mixpanel) AddSig

func (m *Mixpanel) AddSig(params *map[string]string)

func (*Mixpanel) EventQuery

func (m *Mixpanel) EventQuery(params map[string]string) (EventQueryResult, error)

func (*Mixpanel) ExportQuery

func (m *Mixpanel) ExportQuery(params map[string]string) ([]ExportQueryResult, error)

func (*Mixpanel) MakeRequest

func (m *Mixpanel) MakeRequest(action string, params map[string]string) ([]byte, error)

func (*Mixpanel) MostCommonEventsLast31Days

func (m *Mixpanel) MostCommonEventsLast31Days(params map[string]string) (CommonEventsResult, error)

func (*Mixpanel) PeopleQuery

func (m *Mixpanel) PeopleQuery(params map[string]string) (map[string]interface{}, error)

func (*Mixpanel) SegmentationQuery

func (m *Mixpanel) SegmentationQuery(params map[string]string) (SegmentationQueryResult, error)

func (*Mixpanel) TopEvents

func (m *Mixpanel) TopEvents(params map[string]string) (TopEventsResult, error)

func (*Mixpanel) UserInfo

func (m *Mixpanel) UserInfo(id string) (map[string]interface{}, error)

type MixpanelAuth

type MixpanelAuth struct {
	ApiKey, Secret string
}

func NewMixpanelAuth

func NewMixpanelAuth() (*MixpanelAuth, error)

type SegmentationQueryResult

type SegmentationQueryResult struct {
	LegendSize int `json:"legend_size"`
	Data       struct {
		Series []string                  `json:"series"`
		Values map[string]map[string]int `json:"values"`
	} `json:data`
}

type TopEventsResult

type TopEventsResult struct {
	Type   string `json:"type"`
	Events []struct {
		Amount           int     `json:"amount"`
		Event            string  `json:"event"`
		PercentageChange float64 `json:"percent_change"`
	} `json:events`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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