Starting and Configuring the SDK
This feature starts the Flagship SDK using your specific credentials and the necessary configuration parameters. This is typically the initial step when utilizing the Flagship SDK.
In the context of the Flagship SDK, a "decision" refers to the process of assigning variations to a visitor based on the targeting criteria of a campaign.
You can use either the Api
mode or the Bucketing
mode to start the SDK. In the API
mode whenever you fetch your flags, an HTTP request is made to Flagship to take decisions. However in Bucketing
mode, the decisions are made locally on the client side.
It's recommended to start the SDK just once in the most appropriate location for your application.
Below are examples of how to initialize and configure the SDK in different programming environments:
import { Flagship, DecisionMode, CacheStrategy, LogLevel } from "@flagship.io/js-sdk";
Flagship.start("<ENV_ID>", "<API_KEY>", {
decisionMode: DecisionMode.DECISION_API,
timeout: 10,
logLevel: LogLevel.INFO,
});
import React from "react";
import { FlagshipProvider } from "@flagship.io/react-sdk";
const App = () => (
<>
<FlagshipProvider
envId="YOUR_ENV_ID"
apiKey="YOUR_API_KEY"
visitorData={null}
>
{/* ... */}
</FlagshipProvider>
</>
);
import React from "react";
import { FlagshipProvider } from "@flagship.io/react-native-sdk";
const App = () => (
<>
<FlagshipProvider
envId="YOUR_ENV_ID"
apiKey="YOUR_API_KEY"
visitorData={null}
>
{/* ... */}
</FlagshipProvider>
</>
);
require __DIR__ . '/vendor/autoload.php';
use Flagship\Config\FlagshipConfig;
use Flagship\Enum\LogLevel;
use Flagship\Flagship;
$config = FlagshipConfig::decisionApi()
->setLogLevel(LogLevel::DEBUG)
->setTimeout(2000)
Flagship::start("<ENV_ID>", "<API_KEY>", $config);
using Flagship.Config;
using Flagship.Main;
Fs.Start("<ENV_ID>", "<API_KEY>", new DecisionApiConfig(){
LogLevel = Flagship.Enums.LogLevel.DEBUG
});
Each SDK offers a variety of configuration options to manage its behavior. For more detailed information about possible configurations, please consult the reference documentation for your specific SDK:
Updated 5 months ago