flagsup-ts
v1.0.9
Published
Flagsup sdk (written in ts)
Downloads
555
Readme
flagsup-ts
flagsup-ts is a TypeScript package for managing feature flags in TypeScript projects. It offers a flexible and efficient solution for implementing feature flagging strategies, allowing developers to control feature rollout and experimentation with ease.
Installation
Use the package manager yarn or npm to install the package
// Yarn
yarn add flagsup-ts
// NPM
npm install flagsup-ts
Features
- TypeScript Support: Built specifically for TypeScript projects, ensuring type safety and enhanced developer experience.
- Dynamic EntityId Configuration: Support for both static and dynamic entityId configurations, enabling flexible flag evaluation based on user context.
- Integration with flagsup Service: Seamlessly integrates with existing flagsup service features (TBD: such as experiments and treatments, providing advanced capabilities for controlled feature rollouts and experimentation)
Usage
import FlagsupClient, { RequestEvalFlagKeys } from "flagsup-ts";
// Init flagsup client
const flagsupClient = new FlagsupClient({
targetHostname: flagsupServiceHost,
defaultEntityId: currentUserId,
clientInstanceName: "Flagsup-ts",
});
// Define flag keys
const FLAG_KEYS: RequestEvalFlagKeys<IUserDetailsInfo> = {
OLD_KEY: "old_key",
KEY_WITH_STATIC_ENTITY_ID: {
key: "key_with_static_entity_id",
entityId: "static_entityId",
},
KEY_WITH_DYNAMIC_ENTITY_ID: {
key: "key_with_dynamic_entity_id",
getEntityId: (currentUser) => currentUser?.meta_data?.seller_id,
},
};
// Batch eval flags
const flags = await flagsupClient.batchEvaluateFlags(FLAG_KEYS, currentUser);
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.