Skip to content

Commit f2812f4

Browse files
argenisfjbwyme
authored andcommitted
Adding the option to set $ignore_alias on people updates
Including an extra param on people update calls so that the $ignore_alias property can be included
1 parent 5938d30 commit f2812f4

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

lib/Producers/MixpanelPeople.php

+26-17
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ class Producers_MixpanelPeople extends Producers_MixpanelBaseProducer {
1414
* @param null $ip
1515
* @return array
1616
*/
17-
private function _constructPayload($distinct_id, $operation, $value, $ip = null, $ignore_time = false) {
17+
private function _constructPayload($distinct_id, $operation, $value, $ip = null, $ignore_time = false, $ignore_alias = false) {
1818
$payload = array(
1919
'$token' => $this->_token,
2020
'$distinct_id' => $distinct_id,
2121
$operation => $value
2222
);
2323
if ($ip !== null) $payload['$ip'] = $ip;
2424
if ($ignore_time === true) $payload['$ignore_time'] = true;
25+
if ($ignore_alias === true) $payload['$ignore_alias'] = true;
2526
return $payload;
2627
}
2728

@@ -32,9 +33,10 @@ private function _constructPayload($distinct_id, $operation, $value, $ip = null,
3233
* @param array $props associative array of properties to set on the profile
3334
* @param string|null $ip the ip address of the client (used for geo-location)
3435
* @param 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
36+
* @param 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
3537
*/
36-
public function set($distinct_id, $props, $ip = null, $ignore_time = false) {
37-
$payload = $this->_constructPayload($distinct_id, '$set', $props, $ip, $ignore_time);
38+
public function set($distinct_id, $props, $ip = null, $ignore_time = false, $ignore_alias = false) {
39+
$payload = $this->_constructPayload($distinct_id, '$set', $props, $ip, $ignore_time, $ignore_alias);
3840
$this->enqueue($payload);
3941
}
4042

@@ -45,9 +47,10 @@ public function set($distinct_id, $props, $ip = null, $ignore_time = false) {
4547
* @param array $props associative array of properties to set on the profile
4648
* @param string|null $ip the ip address of the client (used for geo-location)
4749
* @param 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
50+
* @param 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
4851
*/
49-
public function setOnce($distinct_id, $props, $ip = null, $ignore_time = false) {
50-
$payload = $this->_constructPayload($distinct_id, '$set_once', $props, $ip, $ignore_time);
52+
public function setOnce($distinct_id, $props, $ip = null, $ignore_time = false, $ignore_alias = false) {
53+
$payload = $this->_constructPayload($distinct_id, '$set_once', $props, $ip, $ignore_time, $ignore_alias);
5154
$this->enqueue($payload);
5255
}
5356

@@ -59,9 +62,10 @@ public function setOnce($distinct_id, $props, $ip = null, $ignore_time = false)
5962
* @param array $props associative array of properties to unset on the profile
6063
* @param string|null $ip the ip address of the client (used for geo-location)
6164
* @param 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
65+
* @param 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
6266
*/
63-
public function remove($distinct_id, $props, $ip = null, $ignore_time = false) {
64-
$payload = $this->_constructPayload($distinct_id, '$unset', $props, $ip, $ignore_time);
67+
public function remove($distinct_id, $props, $ip = null, $ignore_time = false, $ignore_alias = false) {
68+
$payload = $this->_constructPayload($distinct_id, '$unset', $props, $ip, $ignore_time, $ignore_alias);
6569
$this->enqueue($payload);
6670
}
6771

@@ -73,9 +77,10 @@ public function remove($distinct_id, $props, $ip = null, $ignore_time = false) {
7377
* @param int $val the amount to increment the property by
7478
* @param string|null $ip the ip address of the client (used for geo-location)
7579
* @param 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
80+
* @param 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
7681
*/
77-
public function increment($distinct_id, $prop, $val, $ip = null, $ignore_time = false) {
78-
$payload = $this->_constructPayload($distinct_id, '$add', array("$prop" => $val), $ip, $ignore_time);
82+
public function increment($distinct_id, $prop, $val, $ip = null, $ignore_time = false, $ignore_alias = false) {
83+
$payload = $this->_constructPayload($distinct_id, '$add', array("$prop" => $val), $ip, $ignore_time, $ignore_alias);
7984
$this->enqueue($payload);
8085
}
8186

@@ -87,10 +92,11 @@ public function increment($distinct_id, $prop, $val, $ip = null, $ignore_time =
8792
* @param string|array $val items to add to the list
8893
* @param string|null $ip the ip address of the client (used for geo-location)
8994
* @param 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
95+
* @param 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
9096
*/
91-
public function append($distinct_id, $prop, $val, $ip = null, $ignore_time = false) {
97+
public function append($distinct_id, $prop, $val, $ip = null, $ignore_time = false, $ignore_alias = false) {
9298
$operation = gettype($val) == "array" ? '$union' : '$append';
93-
$payload = $this->_constructPayload($distinct_id, $operation, array("$prop" => $val), $ip, $ignore_time);
99+
$payload = $this->_constructPayload($distinct_id, $operation, array("$prop" => $val), $ip, $ignore_time, $ignore_alias);
94100
$this->enqueue($payload);
95101
}
96102

@@ -101,16 +107,17 @@ public function append($distinct_id, $prop, $val, $ip = null, $ignore_time = fal
101107
* @param null $timestamp the timestamp of when the transaction occurred (default to current timestamp)
102108
* @param string|null $ip the ip address of the client (used for geo-location)
103109
* @param 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
110+
* @param 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
104111
*/
105-
public function trackCharge($distinct_id, $amount, $timestamp = null, $ip = null, $ignore_time = false) {
112+
public function trackCharge($distinct_id, $amount, $timestamp = null, $ip = null, $ignore_time = false, $ignore_alias = false) {
106113
$timestamp = $timestamp == null ? time() : $timestamp;
107114
$date_iso = date("c", $timestamp);
108115
$transaction = array(
109116
'$time' => $date_iso,
110117
'$amount' => $amount
111118
);
112119
$val = array('$transactions' => $transaction);
113-
$payload = $this->_constructPayload($distinct_id, '$append', $val, $ip, $ignore_time);
120+
$payload = $this->_constructPayload($distinct_id, '$append', $val, $ip, $ignore_time, $ignore_alias);
114121
$this->enqueue($payload);
115122
}
116123

@@ -119,9 +126,10 @@ public function trackCharge($distinct_id, $amount, $timestamp = null, $ip = null
119126
* @param string|int $distinct_id the distinct_id or alias of a user
120127
* @param string|null $ip the ip address of the client (used for geo-location)
121128
* @param 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
129+
* @param 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
122130
*/
123-
public function clearCharges($distinct_id, $ip = null, $ignore_time = false) {
124-
$payload = $this->_constructPayload($distinct_id, '$set', array('$transactions' => array()), $ip, $ignore_time);
131+
public function clearCharges($distinct_id, $ip = null, $ignore_time = false, $ignore_alias = false) {
132+
$payload = $this->_constructPayload($distinct_id, '$set', array('$transactions' => array()), $ip, $ignore_time, $ignore_alias);
125133
$this->enqueue($payload);
126134
}
127135

@@ -130,9 +138,10 @@ public function clearCharges($distinct_id, $ip = null, $ignore_time = false) {
130138
* @param string|int $distinct_id the distinct_id or alias of a user
131139
* @param string|null $ip the ip address of the client (used for geo-location)
132140
* @param 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
141+
* @param 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
133142
*/
134-
public function deleteUser($distinct_id, $ip = null, $ignore_time = false) {
135-
$payload = $this->_constructPayload($distinct_id, '$delete', "", $ip, $ignore_time);
143+
public function deleteUser($distinct_id, $ip = null, $ignore_time = false, $ignore_alias = false) {
144+
$payload = $this->_constructPayload($distinct_id, '$delete', "", $ip, $ignore_time, $ignore_alias);
136145
$this->enqueue($payload);
137146
}
138147

0 commit comments

Comments
 (0)