Hello everyone, i am wondering if it is possible t...
# ask-questions
g
Hello everyone, i am wondering if it is possible to get the result of a feature flag (like with
isOn
or
evaluateFeature
) but without triggering the trackingCallback? We would like to know in our app which feature is enabled to prepare something in the background even before the feature is beeing used. We use the Web SDK. Thank you in advance!
f
for a lot of users?
or just want to test on a few?
you can always create another SDK instance and just not set a tracking callback, or use that to debug before you call it for real
g
Why we want to know the feature flag value is not user related. So the amount on users does not matter. creating another SDK feels like overkill.
The feature flags are evaluated on client side anyways so i just want to skip the trackingCallback in certain cases.
f
Ya, that could work
g
it feels like schrödingers cat right now... but i dont want to kill the cat by opening the box đŸ˜„
Ok cool! Could you give me some code example on how to do that?
f
What SDK are you using?
g
Web SDK
f
Okay
You can override the tracking callback
g
you mean just temporary?
like so?
Copy code
override callback
read flag
reset callback
actually read the flag
but is the callback then even called when i "actually" read the flag. i assume the value of the feature stays the same. afaik the documentation says when the value did not change the callback is only called on the first time when the festure was read
and looks like there is no way to read the callback to tmp store it to be able to reset it đŸ˜•
f
Can you explain the problem you’re trying to solve a bit more?
g
We are using Nuxt. We were using our own AB-Testing implementation before and we just switched to growthbook recently. We have developed a "plugin" which is visible as a floating button in the WebApp only locally and on staging to toggle the AB tests / Feature Flags. It is implemented inside the WebApp as part of it but ofc hidden on production. It works similar to your chrome extension. There we stored the evaluated values for featureFlags inside a cookie to have it also available for SSR. When flipping the switch inside the plugin the value in the cookie is also changed. We would like to continue using this plugin since everyone is familiar with it. And also it is deeply integrated in our code. We dont have layoutshifts since it also works with SSR. With the chrome extension we would have layout shifts when flipping the switch for testing purpose. Thats why using your chrome extension is not an option right now. So for this plugin we would like to know which feature has which value to show this inside the plugin. We then only store the "overriding value" which would be set by the plugin when flipping the switch for a feature in a cookie. BUT by reading the value of a feature with e.g. isOn we trigger the tracking callback. Yes since we only use it for "testing purpose" locally and on staging this is not a "big issue" but on staging we could not validate if trackings are sent properly.... and it also feels not clean. so we would like to read / evaluate a feature flag value WITHOUT triggering the tracking callback.
Hope you know what i mean. Any questions?
f
I see
g
@fresh-football-47124 any idea how this is possible?
f
so you could make the trackingCallback optional, so thats not a big issue as you say. You can get a list of all features that are loaded in by the SDK. Setting the state for teach flag is also possible - that's what our extension does... let me see if I Can find that code
g
any update on that?
g
Do i need an additional Growthbook instance for this to work? https://github.com/growthbook/devtools/blob/main/src/devtools/ui/App.tsx#L60 So i assume that i could use this second instance WITHOUT the callback to read the features?
so basically this should work?
Copy code
const _growthbook = new GrowthBook<FeatureFlags>({
    attributes: growthbook.getAttributes(),
    features: growthbook.getFeatures(),
  });