diff --git a/CHANGELOG.md b/CHANGELOG.md index c73aebb..e90deff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.7.2] - 2020-05-06 +### Changed +- Fix variable naming and update `README.md` file + ## [1.7.1] - 2020-04-29 ### Changed - Use `bucketinfo` correctly in `VWO.php` which was causing weird issues related to decision making in Feature Rollout and Feature Test. diff --git a/README.md b/README.md index 6e00e50..6095456 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,11 @@ [![Latest Stable Version](https://img.shields.io/packagist/v/vwo/vwo-php-sdk.svg)](https://packagist.org/packages/vwo/vwo-php-sdk) [![Build Status](http://img.shields.io/travis/wingify/vwo-php-sdk/master.svg?style=flat)](http://travis-ci.org/wingify/vwo-php-sdk) [![Coverage Status](https://coveralls.io/repos/github/wingify/vwo-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/wingify/vwo-php-sdk?branch=master)[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0) -VWO server side sdk helps in integrating you integrating the vwo features in backend. -Using the sdk you can fetch the campaigns , variations and goals which you have configured -in vwo app. Sdk will automatically calculate the variation that should be assigned to the user. -One can also send the goal track data to vwo app to check the conversions on the vwo dashborad. - +This open source library provides you server-side testing capabilities. ## Requirements -* PHP 5.6 or later + +> PHP >= 5.6 ## Installation @@ -25,45 +22,38 @@ composer require vwo/vwo-php-sdk ```php $settingsFile, - 'isDevelopmentMode' => 0, // optional: 1 to enable the dev mode - 'logging' => new CustomLogger(), // optional - 'userStorageService' => new userStorageService() // optional +$sdkConfig = [ + 'settingsFile' => $settingsFile, + 'isDevelopmentMode' => 0, // optional: 1 to enable the dev mode + 'logging' => new CustomLogger(), // optional + 'userStorageService' => new userStorageService() // optional ]; -$vwoClient = new VWO($config); +$vwoClient = new VWO($sdkConfig); // to get the variation name along with add a visitor hit to vwo app stats -$varient=$vwoClient->activate($campaignKey, $userId, $options); - - -// to get the variation name -$varient=$vwoClient->getVariation($campaignKey, $userId, $options); - +$variation = $vwoClient->activate($campaignKey, $userId, $options); +// Or, to get the variation name +$variation = $vwoClient->getVariation($campaignKey, $userId, $options); // add code here to use variation //... - /** *send the track api hit to the vwo app stats to increase conversions * $revenue is optional send in case if there is any revenue inside $options @@ -72,39 +62,42 @@ $varient=$vwoClient->getVariation($campaignKey, $userId, $options); $vwoClient->track($campaignKey, $userId, $goalIdentifier, $options); ``` -**Code for UserStorage service** +**Code for implementing User Storage Service** ```php $userId, - 'campaignKey' => $campaignKey, - 'variationName' => 'Variation-2' - ]; - } - - /** - * @param $campaignUserMapping - * @return bool - */ - public function set($campaignUserMapping){ - // S...code to tore in DB/storage system - return True; - } + /** + * @param $userId + * @param $campaignKey + * + * @return array + */ + public function get($userId, $campaignKey) { + // search in DB/Storage system + $variation = $db->fetch($userId, $campaignKey); // replace with your implementation + + return[ + 'userId' => $userId, + 'campaignKey' => $campaignKey, + 'variationName' => $variation + ]; + } + + /** + * @param $campaignUserMapping + * @return bool - could be changed + */ + public function set($campaignUserMapping) { + // S...code to store in DB/storage system + return True; + } } ``` -**Code for customLogger file** +**Code for implementing Custom Logger** ```php $settingsFile, - 'isDevelopmentMode'=> 0, // optional: 1 to enable the dev mode - 'logger'=> new CustomLogger(), // optional - 'userStorageService'=> new userStorageService() // optional -]; - -$vwoClient = new VWO($config); -``` - -**Use the code below to both activate campaign for a user and fetch variation name** - -```php -// to get the variation name along with add a visitor hit to vwo app stats -$varient=$vwoClient->activate($campaignKey, $userId, $options); -``` - -**Use the code below to get variation name** - -```php -// to get the variation name along with add a visitor hit to vwo app stats -$varient=$vwoClient->getVariation($campaignKey, $userId, $options); -``` - -**Use the code below to track** - -```php -/** -*send the track api hit to the vwo app stats to increase conversions -* $revenue is optional send in case if there is any revenue inside $options -*/ - -$vwoClient->track($campaignKey, $userId, $goalIdentifier, $options); -``` - ## Documentation Refer [Official VWO Documentation](https://developers.vwo.com/reference#server-side-introduction) - ## Third-party Resources and Credits Refer [third-party-attributions.txt](https://github.com/wingify/vwo-php-sdk/blob/master/third-party-attributions.txt) diff --git a/src/Constants/Constants.php b/src/Constants/Constants.php index 49671a9..190514a 100755 --- a/src/Constants/Constants.php +++ b/src/Constants/Constants.php @@ -29,7 +29,7 @@ class Constants /** * sdk version for api hit */ - const SDK_VERSION = '1.7.1'; + const SDK_VERSION = '1.7.2'; /** * sdk langauge for api hit */ @@ -71,15 +71,15 @@ class Constants 'CUSTOM_LOGGER_USED' => '({file}): Custom logger used', 'SDK_INITIALIZED' => '({file}): SDK properly initialzed', 'SETTINGS_FILE_PROCESSED' => '({file}): Settings file processed', - 'NO_STORED_VARIATION' => '({file}): No stored variation for UserId:{userId} for Campaign:{campaignTestKey} found in UserStorageService', + 'NO_STORED_VARIATION' => '({file}): No stored variation for UserId:{userId} for Campaign:{campaignKey} found in UserStorageService', 'NO_USER_STORAGE_SERVICE_GET' => '({file}): No UserStorageService to get for stored data', 'NO_USER_STORAGE_SERVICE_SET' => '({file}): No UserStorageService to set data', - 'GETTING_STORED_VARIATION' => '({file}): Got stored variation for UserId:{userId} of Campaign:{campaignTestKey} as Variation: {variationName}, found in UserStorageService', - 'CHECK_USER_ELIGIBILITY_FOR_CAMPAIGN' => '({file}): campaign:{campaignTestKey} having traffic allocation:{trafficAllocation} assigned value:{trafficAllocation} to userId:{userId}', + 'GETTING_STORED_VARIATION' => '({file}): Got stored variation for UserId:{userId} of Campaign:{campaignKey} as Variation: {variationName}, found in UserStorageService', + 'CHECK_USER_ELIGIBILITY_FOR_CAMPAIGN' => '({file}): campaign:{campaignKey} having traffic allocation:{trafficAllocation} assigned value:{trafficAllocation} to userId:{userId}', 'USER_HASH_BUCKET_VALUE' => '({file}): userId:{userId} having hash:{hashValue} got bucketValue:{bucketValue}', - 'VARIATION_HASH_BUCKET_VALUE' => '({file}): userId:{userId} for campaign:{campaignTestKey} having percent traffic:{percentTraffic} got hash-value:{hashValue} and bucket value:{bucketValue}', - 'GOT_VARIATION_FOR_USER' => '({file}): userId:{userId} for campaign:{campaignTestKey} got variationName:{variationName} inside method:{method}', - 'USER_NOT_PART_OF_CAMPAIGN' => '({file}): userId:{userId} for campaign:{campaignTestKey} did not become part of campaign, method:{method}', + 'VARIATION_HASH_BUCKET_VALUE' => '({file}): userId:{userId} for campaign:{campaignKey} having percent traffic:{percentTraffic} got hash-value:{hashValue} and bucket value:{bucketValue}', + 'GOT_VARIATION_FOR_USER' => '({file}): userId:{userId} for campaign:{campaignKey} got variationName:{variationName} inside method:{method}', + 'USER_NOT_PART_OF_CAMPAIGN' => '({file}): userId:{userId} for campaign:{campaignKey} did not become part of campaign, method:{method}', 'UUID_FOR_USER' => '({file}): Uuid generated for userId:{userid} and accountId:{accountId} is {desiredUuid}', 'FEATURE_FLAG_NOT_LINKED' => '({file}): Feature:{featureKey} is not linked to any running campaigns', 'USER_HASH_BUCKET_VALUE' => '({file}): User ID:{userId} having hash:{hashValue} got bucketValue:{bucketValue}', @@ -91,19 +91,19 @@ class Constants */ const INFO_MESSAGES = [ - 'VARIATION_RANGE_ALLOCATION' => '({file}): Campaign:{campaignTestKey} having variations:{variationName} with weight:{variationWeight} got range as: ( {start} - {end} ))', - 'VARIATION_ALLOCATED' => '({file}): UserId:{userId} of Campaign:{campaignTestKey} got variation: {variationName}', + 'VARIATION_RANGE_ALLOCATION' => '({file}): Campaign:{campaignKey} having variations:{variationName} with weight:{variationWeight} got range as: ( {start} - {end} ))', + 'VARIATION_ALLOCATED' => '({file}): UserId:{userId} of Campaign:{campaignKey} got variation: {variationName}', 'GETTING_UP_USER_STORAGE_SERVICE' => '({file}): Getting data into UserStorageService for userId:{userId} successful', 'SETTING_DATA_USER_STORAGE_SERVICE' => '({file}): Setting data into UserStorageService for userId:{userId} successful', - 'GOT_STORED_VARIATION' => '({file}): Got stored variation:{variationName} of campaign:{campaignTestKey} for userId:{userId} from UserStorageService', - 'NO_VARIATION_ALLOCATED' => '({file}): UserId:{userId} of Campaign:{campaignTestKey} did not get any variation', + 'GOT_STORED_VARIATION' => '({file}): Got stored variation:{variationName} of campaign:{campaignKey} for userId:{userId} from UserStorageService', + 'NO_VARIATION_ALLOCATED' => '({file}): UserId:{userId} of Campaign:{campaignKey} did not get any variation', 'USER_ELIGIBILITY_FOR_CAMPAIGN' => '({file}): Is userId:{userId} part of campaign? {isUserPart}', 'AUDIENCE_CONDITION_NOT_MET' => '({file}): userId:{userId} does not become part of campaign because of not meeting audience conditions', - 'GOT_VARIATION_FOR_USER' => '({file}): userId:{userId} for campaign:{campaignTestKey} got variationName:{variationName}', - 'USER_GOT_NO_VARIATION' => '({file}): userId:{userId} for campaign:{campaignTestKey} did not allot any variation', + 'GOT_VARIATION_FOR_USER' => '({file}): userId:{userId} for campaign:{campaignKey} got variationName:{variationName}', + 'USER_GOT_NO_VARIATION' => '({file}): userId:{userId} for campaign:{campaignKey} did not allot any variation', 'IMPRESSION_SUCCESS' => '({file}): Event sent to VWO - {endPoint} having main keys: accountId:{accountId}, userId:{userId}, campaignId:{campaignId} and variationId:{variationId}', 'IMPRESSION_SUCCESS_PUSH' => '({file}): Event sent to VWO - {endPoint} having main keys: accountId:{accountId}, userId:{userId} and tags:{tags}', - 'INVALID_VARIATION_KEY' => '({file}): Variation was not assigned to userId:{userId} for campaign:{campaignTestKey}', + 'INVALID_VARIATION_KEY' => '({file}): Variation was not assigned to userId:{userId} for campaign:{campaignKey}', 'API_CALLED' => '({file}): API: {api} called for userid : {userId}', 'IMPRESSION_FOR_TRACK_USER' => '({file}): impression built for track-user - {properties}', 'IMPRESSION_FOR_TRACK_GOAL' => '({file}): impression built for track-goal - {properties}', @@ -133,15 +133,15 @@ class Constants const ERROR_MESSAGE = [ 'INVALID_CONFIGURATION' => '({file}): SDK configuration or account settings or both is/are not valid.', 'SETTINGS_FILE_CORRUPTED' => '({file}): Settings file is corrupted. Please contact VWO Support for help.', - 'ACTIVATE_API_MISSING_PARAMS' => '({file}): "activate" API got bad parameters. It expects campaignTestKey(String) as first and userId(String/Number) as second argument', + 'ACTIVATE_API_MISSING_PARAMS' => '({file}): "activate" API got bad parameters. It expects campaignKey(String) as first and userId(String/Number) as second argument', 'ACTIVATE_API_CONFIG_CORRUPTED' => '({file}): "activate" API has corrupted configuration', - 'GET_VARIATION_API_MISSING_PARAMS' => '({file}): "getVariation" API got bad parameters. It expects campaignTestKey(String) as first and userId(String/Number) as second argument', + 'GET_VARIATION_API_MISSING_PARAMS' => '({file}): "getVariation" API got bad parameters. It expects campaignKey(String) as first and userId(String/Number) as second argument', 'GET_VARIATION_API_CONFIG_CORRUPTED' => '({file}): "getVariation" API has corrupted configuration', - 'TRACK_API_MISSING_PARAMS' => '({file}): "track" API got bad parameters. It expects campaignTestKey(String) as first, userId(String/Number) as second and goalIdentifier (string) as third argument. options is revenueValue(Float/Number/String) and is required for revenue goal only.', + 'TRACK_API_MISSING_PARAMS' => '({file}): "track" API got bad parameters. It expects campaignKey(String) as first, userId(String/Number) as second and goalIdentifier (string) as third argument. options is revenueValue(Float/Number/String) and is required for revenue goal only.', 'TRACK_API_CONFIG_CORRUPTED' => '({file}): "track" API has corrupted configuration', - 'TRACK_API_GOAL_NOT_FOUND' => '({file}): Goal not found for campaign:{campaignTestKey} and userId:{userId}', - 'TRACK_API_VARIATION_NOT_FOUND' => '({file}): Variation not found for campaign:{campaignTestKey} and userId:{userId}', - 'CAMPAIGN_NOT_RUNNING' => '({file}): Campaign:{campaignTestKey} is not RUNNING. Please verify from VWO App', + 'TRACK_API_GOAL_NOT_FOUND' => '({file}): Goal not found for campaign:{campaignKey} and userId:{userId}', + 'TRACK_API_VARIATION_NOT_FOUND' => '({file}): Variation not found for campaign:{campaignKey} and userId:{userId}', + 'CAMPAIGN_NOT_RUNNING' => '({file}): Campaign:{campaignKey} is not RUNNING. Please verify from VWO App', 'GET_USER_STORAGE_SERVICE_FAILED' => '({file}): Getting data from UserStorageService failed for userId:{userId}', 'SET_USER_STORAGE_SERVICE_FAILED' => '({file}): Setting data into UserStorageService failed for userId:{userId}', 'INVALID_CAMPAIGN' => '({file}): Invalid campaign passed to {method} of this file', @@ -149,7 +149,7 @@ class Constants 'USERID_KEY_CORRUPTED' => '({file}): userId parameter value - {userId} is corrupted', 'FEATURE_KEY_CORRUPTED' => '({file}): featureKey parameter value - {featureKey} is corrupted', 'CUSTOM_LOGGER_MISCONFIGURED' => '({file}): Custom logger is provided but seems to have misconfigured. Please check the API Docs. Using default logger.', - 'MISSING_GOAL_REVENUE' => 'Revenue value should be passed for revenue goal {goalIdentifier} for campaign {campaignTestKey} and userId {userId}', + 'MISSING_GOAL_REVENUE' => 'Revenue value should be passed for revenue goal {goalIdentifier} for campaign {campaignKey} and userId {userId}', 'TAG_KEY_LENGTH_ERROR' => '({file}): Length of tagKey:{tagKey} for userID:{userId} can not be greater than 255', 'TAG_VALUE_LENGTH_ERROR' => '({file}): Length of tagValue:{tagValue} for userID:{userId} can not be greater than 255', 'INVALID_USER_ID' => '({file}): Invalid userId:{userId} passed to {method} of this file', diff --git a/src/Core/Bucketer.php b/src/Core/Bucketer.php index d0308d7..f3fb64e 100644 --- a/src/Core/Bucketer.php +++ b/src/Core/Bucketer.php @@ -79,7 +79,7 @@ public static function getBucket($userId, $campaign) // if bucketing to be done $bucketVal = self::getBucketVal($userId, self::$MAX_CAMPAIGN_TRAFFIC); if (!self::isUserPartofCampaign($bucketVal, $campaign['percentTraffic'])) { - \vwo\VWO::addLog(Logger::DEBUG, Constants::DEBUG_MESSAGES['USER_NOT_PART_OF_CAMPAIGN'], ['{userId}' => $userId, '{method}' => 'getBucket', '{campaignTestKey}' => $campaign['key']], self::$CLASSNAME); + \vwo\VWO::addLog(Logger::DEBUG, Constants::DEBUG_MESSAGES['USER_NOT_PART_OF_CAMPAIGN'], ['{userId}' => $userId, '{method}' => 'getBucket', '{campaignKey}' => $campaign['key']], self::$CLASSNAME); return null; } $multiplier = self::getMultiplier($campaign['percentTraffic']); @@ -89,10 +89,10 @@ public static function getBucket($userId, $campaign) $variation = self::variationUsingRange($rangeForVariations, $campaign['variations']); \vwo\VWO::addLog(Logger::DEBUG, Constants::DEBUG_MESSAGES['VARIATION_HASH_BUCKET_VALUE'], ['{userId}' => $userId,'{bucketValue}' => $rangeForVariations, '{percentTraffic}' => $campaign['percentTraffic'], '{campaignKey}' => $campaign['key']], self::$CLASSNAME); if ($variation !== null) { - \vwo\VWO::addLog(Logger::INFO, Constants::INFO_MESSAGES['GOT_VARIATION_FOR_USER'], ['{variationName}' => $variation['name'], '{userId}' => $userId, '{method}' => 'getBucket', '{campaignTestKey}' => $campaign['key']], self::$CLASSNAME); + \vwo\VWO::addLog(Logger::INFO, Constants::INFO_MESSAGES['GOT_VARIATION_FOR_USER'], ['{variationName}' => $variation['name'], '{userId}' => $userId, '{method}' => 'getBucket', '{campaignKey}' => $campaign['key']], self::$CLASSNAME); return $variation; } - \vwo\VWO::addLog(Logger::INFO, Constants::INFO_MESSAGES['NO_VARIATION_ALLOCATED'], ['{userId}' => $userId, '{campaignTestKey}' => $campaign['key']], self::$CLASSNAME); + \vwo\VWO::addLog(Logger::INFO, Constants::INFO_MESSAGES['NO_VARIATION_ALLOCATED'], ['{userId}' => $userId, '{campaignKey}' => $campaign['key']], self::$CLASSNAME); return null; } diff --git a/src/Storage/UserStorageInterface.php b/src/Storage/UserStorageInterface.php index 29be018..b137a18 100755 --- a/src/Storage/UserStorageInterface.php +++ b/src/Storage/UserStorageInterface.php @@ -21,20 +21,20 @@ /** * Interface UserStorageInterface * - * user interface should be included and used to set and get + * user interface should be included and used to set and get user-campaign mapping */ interface UserStorageInterface { /** * @param $userId - * @param $campaignName + * @param $campaignKey * @return mixed */ - public function get($userId, $campaignName); + public function get($userId, $campaignKey); /** * @param $campaignInfo - * @return mixed + * @return array */ public function set($campaignInfo); } diff --git a/src/Utils/Common.php b/src/Utils/Common.php index fe06192..d94c8e6 100755 --- a/src/Utils/Common.php +++ b/src/Utils/Common.php @@ -58,7 +58,7 @@ public static function makelogMessage($message, $params, $className = '', $apiNa * * @param $campaignKey * @param $bucketInfo - * @param $customerHash + * @param $userId * @return array */ diff --git a/src/Utils/Validations.php b/src/Utils/Validations.php index 408c1d8..7a5edb5 100755 --- a/src/Utils/Validations.php +++ b/src/Utils/Validations.php @@ -182,6 +182,7 @@ public static function validateUserId($userId) * function to check if the campaignkey exists in campign array from settings * * @param $campaignKey + * @param $settings * @return null */ public static function getCampaignFromCampaignKey($campaignKey, $settings) @@ -196,7 +197,7 @@ public static function getCampaignFromCampaignKey($campaignKey, $settings) } } } - VWO::addLog(Logger::ERROR, Constants::ERROR_MESSAGE['CAMPAIGN_NOT_RUNNING'], ['{campaignTestKey}' => $campaignKey], self::$CLASSNAME); + VWO::addLog(Logger::ERROR, Constants::ERROR_MESSAGE['CAMPAIGN_NOT_RUNNING'], ['{campaignKey}' => $campaignKey], self::$CLASSNAME); return null; } } diff --git a/src/VWO.php b/src/VWO.php index 3991e54..cb9ace5 100644 --- a/src/VWO.php +++ b/src/VWO.php @@ -272,7 +272,7 @@ private function fetchVariationData($campaign, $userId, $options = []) if ($campaign !== null) { //check for whitelisting if applied and get Variation Info $bucketInfo = Common::findVariationFromWhiteListing($campaign, $userId, $options); - // do murmur operations and get Variation for the customer + // do murmur operations and get Variation for the userId if ($bucketInfo == null) { $bucketInfo = $this->userStorageGet($userId, $campaign); if ($bucketInfo == null) { @@ -285,7 +285,7 @@ private function fetchVariationData($campaign, $userId, $options = []) [ '{userId}' => $userId, '{variationName}' => $bucketInfo['name'], - '{campaignTestKey}' => $campaign['key'] + '{campaignKey}' => $campaign['key'] ] ); @@ -303,7 +303,7 @@ private function fetchVariationData($campaign, $userId, $options = []) [ '{userId}' => $userId, '{variationName}' => $bucketInfo['name'], - '{campaignTestKey}' => $campaign['key'] + '{campaignKey}' => $campaign['key'] ] ); } @@ -374,10 +374,10 @@ private function userStorageSet($userId, $campaignKey, $variation) * API to send add visitor hit to vwo * * @param $campaign - * @param $customerHash - * @return mixed + * @param $userId + * @return boolean */ - private function addVisitor($campaign, $userId, $varientId) + private function addVisitor($campaign, $userId, $variationId) { try { if ($this->development_mode) { @@ -386,7 +386,7 @@ private function addVisitor($campaign, $userId, $varientId) } else { $params = array( 'experiment_id' => $campaign['id'], - 'combination' => $varientId, // variation id + 'combination' => $variationId, // variation id 'ed' => '{"p":"server"}', ); $parameters = Common::mergeCommonQueryParams($this->settings['accountId'], $userId, $params); @@ -407,7 +407,7 @@ private function addVisitor($campaign, $userId, $varientId) '{userId}' => $userId, '{endPoint}' => 'track-user', '{campaignId}' => $campaign['id'], - '{variationId}' => $varientId, + '{variationId}' => $variationId, '{accountId}' => $this->settings['accountId'] ] ); @@ -543,7 +543,7 @@ public function track($campaignKey = '', $userId = '', $goalName = '', $options self::addLog( Logger::DEBUG, Constants::DEBUG_MESSAGES['NO_STORED_VARIATION'], - ['{userId}' => $userId, '{campaignTestKey}' => $campaignKey] + ['{userId}' => $userId, '{campaignKey}' => $campaignKey] ); $this->userStorageSet($userId, $campaignKey, $bucketInfo); } else { @@ -553,7 +553,7 @@ public function track($campaignKey = '', $userId = '', $goalName = '', $options [ '{userId}' => $userId, '{variationName}' => $bucketInfo['name'], - '{campaignTestKey}' => $campaignKey + '{campaignKey}' => $campaignKey ] ); } @@ -576,7 +576,7 @@ public function track($campaignKey = '', $userId = '', $goalName = '', $options Constants::ERROR_MESSAGE['MISSING_GOAL_REVENUE'], [ '{goalIdentifier}' => $goalName, - '{campaignTestKey}' => $campaignKey, + '{campaignKey}' => $campaignKey, '{userId}' => $userId ] ); @@ -619,7 +619,7 @@ public function track($campaignKey = '', $userId = '', $goalName = '', $options self::addLog( Logger::ERROR, Constants::ERROR_MESSAGE['TRACK_API_GOAL_NOT_FOUND'], - ['{campaignTestKey}' => $campaignKey, '{userId}' => $userId] + ['{campaignKey}' => $campaignKey, '{userId}' => $userId] ); } } @@ -652,7 +652,7 @@ public function activate($campaignKey, $userId, $options = []) * fetch the variation name * * @param $campaignKey - * @param $customerHash + * @param $userId * @param int $addVisitor * @return null| bucketname */ diff --git a/tests/VWOTest.php b/tests/VWOTest.php index a70e45e..8fffdb0 100644 --- a/tests/VWOTest.php +++ b/tests/VWOTest.php @@ -48,15 +48,15 @@ class UserStorageTest implements UserStorageInterface /** * @param $userId - * @param $campaignName + * @param $campaignKey * @return string */ - public function get($userId, $campaignName) + public function get($userId, $campaignKey) { return [ 'userId' => $userId, 'variationName' => 'Control', - 'campaignName' => $campaignName + 'campaignKey' => $campaignKey ]; } @@ -149,13 +149,13 @@ public function testActivate() 'isDevelopmentMode' => 1 ]; $this->vwotest = new VWO($config); - $campaignName = 'DEV_TEST_' . $devtest; + $campaignKey = 'DEV_TEST_' . $devtest; $users = $this->getUsers(); for ($i = 0; $i < 1; $i++) { try { $userId = $users[$i]; - $variationName = $this->vwotest->activate($campaignName, $userId); - $expected = ucfirst($this->variationResults[$campaignName][$userId]); + $variationName = $this->vwotest->activate($campaignKey, $userId); + $expected = ucfirst($this->variationResults[$campaignKey][$userId]); $this->assertEquals($expected, $variationName); } catch (Exception $e) { } @@ -173,12 +173,12 @@ public function testGetVariation() 'isDevelopmentMode' => 1 ]; $this->vwotest = new VWO($config); - $campaignName = 'DEV_TEST_' . $devtest; + $campaignKey = 'DEV_TEST_' . $devtest; $users = $this->getUsers(); for ($i = 0; $i < 26; $i++) { $userId = $users[$i]; - $variationName = $this->vwotest->getVariationName($campaignName, $userId); - $expected = ucfirst($this->variationResults[$campaignName][$userId]); + $variationName = $this->vwotest->getVariationName($campaignKey, $userId); + $expected = ucfirst($this->variationResults[$campaignKey][$userId]); $this->assertEquals($expected, $variationName); break; } @@ -210,14 +210,14 @@ public function testTrack() 'isDevelopmentMode' => 0 ]; $this->vwotest = new VWO($config); - $campaignName = 'DEV_TEST_' . $devtest; + $campaignKey = 'DEV_TEST_' . $devtest; $users = $this->getUsers(); for ($i = 0; $i < 26; $i++) { try { $userId = $users[$i]; $goalname = $config['settingsFile']['campaigns'][2]['goals'][0]['identifier']; - $result = $this->vwotest->track($campaignName, $userId, $goalname); - $expected = ucfirst($this->variationResults[$campaignName][$userId]); + $result = $this->vwotest->track($campaignKey, $userId, $goalname); + $expected = ucfirst($this->variationResults[$campaignKey][$userId]); if ($expected == null) { $expected = false; } else { @@ -241,12 +241,12 @@ public function testTrackForUser() 'userStorageService' => new UserStorageTest() ]; $this->vwotest = new VWO($config); - $campaignName = 'DEV_TEST_8'; + $campaignKey = 'DEV_TEST_8'; $users = $this->getUsers(); $userId = $users[0]; $goalname = 'dsa'; - $result = $this->vwotest->track($campaignName, $userId, $goalname); - $expected = ucfirst($this->variationResults[$campaignName][$userId]); + $result = $this->vwotest->track($campaignKey, $userId, $goalname); + $expected = ucfirst($this->variationResults[$campaignKey][$userId]); if ($expected == null) { $expected = false; } else {