Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getFeatureFlag returns undefined for bootstrapped feature flag #1556

Open
danielbachhuber opened this issue Nov 26, 2024 · 1 comment
Open
Assignees

Comments

@danielbachhuber
Copy link

danielbachhuber commented Nov 26, 2024

Given the following:

posthog.init(POSTHOG_TOKEN, {
    api_host: 'https://us.i.posthog.com',
    person_profiles: 'identified_only',
    bootstrap: {
      featureFlags: {
        'my-awesome-experiment': 'control',
      },
      distinctID: 's0q5mltgmglm3rym95i',
    },
  });

console.log(posthog.version)
posthog.onFeatureFlags((flags, variants) => {
    console.log('variantValue', variants['my-awesome-experiment']);
    console.log('flagValue', posthog.getFeatureFlag('my-awesome-experiment'));
  });

The current output is:

variantValue control
flagValue undefined
variantValue control
flagValue control

The expected output is:


variantValue control
flagValue control
variantValue control
flagValue control

posthog.js version 1.188.0

@havenbarnes havenbarnes self-assigned this Nov 27, 2024
@shawnwall
Copy link

I've noticed similar problems attempting to utilize functions directly after the init call, such as get_distinct_id(). I had to change to utilizing within loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants