DocsSDKsInitialization
SDKsOfficial

Initialization

Initialize the Flutter SDK correctly, choose the right endpoint form, and wire the common setup flags.

Source of truthsdk/sankofa_flutter/README.mdexamples/flutter_example/lib/main.dartsdk/sankofa_flutter/lib/sankofa_flutter.dart

Basic initialization

await Sankofa.instance.init(
  apiKey: 'sk_live_12345',
  endpoint: 'http://localhost:8080',
  debug: true,
);

Full example from the example app

await Sankofa.instance.init(
  apiKey: key,
  endpoint: url,
  debug: _debugMode,
  trackLifecycleEvents: _trackLifecycleEvents,
  enableSessionReplay: _enableSessionReplay,
  replayMode: _replayMode,
);

Endpoint normalization

The SDK accepts several endpoint shapes and normalizes them internally:

endpoint: 'http://localhost:8080'

Internally:

  • resolveServerBaseUri(endpoint) derives the engine base URL
  • resolveTrackUri(endpoint) derives the final track URL

Common flags

FlagPurpose
debugEnables SDK log output during development.
trackLifecycleEventsEnables automatic lifecycle tracking when supported by the SDK.
enableSessionReplayTurns replay collection on and configures replay helpers.
replayModeSelects wireframe or screenshot replay behavior.

Initialization order

  1. 1

    Ensure Flutter bindings are ready

    Call `WidgetsFlutterBinding.ensureInitialized()` before you initialize the SDK.

  2. 2

    Initialize before runApp

    This ensures tracking, identity, and replay configuration are ready as the app tree mounts.

  3. 3

    Wrap replay-aware UI when needed

    If replay is enabled, place `SankofaReplayBoundary` near the root and add `SankofaNavigatorObserver()` to the app navigator.