Skip to content

[statsig, posthog] OpenFeature providers, and their examples on v5 - #615

Merged
dferber90 merged 2 commits into
standardfrom
openfeature-statsig-posthog
Nov 20, 2026
Merged

dferber90 merged 2 commits into
standardfrom
openfeature-statsig-posthog

Conversation

@dferber90

@dferber90 dferber90 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Adds OpenFeature server providers for Statsig and PostHog, and moves their examples to v5. Reflag stays on v4 for now.

@flags-sdk/statsig/openfeature: StatsigProvider

  • Built 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:

    Key Reads
    my_gate or gate:my_gate a feature gate (boolean)
    config:name the value object of a dynamic config
    experiment:name the value object of an experiment
    config:…, experiment:… or layer:…, then .param one parameter. A layer key always needs a parameter, because Statsig records exposures per parameter
  • Errors: FLAG_NOT_FOUND for unknown names, PROVIDER_NOT_READY without rules, TYPE_MISMATCH and PARSE_ERROR for keys that don't fit the flag's type.

  • Results: variant is the group name or the rule ID. flagMetadata has the rule ID and the reason of Statsig.

  • The evaluation context becomes a StatsigUser. track() calls logEvent.

  • Next.js 16.4.6 already lists @statsig/statsig-node-core as a server external package, so the example needs no serverExternalPackages.

@flags-sdk/posthog/openfeature: PostHogProvider

  • new PostHogProvider(client, options?), for a posthog-node 5 or 6 client that the app creates. It uses getFeatureFlagResult.
  • Types: boolean reads whether the flag is enabled, string reads the variant, and number and object read the payload.
  • targetingKey is the distinct ID. groups, personProperties and groupProperties come from the context. track() calls capture.

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 as Adapter and ProviderData, but they built against the workspace flags, which is v5. So the type declarations of all of them failed to build, also on standard. Their devDependency is now flags 4.5.0 from npm. The PostHog adapter test takes the Vitest 4 fix from main.

Examples

  • examples/providers/statsig and examples/providers/posthog now use these providers, with defineSource, bindFlag and the manifest route.
  • The Statsig example no longer uses Global Config (EXPERIMENTATION_CONFIG): the Core SDK has no Global Config adapter.

Tests

  • Statsig provider: 21 tests, with a fake Statsig instance, plus one with the real native module, offline, with local overrides.
  • PostHog provider: 23 tests, with a fake client, plus a check that a posthog-node 5 client fits the type.
  • Package totals: Statsig 35, PostHog 50. All 11 adapters build.
  • turbo run build of both examples passes, and their type checks pass.
  • Against the real projects in .env.local: Statsig gave show_banner = true and the welcome text of the dynamic config; PostHog gave show_banner = true and the payload. Unknown keys give FLAG_NOT_FOUND.
  • Not checked: that a Vercel deployment on Linux includes the Linux binary of the Statsig Core SDK. I checked only on macOS.

Open questions

  • Exposure logging is on by default for both providers, as is usual in OpenFeature. The v4 Statsig adapter turned it off by default. With precompute, the proxy evaluates every flag of the group on each request, so exposures would also be logged for flags that the page doesn't use. Should the default be off?
  • A failed Statsig 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

@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flags-playground Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-dev Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-flagsmith Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-growthbook Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-launchdarkly Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-openfeature Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-posthog Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-reflag Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-snippets Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-statsig Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
flags-sdk-sveltekit-snippets Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
shirt-shop Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC
shirt-shop-api Ready Ready Preview, v0 Nov 20, 2026 2:21pm UTC

@socket-security

socket-security Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​statsig/​statsig-node-core@​0.24.2991007097100
Addednpm/​posthog-node@​6.0.38710089100100

View full report

dferber90 and others added 2 commits November 20, 2026 16:20
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>

This branch was successfully deployed

14 active deployments
Preview – flags-sdk-dev — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-playground — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-snippets — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-launchdarkly — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-growthbook — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-vercel — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-posthog — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-openfeature — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-flagsmith — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-sveltekit-snippets — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – shirt-shop — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – shirt-shop-api — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-statsig — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
Preview – flags-sdk-reflag — 77f02c45 Deployed Nov 20, 2026 by vercel[bot]
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

Successfully merging this pull request may close these issues.

1 participant