mixpanel

package module
v0.0.0-...-9dae0fc Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2013 License: MIT Imports: 10 Imported by: 1

README

mixpanels-go

Go Client for mixpanel http API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuffConsumer

type BuffConsumer struct {
	StdConsumer
	// contains filtered or unexported fields
}

func NewBuffConsumer

func NewBuffConsumer(maxSize int64) *BuffConsumer

func (*BuffConsumer) Flush

func (bc *BuffConsumer) Flush() error

Flush Send all remaining messages to Mixpanel. BufferedConsumers will flush automatically when you call Send(), but you will need to call Flush() when you are completely done using the consumer (for example, when your application exits) to ensure there are no messages remaining in memory.

func (*BuffConsumer) Send

func (bc *BuffConsumer) Send(endpoint string, msg []byte) error

type Consumer

type Consumer interface {
	Send(endpoint string, json_msg []byte) error
}

type Event

type Event struct {
	Event      string `json:"event"`
	Properties *P     `json:"properties"`
}

type Mixpanel

type Mixpanel struct {
	Token string `json:token`
	// contains filtered or unexported fields
}

func NewMixpanel

func NewMixpanel(token string) *Mixpanel

NewMixpanel Creates a new Mixpanel object, which can be used for all tracking.

To use mixpanel, create a new Mixpanel object using your token. Takes in a user token and uses a StdConsumer

func NewMixpanelWithConsumer

func NewMixpanelWithConsumer(token string, c Consumer) *Mixpanel

NewMixpanelWithConsumer Creates a new Mixpanel object, which can be used for all tracking.

To use mixpanel, create a new Mixpanel object using your token. Takes in a user token and an optional Consumer (or anything else with a send() method). If no consumer is provided, Mixpanel will use the default Consumer, which communicates one synchronous request for every message.

func (*Mixpanel) Alias

func (mp *Mixpanel) Alias(alias_id, original_id string) error

Alias gives custom alias to a people record.

Alias sends an update to our servers linking an existing distinct_id with a new id, so that events and profile updates associated with the new id will be associated with the existing user's profile and behavior. Example:

mp.Alias("amy@mixpanel.com", "13793")

func (*Mixpanel) PeopleAppend

func (mp *Mixpanel) PeopleAppend(id string, properties *P) error

PeopleAppend appends to the list associated with a property.

Takes a JSON object containing keys and values, and appends each to a list associated with the corresponding property name. $appending to a property that doesn't exist will result in assigning a list with one element to that property. Example:

mp.PeopleAppend("12345", &P{ "Power Ups": "Bubble Lead" })

func (*Mixpanel) PeopleDelete

func (mp *Mixpanel) PeopleDelete(id string) error

PeopleDelete permanently deletes a profile.

Permanently delete the profile from Mixpanel, along with all of its properties. Example:

mp.PeopleDelete("12345")

func (*Mixpanel) PeopleIncrement

func (mp *Mixpanel) PeopleIncrement(id string, properties *P) error

PeopleIncrement Increments/decrements numerical properties of people record.

Takes in JSON object with keys and numerical values. Adds numerical values to current property of profile. If property doesn't exist adds value to zero. Takes in negative values for subtraction. Example:

mp.PeopleIncrement("12345", &P{"Coins Gathered": 12})

func (*Mixpanel) PeopleSet

func (mp *Mixpanel) PeopleSet(id string, properties *P) error

PeopleSet set properties of a people record.

PeopleSet sets properties of a people record given in JSON object. If the profile does not exist, creates new profile with these properties. Example:

mp.PeopleSet("12345", &P{"Address": "1313 Mockingbird Lane",
                        "Birthday": "1948-01-01"})

func (*Mixpanel) PeopleSetOnce

func (mp *Mixpanel) PeopleSetOnce(id string, properties *P) error

PeopleSetOnce sets immutable properties of a people record.

PeopleSetOnce sets properties of a people record given in JSON object. If the profile does not exist, creates new profile with these properties. Does not overwrite existing property values. Example:

mp.PeopleSetOnce("12345", &P{"First Login": "2013-04-01T13:20:00"})

func (*Mixpanel) PeopleTrackCharge

func (mp *Mixpanel) PeopleTrackCharge(id string, amount float64, prop *P) error

PeopleTrackCharge Tracks a charge to a user.

Record that you have charged the current user a certain amount of money. Charges recorded with track_charge will appear in the Mixpanel revenue report. Example:

//tracks a charge of $50 to user '1234'
mp.PeopleTrackCharge("1234", 50, nil)

//tracks a charge of $50 to user '1234' at a specific time
mp.PeopleTrackCharge("1234", 50, {"$time": "2013-04-01T09:02:00"})

func (*Mixpanel) PeopleUnion

func (mp *Mixpanel) PeopleUnion(id string, properties *P) error

PeopleUnion Merges the values for a list associated with a property.

Takes a JSON object containing keys and list values. The list values in the request are merged with the existing list on the user profile, ignoring duplicate list values. Example:

mp.PeopleUnion("12345", &P{ "Items purchased": ["socks", "shirts"] } )

func (*Mixpanel) PeopleUnset

func (mp *Mixpanel) PeopleUnset(id string, properties []string) error

PeopleUnset removes properties from a profile.

Takes a JSON list of string property names, and permanently removes the properties and their values from a profile. Example:

mp.PeopleUnset("12345", ["Days Overdue"])

func (*Mixpanel) PeopleUpdate

func (mp *Mixpanel) PeopleUpdate(properties *P) error

PeopleUpdate sends a generic update to Mixpanel people analytics. Caller is responsible for formatting the update message, as documented in the Mixpanel HTTP specification, and passing the message as a dict to update. This method might be useful if you want to use very new or experimental features of people analytics from python The Mixpanel HTTP tracking API is documented at https://mixpanel.com/help/reference/http

func (*Mixpanel) Track

func (mp *Mixpanel) Track(distinct_id, event string, prop *P) error

Notes that an event has occurred, along with a distinct_id representing the source of that event (for example, a user id), an event name describing the event and a set of properties describing that event. Properties are provided as a Hash with string keys and strings, numbers or booleans as values.

// Track that user "12345"'s credit card was declined mp.Track("12345", "Credit Card Declined", nil)

// Properties describe the circumstances of the event, // or aspects of the source or user associated with the event

mp.Track("12345", "Welcome Email Sent", &P{
  "Email Template" : "Pretty Pink Welcome",
  "User Sign-up Cohort" : "July 2013",
 })

type P

type P map[string]interface{}

func (*P) Update

func (this *P) Update(other *P) *P

Update replaces all the elements of the map

type StdConsumer

type StdConsumer struct {
	// contains filtered or unexported fields
}

func NewStdConsumer

func NewStdConsumer() *StdConsumer

Creates a new StdConsumer. Sends one message at a time

func (*StdConsumer) Send

func (c *StdConsumer) Send(endpoint string, msg []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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