@@ -195,10 +195,10 @@ private function validateUserInputs($attributes, $eventTags = null)
195
195
* @param array Associative array of user attributes
196
196
* @param DatafileProjectConfig DatafileProjectConfig instance
197
197
*/
198
- protected function sendImpressionEvent ($ config , $ experimentKey , $ variationKey , $ userId , $ attributes )
198
+ protected function sendImpressionEvent ($ config , $ experimentKey , $ variationKey , $ flagKey , $ ruleKey , $ ruleType , $ userId , $ attributes )
199
199
{
200
200
$ impressionEvent = $ this ->_eventBuilder
201
- ->createImpressionEvent ($ config , $ experimentKey , $ variationKey , $ userId , $ attributes );
201
+ ->createImpressionEvent ($ config , $ experimentKey , $ variationKey , $ flagKey , $ ruleKey , $ ruleType , $ userId , $ attributes );
202
202
$ this ->_logger ->log (Logger::INFO , sprintf ('Activating user "%s" in experiment "%s". ' , $ userId , $ experimentKey ));
203
203
$ this ->_logger ->log (
204
204
Logger::DEBUG ,
@@ -274,7 +274,7 @@ public function activate($experimentKey, $userId, $attributes = null)
274
274
return null ;
275
275
}
276
276
277
- $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variationKey , $ userId , $ attributes );
277
+ $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variationKey , '' , $ experimentKey , FeatureDecision:: DECITION_SOURCE_EXPERIMENT , $ userId , $ attributes );
278
278
279
279
return $ variationKey ;
280
280
}
@@ -554,18 +554,22 @@ public function isFeatureEnabled($featureFlagKey, $userId, $attributes = null)
554
554
$ featureEnabled = false ;
555
555
$ decision = $ this ->_decisionService ->getVariationForFeature ($ config , $ featureFlag , $ userId , $ attributes );
556
556
$ 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
+
557
563
if ($ variation ) {
558
- $ experiment = $ decision ->getExperiment ();
564
+ $ experimentKey = $ decision ->getExperiment ()-> getKey ();
559
565
$ featureEnabled = $ variation ->getFeatureEnabled ();
560
566
if ($ decision ->getSource () == FeatureDecision::DECISION_SOURCE_FEATURE_TEST ) {
561
- $ experimentKey = $ experiment ->getKey ();
562
- $ variationKey = $ variation ->getKey ();
563
567
$ sourceInfo = (object ) array (
564
568
'experimentKey ' => $ experimentKey ,
565
- 'variationKey ' => $ variationKey
569
+ 'variationKey ' => $ variation -> getKey ()
566
570
);
567
571
568
- $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variationKey , $ userId , $ attributes );
572
+ $ this ->sendImpressionEvent ($ config , $ experimentKey , $ variation -> getKey (), $ featureFlagKey , $ experimentKey , $ decision -> getSource () , $ userId , $ attributes );
569
573
} else {
570
574
$ this ->_logger ->log (Logger::INFO , "The user ' {$ userId }' is not being experimented on Feature Flag ' {$ featureFlagKey }'. " );
571
575
}
0 commit comments