Migration to 4.X
Overview
This guide assists developers in migrating from Flagship 3.X to Flagship 4.X.
The primary changes include:
- Visitor Creation options
- Flagship configuration
- Flagship SDK Status
For more details, see the change log
Visitor Creation options
In version 4.X, 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.
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
});
const fsVisitor = Flagship.newVisitor();
Flagship configuration
In version 4.X, the enableClientCache
option of IFlagshipConfig has been replaced with reuseVisitorIds and the statusChangedCallback
has been replaced with onSdkStatusChanged
.
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.
V4.X | V3.X |
---|---|
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, 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");
...
const flag = fsVisitor.getFlag("myFlagKey", "default-value");
const flagValue = flag.getValue();
Updated 6 months ago