@@ -18,7 +18,7 @@ import {
1818 MAX_EVENT_QUEUE_SIZE ,
1919 PRECOMPUTED_BASE_URL ,
2020} from '../constants' ;
21- import { decodePrecomputedFlag } from '../decoding' ;
21+ import { decodePrecomputedBandit , decodePrecomputedFlag } from '../decoding' ;
2222import { FlagEvaluationWithoutDetails } from '../evaluator' ;
2323import FetchHttpClient from '../http-client' ;
2424import {
@@ -307,7 +307,7 @@ export default class EppoPrecomputedClient {
307307 ) ;
308308 }
309309
310- getBanditAction (
310+ public getBanditAction (
311311 flagKey : string ,
312312 defaultValue : string ,
313313 ) : Omit < IAssignmentDetails < string > , 'evaluationDetails' > {
@@ -318,6 +318,8 @@ export default class EppoPrecomputedClient {
318318 return { variation : defaultValue , action : null } ;
319319 }
320320
321+ const assignedVariation = this . getStringAssignment ( flagKey , defaultValue ) ;
322+
321323 const banditEvent : IBanditEvent = {
322324 timestamp : new Date ( ) . toISOString ( ) ,
323325 featureFlag : flagKey ,
@@ -341,7 +343,7 @@ export default class EppoPrecomputedClient {
341343 logger . error ( `${ loggerPrefix } Error logging bandit action: ${ error } ` ) ;
342344 }
343345
344- return { variation : defaultValue , action : banditEvent . action } ;
346+ return { variation : assignedVariation , action : banditEvent . action } ;
345347 }
346348
347349 private getPrecomputedFlag ( flagKey : string ) : DecodedPrecomputedFlag | null {
@@ -358,13 +360,17 @@ export default class EppoPrecomputedClient {
358360 }
359361
360362 private getPrecomputedBandit ( banditKey : string ) : IPrecomputedBandit | null {
361- return this . getObfuscatedPrecomputedBandit ( banditKey ) ;
363+ const obfuscatedBandit = this . getObfuscatedPrecomputedBandit ( banditKey ) ;
364+ return obfuscatedBandit ? decodePrecomputedBandit ( obfuscatedBandit ) : null ;
362365 }
363366
364367 private getObfuscatedPrecomputedBandit ( banditKey : string ) : IObfuscatedPrecomputedBandit | null {
365368 const salt = this . precomputedBanditStore ?. salt ;
366369 const saltedAndHashedBanditKey = getMD5Hash ( banditKey , salt ) ;
367- return this . precomputedBanditStore ?. get ( saltedAndHashedBanditKey ) ?? null ;
370+ const precomputedBandit : IObfuscatedPrecomputedBandit | null = this . precomputedBanditStore ?. get (
371+ saltedAndHashedBanditKey ,
372+ ) as IObfuscatedPrecomputedBandit ;
373+ return precomputedBandit ?? null ;
368374 }
369375
370376 public isInitialized ( ) {
0 commit comments