brief-honey-45610
09/21/2023, 4:03 AMbrief-honey-45610
09/21/2023, 4:03 AMfamous-bird-26809
12/12/2023, 8:40 PMbusy-air-96466
01/02/2024, 3:52 PMplain-judge-50181
02/08/2024, 7:56 AMconst { GrowthBook, setPolyfills } = require('@growthbook/growthbook');
setPolyfills({
// Required when using built-in feature loading and Node 17 or lower
fetch: require("cross-fetch"),
// Required when using encrypted feature flags and Node 18 or lower
SubtleCrypto: require("node:crypto").webcrypto.subtle,
// Optional, can make feature rollouts faster
EventSource: require("eventsource"),
// Optional, can reduce startup times by persisting cached feature flags
localStorage: {
// Example using Redis
getItem: (key) => redisClient.get(key),
setItem: (key, value) => redisClient.set(key, value),
}
})
const initGrwothBook = async () => {
return new GrowthBook({
apiHost: "hmyhost",
clientKey: "sdk-key",
// Enable easier debugging during development
enableDevMode: true,
// Update the instance in realtime as features change in GrowthBook
subscribeToChanges: true,
// Targeting attributes
attributes: {
id: "123",
country: "US"
},
// Only required for A/B testing
// Called every time a user is put into an experiment
trackingCallback: (experiment, result) => {
console.log("Experiment Viewed", {
experimentId: experiment.key,
variationId: result.key,
});
},
});
}
async function init() {
// Wait for features to be available
const gb = await initGrwothBook();
// console.log(gb);
try{
const features = await gb.loadFeatures();
console.log('Grwothbook features ', features); // getting undefined
}catch(err){
console.log('Error GrwothBook features ', err);
}
}
init();
hundreds-agent-51861
02/22/2024, 11:03 AMfresh-helicopter-69423
02/28/2024, 11:20 AMonNewFeatureData
is called and it sets the newly fetched features only when you have any subscribedInstances
. Since I don't have any subscribed instances, the values are not set in the same app session but only updates the cache.
function onNewFeatureData(
key: string,
cacheKey: string,
data: FeatureApiResponse
): void {
......
updatePersistentCache();
// Update features for all subscribed GrowthBook instances
const instances = subscribedInstances.get(key);
instances && instances.forEach((instance) => refreshInstance(instance, data));
}
Solution: a straight forward solution for my usecase will be to replace the instance check with the below code as my app does not support auto refresh feature
instance && data && setFeaturesOnInstance(instance, data)
I wanted the understand the implications of these changes and is there any other way to solve this issue
TIA!magnificent-magician-7659
05/09/2024, 3:03 PMimport { GrowthBook } from "@growthbook/growthbook";
^^^^^^^^^^
SyntaxError: Named export 'GrowthBook' not found. The requested module '@growthbook/growthbook' is a CommonJS module, which may not support all module.exports as named exports.
I’m following std SDK implementation manual for Node.js (v20)orange-manchester-61441
05/14/2024, 10:37 AM0.26.0
. As I understand that there are two level of cache in-memory and local-storage. What I am seeing is sometimes the cache returns really older version of the data and cache in local-storage is not updated. Has anyone seen this issue? I can just turn off the cache in the config but I want to understand why it would return old version of the data.flat-advantage-68891
08/21/2024, 12:09 PMbillowy-lizard-55653
11/19/2024, 1:37 PM5: {
0: "event"
1: "experiment_viewed"
2: {
experiment_id: "test-feature"
variation_id: "0"
}
}
6: {
event: "experiment_viewed"
experiment_id: "test-feature"
gtm.uniqueEventId: 15
variation_id: "0"
}
dry-market-38093
11/28/2024, 3:07 PMdocument.addEventListener("DOMContentLoaded", function () {
// Verifica se a modal já foi exibida
if (!localStorage.getItem("paymentModalShown")) {
showModal();
}
// Função para exibir a modal
function showModal() {
const modal = document.getElementById("paymentModal");
modal.style.display = "flex";
localStorage.setItem("paymentModalShown", "true"); // Salva no localStorage
}
// Fecha a modal quando o "X" é clicado ou quando a área fora da modal é clicada
const closeButton = document.querySelector(".close-btn");
const modal = document.getElementById("paymentModal");
closeButton.addEventListener("click", closeModal);
modal.addEventListener("click", function (event) {
if (event.target === modal) {
closeModal();
}
});
// Função para fechar a modal
function closeModal() {
const modal = document.getElementById("paymentModal");
localStorage.setItem("paymentModalShown", "true"); // Salva no localStorage
modal.style.display = "none";
}
});
enough-ice-36370
12/05/2024, 3:05 PMsetForcedVariations
method in the GrowthBook
class.
Is there some way to get hold of the list of these GrowthBook experiments? I tried calling the getExperiments()
method but that always returns an empty array - I am assuming that this would just return the experiments that may have been passed in via the constructor which is not what I want.bland-jewelry-79981
03/03/2025, 6:00 PMuserId
primary, anonymousId
alternative), I enter the site in anonymous I get variation A, I login and I still get variation A, even if userId
hash would end up choosing variation B, and that's fine
but now I change device, I login and I'm on variation B, and at this point I was expecting variation A as the official documentation says:
The very first variation a user is assigned to will "stick" to them and follow them across devices. So if a visitor lands on your website, gets assigned variation B (from their fallback attribute), and then logs in, they will continue seeing variation B, even though they now have awhat I'm missing?attribute. If that same user then logs into your app on a new device, they again will continue seeing variation B.userId
narrow-toddler-83757
06/07/2025, 4:03 AMReferenceError: MutationObserver is not defined
when I try to instantiate a GrowthbookClient instance. Feels strange that we need a mutationObserver for a backend SDK -- is there something obvious here I'm missing?curved-machine-78995
07/15/2025, 7:02 AMApplication error: a client-side exception has occurred (see the browser console for more information).
when I try to click on any of the features. I am getting the same error when I click on web hooks under the settings section. Can someone help me on this ?