Repository navigation
[statsig, posthog] OpenFeature providers, and their examples on v5 - #615
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
The adapters in packages/adapter-* use the v4 API, e.g. the types Adapter and ProviderData, but their devDependency flags was the workspace, which is v5. Their type declarations did not build. The devDependency is now flags 4.5.0 from npm. The test of the PostHog adapter uses a function for the mock of the client, as on main, because Vitest 4 calls it with new. Co-Authored-By: Claude <noreply@anthropic.com>
- @flags-sdk/statsig/openfeature: StatsigProvider on the Statsig Server Core SDK (@statsig/statsig-node-core). A plain key reads a feature gate. config:, experiment: and layer: read the other kinds, and .<param> one parameter. A layer key needs a parameter. - @flags-sdk/posthog/openfeature: PostHogProvider for a posthog-node 5 or 6 client. boolean: enabled, string: variant, number and object: payload. - Neither provider imports flags, so they work with any OpenFeature app. The v4 adapters of both packages do not change. - examples/providers/statsig and posthog use the providers with defineSource and bindFlag, and the manifest route. Global Config is no longer used for Statsig. - The docs list both providers. Co-Authored-By: Claude <noreply@anthropic.com>
dferber90
force-pushed
the
openfeature-statsig-posthog
branch
from
November 20, 2026 14:20
e2e1804 to
77f02c4
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds OpenFeature server providers for Statsig and PostHog, and moves their examples to v5. Reflag stays on v4 for now.
@flags-sdk/statsig/openfeature:StatsigProviderBuilt on the Statsig Server Core SDK,
@statsig/statsig-node-core, an optional peer dependency.new StatsigProvider(sdkKey | statsig, { statsigOptions?, disableExposureLogging? }). Creating it opens no connection:initialize()fetches the rules.onClose()shuts down only an instance that the provider created.Keys:
my_gateorgate:my_gateconfig:nameexperiment:nameconfig:…,experiment:…orlayer:…, then.paramErrors:
FLAG_NOT_FOUNDfor unknown names,PROVIDER_NOT_READYwithout rules,TYPE_MISMATCHandPARSE_ERRORfor keys that don't fit the flag's type.Results:
variantis the group name or the rule ID.flagMetadatahas the rule ID and the reason of Statsig.The evaluation context becomes a
StatsigUser.track()callslogEvent.Next.js 16.4.6 already lists
@statsig/statsig-node-coreas a server external package, so the example needs noserverExternalPackages.@flags-sdk/posthog/openfeature:PostHogProvidernew PostHogProvider(client, options?), for aposthog-node5 or 6 client that the app creates. It usesgetFeatureFlagResult.targetingKeyis the distinct ID.groups,personPropertiesandgroupPropertiescome from the context.track()callscapture.Neither provider imports
flags, so both also work for apps that use OpenFeature without the Flags SDK. The v4 adapters in both packages don't change.Fix for all adapters
The v4 adapters in
packages/adapter-*use v4 types, such asAdapterandProviderData, but they built against the workspaceflags, which is v5. So the type declarations of all of them failed to build, also onstandard. Their devDependency is nowflags4.5.0 from npm. The PostHog adapter test takes the Vitest 4 fix frommain.Examples
examples/providers/statsigandexamples/providers/posthognow use these providers, withdefineSource,bindFlagand the manifest route.EXPERIMENTATION_CONFIG): the Core SDK has no Global Config adapter.Tests
posthog-node5 client fits the type.turbo run buildof both examples passes, and their type checks pass..env.local: Statsig gaveshow_banner= true and the welcome text of the dynamic config; PostHog gaveshow_banner= true and the payload. Unknown keys giveFLAG_NOT_FOUND.Open questions
initialize()(for example, a wrong key) is retried on the next evaluation: one fetch per request. Should a 401 be a fatal error instead?🤖 Generated with Claude Code