Skip to main content

Flutter DataSapien

info

This documentation is for Flutter SDK 2.1.x

DataSapien is the main entry point of the SDK. All members are static. Use it to initialize the SDK, run the post-initialization setup, and obtain the service instances.

Functions​

initialize​

static Future<void> initialize(DataSapienConfig config)

Initializes the SDK with the given configuration.

Parameters:

setup​

static Future<void> setup()

Runs post-initialization setup and synchronizes SDK data (MeData definitions, journeys, rules, managed APIs, segment subscriptions, managed AI models, and audiences).

Parameters: None.

syncAll​

static Future<void> syncAll()

Re-synchronizes all backend-driven data: MeData definitions, natively collected MeData, journeys, rules, managed APIs, segment subscriptions, managed AI models, and audiences. Use it to refresh SDK data while the app is running, for example on pull-to-refresh.

Parameters: None.

deleteAllData​

static Future<void> deleteAllData()

Deletes all data stored by the SDK on the device.

Parameters: None.

getMeDataService​

static MeDataService getMeDataService()

Returns the MeData Service instance.

Parameters: None.

getJourneyService​

static JourneyService getJourneyService()

Returns the Journey Service instance.

Parameters: None.

getAudienceService​

static AudienceService getAudienceService()

Returns the Audience Service instance.

Parameters: None.

getIntelligenceService​

static IntelligenceService getIntelligenceService()

Returns the Intelligence Service instance.

Parameters: None.

getManagedAPIService​

static ManagedAPIService getManagedAPIService()

Returns the Managed API Service instance.

Parameters: None.

getBackupService​

static BackupService getBackupService()

Returns the Backup Service instance.

Parameters: None.

getHostService​

static HostService getHostService()

Returns the Host Service instance. A single long-lived instance is returned so registered host-function handlers persist for the app's lifetime.

Parameters: None.

Classes​

DataSapienConfig​

Configuration for SDK initialization. Instances are created via the Builder, obtained with DataSapienConfig.builder().

DataSapienConfig.Builder​

class Builder {
Builder setAuth({
required String authUrl,
required String authClientId,
required String authClientSecret,
required String authScope,
});

Builder setHostUrl(String hostUrl);
Builder setMediaUrl(String mediaUrl);
Builder setMainColor(String mainColor);
Builder setLogLevel(List<LogLevel> levels);
Builder setDebugViewEnabled(bool enabled);
DataSapienConfig build();
}
  • setAuth — OAuth token endpoint URL, client ID, client secret, and scope. Required.
  • setHostUrl — Base URL for the DataSapien API. Required.
  • setMediaUrl — Base URL for the DataSapien media API. Required.
  • setMainColor — Main hex color used for UI styling (e.g. "#F37102"). Optional.
  • setLogLevel — Sets which log levels the SDK emits (see LogLevel). Optional; an empty list (the default) disables all SDK logging.
  • setDebugViewEnabled — Enables the Journey in-app debug view. Optional, defaults to false.
  • build — Builds the configuration. Throws ArgumentError if any required field is missing.

Example:

final config = DataSapienConfig.builder()
.setAuth(
authUrl: '<YOUR_AUTH_URL>',
authClientId: '<YOUR_CLIENT_ID>',
authClientSecret: '<YOUR_CLIENT_SECRET>',
authScope: '<YOUR_AUTH_SCOPE>',
)
.setHostUrl('<YOUR_HOST_URL>')
.setMediaUrl('<YOUR_MEDIA_URL>')
.setLogLevel([LogLevel.warning, LogLevel.error])
.setDebugViewEnabled(true)
.build();

await DataSapien.initialize(config);

LogLevel​

enum LogLevel {
debug,
info,
warning,
error,
}