Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
7.2 KiB
@flags-sdk/posthog
1.0.1
Patch Changes
-
#452
58e1f5bThanks @luismeyer! - Replace@vercel/edge-configwith@vercel/global-config.Rename the Edge Config adapter package to
@flags-sdk/global-configand rename repository-owned Edge Config files, exports, types, options, variables, and environment variables to Global Config.The previous Edge Config names remain available as deprecated aliases, and the previous environment variables are still honored as fallbacks, so existing code keeps working without changes.
1.0.0
Major Changes
-
#436
aec3c03Thanks @dferber90! - Modernize the PostHog adapter. This release is breaking in five ways:- Environment variables were renamed.
NEXT_PUBLIC_POSTHOG_KEY→POSTHOG_PROJECT_API_KEYandNEXT_PUBLIC_POSTHOG_HOST→POSTHOG_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()becomepostHogAdapterandpostHogAdapter.payload. - A flag's
keyis used as the PostHog flag key verbatim. The old "read until the first." convention is gone. - The per-call
sendFeatureFlagEventsoption and thefeatureFlagPayloadgetValuemapper are removed.
It also upgrades
posthog-nodefrom v4.11.1 to v5.45.0 (which raises the required Node.js version), adds bulk evaluation support, dropsposthog-node's runtime deprecation warnings, and removes the unused@vercel/edge-configdependency.This release requires
flags@^4.2.0, which is where the uninvoked-adapter shorthand and bulk evaluation landed.Environment variables
The adapter runs server-side only, so its credentials were never meant to be exposed to the browser. The
NEXT_PUBLIC_prefixed variables are renamed accordingly, and the project API key variable now says which key it wants:- NEXT_PUBLIC_POSTHOG_KEY=phc_... - NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com + POSTHOG_PROJECT_API_KEY=phc_... + POSTHOG_HOST=https://us.i.posthog.comPOSTHOG_HOSTis also whatgetProviderDataderives the app host from, andPOSTHOG_PERSONAL_API_KEY/POSTHOG_PROJECT_IDare unchanged.Explicit local vs. remote evaluation
Previously the default
postHogAdapterpassedPOSTHOG_PERSONAL_API_KEYinto the runtimeposthog-nodeclient. When that variable was set, this enabled local evaluation and started a feature-flag poller in every warm server process — on serverless that could generate a large, traffic-independent volume of PostHog feature flag requests, as a side effect of a credential you may only have set for the Flags Explorer.The default adapter now evaluates flags remotely unless you opt in to local evaluation by setting
POSTHOG_SECRET_KEY(aphs_...project secret key). When set,posthog-nodepolls flag definitions and evaluates flags in-process. When usingcreatePostHogAdapter, control it explicitly viapostHogOptions(secretKey+enableLocalEvaluation).POSTHOG_PERSONAL_API_KEYcontinues to be used only bygetProviderData(Flags Explorer discovery) and no longer affects runtime evaluation.Single callable adapter
The three adapter methods (
isFeatureEnabled,featureFlagValue,featureFlagPayload) are collapsed into a single callable adapter, matching@flags-sdk/vercel. Pass it uninvoked or invoked, and use.payloadfor a flag's attached payload:// before import { postHogAdapter } from "@flags-sdk/posthog"; flag({ key: "my-flag", adapter: postHogAdapter.isFeatureEnabled() }); flag({ key: "my-flag", adapter: postHogAdapter.featureFlagValue() }); flag({ key: "my-flag", adapter: postHogAdapter.featureFlagPayload((v) => v), }); // after import { postHogAdapter } from "@flags-sdk/posthog"; flag({ key: "my-flag", adapter: postHogAdapter }); // or postHogAdapter() flag({ key: "my-flag", adapter: postHogAdapter.payload }); // or .payload()isFeatureEnabledandfeatureFlagValuemerged into the value adapter, which returns whatever PostHog evaluated the flag to: a boolean for a boolean flag, the variantstringfor a multivariate flag. Type the flag (flag<boolean>,flag<string>) to describe the value you expect.Note that
isFeatureEnabledused to coerce a multivariate flag's variant totrue. Nothing coerces now, so a flag that previously readtrueviaisFeatureEnabledwill read e.g.'variant-a'. Declaringflag<boolean>only changes the TypeScript type — if you relied on the boolean, narrow the value in your owndecideor at the call site.A flag's
keyis now used as the PostHog feature flag key verbatim. The previous convention of trimming everything after the first.(somy-flag.variantread the PostHog flagmy-flag) has been removed; use the exact PostHog flag key as your flagkey.Upgraded
posthog-node, migrated toevaluateFlags, added bulk evaluationposthog-nodeis upgraded from v4.11.1 to v5.45.0. Internally the adapter now uses itsevaluateFlagsinstead of the deprecatedisFeatureEnabled/getFeatureFlag/getFeatureFlagPayloadmethods, removing the deprecation warnings those log at runtime.The adapter also implements
bulkDecide, soevaluate()resolves flags that share anidentifysource through a singleevaluateFlagscall — one/flagsrequest when evaluating remotely, one in-process evaluation when evaluating locally. Flag values and flag payloads are batched separately, so a flag and its payload still resolve through two calls.The per-call
sendFeatureFlagEventsoption and thefeatureFlagPayloadgetValuemapper are removed (neither has anevaluateFlagsequivalent); map payloads in your own flag code instead.Node.js version requirement
posthog-node@5.45.0requires Node.js^20.20.0 || >=22.22.0, and this adapter now declares the sameenginesconstraint.Removed
@vercel/edge-configdependencyThe adapter never used it. It is dropped from
dependencies(and from the package keywords), so installs no longer pull it in. - Environment variables were renamed.
0.2.2
Patch Changes
5f3757a: drop tsconfig dependency
0.2.1
Patch Changes
ff052f0: upgrade internal @vercel/edge-config dependency to v1.4.3
0.2.0
Minor Changes
5586443: List flags includes inactive ones to discover all flags
0.1.0
Minor Changes
44bada7: Publish PostHog adapter
0.1.0
Minor Changes
- postHogAdapter: Default adapter is available
- postHogAdapter.isFeatureEnabled: Check if a feature flag is enabled
- postHogAdapter.featureFlagValue: Get the value of a feature flag
- postHogAdapter.featureFlagPayload: Get the payload of a feature flag
- postHogAdapter.client: Access the PostHog client