PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / wp-media / wp-mixpanel / src / Classes / Producers / MixpanelGroups.php

MixpanelGroups.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF trunk, at vendor/wp-media/wp-mixpanel/src/Classes/Producers/MixpanelGroups.php

103 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Provides an API to create/update group profiles on Mixpanel
5 */
6 class Imagify_WPMedia_Producers_MixpanelGroups extends Imagify_WPMedia_Producers_MixpanelBaseProducer {
7
8 /**
9 * Internal method to prepare a message given the message data
10 * @param $group_key
11 * @param $group_id
12 * @param $operation
13 * @param $value
14 * @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the group Profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
15 * @return array
16 */
17 private function _constructPayload($group_key, $group_id, $operation, $value, $ignore_time = false) {
18 $payload = array(
19 '$token' => $this->_token,
20 '$group_key' => $group_key,
21 '$group_id' => $group_id,
22 '$time' => microtime(true),
23 $operation => $value
24 );
25 if ($ignore_time === true) $payload['$ignore_time'] = true;
26 return $payload;
27 }
28
29 /**
30 * Set properties on a group profile. If the group profile does not exist, it creates it with these properties.
31 * If it does exist, it sets the properties to these values, overwriting existing values.
32 * @param string|int $group_key the group_key used for groups in Project Settings
33 * @param string|int $group_id the group id used for the group profile
34 * @param array $props associative array of properties to set on the group profile
35 * @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the group profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
36 */
37 public function set($group_key, $group_id, $props, $ignore_time = false) {
38 $payload = $this->_constructPayload($group_key, $group_id, '$set', $props, $ignore_time);
39 $this->enqueue($payload);
40 }
41
42 /**
43 * Set properties on a group profile. If the Group profile does not exist, it creates it with these properties.
44 * If it does exist, it sets the properties to these values but WILL NOT overwrite existing values.
45 * @param string|int $group_key the group_key used for groups in Project Settings
46 * @param string|int $group_id the group id used for the group profile
47 * @param array $props associative array of properties to set on the group profile
48 * @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the group profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
49 */
50 public function setOnce($group_key, $group_id, $props, $ignore_time = false) {
51 $payload = $this->_constructPayload($group_key, $group_id, '$set_once', $props, $ignore_time);
52 $this->enqueue($payload);
53 }
54
55 /**
56 * Unset properties on a group profile. If the group does not exist, it creates it with no properties.
57 * If it does exist, it unsets these properties. NOTE: In other libraries we use 'unset' which is
58 * a reserved word in PHP.
59 * @param string|int $group_key the group_key used for groups in Project Settings
60 * @param string|int $group_id the group id used for the group profile
61 * @param array $props associative array of properties to unset on the group profile
62 * @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the group profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
63 */
64 public function remove($group_key, $group_id, $props, $ignore_time = false) {
65 $payload = $this->_constructPayload($group_key, $group_id, '$remove', $props, $ignore_time);
66 $this->enqueue($payload);
67 }
68
69 /**
70 * Adds $val to a list located at $prop. If the property does not exist, it will be created. If $val is a string
71 * and the list is empty or does not exist, a new list with one value will be created.
72 * @param string|int $group_key the group_key used for groups in Project Settings
73 * @param string|int $group_id the group id used for the group profile
74 * @param string $prop the property that holds the list
75 * @param string|array $val items to add to the list
76 * @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the group profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
77 */
78 public function union($group_key, $group_id, $prop, $val, $ignore_time = false) {
79 $payload = $this->_constructPayload($group_key, $group_id, '$union', array("$prop" => $val), $ignore_time);
80 $this->enqueue($payload);
81 }
82
83 /**
84 * Delete this group profile from Mixpanel
85 * @param string|int $group_key the group_key used for groups in Project Settings
86 * @param string|int $group_id the group id used for the group profile
87 * @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
88 */
89 public function deleteGroup($group_key, $group_id, $ignore_time = false) {
90 $payload = $this->_constructPayload($group_key, $group_id, '$delete', "", $ignore_time);
91 $this->enqueue($payload);
92 }
93
94 /**
95 * Returns the "groups" endpoint
96 * @return string
97 */
98 function _getEndpoint() {
99 return $this->_options['groups_endpoint'];
100 }
101
102 }
103