Skip to content

@flags-sdk/flagsmith@2.0.0

Choose a tag to compare

@github-actions github-actions released this 24 Sep 10:46
· 35 commits to main since this release
83bff75

Major Changes

  • #519 05e8e0e Replaced the Flagsmith JavaScript SDK with @flagsmith/nodejs, adding support for local evaluation and batched flag evaluation through evaluate().

    Breaking changes

    • The default adapter reads FLAGSMITH_ENVIRONMENT_KEY instead of FLAGSMITH_ENVIRONMENT_ID. Rename the environment variable in your project, or create a duplicate holding the same value.
    • createFlagsmithAdapter() now accepts FlagsmithConfig from @flagsmith/nodejs. Rename environmentID to environmentKey and api to apiUrl.
    • Browser SDK options, including cacheFlags, state, and onChange, are no longer supported. Supply user identity and traits through the flag's identify function.
    • Internally replaced the deprecated flagsmith package with @flagsmith/nodejs.

For long-running servers, enable local evaluation with a server-side environment key (starting with ser.):

const adapter = createFlagsmithAdapter({
  environmentKey: process.env.FLAGSMITH_ENVIRONMENT_KEY,
  enableLocalEvaluation: true,
});

Local evaluation shares an environment document across requests and refreshes it every 60 seconds. Configure environmentRefreshIntervalSeconds to change the interval, and call the new adapter.close() method on shutdown to stop polling. Remote evaluation does not download or poll an environment document.

evaluate() fetches flags once per batch. Flags with different coercion modes are evaluated in separate batches. Individual flag evaluation, value coercion, and per-flag defaults remain supported.