@@ -207,10 +207,11 @@ private function validateUserInputs($attributes, $eventTags = null)
207207 * @param array Associative array of user attributes
208208 * @param DatafileProjectConfig DatafileProjectConfig instance
209209 */
210- protected function sendImpressionEvent ($ config , $ experimentKey , $ variationKey , $ flagKey , $ ruleKey , $ ruleType , $ enabled , $ userId , $ attributes )
210+ protected function sendImpressionEvent ($ config , $ experimentId , $ variationKey , $ flagKey , $ ruleKey , $ ruleType , $ enabled , $ userId , $ attributes )
211211 {
212+ $ experimentKey = $ config ->getExperimentFromId ($ experimentId )->getId ();
212213 $ impressionEvent = $ this ->_eventBuilder
213- ->createImpressionEvent ($ config , $ experimentKey , $ variationKey , $ flagKey , $ ruleKey , $ ruleType , $ enabled , $ userId , $ attributes );
214+ ->createImpressionEvent ($ config , $ experimentId , $ variationKey , $ flagKey , $ ruleKey , $ ruleType , $ enabled , $ userId , $ attributes );
214215 $ this ->_logger ->log (Logger::INFO , sprintf ('Activating user "%s" in experiment "%s". ' , $ userId , $ experimentKey ));
215216 $ this ->_logger ->log (
216217 Logger::DEBUG ,
@@ -244,10 +245,10 @@ protected function sendImpressionEvent($config, $experimentKey, $variationKey, $
244245 $ this ->notificationCenter ->sendNotifications (
245246 NotificationType::ACTIVATE ,
246247 array (
247- $ config ->getExperimentFromKey ( $ experimentKey ),
248+ $ config ->getExperimentFromId ( $ experimentId ),
248249 $ userId ,
249250 $ attributes ,
250- $ config ->getVariationFromKey ( $ experimentKey , $ variationKey ),
251+ $ config ->getVariationFromKeyByExperimentId ( $ experimentId , $ variationKey ),
251252 $ impressionEvent
252253 )
253254 );
@@ -340,6 +341,7 @@ public function decide(OptimizelyUserContext $userContext, $key, array $decideOp
340341 $ variationKey = null ;
341342 $ featureEnabled = false ;
342343 $ ruleKey = null ;
344+ $ experimentId = null ;
343345 $ flagKey = $ key ;
344346 $ allVariables = [];
345347 $ decisionEventDispatched = false ;
@@ -360,9 +362,11 @@ public function decide(OptimizelyUserContext $userContext, $key, array $decideOp
360362 $ variationKey = $ variation ->getKey ();
361363 $ featureEnabled = $ variation ->getFeatureEnabled ();
362364 $ ruleKey = $ decision ->getExperiment ()->getKey ();
365+ $ experimentId = $ decision ->getExperiment ()->getId ();
363366 } else {
364367 $ variationKey = null ;
365368 $ ruleKey = null ;
369+ $ experimentId = null ;
366370 }
367371
368372 // send impression only if decide options do not contain DISABLE_DECISION_EVENT
@@ -374,7 +378,7 @@ public function decide(OptimizelyUserContext $userContext, $key, array $decideOp
374378 if ($ source == FeatureDecision::DECISION_SOURCE_FEATURE_TEST || $ sendFlagDecisions ) {
375379 $ this ->sendImpressionEvent (
376380 $ config ,
377- $ ruleKey ,
381+ $ experimentId ,
378382 $ variationKey === null ? '' : $ variationKey ,
379383 $ flagKey ,
380384 $ ruleKey === null ? '' : $ ruleKey ,
@@ -531,8 +535,9 @@ public function activate($experimentKey, $userId, $attributes = null)
531535 $ this ->_logger ->log (Logger::INFO , sprintf ('Not activating user "%s". ' , $ userId ));
532536 return null ;
533537 }
538+ $ experimentId = $ config ->getExperimentFromKey ($ experimentKey )->getId ();
534539
535- $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variationKey , '' , $ experimentKey , FeatureDecision::DECISION_SOURCE_EXPERIMENT , true , $ userId , $ attributes );
540+ $ this ->sendImpressionEvent ($ config , $ experimentId , $ variationKey , '' , $ experimentKey , FeatureDecision::DECISION_SOURCE_EXPERIMENT , true , $ userId , $ attributes );
536541
537542 return $ variationKey ;
538543 }
@@ -818,19 +823,21 @@ public function isFeatureEnabled($featureFlagKey, $userId, $attributes = null)
818823 $ featureEnabled = $ variation ->getFeatureEnabled ();
819824 }
820825 $ ruleKey = $ decision ->getExperiment () ? $ decision ->getExperiment ()->getKey () : '' ;
821- $ this ->sendImpressionEvent ($ config , $ ruleKey , $ variation ? $ variation ->getKey () : '' , $ featureFlagKey , $ ruleKey , $ decision ->getSource (), $ featureEnabled , $ userId , $ attributes );
826+ $ experimentId = $ decision ->getExperiment () ? $ decision ->getExperiment ()->getId () : '' ;
827+ $ this ->sendImpressionEvent ($ config , $ experimentId , $ variation ? $ variation ->getKey () : '' , $ featureFlagKey , $ ruleKey , $ decision ->getSource (), $ featureEnabled , $ userId , $ attributes );
822828 }
823829
824830 if ($ variation ) {
825831 $ experimentKey = $ decision ->getExperiment ()->getKey ();
832+ $ experimentId = $ decision ->getExperiment ()->getId ();
826833 $ featureEnabled = $ variation ->getFeatureEnabled ();
827834 if ($ decision ->getSource () == FeatureDecision::DECISION_SOURCE_FEATURE_TEST ) {
828835 $ sourceInfo = (object ) array (
829836 'experimentKey ' => $ experimentKey ,
830837 'variationKey ' => $ variation ->getKey ()
831838 );
832839
833- $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variation ->getKey (), $ featureFlagKey , $ experimentKey , $ decision ->getSource (), $ featureEnabled , $ userId , $ attributes );
840+ $ this ->sendImpressionEvent ($ config , $ experimentId , $ variation ->getKey (), $ featureFlagKey , $ experimentKey , $ decision ->getSource (), $ featureEnabled , $ userId , $ attributes );
834841 } else {
835842 $ this ->_logger ->log (Logger::INFO , "The user ' {$ userId }' is not being experimented on Feature Flag ' {$ featureFlagKey }'. " );
836843 }
0 commit comments