API Documentation

# \Producers_MixpanelEvents

Provides an API to track events on Mixpanel

## Summary

Methods
Properties
Constants
__construct()
__destruct()
flush()
reset()
getQueue()
getToken()
enqueue()
enqueueAll()
_getEndpoint()
track()
register()
registerAll()
registerOnce()
registerAllOnce()
unregister()
unregisterAll()
getProperty()
identify()
createAlias()
No public properties found
No constants found
_getConsumer()
_persist()
_log()
_debug()
$_token
$_max_queue_size
$_options
N/A
No private methods found
$_queue
$_consumer
$_consumers
$_defaults
$_super_properties
N/A

File
  Producers/MixpanelEvents.php
Package
  Default
Class hierarchy
  \Base_MixpanelBase
  \Producers_MixpanelBaseProducer
  \Producers_MixpanelEvents

## Tags

None found

## Properties

### $_token

    $_token : string

#### Type

string — a token associated to a Mixpanel project

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### $_max_queue_size

    $_max_queue_size : integer

If the queue reaches this size we'll auto-flush to prevent out of memory errors

#### Type

integer

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### $_options

    $_options : array

An array of options to be used by the Mixpanel library.

#### Type

array

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### $_queue

    $_queue : array

#### Type

array — a queue to hold messages in memory before flushing in batches

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### $_consumer

    $_consumer : \ConsumerStrategies_AbstractConsumer

#### Type

\ConsumerStrategies_AbstractConsumer — the consumer to use when flushing messages

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### $_consumers

    $_consumers : array

#### Type

array — The list of available consumers

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### $_defaults

    $_defaults : array

Default options that can be overridden via the $options constructor arg

#### Type

array

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### $_super_properties

    $_super_properties : array

An array of properties to attach to every tracked event

#### Type

array

#

## Tags

None found

## Methods

### __construct()

    __construct(array  $options = array())

Construct a new MixpanelBase object and merge custom options with defaults

#### Parameters

array | $options |

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### __destruct()

    __destruct()

Flush the queue when we destruct the client with retries

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### flush()

    flush(integer  $desired_batch_size = 50) : boolean

Iterate the queue and write in batches using the instantiated Consumer Strategy

#### Parameters

integer | $desired_batch_size |

#### Returns

boolean —

whether or not the flush was successful

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### reset()

    reset()

Empties the queue without persisting any of the messages

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### getQueue()

    getQueue() : array

Returns the in-memory queue

#### Returns

array

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### getToken()

    getToken() : string

Returns the current Mixpanel project token

#### Returns

string

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### enqueue()

    enqueue(array  $message = array())

Add an array representing a message to be sent to Mixpanel to a queue.

#### Parameters

array | $message |

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### enqueueAll()

    enqueueAll(array  $messages = array())

Add an array representing a list of messages to be sent to Mixpanel to a queue.

#### Parameters

array | $messages |

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### _getEndpoint()

    _getEndpoint() : string

Returns the "events" endpoint

#### Returns

string

#

## Tags

None found

### track()

    track(string  $event, array  $properties = array())

Track an event defined by $event associated with metadata defined by $properties

#### Parameters

string | $event |
array | $properties |

#

## Tags

None found

### register()

    register(string  $property, mixed  $value)

Register a property to be sent with every event. If the property has already been registered, it will be overwritten.

#### Parameters

string | $property |
mixed | $value |

#

## Tags

None found

### registerAll()

    registerAll(array  $props_and_vals = array())

Register multiple properties to be sent with every event. If any of the properties have already been registered, they will be overwritten.

#### Parameters

array | $props_and_vals |

#

## Tags

None found

### registerOnce()

    registerOnce(  $property,   $value)

Register a property to be sent with every event. If the property has already been registered, it will NOT be overwritten.

#### Parameters

| $property |
| $value |

#

## Tags

None found

### registerAllOnce()

    registerAllOnce(array  $props_and_vals = array())

Register multiple properties to be sent with every event. If any of the properties have already been registered, they will NOT be overwritten.

#### Parameters

array | $props_and_vals |

#

## Tags

None found

### unregister()

    unregister(string  $property)

Un-register an property to be sent with every event.

#### Parameters

string | $property |

#

## Tags

None found

### unregisterAll()

    unregisterAll(array  $properties)

Un-register a list of properties to be sent with every event.

#### Parameters

array | $properties |

#

## Tags

None found

### getProperty()

    getProperty(string  $property) : mixed

Get a property that is set to be sent with every event

#### Parameters

string | $property |

#### Returns

mixed

#

## Tags

None found

### identify()

    identify(string|integer  $user_id, [optional] string|integer $anon_id)

Identify the user you want to associate to tracked events. The $anon_id must be UUID v4 format and not already merged to an $identified_id. All identify calls with a new and valid $anon_id will trigger a track $identify event, and merge to the $identified_id.

#### Parameters

string|integer | $user_id |
string|integer | $anon_id |

#

## Tags

None found

### createAlias()

    createAlias(string|integer  $distinct_id, string|integer  $alias) : array

An alias to be merged with the distinct_id. Each alias can only map to one distinct_id. This is helpful when you want to associate a generated id (such as a session id) to a user id or username.

Because aliasing can be extremely vulnerable to race conditions and ordering issues, we'll make a synchronous call directly to Mixpanel when this method is called. If it fails we'll throw an Exception as subsequent events are likely to be incorrectly tracked.

#### Parameters

string|integer | $distinct_id |
string|integer | $alias |

#### Throws

\Exception

#### Returns

array —

$msg

#

## Tags

None found

### _getConsumer()

    _getConsumer() : \ConsumerStrategies_AbstractConsumer

Given a strategy type, return a new PersistenceStrategy object

#### Returns

\ConsumerStrategies_AbstractConsumer

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### _persist()

    _persist(  $message) : mixed

Given an array of messages, persist it with the instantiated Persistence Strategy

#### Parameters

| $message |

#### Returns

mixed

#

Inherited from
  \Producers_MixpanelBaseProducer

## Tags

None found

### _log()

    _log(  $msg)

Log a message to PHP's error log

#### Parameters

| $msg |

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### _debug()

    _debug() : boolean

Returns true if in debug mode, false if in production mode

#### Returns

boolean

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### MixpanelEvents.php