Skip to content

Latest commit

 

History

History
1414 lines (839 loc) · 60.5 KB

File metadata and controls

1414 lines (839 loc) · 60.5 KB

Changelog

12.0.0 (2026-03-06)

⚠ BREAKING CHANGES

  • migrate npm packages to @flagsmith organization scope (#367)
  • re-add sdk version headers (#344)
  • onError not called if cacheFlags is true and api is not reachable (#365)

Features

Bug Fixes

  • angularHttpClient fetch error (#359) (44e4b79)
  • catch init error in useFlagsmith (#351) (5380dc3)
  • export FlagSource enum as runtime value (#349) (d480bb9)
  • onError not called if cacheFlags is true and api is not reachable (#365) (1411b85)
  • removed-react-native-publishing (#381) (a0894b9)
  • revert User-Agent header again (#362) (53baaa9)
  • types: loading state source unresolved any (#360) (30c35a3)

CI

Other

10.0.0 (2025-12-10)

⚠ BREAKING CHANGES

  • re-add sdk version headers (#344)
  • onError not called if cacheFlags is true and api is not reachable (#365)

Features

Bug Fixes

  • onError not called if cacheFlags is true and api is not reachable (#365) (1411b85)

Other

  • deps: bump js-yaml from 3.14.1 to 3.14.2 (#361) (e15a0dc)

9.3.5 (2025-12-08)

Bug Fixes

9.3.4 (2025-11-18)

Bug Fixes

CI

9.3.3 (2025-11-05)

Bug Fixes

  • export FlagSource enum as runtime value (#349) (d480bb9)

CI

Other

  • deps-dev: bump form-data from 4.0.0 to 4.0.4 (#331) (187feda)

9.3.2 (9.3.2-post0) - 2025-09-03

What's Changed

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/9.3.1...9.3.2

Changes

9.3.1 - 2025-08-19

What's Changed

  • fix: typescript type generation when array of fields is passed. by @rushib1 in #325
  • feat: send flagsmith sdk user agent by @Zaimwa9 in #332
  • fix: renamed-sentry-client-interface by @Zaimwa9 in #335
  • fix: make-id-optional-in-iflags by @Zaimwa9 in #336
  • chore: bumped-react-native-version by @Zaimwa9 in #337

New Contributors

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/9.3.0...9.3.1

Changes

9.3.0 - 2025-07-01

What's Changed

Adds the Sentry integration

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/9.2.2...9.3.0

Changes

9.2.2 - 2025-05-13

What's Changed

  • fix: re-add support for flagsmith.identity by @kyle-ssg in #301

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/9.2.1...9.2.2

Changes

9.2.1 - 2025-05-05

What's Changed

  • fix: updated-interface-flags-for-javascript-client by @Zaimwa9 in #315
  • fix: improved-on-change-and-fvalue-types by @Zaimwa9 in #316

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/9.2.0...9.2.1

Changes

9.2.0 - 2025-04-28

What's Changed

New Contributors

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/9.1.0...9.2.0

Changes

9.1.0 - 2025-04-08

Allows specifying a type definition for all feature flags #298, a pre-requisite for Flagsmith/flagsmith-cli#24

Changes

9.0.5 - 2025-03-13

What's Changed

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/9.0.4...9.0.5

Changes

9.0.4 - 2025-02-12

fixes #289

What's Changed

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/9.0.3...9.0.4

Changes

9.0.3 - 2025-01-23

Closes #287

Changes

9.0.2 - 2025-01-22

Closes #283

Changes

9.0.1 - 2025-01-20

What's Changed

  • fix: Don't use cached traits to initialize sdk state by @tiagoapolo in #282
  • fix: Types not being exported and autocomplete not working by @tiagoapolo in #284

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/9.0.0...9.0.1

Changes

9.0.0 - 2025-01-15

This release removes flagsmith-es and makes the flagsmith npm package both umd and es module compatible. Closes #226

Changes

8.0.3 - 2025-01-15

What's Changed

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/8.0.2...8.0.3

Changes

8.0.2 - 2025-01-02

What's Changed

  • fix: Un-deprecate setTrait, setTraits and identify by @tiagoapolo in #276

New Contributors

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/8.0.1...8.0.2

Changes

8.0.1 - 2024-12-18

Fixes sourcemaps (#239) Fixes ReactNode type (#268) Fixes identifier being removed from context in getFlagsResponse (#262)

Changes

8.0.0 - 2024-12-18

What's Changed

Breaking changes

This release reintroduces the changes originally added in Version 6.0.0. This changes the key used by the flagsmith client for internal storage to allow support for multiple environments. See #252 for further details.

New Contributors

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/7.0.2...8.0.0

Changes

Version 7.0.2 - 2024-11-05

What's Changed

  • fix: Incorrect argument type, interface extension by @khvn26 in #261
  • fix: Interface extensions are not correct by @khvn26 in #266

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/7.0.1...7.0.2

Changes

Version 7.0.1 - 2024-10-17

Allows flagsmith.setContext({...}) prior to init.

Changes

7.0.0 - 2024-10-10

This is a temporary release that reverts the changes in 6.0.0.

What's Changed

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/6.0.0...7.0.0

Changes

Closes #201. The local storage keys for the SDK cache are now unique for each environment. This is being released as a breaking change because, upon upgrading to this version, the cache will be missed the first time due to the previous key ('BULLET_TRAIN_DB') being ignored

Thank you very much for the great PR @oluizcarvalho 🚀

Changes

Transient traits

This release supports the concept of transient traits, setting this will mean the trait is not stored within Flagsmith and evaluated just in that request.

You can define a trait as transient like so:

setTraits({bar:{value:123, transient: true}})
setTraits({foo:"1", bar:{value:123, transient: true}})
flagsmith.init({
  traits: {foo:"1", bar:{value:123, transient: true}}
})

Contexts and transient identities

This release also deprecates the above calls in favour of setting context. Context allows you to set information as a single object which we may extend in future more easily. We suggest migrating to this soon.

You can set a partial context and it will merge with the one provided during SDK init.

Currently, the full context object looks like this:

flagsmith.setContext({
  {
    environment: {apiKey: "<your environment API key>"},
    identifier: "unique-user-id",
    traits:     {foo:"1", bar:{value:123, transient: true}},
    transient:  false
  }
})

Changes

Version 4.1.4 - 2024-09-24

Closes #253

Changes

Version 4.1.3 - 2024-09-17

Closes #250 - thank you @blackjid 🚀

Changes

Version 4.1.2 - 2024-09-11

Closes #238

Fixes a race condition whereby flag state returns as {} if flagsmith.init resolves after flagsmith.identify

Changes

Version 4.1.1 - 2024-09-10

Solves #242. When calling flagsmith.init with traits they will now be merged with any cached traits.

Changes

Version 4.1.0 - 2024-09-04

Resolves #243

Adds a fallback for a feature flag when the flag doesn't exists.

flagsmith.hasFeature("deleted_feature",{fallback:true})

Changes

Version 4.0.3 - 2024-07-03

Closes #235

Changes

Version 4.0.2 - 2024-05-17

What's Changed

  • fix: clear traits when identifying over previous identity by @kyle-ssg in #229

Full Changelog: https://github.com/Flagsmith/flagsmith-js-client/compare/4.0.1...4.0.2

Changes

Closes #224

Changes

This will be the first version compatible with OpenFeature. Merges #223

Breaking changes

  • Init will now reject if:
    • No environment ID is provider
    • Fetch fails and there's no cache (Init resolves on cache)
    • There's no cache/defaults and preventFetch is true
  • The boolean properties traitsChange and flagsChanged are now a string[] of changed keys or null. This reduces breaking changes since falsey and truthy checks will still behave as before.

Other changes

  • Init is (finally) async/await
  • Init code is reduced by pulling out isolated functions
  • Added tests around init promises
  • Organised util files

Changes

Closes #222

The SDK will now synchronously read cache rather than fetching it asynchronously.

Changes

Merges #207 Closes #217

Changes

Merges #216

Changes

Closes #214

  • Fixes flag updates from useFlags
  • Fixes flag updates where flagsmith.init is not called

Changes

Merges #213, thanks to @levrik

Changes

Prior to this release, clients that request identified/unidentified flags simultaneously could see the wrong results due to a race condition. Although this signifies incorrect usage of the SDK, this will no longer occur.

For more information see #205.

Changes

This introduces a strategy to responding to loading state changes in flagsmith

The following will be exposed to Flagsmith:

export declare enum FlagSource {
    "NONE" = "NONE",
    "DEFAULT_FLAGS" = "DEFAULT_FLAGS",
    "CACHE" = "CACHE",
    "SERVER" = "SERVER",
}

export declare type LoadingState = {
    error: Error | null, // Current error, resets on next attempt to fetch flags
    isFetching: bool, // Whether there is a current request to fetch server flags
    isLoading: bool,  // Whether any flag data exists
    source: FlagSource //Indicates freshness of flags
}

It can be consumed via the onChange function of flagsmith.init or the newly introduced useFlagsmithLoading

    onChange?: (previousFlags: IFlags<F> | null, params: IRetrieveInfo, loadingState:LoadingState) => void;
    const loadingState:LoadingState = useFlagsmithLoading()

Changes

3.18.4 - Audit fix - 2023-06-20

This version includes an npm audit fix.

Changes

Closes #167

Changes

This release adds an integration to Datadog RUM, it focuses on the new experimental feature_flags feature, you can read more about it here https://docs.datadoghq.com/real_user_monitoring/guide/setup-feature-flag-data-collection/?tab=npm.

This will track remote config and feature enabled states as feature flags in the following format

flagsmith_value_<FEATURE_NAME> // remote config
flagsmith_enabled_<FEATURE_NAME> // enabled state

Additionally, the integration will also store Flagsmith traits against the Datadog user in the following format:

flagsmith_trait_<FEATURE_NAME> // remote config

You can find an example of this integration here.

Changes

This release adds a stable implementation of realtime features and is used on app.flagsmith.com.

Flagsmith projects that are opted into realtime are able to enable realtime within flagsmith.init as {realtime: true}, this will instruct the SDK to connect to our realtime SSE endpoint to receive feature updates from the environment and segment overrides.

Changes

Closes #93. This aims to make the type of onError more predictable by always sending it as an Error object. Thank you to @gfrancischini for the sensible suggestion!

Changes

Prior to this release, setTrait(s) calls were not returning a promise, they will now resolve when the API returns a new set of flags.

Changes

  • Calls to setTrait/setTraits now only hit 1 endpoint, previously they hit 2.
  • The behaviour of setTrait now matches setTraits, prior to this you could not delete a trait via flagsmith.setTrait("trait",null). Also, this prevents an issue where segment flags were sometimes not returned in response to setting a trait.

Changes

Prior to this release, there were cases where flags provided by serverState are cleared, potentially effecting the isomorphic client (e.g. Next.js applications). This is because <ReactProvider/> initialises Flagsmith internally after server state is set.

This change makes sure that Flagsmith is initialises with the server state so that the state is preserved.

Changes

This release reduces the bundle size (31kb -> 21kb Pre GZIP) of the core SDK, it does so by patching one of our only dependencies (@callstack/async-storage) to export just the functions we need and remove the dependency of lodash.

image

Changes

Closes #153

Changes

Prior to this release, there were cases where useFlags was not updating flags when the Flagsmith cache was received. This was down to event listeners not being initialised prior to the cache being accessed.

Changes

A few releases ago we added the ability to automatically parse JSON in flagsmith.getValue. Since null is parseable by JSON.parse, the fallback was not being used in a lot of cases. Now, the client will ignore null flag values and use the fallback.

  const json = flagsmith.getValue<{foo: string|null, bar: string|null}>("json_value", {
      json: true,
      fallback: {foo:null,bar:null}
  });
  // if the value is null, json before this release would be null

Changes

Closes #148, prior to this release failed API requests (e.g. offline) would incorrectly update the local storage cache. Failed API calls will correctly trigger onError with the appropriate information.

This also fixes a usecase where the client has analytics data for an environment different to the one they are currently requesting https://github.com/Flagsmith/flagsmith-js-client/blob/main/flagsmith-core.ts#L201.

Thank you so much to @gfrancischini for spotting and reporting this.

Changes

This release will allow you to specify the return type of getValue as well as allow you to parse the value as JSON.

// for getting JSON values this will type the return
const json = flagsmith.getValue<{ foo: string | null; bar: string | null }>('json_value', {
 json: true,
 fallback: { foo: null, bar: null },
});
console.log(json.foo); // typed as {foo: string|null, bar: string|null}

// If a type is not specified for getValue it will asume it from the type of fallback. In this case, a number.
const font_size = flagsmith.getValue('font_size', { fallback: 12 });

Thank you very much @azriel46d and @dangrima90 🤩

Changes

Prior to this release, users on React Native had to install both the react-native SDK and standard flagsmith SDK.

An implementation would look like this

import flagsmith from 'react-native-flagsmith';
import {FlagsmithProvider} from 'flagsmith/react';

<FlagsmithProvider flagsmith={flagsmith}
...

With this release you can now import react specific components from 'react-native-flagsmith'. So implementation can be as follows

import flagsmith from 'react-native-flagsmith';
import {FlagsmithProvider} from 'react-native-flagsmith/react';

Changes

Closes #145

Changes

This release configures serverside event urls to match what we intend to use for production. More updates on realtime flags will follow.

Changes

Closes #140, #139, #137.

Changes

This release fixes source mapping for all clients, prior to this you could not inspect ts functions such as init and getFlags from flagsmith-core.ts.

Changes

This release includes working functionality for Serverside Events in the Flagsmith JavaScript client, React Native and SSR clients. A follow-up release will be published when this is released to production.

Changes

Prior to this release, React Native was not receiving flag updates with useFlags(["flag_name"]), this is due to the event emitter not being compatible.

This release also prepares functionality for realtime flags.

Changes

Similarly to version 3.7.1, this change caters for SSR technologies not supporting fetch. This version informs the user when fetch is undefined regardless of whether the user is opted into logging.

Changes

With SSR clients especially where fetch implementations differ, it's important to be able to debug fetch requests. With this version you will be able to see fetch statuses and exceptions when you pass enableLogs:true within flagsmith.init

Changes

Given that we type our flags and traits

 type FlagOptions = "font_size" | "hero"
 type TraitOptions = "example_trait"

We can now enforce these types:

  // enforces you passing the correct key to flagsmith.getValue(x), flagsmith.getTrait(x)
  import flagsmith from "flagsmith"
  const typedFlagsmith = flagsmith as IFlagsmith<FlagOptions,TraitOptions>

  // Similarly for the useFlagsmith hook
  const flagsmith = useFlagsmith<FlagOptions, TraitOptions>(); // enforces flagsmith.getValue()

  // for useFlags this will ensure you only can pass correct keys also
  const flags = useFlags<FlagOptions, TraitOptions>(["font_size"],["example_trait"]);

Thank you very much for this addition @PrettyWood

Changes

Closes #132 Thank you to @dgreene1 for the in-depth review 🚀 .

Changes

Some SSR technologies e.g. Nuxt do not provide a fetch polyfill, this means that sometimes we need to tell Flagsmith how to fetch data.

This is now possible with the following:

flagsmith.init({fetch:myCustomImplementation})

Here's an example of how this can be done with Nuxt https://github.com/Flagsmith/flagsmith-js-client/blob/main/examples/nuxt/plugins/flagsmith-plugin.ts#L10

Changes

IBulletTrainFeature had been deprecated many releases ago, this release removes it entirely. If your application imports it, just import IFlagsmithFeature instead. See https://github.com/Flagsmith/flagsmith-js-client/blob/main/types.d.ts

Changes

This release adds a Next.js middleware compatible bundle, a working example of this can be found here.

Closes #112

Changes

When calling flagsmith.init you can now pass cacheOptions

{
    ttl?:number, // how long to persist the cache in ms (defaults to 0 which is infinite)
    /*
    If this is true and there's cache available, it will skip hitting the API as if preventFetch was true
    Note: this is just for flagsmith.init(), Calls to identify, getFlags etc will still hit the API regardless
    */
    skipAPI?:boolean
}

Thanks to @qrush for the suggestion 🚀

Changes

Prior to this release, flagsmith would initialise inside a useEffect within the FlagsmithProvider component, now it will initialise immediately as can be seen here. Initialising flagsmith asynchronously meant that the UI could flicker when default values are supplied, as well as being overall slower than it needs to be.

Thanks to @briangorham for spotting this 🚀 .

Changes

In order to make the Dynatrace integration more simplistic, this replaces the dtrum init property with "enableDynatrace"

Changes

When providing dtrum instance to flagsmith.init, flagsmith will send session properties corresponding to flag enabled state, flag values and user traits. See here for an example.

  • flag enabled state sends as a shortString as "true" or "false" with the prefix flagsmith_enabled_ example: flagsmith_enabled_hero: "true"

  • Remote config values sends as value with the prefix flagsmith_value_, this value will be a javaDouble for numeric values and a shortString for any other. example: flagsmith_value_font_size: 21, flagsmith_value_hero_colour: "blue"

  • Remote config values sends as value with the prefix flagsmith_value_, this value will be a javaDouble for numeric values and a shortString for any other. example: flagsmith_trait_age: 21, flagsmith_trait_favourite_colour: "blue"

View the docs here!

Changes

Prior to this release, there were instances where calling setTrait or setTraits prior to identifying would attempt to hit the API. With this change, setTrait(s) will always build up an object of intended traits that will get sent as soon as the user is identified.

Changes

After migrating to the v2 SDK, the traits/bulk endpoint was deprecated, this release replaces that endpoint.

Changes

Merges: #120 @matthewelwell 🥳

The Edge API will no longer allow for flagsmith. incrementTrait, this PR removes it from the SDK as well as examples.

Changes

3.0.3 - 2022-06-08

Closes: #118 #115 #111

Merges: #116 Thank you @eschaefer 🥳 f0a62587d0 Thank you @markatom 🥳

Changes

3.0.0 - 2022-06-07

Edge API as default!

Changes

Closes #109, thanks @TD-4242 🚀

Changes

With this release, users are now able to npm install from flagsmith-es, this is a mirrored npm module except it is bundled as an ES module.

Thanks @bradberger for the suggestion 🚀

Changes

Closes #103 thanks to @xrash 🥳 #104

Changes

This release includes a few underlying type fixes as well as a solution to #105

You can now supply identity / trait options to flagsmith.init.

flagsmith.init({... identity:"my_user", traits: {age:21}})

Also if you're using the react hooks / provider, you can now initialise flagsmith outside of the component. To do so you will call flagsmith.init and not pass options to your FlagsmithProvider e.g.

flagsmith.init({
    environmentID: "QjgYur4LQTwe5HpvbvhpzK",
    cacheFlags:true,
    identity: "my_user",
    traits: {{trait1:"value}}
})
...
  <FlagsmithProvider flagsmith={flagsmith}>
    <App />
  </FlagsmithProvider>

Changes

React and React Native users will now be able to use a hook based approach to retrieving flags

import React from 'react';
import flagsmith from 'flagsmith' // 'react-native-flagsmith';  for react-native
import {FlagsmithProvider} from 'flagsmith/react';
import AppComponent from './ExampleComponent';


export default function () {
  return (
    <FlagsmithProvider
      options={{
        environmentID: 'QjgYur4LQTwe5HpvbvhpzK',
      }}
      flagsmith={flagsmith}>
      <AppComponent />
    </FlagsmithProvider>
  );
}

Then in your app

  const flags = useFlags(['font_size'], ['example_trait']); // only causes re-render if specified flag values / traits change
   ...
   <div>font_size: {flags.font_size?.value}</div>

Changes

2.0.0-beta.2 - 2022-03-15

Fixes passing undefined to traits in useFlags, thanks @NileDaley 🚀 #102

Changes

2.0.0-beta.1 - 2022-03-07

This release includes a rewrite to the build system of the SDK. It is now typescript-first and generates much better d.ts output.

This also includes a new react hooks library with easy to use nextjs support.

        <FlagsmithProvider flagsmith={flagsmith}
                           serverState={flagsmithState as IState}
                           options={{
                               environmentID,
                               cacheFlags: true
                           }}>
               <App/>
        </FlagsmithProvider>

...
  const flags = useFlags(["font_size"],["example_trait"]) // only causes re-render if specified flag values / traits change
...

      <div className="App">
        font_size: {flags.font_size?.value}
        example_trait: {flags.example_trait}
       </div>

Changes

1.7.4 - 2022-02-20

Closes #99 Closes #98

Thank you @gf3 and @xrash 🚀

Changes

This non-breaking change release removes mentions of Bullet Train where possible, the release contains the following PR: #94

Changes

1.7.2 - 2021-12-16

Merged: #90

Changes

This release adds the identity typescript type to flagsmith

    /**
     * The stored identity of the user
     */
    identity?:string

Changes

Prior to this release, if you identify a user before calling init then the promise would not resolve.

Changes

Previously, if defaultFlags were set but preventFetch was true, flagsmith would never call onChange. As of this release onChange will callback with the defaultFlags.

Changes

1.6.7 - 2021-09-22

Fixes #84

Changes

1.6.6 - 2021-09-15

This release fixes an issue where flagsmith.init was not resolving if no flags previously existed in cache.

Changes

This release resolves #81, previously types indicated that getFlags,identify,setTrait and other calls would resolve with IFlags however this is not the case. These calls should be followed by getValue / hasFeature.

Changes

This release fixes an issue with react native types #82

Changes

Prior to this release, API calls from the JS SDK went to https://api.bullet-train.io, now they go to https://api.flagsmith.com

Changes

1.5.0

This release allows you to create multiple instances of flagsmith, this may be used when you wish to identify multiple users simultaneously within your app and retain access to getValue, hasFeature etc for each user.

Type:

    export function createFlagsmithInstance (): IFlagsmith<br class="Apple-interchange-newline">

Usage:

import { createFlagsmithInstance } from "flagsmith";
const flagsmith = createFlagsmithInstance();
const flagsmithB = createFlagsmithInstance();

// now you can use flagsmith as before but in its own instance

Changes

As of this release you can now supply traits with the identify call, this combines setTraits and identify into 1 call.

    /**
     * Identify user, triggers a call to get flags if flagsmith.init has been called
     */
    identify:(userId:string, traits?: Record<string, string|number|boolean>,) => Promise<IFlags|undefined>

Changes