next-feature-flags-client

8.7.8 • Public • Published

Next feature flags client Circle CI

Feature toggles for Next with ability to override using x-flags header or next-flags cookie. Also sends reports to sentry of any expired flags still in use.

📣 DEPRECATION NOTICE

This package has been moved in npm to be part of the @financial-times org, and so it has a new home (and slightly different package name): @financial-times/n-flags-client.

The version you’re viewing now will no longer be maintained. Please check https://github.com/Financial-Times/n-flags-client/releases for the latest release notes and update your app’s package.json.

Usage

Client side

Client side feature flags are no handled in n-ui and are passed in to the bootstrap() method

Server side

Does not need to be constructed with an object of values. This is taken care of by next-express, as is middleware for making flags available to requests. By default will request from next's set of platinum flag services, but can be overridden using the setUrls([arr]) method.

The default behaviour when NODE_ENV=production is to get overrides from the http header that Fastly sets. For apps that not routed via Fastly you can set OVERRIDE_FLAGS_FROM_COOKIE=true to get overrides from a cookie.

API

init(options)

Initialises the flag client. Options may have 3 self-explanatory properties:

  • timeout - length of time to wait for response from the flag server [default 3000]
  • interval - interval between attempts to fetch fresh flag data [default 30000]

Returns a promise that is resolved when flags have been successfully fetched at least once (or that resolves immediately if none of the above options are passed)

getArray()

Returns a simplified array of flags similar to that retrieved from the flags api, but lacking expiry date information.

get(name)

Returns the current state of a flag (or false if the flag doesn't exist). If no name is provided it returns a hash of all current flag objects, including information on expiry dates

getModel(name)

Returns a flag model for the named flag. If {withAb: true} is passed in in the options to any of this module's components, it will eventually propagate down to make ab test information is available on the ab property of each flag's model

Readme

Keywords

none

Package Sidebar

Install

npm i next-feature-flags-client

Weekly Downloads

88

Version

8.7.8

License

none

Last publish

Collaborators

  • financial-times
  • mattandrews