Hey all, just wondering if there’s a way to get re...
# ask-questions
b
Hey all, just wondering if there’s a way to get resolved feature flag for a given user in the backend? For example I would like to know what value that user A received for
feature-name
. Then use this value on backend to control execution flow based on that value. If not, is there an alternative approach for my use case?
f
I'm assuming you are evaluating the feature on the front-end, but want to somehow pass that value to the back-end, is that right? If so, there are 2 main options: 1. Explicitly pass the feature value to your back-end in your API calls (e.g. with a querystring or in the request body) 2. Implement one of our back-end SDKs and re-evaluate the feature there. As long as the user attributes are the same as the front-end, it will result in the same feature value.
b
That’s correct! @future-teacher-7046 > 1. Implement one of our back-end SDKs and re-evaluate the feature there. As long as the user attributes are the same as the front-end, it will result in the same feature value. Is only
userId
sufficient? And is this using
Growthbook.setAttributes
? Not all the fields are available on backend
f
You don't necessarily need all the attributes to be the same, but the ones used by your feature flag. For example, if you have a rule to serve a feature value only to users with
browser = "chrome"
, you need to make sure that
browser
attribute is available on the back-end. Otherwise, you could get a different feature value in the front-end and back-end. So there's definitely risk going with this approach since if you forget to set a specific attribute or there's some other mismatch going on, you could get into a conflicted state. Explicitly passing feature flag values in the API requests is safer, but requires more work during implementation.