Skip to content

Commit

Permalink
Bump event builder version to 2.0 beta. (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeproeng37 authored Mar 29, 2018
1 parent 02282a1 commit f12484a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ $booleanVariable = $optimizelyClient->getFeatureVariableBoolean('my_feature_key'
$eventTags = ['revenue' => 4200];
$optimizelyClient->track('event_key', 'user_id', $userAttributes, $eventTags);
```

## 1.5.0
- Added support for notification listeners.
Expand All @@ -44,11 +45,11 @@ $optimizelyClient->track('event_key', 'user_id', $userAttributes, $eventTags);
* Force a user into a variation for a given experiment.
*
* @param $experimentKey string Key identifying the experiment.
* @param $userId string The user ID to be used for bucketing.
* @param $variationKey string The variation key specifies the variation which the user
* @param $userId string The user ID to be used for bucketing.
* @param $variationKey string The variation key specifies the variation which the user
* will be forced into. If null, then clear the existing experiment-to-variation mapping.
*
* @return boolean A boolean value that indicates if the set completed successfully.
* @return boolean A boolean value that indicates if the set completed successfully.
*/
```
```
Expand All @@ -58,14 +59,14 @@ public function setForcedVariation($experimentKey, $userId, $variationKey);
* Gets the forced variation for a given user and experiment.
*
* @param $experimentKey string Key identifying the experiment.
* @param $userId string The user ID to be used for bucketing.
* @param $userId string The user ID to be used for bucketing.
*
* @return string|null The forced variation key.
*/
public function getForcedVariation($experimentKey, $userId);
```

- Added the bucketing ID feature allows decoupling bucketing from user identification so that a group of users that have the same bucketing ID are put into the same variation.
- Added the bucketing ID feature allows decoupling bucketing from user identification so that a group of users that have the same bucketing ID are put into the same variation.

## 1.2.0
- Add user profile service.
Expand Down
4 changes: 2 additions & 2 deletions src/Optimizely/Event/Builder/EventBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EventBuilder
/**
* @const string Version of the Optimizely PHP SDK.
*/
const SDK_VERSION = '1.5.0';
const SDK_VERSION = '2.0.0-beta1';

/**
* @var string URL to send event to.
Expand Down Expand Up @@ -184,7 +184,7 @@ private function getConversionParams($config, $eventKey, $experimentVariationMap
$singleSnapshot = [];
$experiment = $config->getExperimentFromId($experimentId);
$eventEntity = $config->getEvent($eventKey);

$singleSnapshot[DECISIONS] = [
[
CAMPAIGN_ID => $experiment->getLayerId(),
Expand Down
36 changes: 18 additions & 18 deletions tests/EventTests/EventBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function setUp()
]],
'revision' => '15',
'client_name' => 'php-sdk',
'client_version' => '1.5.0',
'client_version' => '2.0.0-beta1',
'anonymize_ip'=> false,
];
$this->expectedEventHttpVerb = 'POST';
Expand All @@ -89,7 +89,7 @@ private function areLogEventsEqual($e1, $e2)
if (!$isEqual) {
$msg = $this->differ->diff(var_export($e1, true), var_export($e2, true));
}

return [$isEqual,$msg];
}

Expand Down Expand Up @@ -129,7 +129,7 @@ public function testCreateImpressionEventNoAttributesNoValue()
$this->testUserId,
null
);

$logEvent = $this->fakeParamsToReconcile($logEvent);
$result = $this->areLogEventsEqual($this->expectedLogEvent, $logEvent);
$this->assertTrue($result[0], $result[1]);
Expand All @@ -149,7 +149,7 @@ public function testCreateImpressionEventWithAttributesNoValue()
$this->expectedEventHttpVerb,
$this->expectedEventHeaders
);

$userAttributes = [
'device_type' => 'iPhone',
'company' => 'Optimizely'
Expand Down Expand Up @@ -218,7 +218,7 @@ public function testCreateImpressionEventWithZeroAttributesNoValue()
$this->expectedEventHttpVerb,
$this->expectedEventHeaders
);

$userAttributes = [
'device_type' => 0,
'company' => 'Optimizely'
Expand Down Expand Up @@ -247,7 +247,7 @@ public function testCreateImpressionEventWithInvalidAttributesNoValue()
$this->expectedEventHttpVerb,
$this->expectedEventHeaders
);

$userAttributes = [
'invalid_attribute' => 'sorry_not_sorry'
];
Expand Down Expand Up @@ -316,7 +316,7 @@ public function testCreateConversionEventWithAttributesNoValue()
$this->expectedEventHttpVerb,
$this->expectedEventHeaders
);

$userAttributes = [
'device_type' => 'iPhone',
'company' => 'Optimizely'
Expand Down Expand Up @@ -346,14 +346,14 @@ public function testCreateConversionEventInvalidAttributesNoValue()
'key'=> 'purchase'
];
$this->expectedEventParams['visitors'][0]['snapshots'][0]['decisions'][0]['variation_id'] = '7722370027';

$expectedLogEvent = new LogEvent(
$this->expectedEventUrl,
$this->expectedEventParams,
$this->expectedEventHttpVerb,
$this->expectedEventHeaders
);

$userAttributes = [
'invalid_attribute'=> 'sorry_not_sorry'
];
Expand Down Expand Up @@ -388,7 +388,7 @@ public function testCreateConversionEventNoAttributesWithValue()
];

$this->expectedEventParams['visitors'][0]['snapshots'][0]['decisions'][0]['variation_id'] = '7722370027';

$expectedLogEvent = new LogEvent(
$this->expectedEventUrl,
$this->expectedEventParams,
Expand Down Expand Up @@ -432,7 +432,7 @@ public function testCreateConversionEventWithAttributesWithValue()
]
];
$this->expectedEventParams['visitors'][0]['snapshots'][0]['decisions'][0]['variation_id'] = '7722370027';

$expectedLogEvent = new LogEvent(
$this->expectedEventUrl,
$this->expectedEventParams,
Expand All @@ -456,7 +456,7 @@ public function testCreateConversionEventWithAttributesWithValue()
'value'=> '13.37'
)
);

$logEvent = $this->fakeParamsToReconcile($logEvent);
$result = $this->areLogEventsEqual($expectedLogEvent, $logEvent);
$this->assertTrue($result[0], $result[1]);
Expand All @@ -482,7 +482,7 @@ public function testCreateConversionEventWithAttributesWithNumericTag()
]
];
$this->expectedEventParams['visitors'][0]['snapshots'][0]['decisions'][0]['variation_id'] = '7722370027';

$expectedLogEvent = new LogEvent(
$this->expectedEventUrl,
$this->expectedEventParams,
Expand All @@ -503,7 +503,7 @@ public function testCreateConversionEventWithAttributesWithNumericTag()
'value'=> '13.37'
)
);

$logEvent = $this->fakeParamsToReconcile($logEvent);
$result = $this->areLogEventsEqual($expectedLogEvent, $logEvent);
$this->assertTrue($result[0], $result[1]);
Expand All @@ -524,14 +524,14 @@ public function testCreateConversionEventNoAttributesWithInvalidValue()
]
];
$this->expectedEventParams['visitors'][0]['snapshots'][0]['decisions'][0]['variation_id'] = '7722370027';

$expectedLogEvent = new LogEvent(
$this->expectedEventUrl,
$this->expectedEventParams,
$this->expectedEventHttpVerb,
$this->expectedEventHeaders
);

$logEvent = $this->eventBuilder->createConversionEvent(
$this->config,
'purchase',
Expand All @@ -544,7 +544,7 @@ public function testCreateConversionEventNoAttributesWithInvalidValue()
'value' => 'invalid value'
)
);

$logEvent = $this->fakeParamsToReconcile($logEvent);
$result = $this->areLogEventsEqual($expectedLogEvent, $logEvent);
$this->assertTrue($result[0], $result[1]);
Expand Down Expand Up @@ -587,7 +587,7 @@ public function testCreateImpressionEventWithBucketingIDAttribute()
$userAttributes
);


$logEvent = $this->fakeParamsToReconcile($logEvent);
$result = $this->areLogEventsEqual($expectedLogEvent, $logEvent);
$this->assertTrue($result[0], $result[1]);
Expand Down

0 comments on commit f12484a

Please sign in to comment.