initialize static method
Future<void>
initialize(
- String writeKey, {
- String? apiHost,
- List<
CellEndpoint> ? cellEndpoints, - CellRegion? preferredRegion,
- bool autoRegionDetection = true,
- String? workspaceId,
- String? locationId,
- bool enableRemoteConfig = true,
- int batchSize = 20,
- int batchInterval = 30000,
- bool enableAdaptiveBatching = false,
- bool autoSessionTracking = true,
- int sessionTimeout = 1800000,
- bool encryptLocalStorage = true,
- bool debugMode = false,
Implementation
static Future<void> initialize(
String writeKey, {
String? apiHost,
List<CellEndpoint>? cellEndpoints,
CellRegion? preferredRegion,
bool autoRegionDetection = true,
String? workspaceId,
String? locationId,
bool enableRemoteConfig = true,
int batchSize = 20,
int batchInterval = 30000,
bool enableAdaptiveBatching = false,
bool autoSessionTracking = true,
int sessionTimeout = 1800000,
bool encryptLocalStorage = true,
bool debugMode = false,
}) async {
_workspaceId = workspaceId;
// Configure + start the push lifecycle module. Wire shape pinned
// by tests/drift/push-engagement-payload.json.
push.configure(
apiHost: apiHost ?? 'https://api.aegis.ai',
writeKey: writeKey,
propertyId: null, // filled by bootstrap()
contactId: null,
anonymousId: null,
);
unawaited(push.start());
// Configure the inline placements module with the write key + host.
// Identity (userId/contactId/organizationId) is resolved later by
// bootstrap() and pushed in via updateUserId/updateContactId, mirroring
// how the push module fills propertyId/contactId post-bootstrap. Host
// fetches/tracks placements via AegisFlutter.placements.
placements.initialize(
writeKey: writeKey,
apiHost: apiHost ?? 'https://api.aegis.ai',
debugMode: debugMode,
);
try {
await _channel.invokeMethod('initialize', {
'writeKey': writeKey,
'apiHost': apiHost ?? 'https://api.aegis.ai',
'cellEndpoints': cellEndpoints?.map((e) => e.toMap()).toList(),
'preferredRegion': preferredRegion?.wire,
'autoRegionDetection': autoRegionDetection,
'workspaceId': workspaceId,
'locationId': locationId,
'enableRemoteConfig': enableRemoteConfig,
'batchSize': batchSize,
'batchInterval': batchInterval,
'enableAdaptiveBatching': enableAdaptiveBatching,
'autoSessionTracking': autoSessionTracking,
'sessionTimeout': sessionTimeout,
'encryptLocalStorage': encryptLocalStorage,
'debugMode': debugMode,
});
} on PlatformException catch (e) {
throw Exception('Failed to initialize Active Reach SDK: ${e.message}');
}
}