@@ -324,39 +324,38 @@ export default class EppoPrecomputedClient {
324
324
flagKey : string ,
325
325
defaultValue : string ,
326
326
) : Omit < IAssignmentDetails < string > , 'evaluationDetails' > {
327
- const banditEvaluation = this . getPrecomputedBandit ( flagKey ) ;
328
-
329
- if ( banditEvaluation == null ) {
330
- logger . warn ( `${ loggerPrefix } No assigned variation. Bandit not found: ${ flagKey } ` ) ;
327
+ const precomputedFlag = this . getPrecomputedFlag ( flagKey ) ;
328
+ if ( ! precomputedFlag ) {
329
+ logger . warn ( `${ loggerPrefix } No assigned variation. Flag not found: ${ flagKey } ` ) ;
331
330
return { variation : defaultValue , action : null } ;
332
331
}
333
-
332
+ const banditEvaluation = this . getPrecomputedBandit ( flagKey ) ;
334
333
const assignedVariation = this . getStringAssignment ( flagKey , defaultValue ) ;
335
-
336
- const banditEvent : IBanditEvent = {
337
- timestamp : new Date ( ) . toISOString ( ) ,
338
- featureFlag : flagKey ,
339
- bandit : banditEvaluation . banditKey ,
340
- subject : this . subject . subjectKey ?? '' ,
341
- action : banditEvaluation . action ,
342
- actionProbability : banditEvaluation . actionProbability ,
343
- optimalityGap : banditEvaluation . optimalityGap ,
344
- modelVersion : banditEvaluation . modelVersion ,
345
- subjectNumericAttributes : banditEvaluation . actionNumericAttributes ,
346
- subjectCategoricalAttributes : banditEvaluation . actionCategoricalAttributes ,
347
- actionNumericAttributes : banditEvaluation . actionNumericAttributes ,
348
- actionCategoricalAttributes : banditEvaluation . actionCategoricalAttributes ,
349
- metaData : this . buildLoggerMetadata ( ) ,
350
- evaluationDetails : null ,
351
- } ;
352
-
353
- try {
354
- this . logBanditAction ( banditEvent ) ;
355
- } catch ( error ) {
356
- logger . error ( `${ loggerPrefix } Error logging bandit action: ${ error } ` ) ;
334
+ if ( banditEvaluation ) {
335
+ const banditEvent : IBanditEvent = {
336
+ timestamp : new Date ( ) . toISOString ( ) ,
337
+ featureFlag : flagKey ,
338
+ bandit : banditEvaluation . banditKey ,
339
+ subject : this . subject . subjectKey ?? '' ,
340
+ action : banditEvaluation . action ,
341
+ actionProbability : banditEvaluation . actionProbability ,
342
+ optimalityGap : banditEvaluation . optimalityGap ,
343
+ modelVersion : banditEvaluation . modelVersion ,
344
+ subjectNumericAttributes : banditEvaluation . actionNumericAttributes ,
345
+ subjectCategoricalAttributes : banditEvaluation . actionCategoricalAttributes ,
346
+ actionNumericAttributes : banditEvaluation . actionNumericAttributes ,
347
+ actionCategoricalAttributes : banditEvaluation . actionCategoricalAttributes ,
348
+ metaData : this . buildLoggerMetadata ( ) ,
349
+ evaluationDetails : null ,
350
+ } ;
351
+ try {
352
+ this . logBanditAction ( banditEvent ) ;
353
+ } catch ( error ) {
354
+ logger . error ( `${ loggerPrefix } Error logging bandit action: ${ error } ` ) ;
355
+ }
356
+ return { variation : assignedVariation , action : banditEvent . action } ;
357
357
}
358
-
359
- return { variation : assignedVariation , action : banditEvent . action } ;
358
+ return { variation : assignedVariation , action : null } ;
360
359
}
361
360
362
361
private getPrecomputedFlag ( flagKey : string ) : DecodedPrecomputedFlag | null {
0 commit comments