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

PostHog::init crashes when adding a personalAPIKey #38

Open
wesleymartincc opened this issue Oct 28, 2022 · 1 comment
Open

PostHog::init crashes when adding a personalAPIKey #38

wesleymartincc opened this issue Oct 28, 2022 · 1 comment

Comments

@wesleymartincc
Copy link

I have been trying to integrate the Experiments feature into our site. I have set up a new experiment at https://app.posthog.com/experiments and it is running.
image

I am currently using "posthog/posthog-php": "^3.0" and php 8.1.

I have been trying to get PostHog::getFeatureFlag('sell-your-classic-test', 'some distinct id'); to work but it would keep returning null. I tried:

if (PostHog::isFeatureEnabled('sell-your-classic-test', 'some distinct id')) {
    // do something here
}

But this always returns false. I then read about Local Evaluation which requires a personal API key. I created one and have added it to PostHog::init but when I do this I get the below error:

array_key_exists(): Argument #2 ($array) must be of type array, null given

Which is found in vendor/posthog/posthog-php/lib/Client.php:356.
image

This is the code that I'm running:

PostHog::init(
    apiKey: "phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    personalAPIKey: "phx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
);

I have also tried:

PostHog::init(
    "phc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    [],
    null,
    "phx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
);

Any help would be helpful.

@wesleymartincc
Copy link
Author

For the time being I'm using the /decide?v=2 API.

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

No branches or pull requests

1 participant