Hey there, I had a question around how Growthbook ...
# announcements
n
Hey there, I had a question around how Growthbook knows that a user has been assigned during a % based feature flag, as in how does Growthbook store the state so as to cap at 10% of users? Love using Growthbook so far, and I am self hosting if that’s useful info. Thanks!
f
Hi Dax
GrowthBook doesn’t actually store state, we use deterministic hashing. As long as the user id (or whatever your randomization unit is) is the same, the user will be assigned the same group or same percent roll out
🙌 1
n
Cool, thank you for clarifying, @fresh-football-47124!
n
thanks @fresh-football-47124 that’s a very neat approach! is it somehow possible to get access to that deterministic hash function in some way? or the results of it run with our ids or something? our use case is that our marketing team wants to send an email to everyone in a feature group (to go check out the new feature they’ll now see in our app) but today we can’t really preemptively see who is in the group until they see the feature in the app so it’s a bit of a sequencing problem, the way Growthbook seems to behave today someone needs to see a feature to be put into a group, but we want to know that they’re in the group before they see the feature so we can message them to go check it out because we had a 10% rollout planned and because we can’t figure out who is in which group until they hit the feature, we just targeted the feature at everyone whose
user_id
(an autoincrement integer id) ends in the number 2 (which should represent 10% of users) but that’s a hack would love if there was some way to somehow understand whether a user is in or out of a feature group before they see the feature
f
Hi Victor - sure - it’s open source - what language would you like?
n
great! any language works, if you can just link/point to the code in Growthbook I can figure it out from there
honestly didn’t occur to me previously to dig through the code to find it myself or I would have 😬 but I’m sure you can point me in the direction faster than I’d find myself
n
peeeerfect, thanks again @fresh-football-47124!
f
and in the code, we call:
Copy code
const n = hash(hashValue + id);
we have some generic examples on how to do the hashing here: