Skip to content

@flags-sdk/posthog: upgrade posthog-node; explicit evaluation modes#436

Open
dferber90 wants to merge 12 commits into
mainfrom
update-posthog
Open

@flags-sdk/posthog: upgrade posthog-node; explicit evaluation modes#436
dferber90 wants to merge 12 commits into
mainfrom
update-posthog

Conversation

@dferber90

@dferber90 dferber90 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Modernize the PostHog adapter. This release is breaking in four ways:

  • Environment variables were renamed. NEXT_PUBLIC_POSTHOG_KEYPOSTHOG_PROJECT_API_KEY and NEXT_PUBLIC_POSTHOG_HOSTPOSTHOG_HOST.
  • Local vs. remote evaluation is now an explicit choice. The default adapter evaluates remotely unless you set POSTHOG_SECRET_KEY.
  • The three adapter methods collapsed into a single callable adapter. isFeatureEnabled() / featureFlagValue() / featureFlagPayload() become postHogAdapter and postHogAdapter.payload.
  • A flag's key is used as the PostHog flag key verbatim, and Node.js ^20.20.0 || >=22.22.0 is now required.

It also upgrades posthog-node from v4.11.1 to v5.45.0, adds bulk evaluation support,
and drops posthog-node's deprecation warnings.

closes #393

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
flags-playground Ready Ready Preview, Comment, Open in v0 Jul 26, 2026 9:41pm
flags-sdk-dev Ready Ready Preview, Comment, Open in v0 Jul 26, 2026 9:41pm
flags-sdk-snippets Ready Ready Preview, Comment, Open in v0 Jul 26, 2026 9:41pm
flags-sdk-sveltekit-snippets Ready Ready Preview, Comment, Open in v0 Jul 26, 2026 9:41pm
shirt-shop Ready Ready Preview, Comment, Open in v0 Jul 26, 2026 9:41pm
shirt-shop-api Ready Ready Preview, Comment, Open in v0 Jul 26, 2026 9:41pm

@socket-security

socket-security Bot commented Jul 21, 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/​posthog-node@​5.45.09110079100100

View full report

@vincent-derks vincent-derks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some issues:

  • 5.45.0 has "engines": { "node": "^20.20.0 || >=22.22.0" }. It used to support >=15. Quite the jump. Should we at least document that? Or maybe also define an engines field mirroring that in packages/adapter-posthog/package.json?
  • 5.45.0 has deprecated isFeatureEnabled, getFeatureFlag, and getFeatureFlagPayload in favor of evaluateFlags. I think this might spam some deprecation warnings now. Should we also migrate to evaluateFlags? Since it's already a major update, that might fit.

Comment thread packages/adapter-posthog/package.json Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should also remove this

The default adapter passed POSTHOG_PERSONAL_API_KEY into the runtime
posthog-node client, which enabled local evaluation and started a
feature-flag poller in every warm process. On serverless this produced
large, traffic-independent PostHog feature flag request volume.

Local evaluation is now opt-in via POSTHOG_SECRET_KEY; without it the
adapter evaluates remotely. POSTHOG_PERSONAL_API_KEY is used only by
getProviderData (Flags Explorer) and no longer affects runtime
evaluation. Drops the forced 10s poll interval in favor of the v5
default. Updates docs, README, and tests.
Comment thread packages/adapter-posthog/src/index.test.ts Outdated
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.

PostHog adapter starts local-evaluation polling when POSTHOG_PERSONAL_API_KEY is set

2 participants