Quick-Start

Installation

You will find all instructions in installation topic

Flagship Usage

Start SDK

The first call you should make is to start the SDK by calling start method through the Flagship class.

import 'package:flagship/flagship.dart';

// Step 1 - Start the Flagship sdk with default configuration.
Flagship.start("_ENV_ID_", "_API_KEY_");

In step 1 The SDK needs to start the environmentId and apiKey. By default the Flagship start with Decision Mode for more details on custom configuration go to Advanced Configuration.// Fix url

📘

API Key & Environment ID required

You can find your apiKey and your environmentId on your Flagship account, in Parameters > Environment & Security.

Create Visitor

The second step after starting the SDK is visitor creation. This object allows you to manage visitor's context, experiments, and track events.

// Step 2 - Create visitor with context "isVip" : true
var visitor = Flagship.newVisitor(visitorId: "visitorId", hasConsented: true)
        .withContext({"isVip": true}).build();

In Step 2 We create a visitor providing his consent and his context. Go to builder methods to learn more about visitor creation.

Getting flags

Once we have created our visitor instance we need to fetch flags. Go to Flag to learn more about.

// Step 3 - Fetch flags
    visitor.fetchFlags().whenComplete(() {
      // Step 4 - Get Flag key
      var flag = v.getFlag("flagKey");
      // Step 5 - Read Flag value
      var value = flag.value("defaultValue");
    });

When flag fetching completes in step 3 its inner code block is executed. In step 4, we are ready to process visitor's flags and read their values in step 5.

Note: SDK will report exposition by default when reading a Flag value.

Tracking hits

Then sending events tracking will allows you to validate objectives in your campaign reporting.

// Step 6 - Send Event
visitor.sendHit( Event(action: "event_action", category: EventCategory.Action_Tracking));

📘

In order to see your events in your campaign reporting you must define objectives kpis beforehand in the campaign configuration. For more details Set up your KPIs.

In step 6 Flagship is on charge of sending the event_action event through the function sendHit. Go to tracking for more information.

You should see your hit using hitStream feature, then on your campaign report.