Migration to v4.X and higher
This guide assists developers in migrating from Flagship 3.X to Flagship 4.X and higher.
The primary changes include:
Asynchronous Flagship.start
Visitor Creation options
Flagship configuration
Renamed Types and APIs
For more details, see the change log
Asynchronous Flagship.start
In version 5.X and higher, The Flagship.start method is now asynchronous and returns a Promise. You may need to update your code to properly await initialization before accessing flags or creating visitors.
// New version - asynchronous
const flagship = await Flagship.start('ENV_ID', 'API_KEY', {
// config options
});
// Now you can safely use the SDK
const visitor = flagship.newVisitor({
visitorId: 'visitor-id',
hasConsented: true
});Visitor Creation options
In version 4.X and higher , when creating a visitor, the hasConsented option is now required. In contrast, this option was optional in version 3.X. Additionally, the isNewInstance option has been replaced with shouldSaveInstance, onFetchFlagsStatusChanged has been renamed to onFlagsStatusChanged
Below is an example of how consent is used in versions 4.X and 3.X
const fsVisitor = Flagship.newVisitor({
hasConsented: true, // This is now mandatory
});Flagship configuration
In version 4.X and higher, the enableClientCacheoption of IFlagshipConfig has been replaced with reuseVisitorIds and the statusChangedCallback has been replaced with onSdkStatusChanged.
Renamed Types and APIs
Flag Status
In the version 5.x and higher, the FetchFlagsStatus type has been renamed to FlagsStatus for clarity.
Flagship SDK Status
The FlagshipStatus enum has been superseded by FSSdkStatus.
The table below matches the FlagshipStatus enum keys from version 3.X to the corresponding FSSdkStatus keys in version 4.X and higher.
SDK_NOT_INITIALIZED
NOT_READY
SDK_NOT_INITIALIZED
NOT_INITIALIZED
SDK_INITIALIZING
STARTING
SDK_INITIALIZING
POLLING
SDK_PANIC
READY_PANIC_ON
SDK_INITIALIZED
READY
GetFlag method update
GetFlag method updateIn version 4.X and higher, the approach to setting a flag's default value has been modified. The default value is no longer set using the getFlag method of visitor instance. Instead, it is now set using the getValue of flag instance.
Here's how you can retrieve the default value of a flag in versions 4.X and 3.X:
...
const flag = fsVisitor.getFlag("myFlagKey");
const flagValue = flag.getValue("default-value");Last updated
Was this helpful?

