PostHog::init crashes when adding a personalAPIKey
wesleymartincc opened this issue · 1 comments
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.
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
.
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.
For the time being I'm using the /decide?v=2
API.