first
This commit is contained in:
15
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/aliasing.php
vendored
Normal file
15
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/aliasing.php
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
// import the Mixpanel class
|
||||
require_once("../lib/Mixpanel.php");
|
||||
|
||||
// instantiate the Mixpanel class
|
||||
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN");
|
||||
|
||||
// create an alias for user id 12345 (note that this is a synchronous call)
|
||||
$mp->createAlias(12345, "john.doe@example.com");
|
||||
|
||||
// update the record previously identified by 12345 using the new alias
|
||||
$mp->people->set("john.doe@example.com", array(
|
||||
'$last_name' => "Doe-Aliased",
|
||||
'aliased' => "indeed"
|
||||
));
|
74
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/all_calls.php
vendored
Normal file
74
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/all_calls.php
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
require_once("/path/to/vendor/mixpanel/mixpanel-php/lib/Mixpanel.php"); // import the Mixpanel class
|
||||
|
||||
$mp = new Mixpanel("MIXPANEL_PROJECT_TOKEN", array(
|
||||
"debug" => true,
|
||||
));
|
||||
|
||||
// this would likely come from a database or session variable
|
||||
$user_id = 12345;
|
||||
|
||||
// associate user 12345 to all subsequent track calls
|
||||
$mp->identify($user_id);
|
||||
|
||||
// send property "color" = "red" with all subsequent track calls
|
||||
$mp->register("color", "red");
|
||||
|
||||
// send property "number" = 1 with all subsequent track calls, don't overwrite an existing value
|
||||
$mp->registerOnce("number", 1);
|
||||
$mp->registerOnce("number", 2); // this will do nothing
|
||||
|
||||
// send all of these properties with all subsequent track calls, overwriting previously set values
|
||||
$mp->registerAll(array("color" => "green", "prop2" => "val2")); // color is now green instead of red
|
||||
|
||||
// send all of these properties with all subsequent track calls, NOT overwriting previously set values
|
||||
$mp->registerAllOnce(array("color" => "blue", "prop3" => "val3")); // color is still green but prop3 is now set to val3
|
||||
|
||||
// track a custom "button click" event
|
||||
$mp->track("button click", array("label" => "Login"));
|
||||
|
||||
// track a custom "logged in" event
|
||||
$mp->track("logged in", array("landing page" => "/specials"));
|
||||
|
||||
// create/update a profile identified by id 12345 with $first_name set to John and $email set to john.doe@example.com
|
||||
// now we can send them Notifications!
|
||||
$mp->people->set($user_id, array(
|
||||
'$first_name' => "John",
|
||||
'$email' => "john.doe@example.com"
|
||||
));
|
||||
|
||||
// update John's profile with property ad_source to be "google" but don't override ad_source if it exists already
|
||||
$mp->people->setOnce($user_id, array("ad_source" => "google"));
|
||||
|
||||
// increment John's total logins by one
|
||||
$mp->people->increment($user_id, "login count", 1);
|
||||
|
||||
// append a new favorite to John's favorites
|
||||
$mp->people->append($user_id, "favorites", "Apples");
|
||||
|
||||
// append a few more favorites to John's favorites
|
||||
$mp->people->append($user_id, "favorites", array("Baseball", "Reading"));
|
||||
|
||||
// track a purchase or charge of $9.99 for user 12345 where the transaction happened just now
|
||||
$mp->people->trackCharge($user_id, "9.99");
|
||||
|
||||
// track a purchase or charge of $20 for user 12345 where the transaction happened on June 01, 2013 at 5pm EST
|
||||
$mp->people->trackCharge($user_id, "20.00", strtotime("01 Jun 2013 5:00:00 PM EST"));
|
||||
|
||||
// clear all purchases for user 12345
|
||||
$mp->people->clearCharges($user_id);
|
||||
|
||||
// delete the profile for user 12345
|
||||
$mp->people->deleteUser($user_id);
|
||||
|
||||
// create an alias for user 12345 (note that this is done synchronously)
|
||||
$mp->createAlias($user_id, "johndoe1");
|
||||
|
||||
// track an even using the alias
|
||||
$mp->track("logout", array("distinct_id" => "johndoe1"));
|
||||
|
||||
// manually put messages on the queue (useful for batch processing)
|
||||
$mp->enqueueAll(array(
|
||||
array("event" => "test"),
|
||||
array("event" => "test2")
|
||||
));
|
21
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/consumers/ObConsumer.php
vendored
Normal file
21
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/consumers/ObConsumer.php
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/../../lib/ConsumerStrategies/AbstractConsumer.php");
|
||||
|
||||
class ObConsumer extends ConsumerStrategies_AbstractConsumer {
|
||||
public function persist($batch) {
|
||||
|
||||
if (isset($batch[0]['event']) && $batch[0]['event'] == "force_error") {
|
||||
$this->_handleError(0, "This is the data from a fake error");
|
||||
return false;
|
||||
} else {
|
||||
echo "<pre>";
|
||||
echo "printing batch:\n";
|
||||
echo "---------------\n";
|
||||
echo json_encode($batch) . "\n";
|
||||
echo "---------------\n\n";
|
||||
echo "</pre>";
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
14
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/curl_consumer.php
vendored
Normal file
14
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/curl_consumer.php
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
require_once("../lib/Mixpanel.php"); // import the Mixpanel class
|
||||
|
||||
// Make calls using the PHP cURL extension not using SSL
|
||||
// Warning: This will block until the requests are complete.
|
||||
$mp = new Mixpanel("MIXPANEL_PROJECT_TOKEN", array(
|
||||
"debug" => true,
|
||||
"consumer" => "curl",
|
||||
"fork" => false,
|
||||
"use_ssl" => false
|
||||
));
|
||||
|
||||
$mp->track("test_event", array("color" => "blue"));
|
||||
$mp->track("test_event", array("color" => "red"));
|
13
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/custom_consumer.php
vendored
Normal file
13
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/custom_consumer.php
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require_once("../lib/Mixpanel.php"); // import the Mixpanel class
|
||||
require_once("consumers/ObConsumer.php"); // import the custom consumer
|
||||
|
||||
$mp = new Mixpanel("MIXPANEL_PROJECT_TOKEN", array(
|
||||
"debug" => true,
|
||||
"max_batch_size" => 1,
|
||||
"consumers" => array("ob" => "ObConsumer"),
|
||||
"consumer" => "ob"
|
||||
));
|
||||
|
||||
$mp->track("test_event", array("color" => "blue"));
|
||||
$mp->track("test_event", array("color" => "red"));
|
21
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/error_handling.php
vendored
Normal file
21
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/error_handling.php
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
require_once("../lib/Mixpanel.php"); // import the Mixpanel class
|
||||
require_once("consumers/ObConsumer.php"); // import the Mixpanel class
|
||||
|
||||
// define a callback function to handle errors made in a consumer
|
||||
function handleError($code, $data) {
|
||||
echo "This is my customer error handler. I've received an error! code = " . $code . " : data = " . $data . "<br />";
|
||||
}
|
||||
|
||||
// instantiate Mixpanel with some different options including a custom consumer and a custom error callback
|
||||
$mp = new Mixpanel("MIXPANEL_PROJECT_TOKEN", array(
|
||||
"debug" => true,
|
||||
"max_batch_size" => 1,
|
||||
"consumers" => array("ob" => "ObConsumer"),
|
||||
"consumer" => "ob",
|
||||
"error_callback" => "handleError" // register the error callback
|
||||
));
|
||||
|
||||
$mp->track("test_event", array("color" => "blue"));
|
||||
$mp->track("test_event", array("color" => "red"));
|
||||
$mp->track("force_error"); // a magical event we've defined as an error in our custom "ObConsumer"
|
34
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/group_advanced.php
vendored
Normal file
34
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/group_advanced.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// import the Mixpanel class
|
||||
require_once("../lib/Mixpanel.php");
|
||||
|
||||
// instantiate the Mixpanel class
|
||||
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN");
|
||||
|
||||
//create or update a grou pprofile with properties Industry and Product
|
||||
$mp->group->set("company","Mixpanel3", array(
|
||||
'Industry' => "Tech",
|
||||
'Product' => "Product Analytics",
|
||||
'Features' => array("Insights"),
|
||||
'test' => "test1234",
|
||||
));
|
||||
|
||||
// create or update a group profile with properties
|
||||
// using SetOnce Industry will not be overwritten as the value already exists
|
||||
|
||||
$mp->group->setOnce("company","Mixpanel3", array(
|
||||
'Industry' => "TechTest",
|
||||
'Name' => "Mixpanel",
|
||||
));
|
||||
|
||||
|
||||
// unsets the property test
|
||||
$mp->group->remove("company","Mixpanel3", array("test"));
|
||||
|
||||
|
||||
// add Funnels Cohorts and Flows to a list of "Features" for Group profile Mixpanel3
|
||||
$mp->group->union("company","Mixpanel3", "Features", array("Funnels","Flows","Cohorts") );
|
||||
|
||||
|
||||
//deletegroup
|
||||
$mp->group->deleteGroup("company","Mixpanel3");
|
9
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/group_simple.php
vendored
Normal file
9
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/group_simple.php
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
require_once("../lib/Mixpanel.php"); // import the Mixpanel class
|
||||
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN"); // instantiate the Mixpanel class
|
||||
|
||||
// create or update a Group profile with First Name, Last Name, E-Mail Address, Phone Number, and Favorite Color
|
||||
$mp->group->set("company","Mixpanel", array(
|
||||
'Industry' => "Tech",
|
||||
'Product' => "Product Analytics",
|
||||
));
|
30
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/profile_advanced.php
vendored
Normal file
30
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/profile_advanced.php
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// import the Mixpanel class
|
||||
require_once("../lib/Mixpanel.php");
|
||||
|
||||
// instantiate the Mixpanel class
|
||||
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN");
|
||||
|
||||
// create or update a profile with First Name, Last Name, E-Mail Address, Phone Number, and Favorite Color
|
||||
$mp->people->set(12345, array(
|
||||
'$first_name' => "John",
|
||||
'$last_name' => "Doe",
|
||||
'$email' => "john.doe@example.com",
|
||||
'$phone' => "5555555555",
|
||||
"Favorite Color" => "red"
|
||||
));
|
||||
|
||||
// increment the count of login attempts for user 12345
|
||||
$mp->people->increment(12345, "Login Attempts", 1);
|
||||
|
||||
// add "Home Page" to a list of "Page Views" for user 12345
|
||||
$mp->people->append(12345, "Page Views", "Home Page");
|
||||
|
||||
// add Cats, Pizza, and Baseball to a list of "Favorites" for user 12345
|
||||
$mp->people->append(12345, "Favorites", array("Cats", "Pizza", "Baseball"));
|
||||
|
||||
// track a purchase or charge of $9.99 for user 12345 where the transaction happened just now
|
||||
$mp->people->trackCharge(12345, "9.99");
|
||||
|
||||
// track a purchase or charge of $20 for user 12345 where the transaction happened on June 01, 2013 at 5pm EST
|
||||
$mp->people->trackCharge(12345, "20.00", strtotime("01 Jun 2013 5:00:00 PM EST"));
|
12
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/profile_simple.php
vendored
Normal file
12
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/profile_simple.php
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
require_once("../lib/Mixpanel.php"); // import the Mixpanel class
|
||||
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN"); // instantiate the Mixpanel class
|
||||
|
||||
// create or update a profile with First Name, Last Name, E-Mail Address, Phone Number, and Favorite Color
|
||||
$mp->people->set(12345, array(
|
||||
'$first_name' => "John",
|
||||
'$last_name' => "Doe",
|
||||
'$email' => "john.doe@example.com",
|
||||
'$phone' => "5555555555",
|
||||
"Favorite Color" => "red"
|
||||
));
|
11
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/socket_consumer.php
vendored
Normal file
11
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/socket_consumer.php
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
require_once("../lib/Mixpanel.php"); // import the Mixpanel class
|
||||
|
||||
$mp = new Mixpanel("MIXPANEL_PROJECT_TOKEN", array(
|
||||
"debug" => true,
|
||||
"consumer" => "socket",
|
||||
"use_ssl" => false
|
||||
));
|
||||
|
||||
$mp->track("test_event", array("color" => "blue"));
|
||||
$mp->track("test_event", array("color" => "red"));
|
21
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/track_advanced.php
vendored
Normal file
21
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/track_advanced.php
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
// import the Mixpanel class
|
||||
require_once("../lib/Mixpanel.php");
|
||||
|
||||
// instantiate the Mixpanel class
|
||||
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN");
|
||||
|
||||
// associate a user id to subsequent events
|
||||
$mp->identify(12345);
|
||||
|
||||
// track a "Login Success" event with a property "Ad Source" having value "Google"
|
||||
$mp->track("Login Success", array("Ad Source" => "Google"));
|
||||
|
||||
// track an "Item Viewed" event with a property "Item" having value "Cool New Shoes"
|
||||
$mp->track("Item Viewed", array("Item" => "Cool New Shoes"));
|
||||
|
||||
// stop associating events to user 12345
|
||||
$mp->unregister("distinct_id");
|
||||
|
||||
// event "Some Event" won't be associated with user 12345
|
||||
$mp->track("Some Event");
|
4
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/track_simple.php
vendored
Normal file
4
wp-content/plugins/wp-smushit/vendor/mixpanel/mixpanel-php/examples/track_simple.php
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
require_once("../lib/Mixpanel.php"); // import the Mixpanel class
|
||||
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN"); // instantiate the Mixpanel class
|
||||
$mp->track("login_clicked"); // track an event
|
Reference in New Issue
Block a user