posthog-node
posthog-node copied to clipboard
posthog.getAllFlags not working
Hi. I'm using posthog-node 2.0.2 and I get the following error when calling getAllFlags
:
TypeError: undici__default.default.fetch is not a function
at PostHogClient.fetch (/node_app/back/api/node_modules/@visage/visage-server-common/node_modules/posthog-node/src/posthog-node.ts:53:19)
at /node_app/back/api/node_modules/@visage/visage-server-common/node_modules/posthog-core/src/index.ts:647:33
at /node_app/back/api/node_modules/@visage/visage-server-common/node_modules/posthog-core/src/utils.ts:23:25
at step (/node_app/back/api/node_modules/@visage/visage-server-common/node_modules/node_modules/tslib/tslib.es6.js:102:23)
at Object.next (/node_app/back/api/node_modules/@visage/visage-server-common/node_modules/node_modules/tslib/tslib.es6.js:83:53)
at fulfilled (/node_app/back/api/node_modules/@visage/visage-server-common/node_modules/node_modules/tslib/tslib.es6.js:73:58)
Hey @SebTVisage , what's getAll
?
Ok actually it's the same with isFeatureEnabled
.
Sorry I meant getAllFlags
(mentioned in the docs). I've edited the issue
Hmm, just tested the library again, I don't face the same.
How're you using the library? Some reproduction instructions would be nice.
On a node 12 project using TS. I'll try to give you a reproduction repo. I do this more or less:
import { PostHog } from 'posthog-node';
import config from '../config';
export const postHogClient = new PostHog(config.thirdParties.posthog.apiKey, {
personalApiKey: config.thirdParties.posthog.personalKey,
});
// In another file:
import { postHogClient } from '<path to file above>';
// In a function I do just something like this
const featureFlags = await postHogClient.getAllFlags('some-user-id');
I'll try to do a reproduction repo
For a quick check, we're using node 16, try if that works? Might mean we need to update the supported node versions 🤔
This will be fixed here but it does bump the minimum version to v14.7.0 https://github.com/PostHog/posthog-js-lite/pull/22