Hi everyone. I have an issue with GB, I setup some...
# announcements
c
Hi everyone. I have an issue with GB, I setup some targeting group on my feature. like for instance
country not equal to 'GB'.
Copy code
trackingCallback: async (experiment, result) => {
    await sendSomeEvent(experiment, result)
},
when I test it manually everything seems right and trackingCallback ( and sendSomeEvent ) is not being called*. But* in larger scale when the code is on production I see events are being called for country GB which is not expected coz I want to exclude that country. ( I'm setting country as an attribute )
Copy code
growthBook.setAttributes({ country });
I don't understand why this is happening.
b
@colossal-alligator-31194 Can you confirm that you have the same targeting conditions applied to your
production
environment? The screenshot you shared shows your
preprod
environment rules.
c
yes they are the same.
both env have the same configuration.
We've selfhosted Growthbook and here is the main setup code, but as I said it's fine when I test it manually but since we've a lot of users a portion of them are getting this event which they shouldn't. My assumption is: 1. the way I'm setting attributes ? ( but it works fine for almost a lot of cases ) 2. the free plan of selfhosted limitation ? 3. race condition between initSelfHostedAPI and setGrowthBookAttrs
Copy code
export const growthBook = new GrowthBook({
  trackingCallback: async (experiment, result) => {
    await sendSomeEvent(experiment, result);
  },
});

const setGrowthBookAttrs = ({ id, country }: { id?: string; country?: string }) =>
  growthBook.setAttributes({
    id,
    ...(country ? { country } : undefined),
  });

export const initiateGrowthBook = ({  country }) => {
  const id = "Getting this from cookies";
  initSelfHostedAPI(growthBook);

  setGrowthBookAttrs({ id, country) }); // set attributes after initiating GB
};
Copy code
useLayoutEffect(() => {
    initiateGrowthBook({ country });
  }, []);
b
@colossal-alligator-31194 Hmm... yea, it's possible this could be a race-case issue.
country
may not be defined at the time of bucketing, but it is available by the time the trackingCallback is fired. I can confirm that this is not a limitation of the free self-hosted plan. One thing that might be helpful is when you're initializing GrowthBooth, you can set
enableDevMode: true
and then use our Chrome DevTool Plugin. This allows you to see what attributes GrowthBook has access to.
c
yeah I have the plugin actually. will look into it again.
👍 1