Hi Team, im trying to force some feature, the firs...
# sdk-kotlin
b
Hi Team, im trying to force some feature, the first think i expected is that `setForcedVariations`could make that but no, the next i checked is that to force feature I need to overrwrite a variable in GrowthBookSDK object , this variable exactly.
Copy code
/* visible for test */ var forcedFeatures: Map<String, GBValue> = emptyMap()
Then i checked inside de sdk , that in the
evaluateFeature
function it is happening that
Copy code
/**
 * Global override
 */
if (forcedFeature.containsKey(featureKey)) {
    if (evaluationContext.loggingEnabled) {
        println("Global override for forced feature with key: $featureKey and value ${forcedFeature[featureKey]}")
    }
    return prepareResult(
        featureKey = featureKey,
        gbValue = forcedFeature[featureKey]?.let(GBValue::from),
        source = GBFeatureSource.override,
    )
}
and the most important thing.
Copy code
gbValue = forcedFeature[featureKey]?.let(GBValue::from),
This is getting me an unexpected result becasue de function
from
makes that
Copy code
internal fun from(anyObj: Any): GBValue =
    when(anyObj) {
        is Boolean -> GBBoolean(anyObj)
        is String -> GBString(anyObj)
        is Number -> GBNumber(anyObj)
        else -> Unknown
    }
But my forcedFeature map never gonna be fine, because is
Map<String, GBValue>
and always is gonna go dor the else case. Is this a bug or what im doing bad at time of force an experiment result. Also you can tell me how works setForcedVariation, because i putted the experiment key or feature key and 0 or 1 but is not working
a
which version are you using?
b
Copy code
"3.1.0"
a
The line was written but after type was changed line also changed. This is the main branch:
👀 1
I am using 5.0.0-alpha-5
b
maybe is the version
what is the most stable?
a
the most stable 3.1.0
b
and where is that fix?
a
but try 5.0.0-alpha-5 it should be forced in updated version
b
mmm i think we will wait until stable version 😄
😅 2
when will be released this in a non alpha, i will ask also if its posible update to that alpha
a
are you forcing only one your feature or you need to force several features?
b
different features, because we are doing via deeplinkn
🆗 1
a
in main branch
forcedFeatures
variable is private again. I was trying to open it to mockk feature call with mockk but it is private again
and in main branch
setForcedFeatures()
method is back
b
perfect, that would be fine, also one more thing
when i use setForcedVariation, the tracking callback method is never executed, that can be fixed?
a
why do you need to force variation exactly (not the feature)?
tracking callback is called to notify about experiment result but you are forcing variation
b
to take the values configured in server
🤔 1
but, its true that trackingCallback will not triggered no?
a
trackingCallback is triggered in experiment end
b
yes, but experiment result is returned before it comes to end
and function trackingCallback is not triggered, its posible to fix that?
a
are you using remote evaluation?
b
i think not, i should?
Not, im not using remoteEval = true
🤔 1
a
No, you should not using remote evaluation. I was just trying to setup the same use scenario as you have specified
If you are not using remote evaluation and setting all feature values by forcing, then I think that tracking callback should not be called if all features are forced
b
i think the tracking callback is not executed becasue in the `evaluateExperiment`function, when u force variation, its returned
getExperimentResult
object before that is called
it is posible?
it came over here
a
yes it is returned immediately and not called trackingCallback
b
😞
Its any posibility to avoid that and call trackingCallback?
a
i don't see reason for forced feature
If you wanna get trackingCallback is being called don't force features
b
yes but if i want to force a experiment, and check if truthly have been forced i dont have any place to put a log 😞
But ok its fine, i will respect that 😄
a
The similar piece of code in Typescript SDK. I can add a log in Kotlin SDK. Maybe absence of log is the concern
b
Maybe that will solve a little our problems 😄
💯 1
That log will only appear if enabledLogging is true , true?
a
yes
b
perfect:D