@@ -195,10 +195,10 @@ private function validateUserInputs($attributes, $eventTags = null)
195195 * @param array Associative array of user attributes
196196 * @param DatafileProjectConfig DatafileProjectConfig instance
197197 */
198- protected function sendImpressionEvent ($ config , $ experimentKey , $ variationKey , $ userId , $ attributes )
198+ protected function sendImpressionEvent ($ config , $ experimentKey , $ variationKey , $ flagKey , $ ruleKey , $ ruleType , $ userId , $ attributes )
199199 {
200200 $ impressionEvent = $ this ->_eventBuilder
201- ->createImpressionEvent ($ config , $ experimentKey , $ variationKey , $ userId , $ attributes );
201+ ->createImpressionEvent ($ config , $ experimentKey , $ variationKey , $ flagKey , $ ruleKey , $ ruleType , $ userId , $ attributes );
202202 $ this ->_logger ->log (Logger::INFO , sprintf ('Activating user "%s" in experiment "%s". ' , $ userId , $ experimentKey ));
203203 $ this ->_logger ->log (
204204 Logger::DEBUG ,
@@ -274,7 +274,7 @@ public function activate($experimentKey, $userId, $attributes = null)
274274 return null ;
275275 }
276276
277- $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variationKey , $ userId , $ attributes );
277+ $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variationKey , '' , $ experimentKey , FeatureDecision:: DECITION_SOURCE_EXPERIMENT , $ userId , $ attributes );
278278
279279 return $ variationKey ;
280280 }
@@ -554,18 +554,22 @@ public function isFeatureEnabled($featureFlagKey, $userId, $attributes = null)
554554 $ featureEnabled = false ;
555555 $ decision = $ this ->_decisionService ->getVariationForFeature ($ config , $ featureFlag , $ userId , $ attributes );
556556 $ variation = $ decision ->getVariation ();
557+
558+ if ($ config ->getSendFlagDecisions () && ($ decision ->getSource () == FeatureDecision::DECISION_SOURCE_ROLLOUT || !$ variation )) {
559+ $ ruleKey = $ decision ->getExperiment () ? $ decision ->getExperiment ()->getKey () : '' ;
560+ $ this ->sendImpressionEvent ($ config , $ ruleKey , $ variation ? $ variation ->getKey () : '' , $ featureFlagKey , $ ruleKey , $ decision ->getSource (), $ userId , $ attributes );
561+ }
562+
557563 if ($ variation ) {
558- $ experiment = $ decision ->getExperiment ();
564+ $ experimentKey = $ decision ->getExperiment ()-> getKey ();
559565 $ featureEnabled = $ variation ->getFeatureEnabled ();
560566 if ($ decision ->getSource () == FeatureDecision::DECISION_SOURCE_FEATURE_TEST ) {
561- $ experimentKey = $ experiment ->getKey ();
562- $ variationKey = $ variation ->getKey ();
563567 $ sourceInfo = (object ) array (
564568 'experimentKey ' => $ experimentKey ,
565- 'variationKey ' => $ variationKey
569+ 'variationKey ' => $ variation -> getKey ()
566570 );
567571
568- $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variationKey , $ userId , $ attributes );
572+ $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variation -> getKey (), $ featureFlagKey , $ experimentKey , $ decision -> getSource () , $ userId , $ attributes );
569573 } else {
570574 $ this ->_logger ->log (Logger::INFO , "The user ' {$ userId }' is not being experimented on Feature Flag ' {$ featureFlagKey }'. " );
571575 }
0 commit comments