I am trying to setup feature flags via the flags sdk with the posthog provider.
Defining
export const myTestFlag = flag({
key: "my-test-flag",
adapter: postHogAdapter.isFeatureEnabled(),
});
is valid and TypeScript doesn’t complain.
However it will throw an error:
Error: PostHog Adapter: Missing entities, flag must be defined with an identify() function.
In the docs this is simple referred to as:
import identify from "@/lib/identify";
export const myFlag = flag({
key: "posthog-is-feature-enabled",
adapter: postHogAdapter.isFeatureEnabled(),
identify,
});
with no details how the identify function has to be implemented.
Adding an async function that returns the email as string or as an object {email: string} will lead to an error on the adapter:
After a while of digging it seems identify should return Promise<{distinctId: string}> . This would be a valuable addition to the docs as it’s not obvious.
Additionally when a feature-flag is disabled in PostHog and the feature flag is implemented as shown in the docs this will lead to following error:
Error: PostHog Adapter isFeatureEnabled returned undefined for my-test-flag and no default value was provided.
hence the documentation should contain the defaultValue:
export const myTestFlag = flag({
key: "my-test-flag",
defaultValue: false,
adapter: postHogAdapter.isFeatureEnabled(),
identify,
});
