hi, is there a JS SDK event or similar i can liste...
# ask-questions
r
hi, is there a JS SDK event or similar i can listen to for when an experiment override is selected in the devtools?
h
Sort of... Wondering what your use case is
You can do something like
Copy code
window.addEventListener(
  "message",
  (event) => {
    if (event?.data?.type === "GB_UPDATE_EXPERIMENTS") {
      // do stuff with event.data.data
    }
  }
)
but I'd constrain this to debugging only
it also won't catch hydrated/saved overrides, just the switch event. For current state, you can probably use
window._growthbook.context.forcedVariations
r
the use case is that i've implemented content A/B testing in a headless CMS (storyblok) using growthbook. there is no clear way to achieve that using flags so i've created a dropdown of all experiments and variations so the user can target a variation for specific content. so i was playing with the idea to make that working with GB dev tools, but then i realized it's just one of those things that i won't hunt down