22
33import io .split .client .api .Key ;
44import io .split .client .api .SplitResult ;
5+ import io .split .client .dtos .DecoratedImpression ;
56import io .split .client .dtos .Event ;
67import io .split .client .events .EventsStorageProducer ;
78import io .split .client .impressions .Impression ;
@@ -356,7 +357,8 @@ private SplitResult getTreatmentWithConfigInternal(String matchingKey, String bu
356357 String .format ("sdk.%s" , methodEnum .getMethod ()),
357358 _config .labelsEnabled () ? result .label : null ,
358359 result .changeNumber ,
359- attributes
360+ attributes ,
361+ result .track
360362 );
361363 _telemetryEvaluationProducer .recordLatency (methodEnum , System .currentTimeMillis () - initTime );
362364 return new SplitResult (result .treatment , result .configurations );
@@ -435,7 +437,7 @@ private Map<String, SplitResult> getTreatmentsBySetsWithConfigInternal(String ma
435437 private Map <String , SplitResult > processEvaluatorResult (Map <String , EvaluatorImp .TreatmentLabelAndChangeNumber > evaluatorResult ,
436438 MethodEnum methodEnum , String matchingKey , String bucketingKey , Map <String ,
437439 Object > attributes , long initTime ){
438- List <Impression > impressions = new ArrayList <>();
440+ List <DecoratedImpression > decoratedImpressions = new ArrayList <>();
439441 Map <String , SplitResult > result = new HashMap <>();
440442 evaluatorResult .keySet ().forEach (t -> {
441443 if (evaluatorResult .get (t ).treatment .equals (Treatments .CONTROL ) && evaluatorResult .get (t ).label .
@@ -445,13 +447,16 @@ private Map<String, SplitResult> processEvaluatorResult(Map<String, EvaluatorImp
445447 result .put (t , SPLIT_RESULT_CONTROL );
446448 } else {
447449 result .put (t , new SplitResult (evaluatorResult .get (t ).treatment , evaluatorResult .get (t ).configurations ));
448- impressions .add (new Impression (matchingKey , bucketingKey , t , evaluatorResult .get (t ).treatment , System .currentTimeMillis (),
449- evaluatorResult .get (t ).label , evaluatorResult .get (t ).changeNumber , attributes ));
450+ decoratedImpressions .add (
451+ new DecoratedImpression (
452+ new Impression (matchingKey , bucketingKey , t , evaluatorResult .get (t ).treatment , System .currentTimeMillis (),
453+ evaluatorResult .get (t ).label , evaluatorResult .get (t ).changeNumber , attributes ),
454+ evaluatorResult .get (t ).track ));
450455 }
451456 });
452457 _telemetryEvaluationProducer .recordLatency (methodEnum , System .currentTimeMillis () - initTime );
453- if (impressions . size () > 0 ) {
454- _impressionManager .track (impressions );
458+ if (! decoratedImpressions . isEmpty () ) {
459+ _impressionManager .track (decoratedImpressions );
455460 }
456461 return result ;
457462 }
@@ -501,10 +506,13 @@ private Set<String> filterSetsAreInConfig(Set<String> sets, MethodEnum methodEnu
501506 return setsToReturn ;
502507 }
503508 private void recordStats (String matchingKey , String bucketingKey , String featureFlagName , long start , String result ,
504- String operation , String label , Long changeNumber , Map <String , Object > attributes ) {
509+ String operation , String label , Long changeNumber , Map <String , Object > attributes , boolean track ) {
505510 try {
506- _impressionManager .track (Stream .of (new Impression (matchingKey , bucketingKey , featureFlagName , result , System .currentTimeMillis (),
507- label , changeNumber , attributes )).collect (Collectors .toList ()));
511+ _impressionManager .track (Stream .of (
512+ new DecoratedImpression (
513+ new Impression (matchingKey , bucketingKey , featureFlagName , result , System .currentTimeMillis (),
514+ label , changeNumber , attributes ),
515+ track )).collect (Collectors .toList ()));
508516 } catch (Throwable t ) {
509517 _log .error ("Exception" , t );
510518 }
0 commit comments