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
  • Flagship configuration
  • Flagship SDK Status

For more details, see the change log

Visitor Creation

In version 4.X, the VisitorBuild api has been updated to be more descriptive.

Below is an example of how consent is used in versions 4.X and 3.X

$visitor = Flagship::newVisitor("visitorId", true)
  ->setIsAuthenticated(true)
  ->setContext(["age" => 31, "isVip" => true])
  ->build()
$visitor = Flagship::newVisitor("visitorId", true)
  ->isAuthenticated(true)
  ->withContext(["age" => 31, "isVip" => true])
  ->build()

Flagship configuration

In version 4.X, the setStatusChangedCallbacksetter of FlagshipConfig has been replaced with setOnSdkStatusChanged.

Flagship SDK Status

The FlagshipStatus class 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.XV3.X
SDK_NOT_INITIALIZEDNOT_READY
SDK_NOT_INITIALIZEDNOT_INITIALIZED
SDK_INITIALIZINGSTARTING
SDK_INITIALIZINGPOLLING
SDK_PANICREADY_PANIC_ON
SDK_INITIALIZEDREADY

GetFlag method update

In 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:


...

$flag = $visitor->getFlag("myFlagKey");
$flagValue = $flag->getValue("default-value");

...

$flag = $visitor->getFlag("myFlagKey", "default-value");
$flagValue = $flag->getValue();