Reference
Flagship SDK Reference
Please refer to the JS SDK Documentation for Flagship classes
ABTastyProvider
class
ABTastyProvider
classThe ABTastyProvider
implements the OpenFeature Provider interface and is responsible for:
- Initializing the Flagship Client:
It starts the Flagship client using the provided environment ID, API key, and correct config. - Creating a Visitor:
It instantiates a visitor with context details (e.g., targetingKey, user context), fetches the associated flags, and updates context (if needed). - Logging Adaptation:
Uses an AdapterLogger to map Flagship logging to the OpenFeature Logger interface. - Delegating Resolution:
Delegates flag resolution tasks to the ABTastyResolver, which performs the resolution based on visitor context.
Key Methods
constructor(envId: string, apiKey: string, config?: IFlagshipConfig, logger?: OpenFeatureLogger)
- Description: Initializes the Flagship client. It:
- Starts the Flagship client using the provided environment ID and API key.
- Arguments:
Name | Type | Required | Description |
---|---|---|---|
envId | String | Required | Environment ID provided by Flagship. |
apiKey | String | Required | Api authentication key provided by Flagship. |
config | Object | Optional | Custom flagship configuration. see SDK configuration |
logger | Object | Optional | AdapterLogger instance. |
Example:
const {
ABTastyProvider,
} = require("@flagship.io/openfeature-provider-js");
// Step 1: Start the OpenFeature SDK by providing the environment ID and API key
let provider = new ABTastyProvider("<ENV_ID>", "<API_KEY>");
initialize(context?: EvaluationContext)
- Description: Internally called by the OpenFeature class when the provider is set and initializes the visitor. It:
- Creates a new visitor with the given evaluation context.
- Fetches feature flags.
- Instantiates the ABTastyResolver.
- Emits the provider's Ready event.
- Arguments:
- context: Optional context (e.g., targeting key and additional user data).
- Returns:
- A promise that resolves when initialization completes.
Example:
const {
ABTastyProvider,
} = require("@flagship.io/openfeature-provider-js");
const { OpenFeature } = require("@openfeature/server-sdk");
// Step 1: Start the OpenFeature SDK by providing the environment ID and API key
let provider = new ABTastyProvider("<ENV_ID>", "<API_KEY>");
// Step 2: Set Flagship SDK as provider
await OpenFeature.setProviderAndWait(provider);
getConfig(): IFlagshipConfig
- Description: Retrieves the current configuration settings used by the Flagship client.
- Returns:
- The configuration object (IFlagshipConfig).
close(): Promise<void>
- Description: Gracefully shuts down the Flagship client connection.
- Returns:
- A promise that resolves when the client has successfully closed.
Updated 12 days ago