@core-sdk/feature-flags-sdk
v0.5.0
Published
HTTP client + cache for feature flags; uses @core-sdk/feature-flags-core for evaluation
Readme
@core-sdk/feature-flags-sdk
HTTP client + in-memory TTL cache for feature flag definitions; evaluation uses @core-sdk/feature-flags-core on the client.
- Node: 18+
- Module: ESM (
"type": "module")
Install
npm install @core-sdk/feature-flags-sdkPostHog-style identify (one-shot context)
Call identify once after login (or when profile is known). Stored fields are merged into every evaluate / evaluateAsync / isEnabled call. Per-flag overrides win on key clashes.
import { FeatureFlagsClient } from "@core-sdk/feature-flags-sdk";
const client = new FeatureFlagsClient({
baseUrl: "https://flag-api.example.com",
projectKey: "my-project",
});
await client.bootstrap();
client.identify(profile.userId, {
email: profile.email,
accountId: profile.accountId,
});
// Uses merged context (email, accountId, userId = profile.userId)
const on = await client.isEnabled("new-checkout");
// Flag-specific props override the base for this call only
const promo = await client.isEnabled("promo-banner", { channelId: "web" });reset()clears the identified person; evaluation uses{}again until the nextidentify.distinctIdKey(optional, defaultuserId): which context key receives the firstidentifyargument. Match your portal rulefieldnames.
Until identify is called, isEnabled("x") uses an empty context ({}). Rules that require user fields therefore evaluate to false for logged-out users—no extra anonymous id layer is needed.
API routes
The client calls:
GET {baseUrl}/projects/{projectKey}/flagsGET {baseUrl}/projects/{projectKey}/flags/{flagKey}GET .../flags/{flagKey}/historyGET .../flags/{flagKey}/versions/{version}
License
See your organization’s license terms.
