Hi everyone, I am playing with the Ruby SDK and I ...
# announcements
o
Hi everyone, I am playing with the Ruby SDK and I noticed that the listener on_experiment_viewed is not trigger with progressive rollouts, is that intentional? I would like to track when any user is exposed to my feature flag. I am wondering also if the listener would be trigger for feature flags without Override Rules
f
There should be a different event for when the feature is served
The Ruby SDK may not have that event
checking the source code
@better-magician-65629 might know
o
with a quick look on the code I just see the listener implementation for experiments
b
the logic for when the experiment tracking callback fires is a bit complex, you can read about when it fires here in the FAQ section of the docs. you can see the logic in detail here. it's possible that your condition is causing an early return in the logic before the tracking callback is called. if you're rolling out to only 50% for example, if the user is not in the rollout, it won't be fired for that user.
it will not be fired for rules with forced variations
o
I debug it on my implementation and it being return here where I assume process the percentage rollout based on the comment
and it is not passing event if the user is inside the active percentage
ok I got it the listener will be fired only for AB test rules or if there are no rules just the feature flag am I correct ?
b
in the case where there is a forced rule or forced variations, it will not fire.
it will be called in the case that there is no rules and the user's hash (e.g. user ID) allows them to be evaluated into the experiment.
there's also the option to run an inline experiment directly but depending on how that's set up, it could result in different results than the feature evaluation if you use both. https://docs.growthbook.io/lib/ruby#inline-experiments
o
got it, thank you for the help and the quick answer
b
but as @fresh-football-47124 mentioned above, there is another method available in the JS SDK but it isn't in any of the other SDK's at the moment, and that's to track feature usage. you can read about that in the JS docs. it's important to note this doesn't fire when there are override rules either so it wouldn't fire in your case anyway.
i took a closer look at the JS SDK's feature usage callback, and it should fire in your case. there was a bit of confusion since the JS SDK forces features in various ways, one of which are not in other SDK's (where the values are forced by key-value pairs) and in that case it won't fire. from what i see, the JS SDK should still trigger a feature usage callback if you aren't calling
setForcedFeatures()
with a
Map
of feature key to forced value.
so if the constraints of the experiment tracking callback don't work for your use cases, you may want to consider the feature usage tracking callback, which is only in JS at the moment. but considering it's something that raises quite a bit of confusion with the SDK's, it may be worth adding to our tasks for the other SDK's as well. i'll add some issues to github to track these and we can consider prioritizing accordingly.
o
Thank you it is more clear now