API Documentation

# \Producers_MixpanelPeople

Provides an API to create/update profiles on Mixpanel

## Summary

Methods
Properties
Constants
__construct()
__destruct()
flush()
reset()
getQueue()
getToken()
enqueue()
enqueueAll()
_getEndpoint()
set()
setOnce()
remove()
increment()
append()
trackCharge()
clearCharges()
deleteUser()
No public properties found
No constants found
_getConsumer()
_persist()
_log()
_debug()
$_token
$_max_queue_size
$_options
N/A
_constructPayload()
$_queue
$_consumer
$_consumers
$_defaults
N/A

File
  Producers/MixpanelPeople.php
Package
  Default
Class hierarchy
  \Base_MixpanelBase
  \Producers_MixpanelBaseProducer
  \Producers_MixpanelPeople

## 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

## 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 "engage" endpoint

#### Returns

string

#

## Tags

None found

### set()

    set(string|integer  $distinct_id, array  $props, string|null  $ip = null, boolean  $ignore_time = false, boolean  $ignore_alias = false)

Set properties on a user record. If the profile does not exist, it creates it with these properties.

If it does exist, it sets the properties to these values, overwriting existing values.

#### Parameters

string|integer | $distinct_id | the distinct_id or alias of a user
array | $props | associative array of properties to set on the profile
string|null | $ip | the ip address of the client (used for geo-location)
boolean | $ignore_time | If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
boolean | $ignore_alias | If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found

#

## Tags

None found

### setOnce()

    setOnce(string|integer  $distinct_id, array  $props, string|null  $ip = null, boolean  $ignore_time = false, boolean  $ignore_alias = false)

Set properties on a user record. If the profile does not exist, it creates it with these properties.

If it does exist, it sets the properties to these values but WILL NOT overwrite existing values.

#### Parameters

string|integer | $distinct_id | the distinct_id or alias of a user
array | $props | associative array of properties to set on the profile
string|null | $ip | the ip address of the client (used for geo-location)
boolean | $ignore_time | If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
boolean | $ignore_alias | If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found

#

## Tags

None found

### remove()

    remove(string|integer  $distinct_id, array  $props, string|null  $ip = null, boolean  $ignore_time = false, boolean  $ignore_alias = false)

Unset properties on a user record. If the profile does not exist, it creates it with no properties.

If it does exist, it unsets these properties. NOTE: In other libraries we use 'unset' which is a reserved word in PHP.

#### Parameters

string|integer | $distinct_id | the distinct_id or alias of a user
array | $props | associative array of properties to unset on the profile
string|null | $ip | the ip address of the client (used for geo-location)
boolean | $ignore_time | If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
boolean | $ignore_alias | If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found

#

## Tags

None found

### increment()

    increment(string|integer  $distinct_id,   $prop, integer  $val, string|null  $ip = null, boolean  $ignore_time = false, boolean  $ignore_alias = false)

Increments the value of a property on a user record. If the profile does not exist, it creates it and sets the property to the increment value.

#### Parameters

string|integer | $distinct_id | the distinct_id or alias of a user
| $prop | string the property to increment
integer | $val | the amount to increment the property by
string|null | $ip | the ip address of the client (used for geo-location)
boolean | $ignore_time | If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
boolean | $ignore_alias | If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found

#

## Tags

None found

### append()

    append(string|integer  $distinct_id, string  $prop, string|array  $val, string|null  $ip = null, boolean  $ignore_time = false, boolean  $ignore_alias = false)

Adds $val to a list located at $prop. If the property does not exist, it will be created. If $val is a string and the list is empty or does not exist, a new list with one value will be created.

#### Parameters

string|integer | $distinct_id | the distinct_id or alias of a user
string | $prop | the property that holds the list
string|array | $val | items to add to the list
string|null | $ip | the ip address of the client (used for geo-location)
boolean | $ignore_time | If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
boolean | $ignore_alias | If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found

#

## Tags

None found

### trackCharge()

    trackCharge(string|integer  $distinct_id, string  $amount, null  $timestamp = null, string|null  $ip = null, boolean  $ignore_time = false, boolean  $ignore_alias = false)

Adds a transaction to the user's profile for revenue tracking

#### Parameters

string|integer | $distinct_id | the distinct_id or alias of a user
string | $amount | the transaction amount e.g. "20.50"
null | $timestamp | the timestamp of when the transaction occurred (default to current timestamp)
string|null | $ip | the ip address of the client (used for geo-location)
boolean | $ignore_time | If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
boolean | $ignore_alias | If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found

#

## Tags

None found

### clearCharges()

    clearCharges(string|integer  $distinct_id, string|null  $ip = null, boolean  $ignore_time = false, boolean  $ignore_alias = false)

Clear all transactions stored on a user's profile

#### Parameters

string|integer | $distinct_id | the distinct_id or alias of a user
string|null | $ip | the ip address of the client (used for geo-location)
boolean | $ignore_time | If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
boolean | $ignore_alias | If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found

#

## Tags

None found

### deleteUser()

    deleteUser(string|integer  $distinct_id, string|null  $ip = null, boolean  $ignore_time = false, boolean  $ignore_alias = false)

Delete this profile from Mixpanel

#### Parameters

string|integer | $distinct_id | the distinct_id or alias of a user
string|null | $ip | the ip address of the client (used for geo-location)
boolean | $ignore_time | If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
boolean | $ignore_alias | If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found

#

## 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

### _constructPayload()

    _constructPayload(  $distinct_id,   $operation,   $value, null  $ip = null, boolean  $ignore_time = false, boolean  $ignore_alias = false) : array

Internal method to prepare a message given the message data

#### Parameters

| $distinct_id |
| $operation |
| $value |
null | $ip |
boolean | $ignore_time | If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
boolean | $ignore_alias | If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found

#### Returns

array

#

## Tags

None found

### MixpanelPeople.php