mixpanel

package
v0.0.0-...-06436dc Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const EventIDKey = "$__$$event_id"

Key into the EventData map that contains the UUID of this event. Name is chosen to make collisions with actual keys very unlikely.

View Source
const MixpanelBaseURL = "https://data.mixpanel.com/api/2.0/export"

The official base URL

View Source
const TimestampKey = "$__$$timestamp"

Key into the EventData map that contains the SQL Timestamp/DateTime compatible timestamp of this event.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventData

type EventData map[string]interface{}

EventData is a representation of each individual JSON record spit out of the export process.

type Mixpanel

type Mixpanel struct {
	Product string
	Key     string
	Secret  string
	BaseURL string
}

Mixpanel struct represents a set of credentials used to access the Mixpanel API for a particular product.

func New

func New(product, key, secret string) *Mixpanel

New creates a Mixpanel object with the given API credentials and uses the official API URL.

func NewWithURL

func NewWithURL(product, key, secret, baseURL string) *Mixpanel

NewWithURL creates a Mixpanel object with the given API credentials and a custom Mixpanel API URL.

I doubt this will ever be useful but there you go.

func (*Mixpanel) ExportDate

func (m *Mixpanel) ExportDate(date time.Time, output chan<- EventData, moreArgs *url.Values) (int, error)

ExportDate downloads event data for the given day and streams the resulting transformed JSON blobs as byte strings over the send-only channel passed to the function.

Returns the number of records that have been processed during the run and possibly an error.

The optional `moreArgs` parameter can be given to add additional URL parameters to the API request.

func (*Mixpanel) TransformEventData

func (m *Mixpanel) TransformEventData(input io.Reader, output chan<- EventData) (int, error)

TransformEventData reads JSON objects line by line from `input`, performs a simple translation, and pipes the result back out through the `output` chan.

The transformation effectively folds the properties map into the top level and attaches product information.

Returns the number of records that have been processed during the run and possibly an error.

Input : `{"event": "...", "properties": {"k": "v"}}` Output: `{"event": "...", "product: "...", "k": "v", ...}`

Jump to

Keyboard shortcuts

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