blue-exabyte-67168
07/18/2023, 9:28 PMgb.setAttributes
on the client side, to "use the same values as SSR when possible". We are using id
for persistent targeting but we can't know it on the server side due to cache. If the client-side id
attribute doesn't match server-side id
, what would the impact be in this case? My guess is there could be a "flash" where the feature flag value changes from what the server-side (cached) id
was bucketed into, to what the client side id
gets bucketed into?swift-helmet-3648
07/19/2023, 3:57 PMid
attribute is not populatedid
is available (force it to render client-side only)blue-exabyte-67168
07/19/2023, 6:50 PMloadFeatures
on the client side, but seeing some inconsistent results. In our local environment, the features are already loaded by default on the server side (which is good, prevents the flicker). But on our staging environment, the features are not loaded until we call loadFeatures
on the client side and thus we are seeing a flicker. Any idea why that would be? Should we be calling loadFeatures
on both the server side and client side?swift-helmet-3648
07/19/2023, 7:51 PMGrowthBook
instance? (Assuming it's the same in either environment)blue-exabyte-67168
07/19/2023, 8:16 PMgetGrowthBookSSRData
(from the growthbook-react SDK) and pass it our context containing apiHost, clientKey, attributes.id and attributes.environment, all of which are the same between local and staging except for the attributes. Looking at the SDK code, I see that it internally creates an instance and attempts to load the features:
// Get features from API and targeting attributes during SSR
export async function getGrowthBookSSRData(
context: Context
): Promise<GrowthBookSSRData> {
// Server-side GrowthBook instance
const gb = new GrowthBook({
...context,
});
// Load feature flags from network if needed
if (context.clientKey) {
await gb.loadFeatures();
}
const data: GrowthBookSSRData = {
attributes: gb.getAttributes(),
features: gb.getFeatures(),
};
gb.destroy();
return data;
}
So now I'm thinking the loadFeatures
request here is being blocked somehow in our staging server. I can look deeper into that, unless you have another idea? Would that loadFeatures
result be logged anywhere that we could look into?swift-helmet-3648
07/19/2023, 8:20 PMgetFeatures
on the GB instance (or directly look into gb._ctx.features
)blue-exabyte-67168
07/19/2023, 8:24 PMgb._ctx.features
it's an empty object on the server sideloadFeatures
, would that error message be logged somewhere?swift-helmet-3648
07/19/2023, 9:11 PMblue-exabyte-67168
07/19/2023, 9:49 PMid
attribute on the client side, and this caused a flicker when the client id was assigned a different variant than the id corresponding to the page cached at the server side. That's not ideal, but it's what we expected when overriding the value on the client side.