https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
j

jolly-chef-93830

02/22/2024, 6:49 AM
Hi, I am initializing in this way. app.use(async function (req, res, next) { // Create a GrowthBook instance and store in the request req.growthbook = new GrowthBook({ apiHost: "http://localhost:4100", clientKey: "my-key", // Set this to
false
to improve performance in server-side environments enableDevMode: false, // Important: make sure this is set to
false
, otherwise features may change in the middle of a request subscribeToChanges: false, attributes: { id: 101, country: "US" }, trackingCallback: (experiment, result) => { // Example using Segment // console.log("MMM", experiment,result) // analytics.track("Experiment Viewed", { // experimentId: experiment.key, // variationId: result.key, // }); }, }); // Clean up at the end of the request res.on("close", () => req.growthbook.destroy()); // Wait for features to load (will be cached in-memory for future requests) req.growthbook .loadFeatures() .then(() => next()) .catch((e) => { console.error("Failed to load features from GrowthBook", e); next(); }); }); I just wanted to know where attributes: { id: 101, country: "US" }, this attribute will store to maintain stickiness?
f

fresh-football-47124

02/22/2024, 8:40 AM
Those attributes have to be stored on your end - by default, GrowthBook stores no state
j

jolly-chef-93830

02/22/2024, 8:54 AM
So how it will maintain stickyness. for same Id?
f

fresh-football-47124

02/22/2024, 4:02 PM
well, you can use an ID that is already sticky, like one that your event tracker already has - or you can make your own id and store it in a cookie yourself
we have some example code on our docs for that
j

jolly-chef-93830

02/23/2024, 4:58 AM
Can i get control over stickyness, like TTL for stickiness?
f

fresh-football-47124

02/26/2024, 10:45 AM
Sure, you can use any attribute you like for the assignment, even an ID you make yourself - and then you can control the stickyness
10 Views