@@ -7,7 +7,7 @@ import { SDK_NOT_READY } from '../utils/labels';
77import { CONTROL , TREATMENT , TREATMENTS , TREATMENT_WITH_CONFIG , TREATMENTS_WITH_CONFIG , TRACK , TREATMENTS_WITH_CONFIG_BY_FLAGSETS , TREATMENTS_BY_FLAGSETS , TREATMENTS_BY_FLAGSET , TREATMENTS_WITH_CONFIG_BY_FLAGSET , GET_TREATMENTS_WITH_CONFIG , GET_TREATMENTS_BY_FLAG_SETS , GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS , GET_TREATMENTS_BY_FLAG_SET , GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET , GET_TREATMENT_WITH_CONFIG , GET_TREATMENT , GET_TREATMENTS , TRACK_FN_LABEL } from '../utils/constants' ;
88import { IEvaluationResult } from '../evaluator/types' ;
99import SplitIO from '../../types/splitio' ;
10- import { IMPRESSION , IMPRESSION_QUEUEING } from '../logger/constants' ;
10+ import { IMPRESSION_QUEUEING } from '../logger/constants' ;
1111import { ISdkFactoryContext } from '../sdkFactory/types' ;
1212import { isConsumerMode } from '../utils/settingsValidation/mode' ;
1313import { Method } from '../sync/submitters/types' ;
@@ -39,7 +39,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
3939 const { log, mode } = settings ;
4040 const isAsync = isConsumerMode ( mode ) ;
4141
42- function getTreatment ( key : SplitIO . SplitKey , featureFlagName : string , attributes ?: SplitIO . Attributes , options ?: SplitIO . EvaluationOptions , withConfig = false , methodName = GET_TREATMENT ) {
42+ function getTreatment ( key : SplitIO . SplitKey | undefined , featureFlagName : string , attributes ?: SplitIO . Attributes , options ?: SplitIO . EvaluationOptions , withConfig = false , methodName = GET_TREATMENT ) {
4343 const stopTelemetryTracker = telemetryTracker . trackEval ( withConfig ? TREATMENT_WITH_CONFIG : TREATMENT ) ;
4444
4545 const wrapUp = ( evaluationResult : IEvaluationResult ) => {
@@ -134,15 +134,12 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
134134 function processEvaluation (
135135 evaluation : IEvaluationResult ,
136136 featureFlagName : string ,
137- key : SplitIO . SplitKey ,
137+ key : SplitIO . SplitKey | undefined ,
138138 properties : string | undefined ,
139139 withConfig : boolean ,
140140 invokingMethodName : string ,
141141 queue : ImpressionDecorated [ ]
142142 ) : SplitIO . Treatment | SplitIO . TreatmentWithConfig {
143- const matchingKey = getMatching ( key ) ;
144- const bucketingKey = getBucketing ( key ) ;
145-
146143 const { changeNumber, impressionsDisabled } = evaluation ;
147144 let { treatment, label, config = null } = evaluation ;
148145
@@ -153,10 +150,12 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
153150 config = fallbackTreatment . config ;
154151 }
155152
156- log . info ( IMPRESSION , [ featureFlagName , matchingKey , treatment , label ] ) ;
153+ // If no target/key, no impression is tracked
154+ if ( validateSplitExistence ( log , readinessManager , featureFlagName , label , invokingMethodName ) && key ) {
155+ const matchingKey = getMatching ( key ) ;
156+ const bucketingKey = getBucketing ( key ) ;
157157
158- if ( validateSplitExistence ( log , readinessManager , featureFlagName , label , invokingMethodName ) ) {
159- log . info ( IMPRESSION_QUEUEING ) ;
158+ log . info ( IMPRESSION_QUEUEING , [ featureFlagName , matchingKey , treatment , label ] ) ;
160159 queue . push ( {
161160 imp : {
162161 feature : featureFlagName ,
0 commit comments