DocsSDKsFlutter SDK
SDKsOfficial

Flutter SDK

Official Flutter support for event tracking, identity, and offline queueing.

Source of truthsdk/sankofa_flutter/README.mdsdk/sankofa_flutter/lib/sankofa_flutter.darthttps://github.com/Sankofa-HQ/sankofa_sdk_flutter

Flutter SDK 🚀

The Sankofa Flutter SDK is the official client integration surface for Flutter applications. It provides high-level APIs for tracking user behavior, capturing identity updates, and recording user sessions.


🚀 Quick Start

1. Install

Add the dependency to your pubspec.yaml:

dependencies:
  sankofa_flutter: ^0.1.0

2. Initialize

Initialize the SDK before calling runApp.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Sankofa.instance.init(
    apiKey: 'sk_live_12345',
    endpoint: 'https://api.sankofa.dev',
    debug: true
  );
  runApp(MyApp());
}

🛠 Configuration & Setup

Endpoint Normalization

The SDK accepts several endpoint shapes and normalizes them internally:

  • Server base: https://api.sankofa.dev
  • API base: https://api.sankofa.dev/api/v1
  • Track URL: http://localhost:8080/api/v1/track

Common Flags

FlagPurpose
debugEnables SDK log output during development.
trackLifecycleEventsEnables automatic lifecycle tracking (app open/close).

📈 Tracking Events

Track any user action with a simple method call. Events are automatically enriched with device metadata.

Basic Event Call

await Sankofa.instance.track('button_clicked', {
  'bg_color': 'blue',
  'screen': 'home',
});

Automatic Enrichment

The SDK automatically injects:

  • $session_id
  • $distinct_id
  • Network and Device properties
  • Default properties

👤 Identity & People

Sankofa uses a dual-method approach to manage user identity and profile updates.

Identify a Known User

await Sankofa.instance.identify('user_123');

This links previous anonymous activity to the new user identity.

Reset on Logout

await Sankofa.instance.reset();

Clears identity, rotates the session, and generates a new anonymous ID.

Set People Properties

await Sankofa.instance.peopleSet({
  'plan': 'growth',
  'role': 'operator',
});

🎥 Session Replay

Session Replay allows you to see exactly how users interact with your app by recording UI states and touch events.

Recording Modes

ModeDescription
wireframeCaptures UI layout using lightweight JSON blueprints (Default).
screenshotCaptures pixel-perfect snapshots at a target FPS.

Setup

1. Wrap your App

import 'package:sankofa_flutter/sankofa_flutter.dart';

void main() {
  runApp(
    SankofaReplayBoundary(
      child: MyApp(),
    ),
  );
}

2. Enable in Init

await Sankofa.instance.init(
  apiKey: 'YOUR_PROJECT_API_KEY',
  endpoint: 'https://sankofa.your-domain.com',
  enableSessionReplay: true,
);

Privacy & Masking

Use the SankofaMask widget to redact sensitive information.

SankofaMask(
  child: Text('Sensitive User Data'),
)

📑 API Reference

Core Instance Methods

MethodDescription
initInitializes the SDK and gather default properties.
trackQueues an event with optional properties.
identifySwitches the active distinct ID to a known user.
peopleSetQueues a people profile update.
resetFlushes pending events and clears identity.