Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/Optimizely/DecisionService/DecisionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
use Optimizely\UserProfile\UserProfileUtils;
use Optimizely\Utils\Validator;

// This value was decided between App Backend, Audience, and Oasis teams, but may possibly change.
// We decided to prefix the reserved keyword with '$' because it is a symbol that is not
// allowed in custom attributes.
// We also thought that the prefix 'opt' makes it apparent to users that the variable belongs to Optimizely.
// Reserved attribute for bucketing ID.
define("RESERVED_ATTRIBUTE_KEY_BUCKETING_ID", "\$opt_bucketing_id");

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Optimizely/Entity/FeatureFlag.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

use Optimizely\Utils\ConfigParser;

class FeatureFlag{
class FeatureFlag
{

/**
* variable to hold feature flag ID
Expand Down
3 changes: 2 additions & 1 deletion src/Optimizely/Entity/FeatureVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

namespace Optimizely\Entity;

class FeatureVariable{
class FeatureVariable
{

// Feature variable primitive types
const BOOLEAN_TYPE = 'boolean';
Expand Down
3 changes: 2 additions & 1 deletion src/Optimizely/Entity/Rollout.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

use Optimizely\Utils\ConfigParser;

class Rollout{
class Rollout
{

/**
* The ID of the rollout
Expand Down
3 changes: 2 additions & 1 deletion src/Optimizely/Entity/VariableUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

namespace Optimizely\Entity;

class VariableUsage{
class VariableUsage
{

/**
* The ID of the live variable this usage is modifying
Expand Down
20 changes: 12 additions & 8 deletions src/Optimizely/Event/Builder/EventBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class EventBuilder
* @param $config ProjectConfig Configuration for the project.
* @param $userId string ID of user.
* @param $attributes array Attributes of the user.
*
* @return array Hash representing parameters which are common to both impression and conversion events.
*/
private function getCommonParams($config, $userId, $attributes)
{
Expand Down Expand Up @@ -89,14 +91,12 @@ private function getCommonParams($config, $userId, $attributes)
if (!is_null($attributeValue)) {
// check for reserved attributes
if (strcmp($attributeKey , RESERVED_ATTRIBUTE_KEY_BUCKETING_ID) == 0) {
// TODO (Alda): the type for bucketing ID attribute may change so that custom
// attributes are not overloaded
$feature = [
ENTITY_ID => RESERVED_ATTRIBUTE_KEY_BUCKETING_ID,
KEY => RESERVED_ATTRIBUTE_KEY_BUCKETING_ID_EVENT_PARAM_KEY,
TYPE => CUSTOM_ATTRIBUTE_FEATURE_TYPE,
VALUE => $attributeValue
];
ENTITY_ID => RESERVED_ATTRIBUTE_KEY_BUCKETING_ID,
KEY => RESERVED_ATTRIBUTE_KEY_BUCKETING_ID_EVENT_PARAM_KEY,
TYPE => CUSTOM_ATTRIBUTE_FEATURE_TYPE,
VALUE => $attributeValue
];

} else {
$attributeEntity = $config->getAttribute($attributeKey);
Expand All @@ -122,7 +122,9 @@ private function getCommonParams($config, $userId, $attributes)
* Helper function to get parameters specific to impression event.
*
* @param $experiment Experiment Experiment being activated.
* @param $variationId string
* @param $variationId String ID representing the variation for the user.
*
* @return array Hash representing parameters particular to impression event.
*/
private function getImpressionParams(Experiment $experiment, $variationId)
{
Expand Down Expand Up @@ -156,6 +158,8 @@ private function getImpressionParams(Experiment $experiment, $variationId)
* @param $eventKey string Key representing the event.
* @param $experimentVariationMap array Map of experiment ID to the ID of the variation that the user is bucketed into.
* @param $eventTags array Hash representing metadata associated with the event.
*
* @return array Hash representing parameters particular to conversion event.
*/
private function getConversionParams($config, $eventKey, $experimentVariationMap, $eventTags)
{
Expand Down
5 changes: 2 additions & 3 deletions src/Optimizely/Optimizely.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use Throwable;
use Monolog\Logger;
use Optimizely\DecisionService\DecisionService;
use Optimizely\Entity\Experiment;
use Optimizely\Logger\DefaultLogger;
use Optimizely\ErrorHandler\ErrorHandlerInterface;
use Optimizely\ErrorHandler\NoOpErrorHandler;
Expand Down Expand Up @@ -175,10 +174,10 @@ private function validateUserInputs($attributes, $eventTags = null) {
* is one that is in "Running" state and into which the user has been bucketed.
*
* @param $event string Event key representing the event which needs to be recorded.
* @param $user string ID for user.
* @param $userId string ID for user.
* @param $attributes array Attributes of the user.
*
* @return Array Of objects where each object contains the ID of the experiment to track and the ID of the variation the user is bucketed into.
* @return array Of objects where each object contains the ID of the experiment to track and the ID of the variation the user is bucketed into.
*/
private function getValidExperimentsForEvent($event, $userId, $attributes = null) {
$validExperiments = [];
Expand Down
1 change: 1 addition & 0 deletions tests/BucketerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
class BucketerTest extends \PHPUnit_Framework_TestCase
{
private $testBucketingIdControl;
private $testBucketingIdVariation;
private $testBucketingIdGroupExp2Var2;
private $testUserId;
private $testUserIdBucketsToVariation;
Expand Down
2 changes: 1 addition & 1 deletion tests/EventTests/EventBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function setUp()
$this->eventBuilder = new EventBuilder();
$this->timestamp = time()*1000;
$this->uuid = 'a68cf1ad-0393-4e18-af87-efe8f01a7c9c';
$this->differ = new Differ;
$this->differ = new Differ();

$this->expectedEventUrl = 'https://logx.optimizely.com/v1/events';
$this->expectedEventParams = [
Expand Down
8 changes: 4 additions & 4 deletions tests/OptimizelyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@

use Exception;
use Monolog\Logger;
use Optimizely\ErrorHandler\DefaultErrorHandler;
use Optimizely\ErrorHandler\NoOpErrorHandler;
use Optimizely\Event\Builder\EventBuilder;
use Optimizely\Event\LogEvent;
use Optimizely\Exceptions\InvalidAttributeException;
use Optimizely\Logger\DefaultLogger;
use Optimizely\Logger\NoOpLogger;
use Optimizely\Optimizely;
use Optimizely\ProjectConfig;
use TypeError;
use Optimizely\ErrorHandler\DefaultErrorHandler;
use Optimizely\Event\Builder\EventBuilder;
use Optimizely\Logger\DefaultLogger;
use Optimizely\Optimizely;


class OptimizelyTest extends \PHPUnit_Framework_TestCase
Expand Down
1 change: 0 additions & 1 deletion tests/ProjectConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use Optimizely\Exceptions\InvalidRolloutException;
use Optimizely\Exceptions\InvalidGroupException;
use Optimizely\Exceptions\InvalidVariationException;
use Optimizely\Logger\DefaultLogger;
use Optimizely\Logger\NoOpLogger;
use Optimizely\Optimizely;
use Optimizely\ProjectConfig;
Expand Down