Taplytics PHP SDK enables the delivery of server-side experiments, feature flags and functionality at edge.
Refer to Getting Started to build Taplytics into your project.
API client can be initialized as following.
$client = new TaplyticsLib\TaplyticsClient();
The singleton instance of the APIController
class can be accessed from the API Client.
$client = $client->getClient();
All variables and their values for the given user
function createGetVariables(
$token,
$userId,
$body = null)
Parameter | Tags | Description |
---|---|---|
token | Required |
SDK token for the project |
userId | Required |
ID for given user |
body | Optional |
All relevant attributes associated with the user |
$token = 'token';
$userId = 'user_id';
$body = new Body();
$result = $client->createGetVariables($token, $userId, $body);
For a given experiment, determine whether or not a user is in the experiment, and in which variation
function createGetVariationForExperiment(
$token,
$userId,
$experimentName,
$body = null)
Parameter | Tags | Description |
---|---|---|
token | Required |
SDK token for the project |
userId | Required |
ID for given user |
experimentName | Required |
Name of an Experiment |
body | Optional |
All relevant attributes associated with the user |
$token = 'token';
$userId = 'user_id';
$experimentName = 'experimentName';
$body = new Body();
$result = $client->createGetVariationForExperiment($token, $userId, $experimentName, $body);
Value for given Taplytics Dynamic Variable. If a user is not in an experiment containing the variable, the response be the provided default value in the query params.
function createGetVariableValue(
$token,
$userId,
$varName,
$defaultValue,
$body = null)
Parameter | Tags | Description |
---|---|---|
token | Required |
SDK token for the project |
userId | Required |
ID for given user |
varName | Required |
name of variable |
defaultValue | Required |
default value to be used if user does not have variable available. |
body | Optional |
All relevant attributes associated with the user |
$token = 'token';
$userId = 'user_id';
$varName = 'varName';
$defaultValue = 'defaultValue';
$body = new Body();
$result = $client->createGetVariableValue($token, $userId, $varName, $defaultValue, $body);
Returns a key/value pairing of all experiments that the user has been segmented into, as well as the variation the users are assigned.
function createGetBucketing(
$token,
$userId,
$body = null)
Parameter | Tags | Description |
---|---|---|
token | Required |
SDK token for the project |
userId | Required |
ID for current user |
body | Optional |
Provide all relevant attributes associated with the user |
$token = 'token';
$userId = 'user_id';
$body = new Body();
$result = $client->createGetBucketing($token, $userId, $body);
Send an event to Taplytics. These events are then used to compare against an experiment's goals to determine the success of an A/B test.
function postEvent(
$token,
$userId,
$body = null)
Parameter | Tags | Description |
---|---|---|
token | Required |
SDK token for the project |
userId | Required |
ID for given user |
body | Optional |
Provide an array of events, as well as all additional relevant user attributes. |
$token = 'token';
$userId = 'user_id';
$body = array(
'events' => array(
array('eventName' => 'event name!', 'eventValue' => 5)
)
);
$result = $client->postEvent($token, $userId, $body);
The format for passing in events is as follows:
{
attributes: {
name: '',
...
},
events: [
{eventName: '', eventValue},
...
]
}
Returns the entire configuration for the project. This is the document that informs the experiment information such as segmentation. Extremely verbose and should be used for debugging.
function createGetConfig(
$token,
$userId,
$body = null)
Parameter | Tags | Description |
---|---|---|
token | Required |
SDK token for the project |
userId | Required |
ID for given user |
body | Optional |
All relevant attributes associated with the user |
$token = 'token';
$userId = 'user_id';
$body = new Body();
$result = $client->createGetConfig($token, $userId, $body);
Returns the list of feature flags with names and key names.
function createGetFeatureFlags(
$token,
$userId,
$body = null)
Parameter | Tags | Description |
---|---|---|
token | Required |
SDK token for the project |
userId | Required |
ID for given user |
body | Optional |
All relevant attributes associated with the user |
$token = 'token';
$userId = 'user_id';
$body = new Body();
$result = $client->createGetFeatureFlags($token, $userId, $body);
foreach($result as $flagObj) {
// $flagObj->name to get the name of the feature flag
// $flagObj->keyName to get the key of the feature flag
}
Returns true or false based on if the keyName passed in is an enabled feature flag.
function isFeatureFlagEnabled(
$token,
$userId,
$keyName,
$body = null)
Parameter | Tags | Description |
---|---|---|
token | Required |
SDK token for the project |
userId | Required |
ID for given user |
keyName | Required |
key name for the feature flag |
body | Optional |
All relevant attributes associated with the user |
$token = 'token';
$userId = 'user_id';
$keyName = 'featureFlagKey';
$body = new Body();
$result = $client->isFeatureFlagEnabled($token, $userId, $keyName, $body);
if ($result) {
showFeature();
}