icy-terabyte-95368
02/14/2022, 2:34 AM// Create a GrowthBook context
const growthbook = new GrowthBook();
// Load feature definitions (from API, database, etc.)
fetch("<https://s3.amazonaws.com/myBucket/features.json>")
.then((res) => res.json())
.then((parsed) => {
growthbook.setFeatures(parsed);
});
My questions are:
1. How does Growthbook know which feature to assign without knowing who the user is at this point?
2. If the user then creates an account and we use use growthbook.setAttributes()
to update the id, will whatever anonymous tracking token that was used previously be merged into the new ID we give it when the user signups?
3. Our app also allows people to create multiple accounts and switch between them. If this happens do we have to refresh the data? I'm assuming setAttribute
won't work here as we want to switch to an existing user id not update the existing user with a new ID.
Any guidance or direction on how to think about and manage this would be much appreciated.future-teacher-7046
icy-terabyte-95368
02/14/2022, 2:39 AMfuture-teacher-7046
id
for logged in user id (set to empty string for anonymous) and anonId
with a cookie id or similar that is passed for all users, logged in and anonymous.icy-terabyte-95368
02/14/2022, 2:44 AMfuture-teacher-7046
icy-terabyte-95368
02/14/2022, 3:00 AMfuture-teacher-7046
icy-terabyte-95368
02/14/2022, 3:23 AMfuture-teacher-7046
icy-terabyte-95368
02/14/2022, 3:38 AMfuture-teacher-7046
growthbook.setRenderer(() => {
// re-render your app here
})
Then when the user switches accounts, you would just call setAttributes
with the new account infoicy-terabyte-95368
02/14/2022, 4:31 AM