Skip to content

Commit 029b1f5

Browse files
Adding revision in conversion and impression events (#34)
1 parent dacfdc5 commit 029b1f5

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

src/Optimizely/Event/Builder/EventBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ private function setCommonParams($config, $userId, $attributes)
105105
{
106106
$this->_eventParams[PROJECT_ID] = $config->getProjectId();
107107
$this->_eventParams[ACCOUNT_ID] = $config->getAccountId();
108+
$this->_eventParams[REVISION] = $config->getRevision();
108109
$this->_eventParams[VISITOR_ID] = $userId;
109110
$this->_eventParams[CLIENT_ENGINE] = self::SDK_TYPE;
110111
$this->_eventParams[CLIENT_VERSION] = self::SDK_VERSION;
@@ -195,6 +196,7 @@ private function setConversionParams($config, $eventKey, $experiments, $userId,
195196
array_push($this->_eventParams[LAYER_STATES], [
196197
LAYER_ID => $experiment->getLayerId(),
197198
ACTION_TRIGGERED => true,
199+
REVISION => $config->getRevision(),
198200
DECISION => [
199201
EXPERIMENT_ID => $experiment->getId(),
200202
VARIATION_ID => $variation->getId(),

src/Optimizely/Event/Builder/Params.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
define('ACCOUNT_ID', 'accountId');
1919
define('PROJECT_ID', 'projectId');
20+
define('REVISION', 'revision');
2021
define('LAYER_ID', 'layerId');
2122
define('EXPERIMENT_ID', 'experimentId');
2223
define('VARIATION_ID', 'variationId');

src/Optimizely/ProjectConfig.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ public function getProjectId()
184184
return $this->_projectId;
185185
}
186186

187+
/**
188+
* @return string String representing revision of the datafile.
189+
*/
190+
public function getRevision()
191+
{
192+
return $this->_revision;
193+
}
194+
187195
/**
188196
* @param $groupId string ID of the group.
189197
*

tests/EventTests/EventBuilderTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function testCreateImpressionEventNoAttributes()
4545
[
4646
'projectId' => '7720880029',
4747
'accountId' => '1592310167',
48+
'revision' => '15',
4849
'layerId' => '7719770039',
4950
'visitorId' => 'testUserId',
5051
'clientEngine' => 'php-sdk',
@@ -79,6 +80,7 @@ public function testCreateImpressionEventWithAttributes()
7980
[
8081
'projectId' => '7720880029',
8182
'accountId' => '1592310167',
83+
'revision' => '15',
8284
'layerId' => '7719770039',
8385
'visitorId' => 'testUserId',
8486
'clientEngine' => 'php-sdk',
@@ -125,6 +127,7 @@ public function testCreateConversionEventNoAttributesNoValue()
125127
'projectId' => '7720880029',
126128
'accountId' => '1592310167',
127129
'visitorId' => 'testUserId',
130+
'revision' => '15',
128131
'clientEngine' => 'php-sdk',
129132
'clientVersion' => '1.0.1',
130133
'userFeatures' => [],
@@ -137,6 +140,7 @@ public function testCreateConversionEventNoAttributesNoValue()
137140
'layerStates' => [[
138141
'layerId' => '7719770039',
139142
'actionTriggered' => true,
143+
'revision' => '15',
140144
'decision' => [
141145
'experimentId' => '7716830082',
142146
'variationId' => '7722370027',
@@ -167,6 +171,7 @@ public function testCreateConversionEventWithAttributesNoValue()
167171
'projectId' => '7720880029',
168172
'accountId' => '1592310167',
169173
'visitorId' => 'testUserId',
174+
'revision' => '15',
170175
'clientEngine' => 'php-sdk',
171176
'clientVersion' => '1.0.1',
172177
'isGlobalHoldback' => false,
@@ -178,6 +183,7 @@ public function testCreateConversionEventWithAttributesNoValue()
178183
'layerStates' => [[
179184
'layerId' => '7719770039',
180185
'actionTriggered' => true,
186+
'revision' => '15',
181187
'decision' => [
182188
'experimentId' => '7716830082',
183189
'variationId' => '7722370027',
@@ -220,6 +226,7 @@ public function testCreateConversionEventNoAttributesWithValue()
220226
'projectId' => '7720880029',
221227
'accountId' => '1592310167',
222228
'visitorId' => 'testUserId',
229+
'revision' => '15',
223230
'clientEngine' => 'php-sdk',
224231
'clientVersion' => '1.0.1',
225232
'userFeatures' => [],
@@ -242,6 +249,7 @@ public function testCreateConversionEventNoAttributesWithValue()
242249
'layerStates' => [[
243250
'layerId' => '7719770039',
244251
'actionTriggered' => true,
252+
'revision' => '15',
245253
'decision' => [
246254
'experimentId' => '7716830082',
247255
'variationId' => '7722370027',
@@ -272,6 +280,7 @@ public function testCreateConversionEventWithAttributesWithValue()
272280
'projectId' => '7720880029',
273281
'accountId' => '1592310167',
274282
'visitorId' => 'testUserId',
283+
'revision' => '15',
275284
'clientEngine' => 'php-sdk',
276285
'clientVersion' => '1.0.1',
277286
'isGlobalHoldback' => false,
@@ -299,6 +308,7 @@ public function testCreateConversionEventWithAttributesWithValue()
299308
'layerStates' => [[
300309
'layerId' => '7719770039',
301310
'actionTriggered' => true,
311+
'revision' => '15',
302312
'decision' => [
303313
'experimentId' => '7716830082',
304314
'variationId' => '7722370027',
@@ -344,6 +354,7 @@ public function testCreateConversionEventNoAttributesWithInvalidValue()
344354
'projectId' => '7720880029',
345355
'accountId' => '1592310167',
346356
'visitorId' => 'testUserId',
357+
'revision' => '15',
347358
'clientEngine' => 'php-sdk',
348359
'clientVersion' => '1.0.1',
349360
'userFeatures' => [],
@@ -369,6 +380,7 @@ public function testCreateConversionEventNoAttributesWithInvalidValue()
369380
'layerStates' => [[
370381
'layerId' => '7719770039',
371382
'actionTriggered' => true,
383+
'revision' => '15',
372384
'decision' => [
373385
'experimentId' => '7716830082',
374386
'variationId' => '7722370027',

tests/ProjectConfigTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ public function testGetProjectId()
181181
$this->assertEquals('7720880029', $this->config->getProjectId());
182182
}
183183

184+
public function testGetRevision()
185+
{
186+
$this->assertEquals('15', $this->config->getRevision());
187+
}
188+
184189
public function testGetGroupValidId()
185190
{
186191
$group = $this->config->getGroup('7722400015');

0 commit comments

Comments
 (0)